babylon.module.d.ts 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384
  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. /**
  1467. * Gets or sets the number of objects referencing this buffer
  1468. */
  1469. references: number;
  1470. /** Gets or sets the size of the underlying buffer */
  1471. capacity: number;
  1472. /**
  1473. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1474. */
  1475. is32Bits: boolean;
  1476. /**
  1477. * Gets the underlying buffer
  1478. */
  1479. get underlyingResource(): any;
  1480. }
  1481. }
  1482. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1483. import { Nullable } from "babylonjs/types";
  1484. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1485. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1486. /** @hidden */
  1487. export interface IShaderProcessor {
  1488. attributeProcessor?: (attribute: string, preProcessors: {
  1489. [key: string]: string;
  1490. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1491. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1492. [key: string]: string;
  1493. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1494. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1495. [key: string]: string;
  1496. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1497. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1498. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1499. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1501. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1502. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1503. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1504. vertexCode: string;
  1505. fragmentCode: string;
  1506. };
  1507. }
  1508. }
  1509. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1510. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1511. import { Nullable } from "babylonjs/types";
  1512. /** @hidden */
  1513. export interface ShaderProcessingContext {
  1514. }
  1515. /** @hidden */
  1516. export interface ProcessingOptions {
  1517. defines: string[];
  1518. indexParameters: any;
  1519. isFragment: boolean;
  1520. shouldUseHighPrecisionShader: boolean;
  1521. supportsUniformBuffers: boolean;
  1522. shadersRepository: string;
  1523. includesShadersStore: {
  1524. [key: string]: string;
  1525. };
  1526. processor: Nullable<IShaderProcessor>;
  1527. version: string;
  1528. platformName: string;
  1529. lookForClosingBracketForUniformBuffer?: boolean;
  1530. processingContext: Nullable<ShaderProcessingContext>;
  1531. }
  1532. }
  1533. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1534. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1535. /** @hidden */
  1536. export class ShaderCodeNode {
  1537. line: string;
  1538. children: ShaderCodeNode[];
  1539. additionalDefineKey?: string;
  1540. additionalDefineValue?: string;
  1541. isValid(preprocessors: {
  1542. [key: string]: string;
  1543. }): boolean;
  1544. process(preprocessors: {
  1545. [key: string]: string;
  1546. }, options: ProcessingOptions): string;
  1547. }
  1548. }
  1549. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1550. /** @hidden */
  1551. export class ShaderCodeCursor {
  1552. private _lines;
  1553. lineIndex: number;
  1554. get currentLine(): string;
  1555. get canRead(): boolean;
  1556. set lines(value: string[]);
  1557. }
  1558. }
  1559. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1560. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1561. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1562. /** @hidden */
  1563. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1564. process(preprocessors: {
  1565. [key: string]: string;
  1566. }, options: ProcessingOptions): string;
  1567. }
  1568. }
  1569. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1570. /** @hidden */
  1571. export class ShaderDefineExpression {
  1572. isTrue(preprocessors: {
  1573. [key: string]: string;
  1574. }): boolean;
  1575. private static _OperatorPriority;
  1576. private static _Stack;
  1577. static postfixToInfix(postfix: string[]): string;
  1578. static infixToPostfix(infix: string): string[];
  1579. }
  1580. }
  1581. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1582. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1583. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1584. /** @hidden */
  1585. export class ShaderCodeTestNode extends ShaderCodeNode {
  1586. testExpression: ShaderDefineExpression;
  1587. isValid(preprocessors: {
  1588. [key: string]: string;
  1589. }): boolean;
  1590. }
  1591. }
  1592. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1593. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1594. /** @hidden */
  1595. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1596. define: string;
  1597. not: boolean;
  1598. constructor(define: string, not?: boolean);
  1599. isTrue(preprocessors: {
  1600. [key: string]: string;
  1601. }): boolean;
  1602. }
  1603. }
  1604. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1605. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1606. /** @hidden */
  1607. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1608. leftOperand: ShaderDefineExpression;
  1609. rightOperand: ShaderDefineExpression;
  1610. isTrue(preprocessors: {
  1611. [key: string]: string;
  1612. }): boolean;
  1613. }
  1614. }
  1615. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1616. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1617. /** @hidden */
  1618. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1619. leftOperand: ShaderDefineExpression;
  1620. rightOperand: ShaderDefineExpression;
  1621. isTrue(preprocessors: {
  1622. [key: string]: string;
  1623. }): boolean;
  1624. }
  1625. }
  1626. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1627. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1628. /** @hidden */
  1629. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1630. define: string;
  1631. operand: string;
  1632. testValue: string;
  1633. constructor(define: string, operand: string, testValue: string);
  1634. isTrue(preprocessors: {
  1635. [key: string]: string;
  1636. }): boolean;
  1637. }
  1638. }
  1639. declare module "babylonjs/Offline/IOfflineProvider" {
  1640. /**
  1641. * Class used to enable access to offline support
  1642. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1643. */
  1644. export interface IOfflineProvider {
  1645. /**
  1646. * Gets a boolean indicating if scene must be saved in the database
  1647. */
  1648. enableSceneOffline: boolean;
  1649. /**
  1650. * Gets a boolean indicating if textures must be saved in the database
  1651. */
  1652. enableTexturesOffline: boolean;
  1653. /**
  1654. * Open the offline support and make it available
  1655. * @param successCallback defines the callback to call on success
  1656. * @param errorCallback defines the callback to call on error
  1657. */
  1658. open(successCallback: () => void, errorCallback: () => void): void;
  1659. /**
  1660. * Loads an image from the offline support
  1661. * @param url defines the url to load from
  1662. * @param image defines the target DOM image
  1663. */
  1664. loadImage(url: string, image: HTMLImageElement): void;
  1665. /**
  1666. * Loads a file from offline support
  1667. * @param url defines the URL to load from
  1668. * @param sceneLoaded defines a callback to call on success
  1669. * @param progressCallBack defines a callback to call when progress changed
  1670. * @param errorCallback defines a callback to call on error
  1671. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1672. */
  1673. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1674. }
  1675. }
  1676. declare module "babylonjs/Misc/filesInputStore" {
  1677. /**
  1678. * Class used to help managing file picking and drag'n'drop
  1679. * File Storage
  1680. */
  1681. export class FilesInputStore {
  1682. /**
  1683. * List of files ready to be loaded
  1684. */
  1685. static FilesToLoad: {
  1686. [key: string]: File;
  1687. };
  1688. }
  1689. }
  1690. declare module "babylonjs/Misc/retryStrategy" {
  1691. import { WebRequest } from "babylonjs/Misc/webRequest";
  1692. /**
  1693. * Class used to define a retry strategy when error happens while loading assets
  1694. */
  1695. export class RetryStrategy {
  1696. /**
  1697. * Function used to defines an exponential back off strategy
  1698. * @param maxRetries defines the maximum number of retries (3 by default)
  1699. * @param baseInterval defines the interval between retries
  1700. * @returns the strategy function to use
  1701. */
  1702. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1703. }
  1704. }
  1705. declare module "babylonjs/Misc/baseError" {
  1706. /**
  1707. * @ignore
  1708. * Application error to support additional information when loading a file
  1709. */
  1710. export abstract class BaseError extends Error {
  1711. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1712. }
  1713. }
  1714. declare module "babylonjs/Misc/fileTools" {
  1715. import { WebRequest } from "babylonjs/Misc/webRequest";
  1716. import { Nullable } from "babylonjs/types";
  1717. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1718. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1719. import { BaseError } from "babylonjs/Misc/baseError";
  1720. /** @ignore */
  1721. export class LoadFileError extends BaseError {
  1722. request?: WebRequest;
  1723. file?: File;
  1724. /**
  1725. * Creates a new LoadFileError
  1726. * @param message defines the message of the error
  1727. * @param request defines the optional web request
  1728. * @param file defines the optional file
  1729. */
  1730. constructor(message: string, object?: WebRequest | File);
  1731. }
  1732. /** @ignore */
  1733. export class RequestFileError extends BaseError {
  1734. request: WebRequest;
  1735. /**
  1736. * Creates a new LoadFileError
  1737. * @param message defines the message of the error
  1738. * @param request defines the optional web request
  1739. */
  1740. constructor(message: string, request: WebRequest);
  1741. }
  1742. /** @ignore */
  1743. export class ReadFileError extends BaseError {
  1744. file: File;
  1745. /**
  1746. * Creates a new ReadFileError
  1747. * @param message defines the message of the error
  1748. * @param file defines the optional file
  1749. */
  1750. constructor(message: string, file: File);
  1751. }
  1752. /**
  1753. * @hidden
  1754. */
  1755. export class FileTools {
  1756. /**
  1757. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1758. */
  1759. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1760. /**
  1761. * Gets or sets the base URL to use to load assets
  1762. */
  1763. static BaseUrl: string;
  1764. /**
  1765. * Default behaviour for cors in the application.
  1766. * It can be a string if the expected behavior is identical in the entire app.
  1767. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1768. */
  1769. static CorsBehavior: string | ((url: string | string[]) => string);
  1770. /**
  1771. * Gets or sets a function used to pre-process url before using them to load assets
  1772. */
  1773. static PreprocessUrl: (url: string) => string;
  1774. /**
  1775. * Removes unwanted characters from an url
  1776. * @param url defines the url to clean
  1777. * @returns the cleaned url
  1778. */
  1779. private static _CleanUrl;
  1780. /**
  1781. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1782. * @param url define the url we are trying
  1783. * @param element define the dom element where to configure the cors policy
  1784. */
  1785. static SetCorsBehavior(url: string | string[], element: {
  1786. crossOrigin: string | null;
  1787. }): void;
  1788. /**
  1789. * Loads an image as an HTMLImageElement.
  1790. * @param input url string, ArrayBuffer, or Blob to load
  1791. * @param onLoad callback called when the image successfully loads
  1792. * @param onError callback called when the image fails to load
  1793. * @param offlineProvider offline provider for caching
  1794. * @param mimeType optional mime type
  1795. * @returns the HTMLImageElement of the loaded image
  1796. */
  1797. 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>;
  1798. /**
  1799. * Reads a file from a File object
  1800. * @param file defines the file to load
  1801. * @param onSuccess defines the callback to call when data is loaded
  1802. * @param onProgress defines the callback to call during loading process
  1803. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1804. * @param onError defines the callback to call when an error occurs
  1805. * @returns a file request object
  1806. */
  1807. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1808. /**
  1809. * Loads a file from a url
  1810. * @param url url to load
  1811. * @param onSuccess callback called when the file successfully loads
  1812. * @param onProgress callback called while file is loading (if the server supports this mode)
  1813. * @param offlineProvider defines the offline provider for caching
  1814. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1815. * @param onError callback called when the file fails to load
  1816. * @returns a file request object
  1817. */
  1818. 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;
  1819. /**
  1820. * Loads a file
  1821. * @param url url to load
  1822. * @param onSuccess callback called when the file successfully loads
  1823. * @param onProgress callback called while file is loading (if the server supports this mode)
  1824. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1825. * @param onError callback called when the file fails to load
  1826. * @param onOpened callback called when the web request is opened
  1827. * @returns a file request object
  1828. */
  1829. 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;
  1830. /**
  1831. * Checks if the loaded document was accessed via `file:`-Protocol.
  1832. * @returns boolean
  1833. */
  1834. static IsFileURL(): boolean;
  1835. }
  1836. }
  1837. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1838. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1839. import { WebRequest } from "babylonjs/Misc/webRequest";
  1840. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1841. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1843. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1844. /** @hidden */
  1845. export class ShaderProcessor {
  1846. static Initialize(options: ProcessingOptions): void;
  1847. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1848. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1849. vertexCode: string;
  1850. fragmentCode: string;
  1851. };
  1852. private static _ProcessPrecision;
  1853. private static _ExtractOperation;
  1854. private static _BuildSubExpression;
  1855. private static _BuildExpression;
  1856. private static _MoveCursorWithinIf;
  1857. private static _MoveCursor;
  1858. private static _EvaluatePreProcessors;
  1859. private static _PreparePreProcessors;
  1860. private static _ProcessShaderConversion;
  1861. private static _ProcessIncludes;
  1862. /**
  1863. * Loads a file from a url
  1864. * @param url url to load
  1865. * @param onSuccess callback called when the file successfully loads
  1866. * @param onProgress callback called while file is loading (if the server supports this mode)
  1867. * @param offlineProvider defines the offline provider for caching
  1868. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1869. * @param onError callback called when the file fails to load
  1870. * @returns a file request object
  1871. * @hidden
  1872. */
  1873. 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;
  1874. }
  1875. }
  1876. declare module "babylonjs/Materials/iEffectFallbacks" {
  1877. import { Effect } from "babylonjs/Materials/effect";
  1878. /**
  1879. * Interface used to define common properties for effect fallbacks
  1880. */
  1881. export interface IEffectFallbacks {
  1882. /**
  1883. * Removes the defines that should be removed when falling back.
  1884. * @param currentDefines defines the current define statements for the shader.
  1885. * @param effect defines the current effect we try to compile
  1886. * @returns The resulting defines with defines of the current rank removed.
  1887. */
  1888. reduce(currentDefines: string, effect: Effect): string;
  1889. /**
  1890. * Removes the fallback from the bound mesh.
  1891. */
  1892. unBindMesh(): void;
  1893. /**
  1894. * Checks to see if more fallbacks are still availible.
  1895. */
  1896. hasMoreFallbacks: boolean;
  1897. }
  1898. }
  1899. declare module "babylonjs/Maths/math.size" {
  1900. /**
  1901. * Interface for the size containing width and height
  1902. */
  1903. export interface ISize {
  1904. /**
  1905. * Width
  1906. */
  1907. width: number;
  1908. /**
  1909. * Heighht
  1910. */
  1911. height: number;
  1912. }
  1913. /**
  1914. * Size containing widht and height
  1915. */
  1916. export class Size implements ISize {
  1917. /**
  1918. * Width
  1919. */
  1920. width: number;
  1921. /**
  1922. * Height
  1923. */
  1924. height: number;
  1925. /**
  1926. * Creates a Size object from the given width and height (floats).
  1927. * @param width width of the new size
  1928. * @param height height of the new size
  1929. */
  1930. constructor(width: number, height: number);
  1931. /**
  1932. * Returns a string with the Size width and height
  1933. * @returns a string with the Size width and height
  1934. */
  1935. toString(): string;
  1936. /**
  1937. * "Size"
  1938. * @returns the string "Size"
  1939. */
  1940. getClassName(): string;
  1941. /**
  1942. * Returns the Size hash code.
  1943. * @returns a hash code for a unique width and height
  1944. */
  1945. getHashCode(): number;
  1946. /**
  1947. * Updates the current size from the given one.
  1948. * @param src the given size
  1949. */
  1950. copyFrom(src: Size): void;
  1951. /**
  1952. * Updates in place the current Size from the given floats.
  1953. * @param width width of the new size
  1954. * @param height height of the new size
  1955. * @returns the updated Size.
  1956. */
  1957. copyFromFloats(width: number, height: number): Size;
  1958. /**
  1959. * Updates in place the current Size from the given floats.
  1960. * @param width width to set
  1961. * @param height height to set
  1962. * @returns the updated Size.
  1963. */
  1964. set(width: number, height: number): Size;
  1965. /**
  1966. * Multiplies the width and height by numbers
  1967. * @param w factor to multiple the width by
  1968. * @param h factor to multiple the height by
  1969. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1970. */
  1971. multiplyByFloats(w: number, h: number): Size;
  1972. /**
  1973. * Clones the size
  1974. * @returns a new Size copied from the given one.
  1975. */
  1976. clone(): Size;
  1977. /**
  1978. * True if the current Size and the given one width and height are strictly equal.
  1979. * @param other the other size to compare against
  1980. * @returns True if the current Size and the given one width and height are strictly equal.
  1981. */
  1982. equals(other: Size): boolean;
  1983. /**
  1984. * The surface of the Size : width * height (float).
  1985. */
  1986. get surface(): number;
  1987. /**
  1988. * Create a new size of zero
  1989. * @returns a new Size set to (0.0, 0.0)
  1990. */
  1991. static Zero(): Size;
  1992. /**
  1993. * Sums the width and height of two sizes
  1994. * @param otherSize size to add to this size
  1995. * @returns a new Size set as the addition result of the current Size and the given one.
  1996. */
  1997. add(otherSize: Size): Size;
  1998. /**
  1999. * Subtracts the width and height of two
  2000. * @param otherSize size to subtract to this size
  2001. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2002. */
  2003. subtract(otherSize: Size): Size;
  2004. /**
  2005. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2006. * @param start starting size to lerp between
  2007. * @param end end size to lerp between
  2008. * @param amount amount to lerp between the start and end values
  2009. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2010. */
  2011. static Lerp(start: Size, end: Size, amount: number): Size;
  2012. }
  2013. }
  2014. declare module "babylonjs/Materials/Textures/thinTexture" {
  2015. import { Nullable } from "babylonjs/types";
  2016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  2017. import { ISize } from "babylonjs/Maths/math.size";
  2018. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  2019. /**
  2020. * Base class of all the textures in babylon.
  2021. * It groups all the common properties required to work with Thin Engine.
  2022. */
  2023. export class ThinTexture {
  2024. protected _wrapU: number;
  2025. /**
  2026. * | Value | Type | Description |
  2027. * | ----- | ------------------ | ----------- |
  2028. * | 0 | CLAMP_ADDRESSMODE | |
  2029. * | 1 | WRAP_ADDRESSMODE | |
  2030. * | 2 | MIRROR_ADDRESSMODE | |
  2031. */
  2032. get wrapU(): number;
  2033. set wrapU(value: number);
  2034. protected _wrapV: number;
  2035. /**
  2036. * | Value | Type | Description |
  2037. * | ----- | ------------------ | ----------- |
  2038. * | 0 | CLAMP_ADDRESSMODE | |
  2039. * | 1 | WRAP_ADDRESSMODE | |
  2040. * | 2 | MIRROR_ADDRESSMODE | |
  2041. */
  2042. get wrapV(): number;
  2043. set wrapV(value: number);
  2044. /**
  2045. * | Value | Type | Description |
  2046. * | ----- | ------------------ | ----------- |
  2047. * | 0 | CLAMP_ADDRESSMODE | |
  2048. * | 1 | WRAP_ADDRESSMODE | |
  2049. * | 2 | MIRROR_ADDRESSMODE | |
  2050. */
  2051. wrapR: number;
  2052. /**
  2053. * With compliant hardware and browser (supporting anisotropic filtering)
  2054. * this defines the level of anisotropic filtering in the texture.
  2055. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2056. */
  2057. anisotropicFilteringLevel: number;
  2058. /**
  2059. * Define the current state of the loading sequence when in delayed load mode.
  2060. */
  2061. delayLoadState: number;
  2062. /**
  2063. * How a texture is mapped.
  2064. * Unused in thin texture mode.
  2065. */
  2066. get coordinatesMode(): number;
  2067. /**
  2068. * Define if the texture is a cube texture or if false a 2d texture.
  2069. */
  2070. get isCube(): boolean;
  2071. set isCube(value: boolean);
  2072. /**
  2073. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2074. */
  2075. get is3D(): boolean;
  2076. set is3D(value: boolean);
  2077. /**
  2078. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2079. */
  2080. get is2DArray(): boolean;
  2081. set is2DArray(value: boolean);
  2082. /**
  2083. * Get the class name of the texture.
  2084. * @returns "ThinTexture"
  2085. */
  2086. getClassName(): string;
  2087. /** @hidden */
  2088. _texture: Nullable<InternalTexture>;
  2089. protected _engine: Nullable<ThinEngine>;
  2090. private _cachedSize;
  2091. private _cachedBaseSize;
  2092. /**
  2093. * Instantiates a new ThinTexture.
  2094. * Base class of all the textures in babylon.
  2095. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2096. * @param internalTexture Define the internalTexture to wrap
  2097. */
  2098. constructor(internalTexture: Nullable<InternalTexture>);
  2099. /**
  2100. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2101. * @returns true if fully ready
  2102. */
  2103. isReady(): boolean;
  2104. /**
  2105. * Triggers the load sequence in delayed load mode.
  2106. */
  2107. delayLoad(): void;
  2108. /**
  2109. * Get the underlying lower level texture from Babylon.
  2110. * @returns the insternal texture
  2111. */
  2112. getInternalTexture(): Nullable<InternalTexture>;
  2113. /**
  2114. * Get the size of the texture.
  2115. * @returns the texture size.
  2116. */
  2117. getSize(): ISize;
  2118. /**
  2119. * Get the base size of the texture.
  2120. * It can be different from the size if the texture has been resized for POT for instance
  2121. * @returns the base size
  2122. */
  2123. getBaseSize(): ISize;
  2124. /**
  2125. * Update the sampling mode of the texture.
  2126. * Default is Trilinear mode.
  2127. *
  2128. * | Value | Type | Description |
  2129. * | ----- | ------------------ | ----------- |
  2130. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2131. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2132. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2133. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2134. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2135. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2136. * | 7 | NEAREST_LINEAR | |
  2137. * | 8 | NEAREST_NEAREST | |
  2138. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2139. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2140. * | 11 | LINEAR_LINEAR | |
  2141. * | 12 | LINEAR_NEAREST | |
  2142. *
  2143. * > _mag_: magnification filter (close to the viewer)
  2144. * > _min_: minification filter (far from the viewer)
  2145. * > _mip_: filter used between mip map levels
  2146. *@param samplingMode Define the new sampling mode of the texture
  2147. */
  2148. updateSamplingMode(samplingMode: number): void;
  2149. /**
  2150. * Release and destroy the underlying lower level texture aka internalTexture.
  2151. */
  2152. releaseInternalTexture(): void;
  2153. /**
  2154. * Dispose the texture and release its associated resources.
  2155. */
  2156. dispose(): void;
  2157. }
  2158. }
  2159. declare module "babylonjs/Misc/smartArray" {
  2160. /**
  2161. * Defines an array and its length.
  2162. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2163. */
  2164. export interface ISmartArrayLike<T> {
  2165. /**
  2166. * The data of the array.
  2167. */
  2168. data: Array<T>;
  2169. /**
  2170. * The active length of the array.
  2171. */
  2172. length: number;
  2173. }
  2174. /**
  2175. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2176. */
  2177. export class SmartArray<T> implements ISmartArrayLike<T> {
  2178. /**
  2179. * The full set of data from the array.
  2180. */
  2181. data: Array<T>;
  2182. /**
  2183. * The active length of the array.
  2184. */
  2185. length: number;
  2186. protected _id: number;
  2187. /**
  2188. * Instantiates a Smart Array.
  2189. * @param capacity defines the default capacity of the array.
  2190. */
  2191. constructor(capacity: number);
  2192. /**
  2193. * Pushes a value at the end of the active data.
  2194. * @param value defines the object to push in the array.
  2195. */
  2196. push(value: T): void;
  2197. /**
  2198. * Iterates over the active data and apply the lambda to them.
  2199. * @param func defines the action to apply on each value.
  2200. */
  2201. forEach(func: (content: T) => void): void;
  2202. /**
  2203. * Sorts the full sets of data.
  2204. * @param compareFn defines the comparison function to apply.
  2205. */
  2206. sort(compareFn: (a: T, b: T) => number): void;
  2207. /**
  2208. * Resets the active data to an empty array.
  2209. */
  2210. reset(): void;
  2211. /**
  2212. * Releases all the data from the array as well as the array.
  2213. */
  2214. dispose(): void;
  2215. /**
  2216. * Concats the active data with a given array.
  2217. * @param array defines the data to concatenate with.
  2218. */
  2219. concat(array: any): void;
  2220. /**
  2221. * Returns the position of a value in the active data.
  2222. * @param value defines the value to find the index for
  2223. * @returns the index if found in the active data otherwise -1
  2224. */
  2225. indexOf(value: T): number;
  2226. /**
  2227. * Returns whether an element is part of the active data.
  2228. * @param value defines the value to look for
  2229. * @returns true if found in the active data otherwise false
  2230. */
  2231. contains(value: T): boolean;
  2232. private static _GlobalId;
  2233. }
  2234. /**
  2235. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2236. * The data in this array can only be present once
  2237. */
  2238. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2239. private _duplicateId;
  2240. /**
  2241. * Pushes a value at the end of the active data.
  2242. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2243. * @param value defines the object to push in the array.
  2244. */
  2245. push(value: T): void;
  2246. /**
  2247. * Pushes a value at the end of the active data.
  2248. * If the data is already present, it won t be added again
  2249. * @param value defines the object to push in the array.
  2250. * @returns true if added false if it was already present
  2251. */
  2252. pushNoDuplicate(value: T): boolean;
  2253. /**
  2254. * Resets the active data to an empty array.
  2255. */
  2256. reset(): void;
  2257. /**
  2258. * Concats the active data with a given array.
  2259. * This ensures no dupplicate will be present in the result.
  2260. * @param array defines the data to concatenate with.
  2261. */
  2262. concatWithNoDuplicate(array: any): void;
  2263. }
  2264. }
  2265. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2266. /**
  2267. * Class used to evalaute queries containing `and` and `or` operators
  2268. */
  2269. export class AndOrNotEvaluator {
  2270. /**
  2271. * Evaluate a query
  2272. * @param query defines the query to evaluate
  2273. * @param evaluateCallback defines the callback used to filter result
  2274. * @returns true if the query matches
  2275. */
  2276. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2277. private static _HandleParenthesisContent;
  2278. private static _SimplifyNegation;
  2279. }
  2280. }
  2281. declare module "babylonjs/Misc/tags" {
  2282. /**
  2283. * Class used to store custom tags
  2284. */
  2285. export class Tags {
  2286. /**
  2287. * Adds support for tags on the given object
  2288. * @param obj defines the object to use
  2289. */
  2290. static EnableFor(obj: any): void;
  2291. /**
  2292. * Removes tags support
  2293. * @param obj defines the object to use
  2294. */
  2295. static DisableFor(obj: any): void;
  2296. /**
  2297. * Gets a boolean indicating if the given object has tags
  2298. * @param obj defines the object to use
  2299. * @returns a boolean
  2300. */
  2301. static HasTags(obj: any): boolean;
  2302. /**
  2303. * Gets the tags available on a given object
  2304. * @param obj defines the object to use
  2305. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2306. * @returns the tags
  2307. */
  2308. static GetTags(obj: any, asString?: boolean): any;
  2309. /**
  2310. * Adds tags to an object
  2311. * @param obj defines the object to use
  2312. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2313. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2314. */
  2315. static AddTagsTo(obj: any, tagsString: string): void;
  2316. /**
  2317. * @hidden
  2318. */
  2319. static _AddTagTo(obj: any, tag: string): void;
  2320. /**
  2321. * Removes specific tags from a specific object
  2322. * @param obj defines the object to use
  2323. * @param tagsString defines the tags to remove
  2324. */
  2325. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2326. /**
  2327. * @hidden
  2328. */
  2329. static _RemoveTagFrom(obj: any, tag: string): void;
  2330. /**
  2331. * Defines if tags hosted on an object match a given query
  2332. * @param obj defines the object to use
  2333. * @param tagsQuery defines the tag query
  2334. * @returns a boolean
  2335. */
  2336. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2337. }
  2338. }
  2339. declare module "babylonjs/Maths/math.scalar" {
  2340. /**
  2341. * Scalar computation library
  2342. */
  2343. export class Scalar {
  2344. /**
  2345. * Two pi constants convenient for computation.
  2346. */
  2347. static TwoPi: number;
  2348. /**
  2349. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2350. * @param a number
  2351. * @param b number
  2352. * @param epsilon (default = 1.401298E-45)
  2353. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2354. */
  2355. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2356. /**
  2357. * Returns a string : the upper case translation of the number i to hexadecimal.
  2358. * @param i number
  2359. * @returns the upper case translation of the number i to hexadecimal.
  2360. */
  2361. static ToHex(i: number): string;
  2362. /**
  2363. * Returns -1 if value is negative and +1 is value is positive.
  2364. * @param value the value
  2365. * @returns the value itself if it's equal to zero.
  2366. */
  2367. static Sign(value: number): number;
  2368. /**
  2369. * Returns the value itself if it's between min and max.
  2370. * Returns min if the value is lower than min.
  2371. * Returns max if the value is greater than max.
  2372. * @param value the value to clmap
  2373. * @param min the min value to clamp to (default: 0)
  2374. * @param max the max value to clamp to (default: 1)
  2375. * @returns the clamped value
  2376. */
  2377. static Clamp(value: number, min?: number, max?: number): number;
  2378. /**
  2379. * the log2 of value.
  2380. * @param value the value to compute log2 of
  2381. * @returns the log2 of value.
  2382. */
  2383. static Log2(value: number): number;
  2384. /**
  2385. * the floor part of a log2 value.
  2386. * @param value the value to compute log2 of
  2387. * @returns the log2 of value.
  2388. */
  2389. static ILog2(value: number): number;
  2390. /**
  2391. * Loops the value, so that it is never larger than length and never smaller than 0.
  2392. *
  2393. * This is similar to the modulo operator but it works with floating point numbers.
  2394. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2395. * With t = 5 and length = 2.5, the result would be 0.0.
  2396. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2397. * @param value the value
  2398. * @param length the length
  2399. * @returns the looped value
  2400. */
  2401. static Repeat(value: number, length: number): number;
  2402. /**
  2403. * Normalize the value between 0.0 and 1.0 using min and max values
  2404. * @param value value to normalize
  2405. * @param min max to normalize between
  2406. * @param max min to normalize between
  2407. * @returns the normalized value
  2408. */
  2409. static Normalize(value: number, min: number, max: number): number;
  2410. /**
  2411. * Denormalize the value from 0.0 and 1.0 using min and max values
  2412. * @param normalized value to denormalize
  2413. * @param min max to denormalize between
  2414. * @param max min to denormalize between
  2415. * @returns the denormalized value
  2416. */
  2417. static Denormalize(normalized: number, min: number, max: number): number;
  2418. /**
  2419. * Calculates the shortest difference between two given angles given in degrees.
  2420. * @param current current angle in degrees
  2421. * @param target target angle in degrees
  2422. * @returns the delta
  2423. */
  2424. static DeltaAngle(current: number, target: number): number;
  2425. /**
  2426. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2427. * @param tx value
  2428. * @param length length
  2429. * @returns The returned value will move back and forth between 0 and length
  2430. */
  2431. static PingPong(tx: number, length: number): number;
  2432. /**
  2433. * Interpolates between min and max with smoothing at the limits.
  2434. *
  2435. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2436. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2437. * @param from from
  2438. * @param to to
  2439. * @param tx value
  2440. * @returns the smooth stepped value
  2441. */
  2442. static SmoothStep(from: number, to: number, tx: number): number;
  2443. /**
  2444. * Moves a value current towards target.
  2445. *
  2446. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2447. * Negative values of maxDelta pushes the value away from target.
  2448. * @param current current value
  2449. * @param target target value
  2450. * @param maxDelta max distance to move
  2451. * @returns resulting value
  2452. */
  2453. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2454. /**
  2455. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2456. *
  2457. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2458. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2459. * @param current current value
  2460. * @param target target value
  2461. * @param maxDelta max distance to move
  2462. * @returns resulting angle
  2463. */
  2464. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2465. /**
  2466. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2467. * @param start start value
  2468. * @param end target value
  2469. * @param amount amount to lerp between
  2470. * @returns the lerped value
  2471. */
  2472. static Lerp(start: number, end: number, amount: number): number;
  2473. /**
  2474. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2475. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  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 LerpAngle(start: number, end: number, amount: number): number;
  2482. /**
  2483. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2484. * @param a start value
  2485. * @param b target value
  2486. * @param value value between a and b
  2487. * @returns the inverseLerp value
  2488. */
  2489. static InverseLerp(a: number, b: number, value: number): number;
  2490. /**
  2491. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2492. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2493. * @param value1 spline value
  2494. * @param tangent1 spline value
  2495. * @param value2 spline value
  2496. * @param tangent2 spline value
  2497. * @param amount input value
  2498. * @returns hermite result
  2499. */
  2500. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2501. /**
  2502. * Returns a random float number between and min and max values
  2503. * @param min min value of random
  2504. * @param max max value of random
  2505. * @returns random value
  2506. */
  2507. static RandomRange(min: number, max: number): number;
  2508. /**
  2509. * This function returns percentage of a number in a given range.
  2510. *
  2511. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2512. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2513. * @param number to convert to percentage
  2514. * @param min min range
  2515. * @param max max range
  2516. * @returns the percentage
  2517. */
  2518. static RangeToPercent(number: number, min: number, max: number): number;
  2519. /**
  2520. * This function returns number that corresponds to the percentage in a given range.
  2521. *
  2522. * PercentToRange(0.34,0,100) will return 34.
  2523. * @param percent to convert to number
  2524. * @param min min range
  2525. * @param max max range
  2526. * @returns the number
  2527. */
  2528. static PercentToRange(percent: number, min: number, max: number): number;
  2529. /**
  2530. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2531. * @param angle The angle to normalize in radian.
  2532. * @return The converted angle.
  2533. */
  2534. static NormalizeRadians(angle: number): number;
  2535. }
  2536. }
  2537. declare module "babylonjs/Maths/math.constants" {
  2538. /**
  2539. * Constant used to convert a value to gamma space
  2540. * @ignorenaming
  2541. */
  2542. export const ToGammaSpace: number;
  2543. /**
  2544. * Constant used to convert a value to linear space
  2545. * @ignorenaming
  2546. */
  2547. export const ToLinearSpace = 2.2;
  2548. /**
  2549. * Constant used to define the minimal number value in Babylon.js
  2550. * @ignorenaming
  2551. */
  2552. let Epsilon: number;
  2553. export { Epsilon };
  2554. }
  2555. declare module "babylonjs/Maths/math.viewport" {
  2556. /**
  2557. * Class used to represent a viewport on screen
  2558. */
  2559. export class Viewport {
  2560. /** viewport left coordinate */
  2561. x: number;
  2562. /** viewport top coordinate */
  2563. y: number;
  2564. /**viewport width */
  2565. width: number;
  2566. /** viewport height */
  2567. height: number;
  2568. /**
  2569. * Creates a Viewport object located at (x, y) and sized (width, height)
  2570. * @param x defines viewport left coordinate
  2571. * @param y defines viewport top coordinate
  2572. * @param width defines the viewport width
  2573. * @param height defines the viewport height
  2574. */
  2575. constructor(
  2576. /** viewport left coordinate */
  2577. x: number,
  2578. /** viewport top coordinate */
  2579. y: number,
  2580. /**viewport width */
  2581. width: number,
  2582. /** viewport height */
  2583. height: number);
  2584. /**
  2585. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2586. * @param renderWidth defines the rendering width
  2587. * @param renderHeight defines the rendering height
  2588. * @returns a new Viewport
  2589. */
  2590. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2591. /**
  2592. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2593. * @param renderWidth defines the rendering width
  2594. * @param renderHeight defines the rendering height
  2595. * @param ref defines the target viewport
  2596. * @returns the current viewport
  2597. */
  2598. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2599. /**
  2600. * Returns a new Viewport copied from the current one
  2601. * @returns a new Viewport
  2602. */
  2603. clone(): Viewport;
  2604. }
  2605. }
  2606. declare module "babylonjs/Misc/arrayTools" {
  2607. /**
  2608. * Class containing a set of static utilities functions for arrays.
  2609. */
  2610. export class ArrayTools {
  2611. /**
  2612. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2613. * @param size the number of element to construct and put in the array
  2614. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2615. * @returns a new array filled with new objects
  2616. */
  2617. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2618. }
  2619. }
  2620. declare module "babylonjs/Maths/math.plane" {
  2621. import { DeepImmutable } from "babylonjs/types";
  2622. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2623. /**
  2624. * Represents a plane by the equation ax + by + cz + d = 0
  2625. */
  2626. export class Plane {
  2627. private static _TmpMatrix;
  2628. /**
  2629. * Normal of the plane (a,b,c)
  2630. */
  2631. normal: Vector3;
  2632. /**
  2633. * d component of the plane
  2634. */
  2635. d: number;
  2636. /**
  2637. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2638. * @param a a component of the plane
  2639. * @param b b component of the plane
  2640. * @param c c component of the plane
  2641. * @param d d component of the plane
  2642. */
  2643. constructor(a: number, b: number, c: number, d: number);
  2644. /**
  2645. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2646. */
  2647. asArray(): number[];
  2648. /**
  2649. * @returns a new plane copied from the current Plane.
  2650. */
  2651. clone(): Plane;
  2652. /**
  2653. * @returns the string "Plane".
  2654. */
  2655. getClassName(): string;
  2656. /**
  2657. * @returns the Plane hash code.
  2658. */
  2659. getHashCode(): number;
  2660. /**
  2661. * Normalize the current Plane in place.
  2662. * @returns the updated Plane.
  2663. */
  2664. normalize(): Plane;
  2665. /**
  2666. * Applies a transformation the plane and returns the result
  2667. * @param transformation the transformation matrix to be applied to the plane
  2668. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2669. */
  2670. transform(transformation: DeepImmutable<Matrix>): Plane;
  2671. /**
  2672. * Compute the dot product between the point and the plane normal
  2673. * @param point point to calculate the dot product with
  2674. * @returns the dot product (float) of the point coordinates and the plane normal.
  2675. */
  2676. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2677. /**
  2678. * Updates the current Plane from the plane defined by the three given points.
  2679. * @param point1 one of the points used to contruct the plane
  2680. * @param point2 one of the points used to contruct the plane
  2681. * @param point3 one of the points used to contruct the plane
  2682. * @returns the updated Plane.
  2683. */
  2684. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2685. /**
  2686. * 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).
  2687. * Note that for this function to work as expected you should make sure that:
  2688. * - direction and the plane normal are normalized
  2689. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2690. * @param direction the direction to check if the plane is facing
  2691. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2692. * @returns True if the plane is facing the given direction
  2693. */
  2694. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2695. /**
  2696. * Calculates the distance to a point
  2697. * @param point point to calculate distance to
  2698. * @returns the signed distance (float) from the given point to the Plane.
  2699. */
  2700. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2701. /**
  2702. * Creates a plane from an array
  2703. * @param array the array to create a plane from
  2704. * @returns a new Plane from the given array.
  2705. */
  2706. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2707. /**
  2708. * Creates a plane from three points
  2709. * @param point1 point used to create the plane
  2710. * @param point2 point used to create the plane
  2711. * @param point3 point used to create the plane
  2712. * @returns a new Plane defined by the three given points.
  2713. */
  2714. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2715. /**
  2716. * Creates a plane from an origin point and a normal
  2717. * @param origin origin of the plane to be constructed
  2718. * @param normal normal of the plane to be constructed
  2719. * @returns a new Plane the normal vector to this plane at the given origin point.
  2720. * Note : the vector "normal" is updated because normalized.
  2721. */
  2722. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2723. /**
  2724. * Calculates the distance from a plane and a point
  2725. * @param origin origin of the plane to be constructed
  2726. * @param normal normal of the plane to be constructed
  2727. * @param point point to calculate distance to
  2728. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2729. */
  2730. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2731. }
  2732. }
  2733. declare module "babylonjs/Engines/performanceConfigurator" {
  2734. /** @hidden */
  2735. export class PerformanceConfigurator {
  2736. /** @hidden */
  2737. static MatrixUse64Bits: boolean;
  2738. /** @hidden */
  2739. static MatrixTrackPrecisionChange: boolean;
  2740. /** @hidden */
  2741. static MatrixCurrentType: any;
  2742. /** @hidden */
  2743. static MatrixTrackedMatrices: Array<any> | null;
  2744. /** @hidden */
  2745. static SetMatrixPrecision(use64bits: boolean): void;
  2746. }
  2747. }
  2748. declare module "babylonjs/Maths/math.vector" {
  2749. import { Viewport } from "babylonjs/Maths/math.viewport";
  2750. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2751. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2752. import { Plane } from "babylonjs/Maths/math.plane";
  2753. /**
  2754. * Class representing a vector containing 2 coordinates
  2755. */
  2756. export class Vector2 {
  2757. /** defines the first coordinate */
  2758. x: number;
  2759. /** defines the second coordinate */
  2760. y: number;
  2761. /**
  2762. * Creates a new Vector2 from the given x and y coordinates
  2763. * @param x defines the first coordinate
  2764. * @param y defines the second coordinate
  2765. */
  2766. constructor(
  2767. /** defines the first coordinate */
  2768. x?: number,
  2769. /** defines the second coordinate */
  2770. y?: number);
  2771. /**
  2772. * Gets a string with the Vector2 coordinates
  2773. * @returns a string with the Vector2 coordinates
  2774. */
  2775. toString(): string;
  2776. /**
  2777. * Gets class name
  2778. * @returns the string "Vector2"
  2779. */
  2780. getClassName(): string;
  2781. /**
  2782. * Gets current vector hash code
  2783. * @returns the Vector2 hash code as a number
  2784. */
  2785. getHashCode(): number;
  2786. /**
  2787. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2788. * @param array defines the source array
  2789. * @param index defines the offset in source array
  2790. * @returns the current Vector2
  2791. */
  2792. toArray(array: FloatArray, index?: number): Vector2;
  2793. /**
  2794. * Update the current vector from an array
  2795. * @param array defines the destination array
  2796. * @param index defines the offset in the destination array
  2797. * @returns the current Vector3
  2798. */
  2799. fromArray(array: FloatArray, index?: number): Vector2;
  2800. /**
  2801. * Copy the current vector to an array
  2802. * @returns a new array with 2 elements: the Vector2 coordinates.
  2803. */
  2804. asArray(): number[];
  2805. /**
  2806. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2807. * @param source defines the source Vector2
  2808. * @returns the current updated Vector2
  2809. */
  2810. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2811. /**
  2812. * Sets the Vector2 coordinates with the given floats
  2813. * @param x defines the first coordinate
  2814. * @param y defines the second coordinate
  2815. * @returns the current updated Vector2
  2816. */
  2817. copyFromFloats(x: number, y: number): Vector2;
  2818. /**
  2819. * Sets the Vector2 coordinates with the given floats
  2820. * @param x defines the first coordinate
  2821. * @param y defines the second coordinate
  2822. * @returns the current updated Vector2
  2823. */
  2824. set(x: number, y: number): Vector2;
  2825. /**
  2826. * Add another vector with the current one
  2827. * @param otherVector defines the other vector
  2828. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2829. */
  2830. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2831. /**
  2832. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2833. * @param otherVector defines the other vector
  2834. * @param result defines the target vector
  2835. * @returns the unmodified current Vector2
  2836. */
  2837. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2838. /**
  2839. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2840. * @param otherVector defines the other vector
  2841. * @returns the current updated Vector2
  2842. */
  2843. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2844. /**
  2845. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2846. * @param otherVector defines the other vector
  2847. * @returns a new Vector2
  2848. */
  2849. addVector3(otherVector: Vector3): Vector2;
  2850. /**
  2851. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2852. * @param otherVector defines the other vector
  2853. * @returns a new Vector2
  2854. */
  2855. subtract(otherVector: Vector2): Vector2;
  2856. /**
  2857. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2858. * @param otherVector defines the other vector
  2859. * @param result defines the target vector
  2860. * @returns the unmodified current Vector2
  2861. */
  2862. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2863. /**
  2864. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2865. * @param otherVector defines the other vector
  2866. * @returns the current updated Vector2
  2867. */
  2868. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2869. /**
  2870. * Multiplies in place the current Vector2 coordinates by the given ones
  2871. * @param otherVector defines the other vector
  2872. * @returns the current updated Vector2
  2873. */
  2874. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2875. /**
  2876. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2877. * @param otherVector defines the other vector
  2878. * @returns a new Vector2
  2879. */
  2880. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2881. /**
  2882. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2883. * @param otherVector defines the other vector
  2884. * @param result defines the target vector
  2885. * @returns the unmodified current Vector2
  2886. */
  2887. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2888. /**
  2889. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2890. * @param x defines the first coordinate
  2891. * @param y defines the second coordinate
  2892. * @returns a new Vector2
  2893. */
  2894. multiplyByFloats(x: number, y: number): Vector2;
  2895. /**
  2896. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2897. * @param otherVector defines the other vector
  2898. * @returns a new Vector2
  2899. */
  2900. divide(otherVector: Vector2): Vector2;
  2901. /**
  2902. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2903. * @param otherVector defines the other vector
  2904. * @param result defines the target vector
  2905. * @returns the unmodified current Vector2
  2906. */
  2907. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2908. /**
  2909. * Divides the current Vector2 coordinates by the given ones
  2910. * @param otherVector defines the other vector
  2911. * @returns the current updated Vector2
  2912. */
  2913. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2914. /**
  2915. * Gets a new Vector2 with current Vector2 negated coordinates
  2916. * @returns a new Vector2
  2917. */
  2918. negate(): Vector2;
  2919. /**
  2920. * Negate this vector in place
  2921. * @returns this
  2922. */
  2923. negateInPlace(): Vector2;
  2924. /**
  2925. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2926. * @param result defines the Vector3 object where to store the result
  2927. * @returns the current Vector2
  2928. */
  2929. negateToRef(result: Vector2): Vector2;
  2930. /**
  2931. * Multiply the Vector2 coordinates by scale
  2932. * @param scale defines the scaling factor
  2933. * @returns the current updated Vector2
  2934. */
  2935. scaleInPlace(scale: number): Vector2;
  2936. /**
  2937. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2938. * @param scale defines the scaling factor
  2939. * @returns a new Vector2
  2940. */
  2941. scale(scale: number): Vector2;
  2942. /**
  2943. * Scale the current Vector2 values by a factor to a given Vector2
  2944. * @param scale defines the scale factor
  2945. * @param result defines the Vector2 object where to store the result
  2946. * @returns the unmodified current Vector2
  2947. */
  2948. scaleToRef(scale: number, result: Vector2): Vector2;
  2949. /**
  2950. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2951. * @param scale defines the scale factor
  2952. * @param result defines the Vector2 object where to store the result
  2953. * @returns the unmodified current Vector2
  2954. */
  2955. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2956. /**
  2957. * Gets a boolean if two vectors are equals
  2958. * @param otherVector defines the other vector
  2959. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2960. */
  2961. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2962. /**
  2963. * Gets a boolean if two vectors are equals (using an epsilon value)
  2964. * @param otherVector defines the other vector
  2965. * @param epsilon defines the minimal distance to consider equality
  2966. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2967. */
  2968. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2969. /**
  2970. * Gets a new Vector2 from current Vector2 floored values
  2971. * @returns a new Vector2
  2972. */
  2973. floor(): Vector2;
  2974. /**
  2975. * Gets a new Vector2 from current Vector2 floored values
  2976. * @returns a new Vector2
  2977. */
  2978. fract(): Vector2;
  2979. /**
  2980. * Gets the length of the vector
  2981. * @returns the vector length (float)
  2982. */
  2983. length(): number;
  2984. /**
  2985. * Gets the vector squared length
  2986. * @returns the vector squared length (float)
  2987. */
  2988. lengthSquared(): number;
  2989. /**
  2990. * Normalize the vector
  2991. * @returns the current updated Vector2
  2992. */
  2993. normalize(): Vector2;
  2994. /**
  2995. * Gets a new Vector2 copied from the Vector2
  2996. * @returns a new Vector2
  2997. */
  2998. clone(): Vector2;
  2999. /**
  3000. * Gets a new Vector2(0, 0)
  3001. * @returns a new Vector2
  3002. */
  3003. static Zero(): Vector2;
  3004. /**
  3005. * Gets a new Vector2(1, 1)
  3006. * @returns a new Vector2
  3007. */
  3008. static One(): Vector2;
  3009. /**
  3010. * Gets a new Vector2 set from the given index element of the given array
  3011. * @param array defines the data source
  3012. * @param offset defines the offset in the data source
  3013. * @returns a new Vector2
  3014. */
  3015. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  3016. /**
  3017. * Sets "result" from the given index element of the given array
  3018. * @param array defines the data source
  3019. * @param offset defines the offset in the data source
  3020. * @param result defines the target vector
  3021. */
  3022. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  3023. /**
  3024. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  3025. * @param value1 defines 1st point of control
  3026. * @param value2 defines 2nd point of control
  3027. * @param value3 defines 3rd point of control
  3028. * @param value4 defines 4th point of control
  3029. * @param amount defines the interpolation factor
  3030. * @returns a new Vector2
  3031. */
  3032. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  3033. /**
  3034. * 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".
  3035. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3036. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3037. * @param value defines the value to clamp
  3038. * @param min defines the lower limit
  3039. * @param max defines the upper limit
  3040. * @returns a new Vector2
  3041. */
  3042. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3043. /**
  3044. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3045. * @param value1 defines the 1st control point
  3046. * @param tangent1 defines the outgoing tangent
  3047. * @param value2 defines the 2nd control point
  3048. * @param tangent2 defines the incoming tangent
  3049. * @param amount defines the interpolation factor
  3050. * @returns a new Vector2
  3051. */
  3052. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3053. /**
  3054. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3055. * @param start defines the start vector
  3056. * @param end defines the end vector
  3057. * @param amount defines the interpolation factor
  3058. * @returns a new Vector2
  3059. */
  3060. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3061. /**
  3062. * Gets the dot product of the vector "left" and the vector "right"
  3063. * @param left defines first vector
  3064. * @param right defines second vector
  3065. * @returns the dot product (float)
  3066. */
  3067. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3068. /**
  3069. * Returns a new Vector2 equal to the normalized given vector
  3070. * @param vector defines the vector to normalize
  3071. * @returns a new Vector2
  3072. */
  3073. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3074. /**
  3075. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3076. * @param left defines 1st vector
  3077. * @param right defines 2nd vector
  3078. * @returns a new Vector2
  3079. */
  3080. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3081. /**
  3082. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3083. * @param left defines 1st vector
  3084. * @param right defines 2nd vector
  3085. * @returns a new Vector2
  3086. */
  3087. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3088. /**
  3089. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3090. * @param vector defines the vector to transform
  3091. * @param transformation defines the matrix to apply
  3092. * @returns a new Vector2
  3093. */
  3094. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3095. /**
  3096. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3097. * @param vector defines the vector to transform
  3098. * @param transformation defines the matrix to apply
  3099. * @param result defines the target vector
  3100. */
  3101. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3102. /**
  3103. * Determines if a given vector is included in a triangle
  3104. * @param p defines the vector to test
  3105. * @param p0 defines 1st triangle point
  3106. * @param p1 defines 2nd triangle point
  3107. * @param p2 defines 3rd triangle point
  3108. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3109. */
  3110. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3111. /**
  3112. * Gets the distance between the vectors "value1" and "value2"
  3113. * @param value1 defines first vector
  3114. * @param value2 defines second vector
  3115. * @returns the distance between vectors
  3116. */
  3117. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3118. /**
  3119. * Returns the squared distance between the vectors "value1" and "value2"
  3120. * @param value1 defines first vector
  3121. * @param value2 defines second vector
  3122. * @returns the squared distance between vectors
  3123. */
  3124. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3125. /**
  3126. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3127. * @param value1 defines first vector
  3128. * @param value2 defines second vector
  3129. * @returns a new Vector2
  3130. */
  3131. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3132. /**
  3133. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3134. * @param value1 defines first vector
  3135. * @param value2 defines second vector
  3136. * @param ref defines third vector
  3137. * @returns ref
  3138. */
  3139. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3140. /**
  3141. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3142. * @param p defines the middle point
  3143. * @param segA defines one point of the segment
  3144. * @param segB defines the other point of the segment
  3145. * @returns the shortest distance
  3146. */
  3147. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3148. }
  3149. /**
  3150. * Class used to store (x,y,z) vector representation
  3151. * A Vector3 is the main object used in 3D geometry
  3152. * It can represent etiher the coordinates of a point the space, either a direction
  3153. * Reminder: js uses a left handed forward facing system
  3154. */
  3155. export class Vector3 {
  3156. private static _UpReadOnly;
  3157. private static _ZeroReadOnly;
  3158. /** @hidden */
  3159. _x: number;
  3160. /** @hidden */
  3161. _y: number;
  3162. /** @hidden */
  3163. _z: number;
  3164. /** @hidden */
  3165. _isDirty: boolean;
  3166. /** Gets or sets the x coordinate */
  3167. get x(): number;
  3168. set x(value: number);
  3169. /** Gets or sets the y coordinate */
  3170. get y(): number;
  3171. set y(value: number);
  3172. /** Gets or sets the z coordinate */
  3173. get z(): number;
  3174. set z(value: number);
  3175. /**
  3176. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3177. * @param x defines the first coordinates (on X axis)
  3178. * @param y defines the second coordinates (on Y axis)
  3179. * @param z defines the third coordinates (on Z axis)
  3180. */
  3181. constructor(x?: number, y?: number, z?: number);
  3182. /**
  3183. * Creates a string representation of the Vector3
  3184. * @returns a string with the Vector3 coordinates.
  3185. */
  3186. toString(): string;
  3187. /**
  3188. * Gets the class name
  3189. * @returns the string "Vector3"
  3190. */
  3191. getClassName(): string;
  3192. /**
  3193. * Creates the Vector3 hash code
  3194. * @returns a number which tends to be unique between Vector3 instances
  3195. */
  3196. getHashCode(): number;
  3197. /**
  3198. * Creates an array containing three elements : the coordinates of the Vector3
  3199. * @returns a new array of numbers
  3200. */
  3201. asArray(): number[];
  3202. /**
  3203. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3204. * @param array defines the destination array
  3205. * @param index defines the offset in the destination array
  3206. * @returns the current Vector3
  3207. */
  3208. toArray(array: FloatArray, index?: number): Vector3;
  3209. /**
  3210. * Update the current vector from an array
  3211. * @param array defines the destination array
  3212. * @param index defines the offset in the destination array
  3213. * @returns the current Vector3
  3214. */
  3215. fromArray(array: FloatArray, index?: number): Vector3;
  3216. /**
  3217. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3218. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3219. */
  3220. toQuaternion(): Quaternion;
  3221. /**
  3222. * Adds the given vector to the current Vector3
  3223. * @param otherVector defines the second operand
  3224. * @returns the current updated Vector3
  3225. */
  3226. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Adds the given coordinates to the current Vector3
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @returns the current updated Vector3
  3233. */
  3234. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3235. /**
  3236. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3237. * @param otherVector defines the second operand
  3238. * @returns the resulting Vector3
  3239. */
  3240. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3241. /**
  3242. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3243. * @param otherVector defines the second operand
  3244. * @param result defines the Vector3 object where to store the result
  3245. * @returns the current Vector3
  3246. */
  3247. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3248. /**
  3249. * Subtract the given vector from the current Vector3
  3250. * @param otherVector defines the second operand
  3251. * @returns the current updated Vector3
  3252. */
  3253. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3254. /**
  3255. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3256. * @param otherVector defines the second operand
  3257. * @returns the resulting Vector3
  3258. */
  3259. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3260. /**
  3261. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3262. * @param otherVector defines the second operand
  3263. * @param result defines the Vector3 object where to store the result
  3264. * @returns the current Vector3
  3265. */
  3266. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3267. /**
  3268. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3269. * @param x defines the x coordinate of the operand
  3270. * @param y defines the y coordinate of the operand
  3271. * @param z defines the z coordinate of the operand
  3272. * @returns the resulting Vector3
  3273. */
  3274. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3275. /**
  3276. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3277. * @param x defines the x coordinate of the operand
  3278. * @param y defines the y coordinate of the operand
  3279. * @param z defines the z coordinate of the operand
  3280. * @param result defines the Vector3 object where to store the result
  3281. * @returns the current Vector3
  3282. */
  3283. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3284. /**
  3285. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3286. * @returns a new Vector3
  3287. */
  3288. negate(): Vector3;
  3289. /**
  3290. * Negate this vector in place
  3291. * @returns this
  3292. */
  3293. negateInPlace(): Vector3;
  3294. /**
  3295. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3296. * @param result defines the Vector3 object where to store the result
  3297. * @returns the current Vector3
  3298. */
  3299. negateToRef(result: Vector3): Vector3;
  3300. /**
  3301. * Multiplies the Vector3 coordinates by the float "scale"
  3302. * @param scale defines the multiplier factor
  3303. * @returns the current updated Vector3
  3304. */
  3305. scaleInPlace(scale: number): Vector3;
  3306. /**
  3307. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3308. * @param scale defines the multiplier factor
  3309. * @returns a new Vector3
  3310. */
  3311. scale(scale: number): Vector3;
  3312. /**
  3313. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3314. * @param scale defines the multiplier factor
  3315. * @param result defines the Vector3 object where to store the result
  3316. * @returns the current Vector3
  3317. */
  3318. scaleToRef(scale: number, result: Vector3): Vector3;
  3319. /**
  3320. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3321. * @param scale defines the scale factor
  3322. * @param result defines the Vector3 object where to store the result
  3323. * @returns the unmodified current Vector3
  3324. */
  3325. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3326. /**
  3327. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3328. * @param origin defines the origin of the projection ray
  3329. * @param plane defines the plane to project to
  3330. * @returns the projected vector3
  3331. */
  3332. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3333. /**
  3334. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3335. * @param origin defines the origin of the projection ray
  3336. * @param plane defines the plane to project to
  3337. * @param result defines the Vector3 where to store the result
  3338. */
  3339. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3340. /**
  3341. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3342. * @param otherVector defines the second operand
  3343. * @returns true if both vectors are equals
  3344. */
  3345. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3346. /**
  3347. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3348. * @param otherVector defines the second operand
  3349. * @param epsilon defines the minimal distance to define values as equals
  3350. * @returns true if both vectors are distant less than epsilon
  3351. */
  3352. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3353. /**
  3354. * Returns true if the current Vector3 coordinates equals the given floats
  3355. * @param x defines the x coordinate of the operand
  3356. * @param y defines the y coordinate of the operand
  3357. * @param z defines the z coordinate of the operand
  3358. * @returns true if both vectors are equals
  3359. */
  3360. equalsToFloats(x: number, y: number, z: number): boolean;
  3361. /**
  3362. * Multiplies the current Vector3 coordinates by the given ones
  3363. * @param otherVector defines the second operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3367. /**
  3368. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3369. * @param otherVector defines the second operand
  3370. * @returns the new Vector3
  3371. */
  3372. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3373. /**
  3374. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3375. * @param otherVector defines the second operand
  3376. * @param result defines the Vector3 object where to store the result
  3377. * @returns the current Vector3
  3378. */
  3379. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3380. /**
  3381. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3382. * @param x defines the x coordinate of the operand
  3383. * @param y defines the y coordinate of the operand
  3384. * @param z defines the z coordinate of the operand
  3385. * @returns the new Vector3
  3386. */
  3387. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3388. /**
  3389. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3390. * @param otherVector defines the second operand
  3391. * @returns the new Vector3
  3392. */
  3393. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3394. /**
  3395. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3396. * @param otherVector defines the second operand
  3397. * @param result defines the Vector3 object where to store the result
  3398. * @returns the current Vector3
  3399. */
  3400. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3401. /**
  3402. * Divides the current Vector3 coordinates by the given ones.
  3403. * @param otherVector defines the second operand
  3404. * @returns the current updated Vector3
  3405. */
  3406. divideInPlace(otherVector: Vector3): Vector3;
  3407. /**
  3408. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3409. * @param other defines the second operand
  3410. * @returns the current updated Vector3
  3411. */
  3412. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3413. /**
  3414. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3415. * @param other defines the second operand
  3416. * @returns the current updated Vector3
  3417. */
  3418. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3419. /**
  3420. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3421. * @param x defines the x coordinate of the operand
  3422. * @param y defines the y coordinate of the operand
  3423. * @param z defines the z coordinate of the operand
  3424. * @returns the current updated Vector3
  3425. */
  3426. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3427. /**
  3428. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3429. * @param x defines the x coordinate of the operand
  3430. * @param y defines the y coordinate of the operand
  3431. * @param z defines the z coordinate of the operand
  3432. * @returns the current updated Vector3
  3433. */
  3434. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3435. /**
  3436. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3437. * Check if is non uniform within a certain amount of decimal places to account for this
  3438. * @param epsilon the amount the values can differ
  3439. * @returns if the the vector is non uniform to a certain number of decimal places
  3440. */
  3441. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3442. /**
  3443. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3444. */
  3445. get isNonUniform(): boolean;
  3446. /**
  3447. * Gets a new Vector3 from current Vector3 floored values
  3448. * @returns a new Vector3
  3449. */
  3450. floor(): Vector3;
  3451. /**
  3452. * Gets a new Vector3 from current Vector3 floored values
  3453. * @returns a new Vector3
  3454. */
  3455. fract(): Vector3;
  3456. /**
  3457. * Gets the length of the Vector3
  3458. * @returns the length of the Vector3
  3459. */
  3460. length(): number;
  3461. /**
  3462. * Gets the squared length of the Vector3
  3463. * @returns squared length of the Vector3
  3464. */
  3465. lengthSquared(): number;
  3466. /**
  3467. * Normalize the current Vector3.
  3468. * Please note that this is an in place operation.
  3469. * @returns the current updated Vector3
  3470. */
  3471. normalize(): Vector3;
  3472. /**
  3473. * Reorders the x y z properties of the vector in place
  3474. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3475. * @returns the current updated vector
  3476. */
  3477. reorderInPlace(order: string): this;
  3478. /**
  3479. * Rotates the vector around 0,0,0 by a quaternion
  3480. * @param quaternion the rotation quaternion
  3481. * @param result vector to store the result
  3482. * @returns the resulting vector
  3483. */
  3484. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3485. /**
  3486. * Rotates a vector around a given point
  3487. * @param quaternion the rotation quaternion
  3488. * @param point the point to rotate around
  3489. * @param result vector to store the result
  3490. * @returns the resulting vector
  3491. */
  3492. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3493. /**
  3494. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3495. * The cross product is then orthogonal to both current and "other"
  3496. * @param other defines the right operand
  3497. * @returns the cross product
  3498. */
  3499. cross(other: Vector3): Vector3;
  3500. /**
  3501. * Normalize the current Vector3 with the given input length.
  3502. * Please note that this is an in place operation.
  3503. * @param len the length of the vector
  3504. * @returns the current updated Vector3
  3505. */
  3506. normalizeFromLength(len: number): Vector3;
  3507. /**
  3508. * Normalize the current Vector3 to a new vector
  3509. * @returns the new Vector3
  3510. */
  3511. normalizeToNew(): Vector3;
  3512. /**
  3513. * Normalize the current Vector3 to the reference
  3514. * @param reference define the Vector3 to update
  3515. * @returns the updated Vector3
  3516. */
  3517. normalizeToRef(reference: Vector3): Vector3;
  3518. /**
  3519. * Creates a new Vector3 copied from the current Vector3
  3520. * @returns the new Vector3
  3521. */
  3522. clone(): Vector3;
  3523. /**
  3524. * Copies the given vector coordinates to the current Vector3 ones
  3525. * @param source defines the source Vector3
  3526. * @returns the current updated Vector3
  3527. */
  3528. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3529. /**
  3530. * Copies the given floats to the current Vector3 coordinates
  3531. * @param x defines the x coordinate of the operand
  3532. * @param y defines the y coordinate of the operand
  3533. * @param z defines the z coordinate of the operand
  3534. * @returns the current updated Vector3
  3535. */
  3536. copyFromFloats(x: number, y: number, z: number): Vector3;
  3537. /**
  3538. * Copies the given floats to the current Vector3 coordinates
  3539. * @param x defines the x coordinate of the operand
  3540. * @param y defines the y coordinate of the operand
  3541. * @param z defines the z coordinate of the operand
  3542. * @returns the current updated Vector3
  3543. */
  3544. set(x: number, y: number, z: number): Vector3;
  3545. /**
  3546. * Copies the given float to the current Vector3 coordinates
  3547. * @param v defines the x, y and z coordinates of the operand
  3548. * @returns the current updated Vector3
  3549. */
  3550. setAll(v: number): Vector3;
  3551. /**
  3552. * Get the clip factor between two vectors
  3553. * @param vector0 defines the first operand
  3554. * @param vector1 defines the second operand
  3555. * @param axis defines the axis to use
  3556. * @param size defines the size along the axis
  3557. * @returns the clip factor
  3558. */
  3559. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3560. /**
  3561. * Get angle between two vectors
  3562. * @param vector0 angle between vector0 and vector1
  3563. * @param vector1 angle between vector0 and vector1
  3564. * @param normal direction of the normal
  3565. * @return the angle between vector0 and vector1
  3566. */
  3567. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3568. /**
  3569. * Returns a new Vector3 set from the index "offset" of the given array
  3570. * @param array defines the source array
  3571. * @param offset defines the offset in the source array
  3572. * @returns the new Vector3
  3573. */
  3574. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3575. /**
  3576. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3577. * @param array defines the source array
  3578. * @param offset defines the offset in the source array
  3579. * @returns the new Vector3
  3580. * @deprecated Please use FromArray instead.
  3581. */
  3582. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3583. /**
  3584. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3585. * @param array defines the source array
  3586. * @param offset defines the offset in the source array
  3587. * @param result defines the Vector3 where to store the result
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3590. /**
  3591. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3592. * @param array defines the source array
  3593. * @param offset defines the offset in the source array
  3594. * @param result defines the Vector3 where to store the result
  3595. * @deprecated Please use FromArrayToRef instead.
  3596. */
  3597. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3598. /**
  3599. * Sets the given vector "result" with the given floats.
  3600. * @param x defines the x coordinate of the source
  3601. * @param y defines the y coordinate of the source
  3602. * @param z defines the z coordinate of the source
  3603. * @param result defines the Vector3 where to store the result
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3608. * @returns a new empty Vector3
  3609. */
  3610. static Zero(): Vector3;
  3611. /**
  3612. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3613. * @returns a new unit Vector3
  3614. */
  3615. static One(): Vector3;
  3616. /**
  3617. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3618. * @returns a new up Vector3
  3619. */
  3620. static Up(): Vector3;
  3621. /**
  3622. * Gets a up Vector3 that must not be updated
  3623. */
  3624. static get UpReadOnly(): DeepImmutable<Vector3>;
  3625. /**
  3626. * Gets a zero Vector3 that must not be updated
  3627. */
  3628. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3629. /**
  3630. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3631. * @returns a new down Vector3
  3632. */
  3633. static Down(): Vector3;
  3634. /**
  3635. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3636. * @param rightHandedSystem is the scene right-handed (negative z)
  3637. * @returns a new forward Vector3
  3638. */
  3639. static Forward(rightHandedSystem?: boolean): Vector3;
  3640. /**
  3641. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3642. * @param rightHandedSystem is the scene right-handed (negative-z)
  3643. * @returns a new forward Vector3
  3644. */
  3645. static Backward(rightHandedSystem?: boolean): Vector3;
  3646. /**
  3647. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3648. * @returns a new right Vector3
  3649. */
  3650. static Right(): Vector3;
  3651. /**
  3652. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3653. * @returns a new left Vector3
  3654. */
  3655. static Left(): Vector3;
  3656. /**
  3657. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3658. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3659. * @param vector defines the Vector3 to transform
  3660. * @param transformation defines the transformation matrix
  3661. * @returns the transformed Vector3
  3662. */
  3663. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3664. /**
  3665. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3666. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3667. * @param vector defines the Vector3 to transform
  3668. * @param transformation defines the transformation matrix
  3669. * @param result defines the Vector3 where to store the result
  3670. */
  3671. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3672. /**
  3673. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3674. * This method computes tranformed coordinates only, not transformed direction vectors
  3675. * @param x define the x coordinate of the source vector
  3676. * @param y define the y coordinate of the source vector
  3677. * @param z define the z coordinate of the source vector
  3678. * @param transformation defines the transformation matrix
  3679. * @param result defines the Vector3 where to store the result
  3680. */
  3681. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3682. /**
  3683. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3684. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3685. * @param vector defines the Vector3 to transform
  3686. * @param transformation defines the transformation matrix
  3687. * @returns the new Vector3
  3688. */
  3689. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3690. /**
  3691. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3692. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3693. * @param vector defines the Vector3 to transform
  3694. * @param transformation defines the transformation matrix
  3695. * @param result defines the Vector3 where to store the result
  3696. */
  3697. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3698. /**
  3699. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3700. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3701. * @param x define the x coordinate of the source vector
  3702. * @param y define the y coordinate of the source vector
  3703. * @param z define the z coordinate of the source vector
  3704. * @param transformation defines the transformation matrix
  3705. * @param result defines the Vector3 where to store the result
  3706. */
  3707. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3708. /**
  3709. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3710. * @param value1 defines the first control point
  3711. * @param value2 defines the second control point
  3712. * @param value3 defines the third control point
  3713. * @param value4 defines the fourth control point
  3714. * @param amount defines the amount on the spline to use
  3715. * @returns the new Vector3
  3716. */
  3717. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3718. /**
  3719. * 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"
  3720. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3721. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3722. * @param value defines the current value
  3723. * @param min defines the lower range value
  3724. * @param max defines the upper range value
  3725. * @returns the new Vector3
  3726. */
  3727. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3728. /**
  3729. * 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"
  3730. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3731. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3732. * @param value defines the current value
  3733. * @param min defines the lower range value
  3734. * @param max defines the upper range value
  3735. * @param result defines the Vector3 where to store the result
  3736. */
  3737. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3738. /**
  3739. * Checks if a given vector is inside a specific range
  3740. * @param v defines the vector to test
  3741. * @param min defines the minimum range
  3742. * @param max defines the maximum range
  3743. */
  3744. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3745. /**
  3746. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3747. * @param value1 defines the first control point
  3748. * @param tangent1 defines the first tangent vector
  3749. * @param value2 defines the second control point
  3750. * @param tangent2 defines the second tangent vector
  3751. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3752. * @returns the new Vector3
  3753. */
  3754. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3755. /**
  3756. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3757. * @param start defines the start value
  3758. * @param end defines the end value
  3759. * @param amount max defines amount between both (between 0 and 1)
  3760. * @returns the new Vector3
  3761. */
  3762. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3763. /**
  3764. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3765. * @param start defines the start value
  3766. * @param end defines the end value
  3767. * @param amount max defines amount between both (between 0 and 1)
  3768. * @param result defines the Vector3 where to store the result
  3769. */
  3770. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3771. /**
  3772. * Returns the dot product (float) between the vectors "left" and "right"
  3773. * @param left defines the left operand
  3774. * @param right defines the right operand
  3775. * @returns the dot product
  3776. */
  3777. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3778. /**
  3779. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3780. * The cross product is then orthogonal to both "left" and "right"
  3781. * @param left defines the left operand
  3782. * @param right defines the right operand
  3783. * @returns the cross product
  3784. */
  3785. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3786. /**
  3787. * Sets the given vector "result" with the cross product of "left" and "right"
  3788. * The cross product is then orthogonal to both "left" and "right"
  3789. * @param left defines the left operand
  3790. * @param right defines the right operand
  3791. * @param result defines the Vector3 where to store the result
  3792. */
  3793. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3794. /**
  3795. * Returns a new Vector3 as the normalization of the given vector
  3796. * @param vector defines the Vector3 to normalize
  3797. * @returns the new Vector3
  3798. */
  3799. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3800. /**
  3801. * Sets the given vector "result" with the normalization of the given first vector
  3802. * @param vector defines the Vector3 to normalize
  3803. * @param result defines the Vector3 where to store the result
  3804. */
  3805. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3806. /**
  3807. * Project a Vector3 onto screen space
  3808. * @param vector defines the Vector3 to project
  3809. * @param world defines the world matrix to use
  3810. * @param transform defines the transform (view x projection) matrix to use
  3811. * @param viewport defines the screen viewport to use
  3812. * @returns the new Vector3
  3813. */
  3814. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3815. /**
  3816. * Project a Vector3 onto screen space to reference
  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. * @param result the vector in which the screen space will be stored
  3822. * @returns the new Vector3
  3823. */
  3824. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3825. /** @hidden */
  3826. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3827. /**
  3828. * Unproject from screen space to object space
  3829. * @param source defines the screen space Vector3 to use
  3830. * @param viewportWidth defines the current width of the viewport
  3831. * @param viewportHeight defines the current height of the viewport
  3832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3833. * @param transform defines the transform (view x projection) matrix to use
  3834. * @returns the new Vector3
  3835. */
  3836. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3837. /**
  3838. * Unproject from screen space to object space
  3839. * @param source defines the screen space Vector3 to use
  3840. * @param viewportWidth defines the current width of the viewport
  3841. * @param viewportHeight defines the current height of the viewport
  3842. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3843. * @param view defines the view matrix to use
  3844. * @param projection defines the projection matrix to use
  3845. * @returns the new Vector3
  3846. */
  3847. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3848. /**
  3849. * Unproject from screen space to object space
  3850. * @param source defines the screen space Vector3 to use
  3851. * @param viewportWidth defines the current width of the viewport
  3852. * @param viewportHeight defines the current height of the viewport
  3853. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3854. * @param view defines the view matrix to use
  3855. * @param projection defines the projection matrix to use
  3856. * @param result defines the Vector3 where to store the result
  3857. */
  3858. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3859. /**
  3860. * Unproject from screen space to object space
  3861. * @param sourceX defines the screen space x coordinate to use
  3862. * @param sourceY defines the screen space y coordinate to use
  3863. * @param sourceZ defines the screen space z coordinate to use
  3864. * @param viewportWidth defines the current width of the viewport
  3865. * @param viewportHeight defines the current height of the viewport
  3866. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3867. * @param view defines the view matrix to use
  3868. * @param projection defines the projection matrix to use
  3869. * @param result defines the Vector3 where to store the result
  3870. */
  3871. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3872. /**
  3873. * Gets the minimal coordinate values between two Vector3
  3874. * @param left defines the first operand
  3875. * @param right defines the second operand
  3876. * @returns the new Vector3
  3877. */
  3878. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3879. /**
  3880. * Gets the maximal coordinate values between two Vector3
  3881. * @param left defines the first operand
  3882. * @param right defines the second operand
  3883. * @returns the new Vector3
  3884. */
  3885. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3886. /**
  3887. * Returns the distance between the vectors "value1" and "value2"
  3888. * @param value1 defines the first operand
  3889. * @param value2 defines the second operand
  3890. * @returns the distance
  3891. */
  3892. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3893. /**
  3894. * Returns the squared distance between the vectors "value1" and "value2"
  3895. * @param value1 defines the first operand
  3896. * @param value2 defines the second operand
  3897. * @returns the squared distance
  3898. */
  3899. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3900. /**
  3901. * Returns a new Vector3 located at the center between "value1" and "value2"
  3902. * @param value1 defines the first operand
  3903. * @param value2 defines the second operand
  3904. * @returns the new Vector3
  3905. */
  3906. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3907. /**
  3908. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3909. * @param value1 defines first vector
  3910. * @param value2 defines second vector
  3911. * @param ref defines third vector
  3912. * @returns ref
  3913. */
  3914. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3915. /**
  3916. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3917. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3918. * to something in order to rotate it from its local system to the given target system
  3919. * Note: axis1, axis2 and axis3 are normalized during this operation
  3920. * @param axis1 defines the first axis
  3921. * @param axis2 defines the second axis
  3922. * @param axis3 defines the third axis
  3923. * @returns a new Vector3
  3924. */
  3925. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3926. /**
  3927. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3928. * @param axis1 defines the first axis
  3929. * @param axis2 defines the second axis
  3930. * @param axis3 defines the third axis
  3931. * @param ref defines the Vector3 where to store the result
  3932. */
  3933. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3934. }
  3935. /**
  3936. * Vector4 class created for EulerAngle class conversion to Quaternion
  3937. */
  3938. export class Vector4 {
  3939. /** x value of the vector */
  3940. x: number;
  3941. /** y value of the vector */
  3942. y: number;
  3943. /** z value of the vector */
  3944. z: number;
  3945. /** w value of the vector */
  3946. w: number;
  3947. /**
  3948. * Creates a Vector4 object from the given floats.
  3949. * @param x x value of the vector
  3950. * @param y y value of the vector
  3951. * @param z z value of the vector
  3952. * @param w w value of the vector
  3953. */
  3954. constructor(
  3955. /** x value of the vector */
  3956. x: number,
  3957. /** y value of the vector */
  3958. y: number,
  3959. /** z value of the vector */
  3960. z: number,
  3961. /** w value of the vector */
  3962. w: number);
  3963. /**
  3964. * Returns the string with the Vector4 coordinates.
  3965. * @returns a string containing all the vector values
  3966. */
  3967. toString(): string;
  3968. /**
  3969. * Returns the string "Vector4".
  3970. * @returns "Vector4"
  3971. */
  3972. getClassName(): string;
  3973. /**
  3974. * Returns the Vector4 hash code.
  3975. * @returns a unique hash code
  3976. */
  3977. getHashCode(): number;
  3978. /**
  3979. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3980. * @returns the resulting array
  3981. */
  3982. asArray(): number[];
  3983. /**
  3984. * Populates the given array from the given index with the Vector4 coordinates.
  3985. * @param array array to populate
  3986. * @param index index of the array to start at (default: 0)
  3987. * @returns the Vector4.
  3988. */
  3989. toArray(array: FloatArray, index?: number): Vector4;
  3990. /**
  3991. * Update the current vector from an array
  3992. * @param array defines the destination array
  3993. * @param index defines the offset in the destination array
  3994. * @returns the current Vector3
  3995. */
  3996. fromArray(array: FloatArray, index?: number): Vector4;
  3997. /**
  3998. * Adds the given vector to the current Vector4.
  3999. * @param otherVector the vector to add
  4000. * @returns the updated Vector4.
  4001. */
  4002. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4003. /**
  4004. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  4005. * @param otherVector the vector to add
  4006. * @returns the resulting vector
  4007. */
  4008. add(otherVector: DeepImmutable<Vector4>): Vector4;
  4009. /**
  4010. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  4011. * @param otherVector the vector to add
  4012. * @param result the vector to store the result
  4013. * @returns the current Vector4.
  4014. */
  4015. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4016. /**
  4017. * Subtract in place the given vector from the current Vector4.
  4018. * @param otherVector the vector to subtract
  4019. * @returns the updated Vector4.
  4020. */
  4021. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4022. /**
  4023. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  4024. * @param otherVector the vector to add
  4025. * @returns the new vector with the result
  4026. */
  4027. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  4028. /**
  4029. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  4030. * @param otherVector the vector to subtract
  4031. * @param result the vector to store the result
  4032. * @returns the current Vector4.
  4033. */
  4034. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4035. /**
  4036. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4037. */
  4038. /**
  4039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4040. * @param x value to subtract
  4041. * @param y value to subtract
  4042. * @param z value to subtract
  4043. * @param w value to subtract
  4044. * @returns new vector containing the result
  4045. */
  4046. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4047. /**
  4048. * Sets the given vector "result" 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. * @param result the vector to store the result in
  4054. * @returns the current Vector4.
  4055. */
  4056. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4057. /**
  4058. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4059. * @returns a new vector with the negated values
  4060. */
  4061. negate(): Vector4;
  4062. /**
  4063. * Negate this vector in place
  4064. * @returns this
  4065. */
  4066. negateInPlace(): Vector4;
  4067. /**
  4068. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4069. * @param result defines the Vector3 object where to store the result
  4070. * @returns the current Vector4
  4071. */
  4072. negateToRef(result: Vector4): Vector4;
  4073. /**
  4074. * Multiplies the current Vector4 coordinates by scale (float).
  4075. * @param scale the number to scale with
  4076. * @returns the updated Vector4.
  4077. */
  4078. scaleInPlace(scale: number): Vector4;
  4079. /**
  4080. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4081. * @param scale the number to scale with
  4082. * @returns a new vector with the result
  4083. */
  4084. scale(scale: number): Vector4;
  4085. /**
  4086. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4087. * @param scale the number to scale with
  4088. * @param result a vector to store the result in
  4089. * @returns the current Vector4.
  4090. */
  4091. scaleToRef(scale: number, result: Vector4): Vector4;
  4092. /**
  4093. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4094. * @param scale defines the scale factor
  4095. * @param result defines the Vector4 object where to store the result
  4096. * @returns the unmodified current Vector4
  4097. */
  4098. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4099. /**
  4100. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4101. * @param otherVector the vector to compare against
  4102. * @returns true if they are equal
  4103. */
  4104. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4105. /**
  4106. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4107. * @param otherVector vector to compare against
  4108. * @param epsilon (Default: very small number)
  4109. * @returns true if they are equal
  4110. */
  4111. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4112. /**
  4113. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4114. * @param x x value to compare against
  4115. * @param y y value to compare against
  4116. * @param z z value to compare against
  4117. * @param w w value to compare against
  4118. * @returns true if equal
  4119. */
  4120. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4121. /**
  4122. * Multiplies in place the current Vector4 by the given one.
  4123. * @param otherVector vector to multiple with
  4124. * @returns the updated Vector4.
  4125. */
  4126. multiplyInPlace(otherVector: Vector4): Vector4;
  4127. /**
  4128. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4129. * @param otherVector vector to multiple with
  4130. * @returns resulting new vector
  4131. */
  4132. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4133. /**
  4134. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4135. * @param otherVector vector to multiple with
  4136. * @param result vector to store the result
  4137. * @returns the current Vector4.
  4138. */
  4139. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4140. /**
  4141. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4142. * @param x x value multiply with
  4143. * @param y y value multiply with
  4144. * @param z z value multiply with
  4145. * @param w w value multiply with
  4146. * @returns resulting new vector
  4147. */
  4148. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4149. /**
  4150. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4151. * @param otherVector vector to devide with
  4152. * @returns resulting new vector
  4153. */
  4154. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4155. /**
  4156. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4157. * @param otherVector vector to devide with
  4158. * @param result vector to store the result
  4159. * @returns the current Vector4.
  4160. */
  4161. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4162. /**
  4163. * Divides the current Vector3 coordinates by the given ones.
  4164. * @param otherVector vector to devide with
  4165. * @returns the updated Vector3.
  4166. */
  4167. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4168. /**
  4169. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4170. * @param other defines the second operand
  4171. * @returns the current updated Vector4
  4172. */
  4173. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4174. /**
  4175. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4176. * @param other defines the second operand
  4177. * @returns the current updated Vector4
  4178. */
  4179. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4180. /**
  4181. * Gets a new Vector4 from current Vector4 floored values
  4182. * @returns a new Vector4
  4183. */
  4184. floor(): Vector4;
  4185. /**
  4186. * Gets a new Vector4 from current Vector3 floored values
  4187. * @returns a new Vector4
  4188. */
  4189. fract(): Vector4;
  4190. /**
  4191. * Returns the Vector4 length (float).
  4192. * @returns the length
  4193. */
  4194. length(): number;
  4195. /**
  4196. * Returns the Vector4 squared length (float).
  4197. * @returns the length squared
  4198. */
  4199. lengthSquared(): number;
  4200. /**
  4201. * Normalizes in place the Vector4.
  4202. * @returns the updated Vector4.
  4203. */
  4204. normalize(): Vector4;
  4205. /**
  4206. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4207. * @returns this converted to a new vector3
  4208. */
  4209. toVector3(): Vector3;
  4210. /**
  4211. * Returns a new Vector4 copied from the current one.
  4212. * @returns the new cloned vector
  4213. */
  4214. clone(): Vector4;
  4215. /**
  4216. * Updates the current Vector4 with the given one coordinates.
  4217. * @param source the source vector to copy from
  4218. * @returns the updated Vector4.
  4219. */
  4220. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4221. /**
  4222. * Updates the current Vector4 coordinates with the given floats.
  4223. * @param x float to copy from
  4224. * @param y float to copy from
  4225. * @param z float to copy from
  4226. * @param w float to copy from
  4227. * @returns the updated Vector4.
  4228. */
  4229. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4230. /**
  4231. * Updates the current Vector4 coordinates with the given floats.
  4232. * @param x float to set from
  4233. * @param y float to set from
  4234. * @param z float to set from
  4235. * @param w float to set from
  4236. * @returns the updated Vector4.
  4237. */
  4238. set(x: number, y: number, z: number, w: number): Vector4;
  4239. /**
  4240. * Copies the given float to the current Vector3 coordinates
  4241. * @param v defines the x, y, z and w coordinates of the operand
  4242. * @returns the current updated Vector3
  4243. */
  4244. setAll(v: number): Vector4;
  4245. /**
  4246. * Returns a new Vector4 set from the starting index of the given array.
  4247. * @param array the array to pull values from
  4248. * @param offset the offset into the array to start at
  4249. * @returns the new vector
  4250. */
  4251. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4252. /**
  4253. * Updates the given vector "result" from the starting index of the given array.
  4254. * @param array the array to pull values from
  4255. * @param offset the offset into the array to start at
  4256. * @param result the vector to store the result in
  4257. */
  4258. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4259. /**
  4260. * Updates the given vector "result" from the starting index of the given Float32Array.
  4261. * @param array the array to pull values from
  4262. * @param offset the offset into the array to start at
  4263. * @param result the vector to store the result in
  4264. */
  4265. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4266. /**
  4267. * Updates the given vector "result" coordinates from the given floats.
  4268. * @param x float to set from
  4269. * @param y float to set from
  4270. * @param z float to set from
  4271. * @param w float to set from
  4272. * @param result the vector to the floats in
  4273. */
  4274. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4275. /**
  4276. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4277. * @returns the new vector
  4278. */
  4279. static Zero(): Vector4;
  4280. /**
  4281. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4282. * @returns the new vector
  4283. */
  4284. static One(): Vector4;
  4285. /**
  4286. * Returns a new normalized Vector4 from the given one.
  4287. * @param vector the vector to normalize
  4288. * @returns the vector
  4289. */
  4290. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4291. /**
  4292. * Updates the given vector "result" from the normalization of the given one.
  4293. * @param vector the vector to normalize
  4294. * @param result the vector to store the result in
  4295. */
  4296. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4297. /**
  4298. * Returns a vector with the minimum values from the left and right vectors
  4299. * @param left left vector to minimize
  4300. * @param right right vector to minimize
  4301. * @returns a new vector with the minimum of the left and right vector values
  4302. */
  4303. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4304. /**
  4305. * Returns a vector with the maximum values from the left and right vectors
  4306. * @param left left vector to maximize
  4307. * @param right right vector to maximize
  4308. * @returns a new vector with the maximum of the left and right vector values
  4309. */
  4310. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4311. /**
  4312. * Returns the distance (float) between the vectors "value1" and "value2".
  4313. * @param value1 value to calulate the distance between
  4314. * @param value2 value to calulate the distance between
  4315. * @return the distance between the two vectors
  4316. */
  4317. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4318. /**
  4319. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4320. * @param value1 value to calulate the distance between
  4321. * @param value2 value to calulate the distance between
  4322. * @return the distance between the two vectors squared
  4323. */
  4324. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4325. /**
  4326. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4327. * @param value1 value to calulate the center between
  4328. * @param value2 value to calulate the center between
  4329. * @return the center between the two vectors
  4330. */
  4331. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4332. /**
  4333. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4334. * @param value1 defines first vector
  4335. * @param value2 defines second vector
  4336. * @param ref defines third vector
  4337. * @returns ref
  4338. */
  4339. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4340. /**
  4341. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4342. * This methods computes transformed normalized direction vectors only.
  4343. * @param vector the vector to transform
  4344. * @param transformation the transformation matrix to apply
  4345. * @returns the new vector
  4346. */
  4347. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4348. /**
  4349. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4350. * This methods computes transformed normalized direction vectors only.
  4351. * @param vector the vector to transform
  4352. * @param transformation the transformation matrix to apply
  4353. * @param result the vector to store the result in
  4354. */
  4355. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4356. /**
  4357. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4358. * This methods computes transformed normalized direction vectors only.
  4359. * @param x value to transform
  4360. * @param y value to transform
  4361. * @param z value to transform
  4362. * @param w value to transform
  4363. * @param transformation the transformation matrix to apply
  4364. * @param result the vector to store the results in
  4365. */
  4366. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4367. /**
  4368. * Creates a new Vector4 from a Vector3
  4369. * @param source defines the source data
  4370. * @param w defines the 4th component (default is 0)
  4371. * @returns a new Vector4
  4372. */
  4373. static FromVector3(source: Vector3, w?: number): Vector4;
  4374. }
  4375. /**
  4376. * Class used to store quaternion data
  4377. * @see https://en.wikipedia.org/wiki/Quaternion
  4378. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4379. */
  4380. export class Quaternion {
  4381. /** @hidden */
  4382. _x: number;
  4383. /** @hidden */
  4384. _y: number;
  4385. /** @hidden */
  4386. _z: number;
  4387. /** @hidden */
  4388. _w: number;
  4389. /** @hidden */
  4390. _isDirty: boolean;
  4391. /** Gets or sets the x coordinate */
  4392. get x(): number;
  4393. set x(value: number);
  4394. /** Gets or sets the y coordinate */
  4395. get y(): number;
  4396. set y(value: number);
  4397. /** Gets or sets the z coordinate */
  4398. get z(): number;
  4399. set z(value: number);
  4400. /** Gets or sets the w coordinate */
  4401. get w(): number;
  4402. set w(value: number);
  4403. /**
  4404. * Creates a new Quaternion from the given floats
  4405. * @param x defines the first component (0 by default)
  4406. * @param y defines the second component (0 by default)
  4407. * @param z defines the third component (0 by default)
  4408. * @param w defines the fourth component (1.0 by default)
  4409. */
  4410. constructor(x?: number, y?: number, z?: number, w?: number);
  4411. /**
  4412. * Gets a string representation for the current quaternion
  4413. * @returns a string with the Quaternion coordinates
  4414. */
  4415. toString(): string;
  4416. /**
  4417. * Gets the class name of the quaternion
  4418. * @returns the string "Quaternion"
  4419. */
  4420. getClassName(): string;
  4421. /**
  4422. * Gets a hash code for this quaternion
  4423. * @returns the quaternion hash code
  4424. */
  4425. getHashCode(): number;
  4426. /**
  4427. * Copy the quaternion to an array
  4428. * @returns a new array populated with 4 elements from the quaternion coordinates
  4429. */
  4430. asArray(): number[];
  4431. /**
  4432. * Check if two quaternions are equals
  4433. * @param otherQuaternion defines the second operand
  4434. * @return true if the current quaternion and the given one coordinates are strictly equals
  4435. */
  4436. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4437. /**
  4438. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4439. * @param otherQuaternion defines the other quaternion
  4440. * @param epsilon defines the minimal distance to consider equality
  4441. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4442. */
  4443. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4444. /**
  4445. * Clone the current quaternion
  4446. * @returns a new quaternion copied from the current one
  4447. */
  4448. clone(): Quaternion;
  4449. /**
  4450. * Copy a quaternion to the current one
  4451. * @param other defines the other quaternion
  4452. * @returns the updated current quaternion
  4453. */
  4454. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4455. /**
  4456. * Updates the current quaternion with the given float coordinates
  4457. * @param x defines the x coordinate
  4458. * @param y defines the y coordinate
  4459. * @param z defines the z coordinate
  4460. * @param w defines the w coordinate
  4461. * @returns the updated current quaternion
  4462. */
  4463. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4464. /**
  4465. * Updates the current quaternion from 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. set(x: number, y: number, z: number, w: number): Quaternion;
  4473. /**
  4474. * Adds two quaternions
  4475. * @param other defines the second operand
  4476. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4477. */
  4478. add(other: DeepImmutable<Quaternion>): Quaternion;
  4479. /**
  4480. * Add a quaternion to the current one
  4481. * @param other defines the quaternion to add
  4482. * @returns the current quaternion
  4483. */
  4484. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4485. /**
  4486. * Subtract two quaternions
  4487. * @param other defines the second operand
  4488. * @returns a new quaternion as the subtraction result of the given one from the current one
  4489. */
  4490. subtract(other: Quaternion): Quaternion;
  4491. /**
  4492. * Multiplies the current quaternion by a scale factor
  4493. * @param value defines the scale factor
  4494. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4495. */
  4496. scale(value: number): Quaternion;
  4497. /**
  4498. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4499. * @param scale defines the scale factor
  4500. * @param result defines the Quaternion object where to store the result
  4501. * @returns the unmodified current quaternion
  4502. */
  4503. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4504. /**
  4505. * Multiplies in place the current quaternion by a scale factor
  4506. * @param value defines the scale factor
  4507. * @returns the current modified quaternion
  4508. */
  4509. scaleInPlace(value: number): Quaternion;
  4510. /**
  4511. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4512. * @param scale defines the scale factor
  4513. * @param result defines the Quaternion object where to store the result
  4514. * @returns the unmodified current quaternion
  4515. */
  4516. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4517. /**
  4518. * Multiplies two quaternions
  4519. * @param q1 defines the second operand
  4520. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4521. */
  4522. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4523. /**
  4524. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4525. * @param q1 defines the second operand
  4526. * @param result defines the target quaternion
  4527. * @returns the current quaternion
  4528. */
  4529. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4530. /**
  4531. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4532. * @param q1 defines the second operand
  4533. * @returns the currentupdated quaternion
  4534. */
  4535. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4536. /**
  4537. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4538. * @param ref defines the target quaternion
  4539. * @returns the current quaternion
  4540. */
  4541. conjugateToRef(ref: Quaternion): Quaternion;
  4542. /**
  4543. * Conjugates in place (1-q) the current quaternion
  4544. * @returns the current updated quaternion
  4545. */
  4546. conjugateInPlace(): Quaternion;
  4547. /**
  4548. * Conjugates in place (1-q) the current quaternion
  4549. * @returns a new quaternion
  4550. */
  4551. conjugate(): Quaternion;
  4552. /**
  4553. * Gets length of current quaternion
  4554. * @returns the quaternion length (float)
  4555. */
  4556. length(): number;
  4557. /**
  4558. * Normalize in place the current quaternion
  4559. * @returns the current updated quaternion
  4560. */
  4561. normalize(): Quaternion;
  4562. /**
  4563. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4564. * @param order is a reserved parameter and is ignored for now
  4565. * @returns a new Vector3 containing the Euler angles
  4566. */
  4567. toEulerAngles(order?: string): Vector3;
  4568. /**
  4569. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4570. * @param result defines the vector which will be filled with the Euler angles
  4571. * @returns the current unchanged quaternion
  4572. */
  4573. toEulerAnglesToRef(result: Vector3): Quaternion;
  4574. /**
  4575. * Updates the given rotation matrix with the current quaternion values
  4576. * @param result defines the target matrix
  4577. * @returns the current unchanged quaternion
  4578. */
  4579. toRotationMatrix(result: Matrix): Quaternion;
  4580. /**
  4581. * Updates the current quaternion from the given rotation matrix values
  4582. * @param matrix defines the source matrix
  4583. * @returns the current updated quaternion
  4584. */
  4585. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4586. /**
  4587. * Creates a new quaternion from a rotation matrix
  4588. * @param matrix defines the source matrix
  4589. * @returns a new quaternion created from the given rotation matrix values
  4590. */
  4591. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4592. /**
  4593. * Updates the given quaternion with the given rotation matrix values
  4594. * @param matrix defines the source matrix
  4595. * @param result defines the target quaternion
  4596. */
  4597. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4598. /**
  4599. * Returns the dot product (float) between the quaternions "left" and "right"
  4600. * @param left defines the left operand
  4601. * @param right defines the right operand
  4602. * @returns the dot product
  4603. */
  4604. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4605. /**
  4606. * Checks if the two quaternions are close to each other
  4607. * @param quat0 defines the first quaternion to check
  4608. * @param quat1 defines the second quaternion to check
  4609. * @returns true if the two quaternions are close to each other
  4610. */
  4611. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4612. /**
  4613. * Creates an empty quaternion
  4614. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4615. */
  4616. static Zero(): Quaternion;
  4617. /**
  4618. * Inverse a given quaternion
  4619. * @param q defines the source quaternion
  4620. * @returns a new quaternion as the inverted current quaternion
  4621. */
  4622. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4623. /**
  4624. * Inverse a given quaternion
  4625. * @param q defines the source quaternion
  4626. * @param result the quaternion the result will be stored in
  4627. * @returns the result quaternion
  4628. */
  4629. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4630. /**
  4631. * Creates an identity quaternion
  4632. * @returns the identity quaternion
  4633. */
  4634. static Identity(): Quaternion;
  4635. /**
  4636. * Gets a boolean indicating if the given quaternion is identity
  4637. * @param quaternion defines the quaternion to check
  4638. * @returns true if the quaternion is identity
  4639. */
  4640. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4641. /**
  4642. * Creates a quaternion from a rotation around an axis
  4643. * @param axis defines the axis to use
  4644. * @param angle defines the angle to use
  4645. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4646. */
  4647. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4648. /**
  4649. * Creates a rotation around an axis and stores it into the given quaternion
  4650. * @param axis defines the axis to use
  4651. * @param angle defines the angle to use
  4652. * @param result defines the target quaternion
  4653. * @returns the target quaternion
  4654. */
  4655. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4656. /**
  4657. * Creates a new quaternion from data stored into an array
  4658. * @param array defines the data source
  4659. * @param offset defines the offset in the source array where the data starts
  4660. * @returns a new quaternion
  4661. */
  4662. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4663. /**
  4664. * Updates the given quaternion "result" from the starting index of the given array.
  4665. * @param array the array to pull values from
  4666. * @param offset the offset into the array to start at
  4667. * @param result the quaternion to store the result in
  4668. */
  4669. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4670. /**
  4671. * Create a quaternion from Euler rotation angles
  4672. * @param x Pitch
  4673. * @param y Yaw
  4674. * @param z Roll
  4675. * @returns the new Quaternion
  4676. */
  4677. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4678. /**
  4679. * Updates a quaternion from Euler rotation angles
  4680. * @param x Pitch
  4681. * @param y Yaw
  4682. * @param z Roll
  4683. * @param result the quaternion to store the result
  4684. * @returns the updated quaternion
  4685. */
  4686. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4687. /**
  4688. * Create a quaternion from Euler rotation vector
  4689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4690. * @returns the new Quaternion
  4691. */
  4692. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4693. /**
  4694. * Updates a quaternion from Euler rotation vector
  4695. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4696. * @param result the quaternion to store the result
  4697. * @returns the updated quaternion
  4698. */
  4699. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4700. /**
  4701. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4702. * @param yaw defines the rotation around Y axis
  4703. * @param pitch defines the rotation around X axis
  4704. * @param roll defines the rotation around Z axis
  4705. * @returns the new quaternion
  4706. */
  4707. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4708. /**
  4709. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4710. * @param yaw defines the rotation around Y axis
  4711. * @param pitch defines the rotation around X axis
  4712. * @param roll defines the rotation around Z axis
  4713. * @param result defines the target quaternion
  4714. */
  4715. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4716. /**
  4717. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4718. * @param alpha defines the rotation around first axis
  4719. * @param beta defines the rotation around second axis
  4720. * @param gamma defines the rotation around third axis
  4721. * @returns the new quaternion
  4722. */
  4723. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4724. /**
  4725. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4726. * @param alpha defines the rotation around first axis
  4727. * @param beta defines the rotation around second axis
  4728. * @param gamma defines the rotation around third axis
  4729. * @param result defines the target quaternion
  4730. */
  4731. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4732. /**
  4733. * 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)
  4734. * @param axis1 defines the first axis
  4735. * @param axis2 defines the second axis
  4736. * @param axis3 defines the third axis
  4737. * @returns the new quaternion
  4738. */
  4739. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4740. /**
  4741. * 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
  4742. * @param axis1 defines the first axis
  4743. * @param axis2 defines the second axis
  4744. * @param axis3 defines the third axis
  4745. * @param ref defines the target quaternion
  4746. */
  4747. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4748. /**
  4749. * Interpolates between two quaternions
  4750. * @param left defines first quaternion
  4751. * @param right defines second quaternion
  4752. * @param amount defines the gradient to use
  4753. * @returns the new interpolated quaternion
  4754. */
  4755. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4756. /**
  4757. * Interpolates between two quaternions and stores it into a target quaternion
  4758. * @param left defines first quaternion
  4759. * @param right defines second quaternion
  4760. * @param amount defines the gradient to use
  4761. * @param result defines the target quaternion
  4762. */
  4763. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4764. /**
  4765. * Interpolate between two quaternions using Hermite interpolation
  4766. * @param value1 defines first quaternion
  4767. * @param tangent1 defines the incoming tangent
  4768. * @param value2 defines second quaternion
  4769. * @param tangent2 defines the outgoing tangent
  4770. * @param amount defines the target quaternion
  4771. * @returns the new interpolated quaternion
  4772. */
  4773. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4774. }
  4775. /**
  4776. * Class used to store matrix data (4x4)
  4777. */
  4778. export class Matrix {
  4779. /**
  4780. * Gets the precision of matrix computations
  4781. */
  4782. static get Use64Bits(): boolean;
  4783. private static _updateFlagSeed;
  4784. private static _identityReadOnly;
  4785. private _isIdentity;
  4786. private _isIdentityDirty;
  4787. private _isIdentity3x2;
  4788. private _isIdentity3x2Dirty;
  4789. /**
  4790. * Gets the update flag of the matrix which is an unique number for the matrix.
  4791. * It will be incremented every time the matrix data change.
  4792. * You can use it to speed the comparison between two versions of the same matrix.
  4793. */
  4794. updateFlag: number;
  4795. private readonly _m;
  4796. /**
  4797. * Gets the internal data of the matrix
  4798. */
  4799. get m(): DeepImmutable<Float32Array | Array<number>>;
  4800. /** @hidden */
  4801. _markAsUpdated(): void;
  4802. /** @hidden */
  4803. private _updateIdentityStatus;
  4804. /**
  4805. * Creates an empty matrix (filled with zeros)
  4806. */
  4807. constructor();
  4808. /**
  4809. * Check if the current matrix is identity
  4810. * @returns true is the matrix is the identity matrix
  4811. */
  4812. isIdentity(): boolean;
  4813. /**
  4814. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4815. * @returns true is the matrix is the identity matrix
  4816. */
  4817. isIdentityAs3x2(): boolean;
  4818. /**
  4819. * Gets the determinant of the matrix
  4820. * @returns the matrix determinant
  4821. */
  4822. determinant(): number;
  4823. /**
  4824. * Returns the matrix as a Float32Array or Array<number>
  4825. * @returns the matrix underlying array
  4826. */
  4827. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4828. /**
  4829. * Returns the matrix as a Float32Array or Array<number>
  4830. * @returns the matrix underlying array.
  4831. */
  4832. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4833. /**
  4834. * Inverts the current matrix in place
  4835. * @returns the current inverted matrix
  4836. */
  4837. invert(): Matrix;
  4838. /**
  4839. * Sets all the matrix elements to zero
  4840. * @returns the current matrix
  4841. */
  4842. reset(): Matrix;
  4843. /**
  4844. * Adds the current matrix with a second one
  4845. * @param other defines the matrix to add
  4846. * @returns a new matrix as the addition of the current matrix and the given one
  4847. */
  4848. add(other: DeepImmutable<Matrix>): Matrix;
  4849. /**
  4850. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4851. * @param other defines the matrix to add
  4852. * @param result defines the target matrix
  4853. * @returns the current matrix
  4854. */
  4855. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4856. /**
  4857. * Adds in place the given matrix to the current matrix
  4858. * @param other defines the second operand
  4859. * @returns the current updated matrix
  4860. */
  4861. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4862. /**
  4863. * Sets the given matrix to the current inverted Matrix
  4864. * @param other defines the target matrix
  4865. * @returns the unmodified current matrix
  4866. */
  4867. invertToRef(other: Matrix): Matrix;
  4868. /**
  4869. * add a value at the specified position in the current Matrix
  4870. * @param index the index of the value within the matrix. between 0 and 15.
  4871. * @param value the value to be added
  4872. * @returns the current updated matrix
  4873. */
  4874. addAtIndex(index: number, value: number): Matrix;
  4875. /**
  4876. * mutiply the specified position in the current Matrix by a value
  4877. * @param index the index of the value within the matrix. between 0 and 15.
  4878. * @param value the value to be added
  4879. * @returns the current updated matrix
  4880. */
  4881. multiplyAtIndex(index: number, value: number): Matrix;
  4882. /**
  4883. * Inserts the translation vector (using 3 floats) in the current matrix
  4884. * @param x defines the 1st component of the translation
  4885. * @param y defines the 2nd component of the translation
  4886. * @param z defines the 3rd component of the translation
  4887. * @returns the current updated matrix
  4888. */
  4889. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4890. /**
  4891. * Adds the translation vector (using 3 floats) in the current matrix
  4892. * @param x defines the 1st component of the translation
  4893. * @param y defines the 2nd component of the translation
  4894. * @param z defines the 3rd component of the translation
  4895. * @returns the current updated matrix
  4896. */
  4897. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4898. /**
  4899. * Inserts the translation vector in the current matrix
  4900. * @param vector3 defines the translation to insert
  4901. * @returns the current updated matrix
  4902. */
  4903. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4904. /**
  4905. * Gets the translation value of the current matrix
  4906. * @returns a new Vector3 as the extracted translation from the matrix
  4907. */
  4908. getTranslation(): Vector3;
  4909. /**
  4910. * Fill a Vector3 with the extracted translation from the matrix
  4911. * @param result defines the Vector3 where to store the translation
  4912. * @returns the current matrix
  4913. */
  4914. getTranslationToRef(result: Vector3): Matrix;
  4915. /**
  4916. * Remove rotation and scaling part from the matrix
  4917. * @returns the updated matrix
  4918. */
  4919. removeRotationAndScaling(): Matrix;
  4920. /**
  4921. * Multiply two matrices
  4922. * @param other defines the second operand
  4923. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4924. */
  4925. multiply(other: DeepImmutable<Matrix>): Matrix;
  4926. /**
  4927. * Copy the current matrix from the given one
  4928. * @param other defines the source matrix
  4929. * @returns the current updated matrix
  4930. */
  4931. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4932. /**
  4933. * Populates the given array from the starting index with the current matrix values
  4934. * @param array defines the target array
  4935. * @param offset defines the offset in the target array where to start storing values
  4936. * @returns the current matrix
  4937. */
  4938. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4939. /**
  4940. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4941. * @param other defines the second operand
  4942. * @param result defines the matrix where to store the multiplication
  4943. * @returns the current matrix
  4944. */
  4945. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4946. /**
  4947. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4948. * @param other defines the second operand
  4949. * @param result defines the array where to store the multiplication
  4950. * @param offset defines the offset in the target array where to start storing values
  4951. * @returns the current matrix
  4952. */
  4953. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4954. /**
  4955. * Check equality between this matrix and a second one
  4956. * @param value defines the second matrix to compare
  4957. * @returns true is the current matrix and the given one values are strictly equal
  4958. */
  4959. equals(value: DeepImmutable<Matrix>): boolean;
  4960. /**
  4961. * Clone the current matrix
  4962. * @returns a new matrix from the current matrix
  4963. */
  4964. clone(): Matrix;
  4965. /**
  4966. * Returns the name of the current matrix class
  4967. * @returns the string "Matrix"
  4968. */
  4969. getClassName(): string;
  4970. /**
  4971. * Gets the hash code of the current matrix
  4972. * @returns the hash code
  4973. */
  4974. getHashCode(): number;
  4975. /**
  4976. * Decomposes the current Matrix into a translation, rotation and scaling components
  4977. * @param scale defines the scale vector3 given as a reference to update
  4978. * @param rotation defines the rotation quaternion given as a reference to update
  4979. * @param translation defines the translation vector3 given as a reference to update
  4980. * @returns true if operation was successful
  4981. */
  4982. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4983. /**
  4984. * Gets specific row of the matrix
  4985. * @param index defines the number of the row to get
  4986. * @returns the index-th row of the current matrix as a new Vector4
  4987. */
  4988. getRow(index: number): Nullable<Vector4>;
  4989. /**
  4990. * Sets the index-th row of the current matrix to the vector4 values
  4991. * @param index defines the number of the row to set
  4992. * @param row defines the target vector4
  4993. * @returns the updated current matrix
  4994. */
  4995. setRow(index: number, row: Vector4): Matrix;
  4996. /**
  4997. * Compute the transpose of the matrix
  4998. * @returns the new transposed matrix
  4999. */
  5000. transpose(): Matrix;
  5001. /**
  5002. * Compute the transpose of the matrix and store it in a given matrix
  5003. * @param result defines the target matrix
  5004. * @returns the current matrix
  5005. */
  5006. transposeToRef(result: Matrix): Matrix;
  5007. /**
  5008. * Sets the index-th row of the current matrix with the given 4 x float values
  5009. * @param index defines the row index
  5010. * @param x defines the x component to set
  5011. * @param y defines the y component to set
  5012. * @param z defines the z component to set
  5013. * @param w defines the w component to set
  5014. * @returns the updated current matrix
  5015. */
  5016. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  5017. /**
  5018. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  5019. * @param scale defines the scale factor
  5020. * @returns a new matrix
  5021. */
  5022. scale(scale: number): Matrix;
  5023. /**
  5024. * Scale the current matrix values by a factor to a given result matrix
  5025. * @param scale defines the scale factor
  5026. * @param result defines the matrix to store the result
  5027. * @returns the current matrix
  5028. */
  5029. scaleToRef(scale: number, result: Matrix): Matrix;
  5030. /**
  5031. * Scale the current matrix values by a factor and add the result to a given matrix
  5032. * @param scale defines the scale factor
  5033. * @param result defines the Matrix to store the result
  5034. * @returns the current matrix
  5035. */
  5036. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5037. /**
  5038. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5039. * @param ref matrix to store the result
  5040. */
  5041. toNormalMatrix(ref: Matrix): void;
  5042. /**
  5043. * Gets only rotation part of the current matrix
  5044. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5045. */
  5046. getRotationMatrix(): Matrix;
  5047. /**
  5048. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5049. * @param result defines the target matrix to store data to
  5050. * @returns the current matrix
  5051. */
  5052. getRotationMatrixToRef(result: Matrix): Matrix;
  5053. /**
  5054. * Toggles model matrix from being right handed to left handed in place and vice versa
  5055. */
  5056. toggleModelMatrixHandInPlace(): void;
  5057. /**
  5058. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5059. */
  5060. toggleProjectionMatrixHandInPlace(): void;
  5061. /**
  5062. * Creates a matrix from an array
  5063. * @param array defines the source array
  5064. * @param offset defines an offset in the source array
  5065. * @returns a new Matrix set from the starting index of the given array
  5066. */
  5067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5068. /**
  5069. * Copy the content of an array into a given matrix
  5070. * @param array defines the source array
  5071. * @param offset defines an offset in the source array
  5072. * @param result defines the target matrix
  5073. */
  5074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5075. /**
  5076. * Stores an array into a matrix after having multiplied each component by a given factor
  5077. * @param array defines the source array
  5078. * @param offset defines the offset in the source array
  5079. * @param scale defines the scaling factor
  5080. * @param result defines the target matrix
  5081. */
  5082. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5083. /**
  5084. * Gets an identity matrix that must not be updated
  5085. */
  5086. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5087. /**
  5088. * Stores a list of values (16) inside a given matrix
  5089. * @param initialM11 defines 1st value of 1st row
  5090. * @param initialM12 defines 2nd value of 1st row
  5091. * @param initialM13 defines 3rd value of 1st row
  5092. * @param initialM14 defines 4th value of 1st row
  5093. * @param initialM21 defines 1st value of 2nd row
  5094. * @param initialM22 defines 2nd value of 2nd row
  5095. * @param initialM23 defines 3rd value of 2nd row
  5096. * @param initialM24 defines 4th value of 2nd row
  5097. * @param initialM31 defines 1st value of 3rd row
  5098. * @param initialM32 defines 2nd value of 3rd row
  5099. * @param initialM33 defines 3rd value of 3rd row
  5100. * @param initialM34 defines 4th value of 3rd row
  5101. * @param initialM41 defines 1st value of 4th row
  5102. * @param initialM42 defines 2nd value of 4th row
  5103. * @param initialM43 defines 3rd value of 4th row
  5104. * @param initialM44 defines 4th value of 4th row
  5105. * @param result defines the target matrix
  5106. */
  5107. 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;
  5108. /**
  5109. * Creates new matrix from a list of values (16)
  5110. * @param initialM11 defines 1st value of 1st row
  5111. * @param initialM12 defines 2nd value of 1st row
  5112. * @param initialM13 defines 3rd value of 1st row
  5113. * @param initialM14 defines 4th value of 1st row
  5114. * @param initialM21 defines 1st value of 2nd row
  5115. * @param initialM22 defines 2nd value of 2nd row
  5116. * @param initialM23 defines 3rd value of 2nd row
  5117. * @param initialM24 defines 4th value of 2nd row
  5118. * @param initialM31 defines 1st value of 3rd row
  5119. * @param initialM32 defines 2nd value of 3rd row
  5120. * @param initialM33 defines 3rd value of 3rd row
  5121. * @param initialM34 defines 4th value of 3rd row
  5122. * @param initialM41 defines 1st value of 4th row
  5123. * @param initialM42 defines 2nd value of 4th row
  5124. * @param initialM43 defines 3rd value of 4th row
  5125. * @param initialM44 defines 4th value of 4th row
  5126. * @returns the new matrix
  5127. */
  5128. 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;
  5129. /**
  5130. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5131. * @param scale defines the scale vector3
  5132. * @param rotation defines the rotation quaternion
  5133. * @param translation defines the translation vector3
  5134. * @returns a new matrix
  5135. */
  5136. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5137. /**
  5138. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5139. * @param scale defines the scale vector3
  5140. * @param rotation defines the rotation quaternion
  5141. * @param translation defines the translation vector3
  5142. * @param result defines the target matrix
  5143. */
  5144. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5145. /**
  5146. * Creates a new identity matrix
  5147. * @returns a new identity matrix
  5148. */
  5149. static Identity(): Matrix;
  5150. /**
  5151. * Creates a new identity matrix and stores the result in a given matrix
  5152. * @param result defines the target matrix
  5153. */
  5154. static IdentityToRef(result: Matrix): void;
  5155. /**
  5156. * Creates a new zero matrix
  5157. * @returns a new zero matrix
  5158. */
  5159. static Zero(): Matrix;
  5160. /**
  5161. * Creates a new rotation matrix for "angle" radians around the X axis
  5162. * @param angle defines the angle (in radians) to use
  5163. * @return the new matrix
  5164. */
  5165. static RotationX(angle: number): Matrix;
  5166. /**
  5167. * Creates a new matrix as the invert of a given matrix
  5168. * @param source defines the source matrix
  5169. * @returns the new matrix
  5170. */
  5171. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5172. /**
  5173. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5174. * @param angle defines the angle (in radians) to use
  5175. * @param result defines the target matrix
  5176. */
  5177. static RotationXToRef(angle: number, result: Matrix): void;
  5178. /**
  5179. * Creates a new rotation matrix for "angle" radians around the Y axis
  5180. * @param angle defines the angle (in radians) to use
  5181. * @return the new matrix
  5182. */
  5183. static RotationY(angle: number): Matrix;
  5184. /**
  5185. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5186. * @param angle defines the angle (in radians) to use
  5187. * @param result defines the target matrix
  5188. */
  5189. static RotationYToRef(angle: number, result: Matrix): void;
  5190. /**
  5191. * Creates a new rotation matrix for "angle" radians around the Z axis
  5192. * @param angle defines the angle (in radians) to use
  5193. * @return the new matrix
  5194. */
  5195. static RotationZ(angle: number): Matrix;
  5196. /**
  5197. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5198. * @param angle defines the angle (in radians) to use
  5199. * @param result defines the target matrix
  5200. */
  5201. static RotationZToRef(angle: number, result: Matrix): void;
  5202. /**
  5203. * Creates a new rotation matrix for "angle" radians around the given axis
  5204. * @param axis defines the axis to use
  5205. * @param angle defines the angle (in radians) to use
  5206. * @return the new matrix
  5207. */
  5208. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5209. /**
  5210. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5211. * @param axis defines the axis to use
  5212. * @param angle defines the angle (in radians) to use
  5213. * @param result defines the target matrix
  5214. */
  5215. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5216. /**
  5217. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5218. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5219. * @param from defines the vector to align
  5220. * @param to defines the vector to align to
  5221. * @param result defines the target matrix
  5222. */
  5223. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5224. /**
  5225. * Creates a rotation matrix
  5226. * @param yaw defines the yaw angle in radians (Y axis)
  5227. * @param pitch defines the pitch angle in radians (X axis)
  5228. * @param roll defines the roll angle in radians (Z axis)
  5229. * @returns the new rotation matrix
  5230. */
  5231. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5232. /**
  5233. * Creates a rotation matrix and stores it in a given matrix
  5234. * @param yaw defines the yaw angle in radians (Y axis)
  5235. * @param pitch defines the pitch angle in radians (X axis)
  5236. * @param roll defines the roll angle in radians (Z axis)
  5237. * @param result defines the target matrix
  5238. */
  5239. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5240. /**
  5241. * Creates a scaling matrix
  5242. * @param x defines the scale factor on X axis
  5243. * @param y defines the scale factor on Y axis
  5244. * @param z defines the scale factor on Z axis
  5245. * @returns the new matrix
  5246. */
  5247. static Scaling(x: number, y: number, z: number): Matrix;
  5248. /**
  5249. * Creates a scaling matrix and stores it in a given matrix
  5250. * @param x defines the scale factor on X axis
  5251. * @param y defines the scale factor on Y axis
  5252. * @param z defines the scale factor on Z axis
  5253. * @param result defines the target matrix
  5254. */
  5255. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5256. /**
  5257. * Creates a translation matrix
  5258. * @param x defines the translation on X axis
  5259. * @param y defines the translation on Y axis
  5260. * @param z defines the translationon Z axis
  5261. * @returns the new matrix
  5262. */
  5263. static Translation(x: number, y: number, z: number): Matrix;
  5264. /**
  5265. * Creates a translation matrix and stores it in a given matrix
  5266. * @param x defines the translation on X axis
  5267. * @param y defines the translation on Y axis
  5268. * @param z defines the translationon Z axis
  5269. * @param result defines the target matrix
  5270. */
  5271. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5272. /**
  5273. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5274. * @param startValue defines the start value
  5275. * @param endValue defines the end value
  5276. * @param gradient defines the gradient factor
  5277. * @returns the new matrix
  5278. */
  5279. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5280. /**
  5281. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5282. * @param startValue defines the start value
  5283. * @param endValue defines the end value
  5284. * @param gradient defines the gradient factor
  5285. * @param result defines the Matrix object where to store data
  5286. */
  5287. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5288. /**
  5289. * Builds a new matrix whose values are computed by:
  5290. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5291. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5292. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5293. * @param startValue defines the first matrix
  5294. * @param endValue defines the second matrix
  5295. * @param gradient defines the gradient between the two matrices
  5296. * @returns the new matrix
  5297. */
  5298. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5299. /**
  5300. * Update a matrix to values which are computed by:
  5301. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5302. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5303. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5304. * @param startValue defines the first matrix
  5305. * @param endValue defines the second matrix
  5306. * @param gradient defines the gradient between the two matrices
  5307. * @param result defines the target matrix
  5308. */
  5309. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5310. /**
  5311. * 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"
  5312. * This function works in left handed mode
  5313. * @param eye defines the final position of the entity
  5314. * @param target defines where the entity should look at
  5315. * @param up defines the up vector for the entity
  5316. * @returns the new matrix
  5317. */
  5318. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5319. /**
  5320. * 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".
  5321. * This function works in left handed mode
  5322. * @param eye defines the final position of the entity
  5323. * @param target defines where the entity should look at
  5324. * @param up defines the up vector for the entity
  5325. * @param result defines the target matrix
  5326. */
  5327. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5328. /**
  5329. * 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"
  5330. * This function works in right handed mode
  5331. * @param eye defines the final position of the entity
  5332. * @param target defines where the entity should look at
  5333. * @param up defines the up vector for the entity
  5334. * @returns the new matrix
  5335. */
  5336. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5337. /**
  5338. * 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".
  5339. * This function works in right handed mode
  5340. * @param eye defines the final position of the entity
  5341. * @param target defines where the entity should look at
  5342. * @param up defines the up vector for the entity
  5343. * @param result defines the target matrix
  5344. */
  5345. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5346. /**
  5347. * Create a left-handed orthographic projection matrix
  5348. * @param width defines the viewport width
  5349. * @param height defines the viewport height
  5350. * @param znear defines the near clip plane
  5351. * @param zfar defines the far clip plane
  5352. * @returns a new matrix as a left-handed orthographic projection matrix
  5353. */
  5354. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5355. /**
  5356. * Store a left-handed orthographic projection to a given matrix
  5357. * @param width defines the viewport width
  5358. * @param height defines the viewport height
  5359. * @param znear defines the near clip plane
  5360. * @param zfar defines the far clip plane
  5361. * @param result defines the target matrix
  5362. */
  5363. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5364. /**
  5365. * Create a left-handed orthographic projection matrix
  5366. * @param left defines the viewport left coordinate
  5367. * @param right defines the viewport right coordinate
  5368. * @param bottom defines the viewport bottom coordinate
  5369. * @param top defines the viewport top coordinate
  5370. * @param znear defines the near clip plane
  5371. * @param zfar defines the far clip plane
  5372. * @returns a new matrix as a left-handed orthographic projection matrix
  5373. */
  5374. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5375. /**
  5376. * Stores a left-handed orthographic projection into a given matrix
  5377. * @param left defines the viewport left coordinate
  5378. * @param right defines the viewport right coordinate
  5379. * @param bottom defines the viewport bottom coordinate
  5380. * @param top defines the viewport top coordinate
  5381. * @param znear defines the near clip plane
  5382. * @param zfar defines the far clip plane
  5383. * @param result defines the target matrix
  5384. */
  5385. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5386. /**
  5387. * Creates a right-handed orthographic projection matrix
  5388. * @param left defines the viewport left coordinate
  5389. * @param right defines the viewport right coordinate
  5390. * @param bottom defines the viewport bottom coordinate
  5391. * @param top defines the viewport top coordinate
  5392. * @param znear defines the near clip plane
  5393. * @param zfar defines the far clip plane
  5394. * @returns a new matrix as a right-handed orthographic projection matrix
  5395. */
  5396. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5397. /**
  5398. * Stores a right-handed orthographic projection into a given matrix
  5399. * @param left defines the viewport left coordinate
  5400. * @param right defines the viewport right coordinate
  5401. * @param bottom defines the viewport bottom coordinate
  5402. * @param top defines the viewport top coordinate
  5403. * @param znear defines the near clip plane
  5404. * @param zfar defines the far clip plane
  5405. * @param result defines the target matrix
  5406. */
  5407. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5408. /**
  5409. * Creates a left-handed perspective projection matrix
  5410. * @param width defines the viewport width
  5411. * @param height defines the viewport height
  5412. * @param znear defines the near clip plane
  5413. * @param zfar defines the far clip plane
  5414. * @returns a new matrix as a left-handed perspective projection matrix
  5415. */
  5416. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5417. /**
  5418. * Creates a left-handed perspective projection matrix
  5419. * @param fov defines the horizontal field of view
  5420. * @param aspect defines the aspect ratio
  5421. * @param znear defines the near clip plane
  5422. * @param zfar defines the far clip plane
  5423. * @returns a new matrix as a left-handed perspective projection matrix
  5424. */
  5425. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5426. /**
  5427. * Stores a left-handed perspective projection into a given matrix
  5428. * @param fov defines the horizontal field of view
  5429. * @param aspect defines the aspect ratio
  5430. * @param znear defines the near clip plane
  5431. * @param zfar defines the far clip plane
  5432. * @param result defines the target matrix
  5433. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5434. */
  5435. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5436. /**
  5437. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5438. * @param fov defines the horizontal field of view
  5439. * @param aspect defines the aspect ratio
  5440. * @param znear defines the near clip plane
  5441. * @param zfar not used as infinity is used as far clip
  5442. * @param result defines the target matrix
  5443. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5444. */
  5445. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5446. /**
  5447. * Creates a right-handed perspective projection matrix
  5448. * @param fov defines the horizontal field of view
  5449. * @param aspect defines the aspect ratio
  5450. * @param znear defines the near clip plane
  5451. * @param zfar defines the far clip plane
  5452. * @returns a new matrix as a right-handed perspective projection matrix
  5453. */
  5454. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5455. /**
  5456. * Stores a right-handed perspective projection into a given matrix
  5457. * @param fov defines the horizontal field of view
  5458. * @param aspect defines the aspect ratio
  5459. * @param znear defines the near clip plane
  5460. * @param zfar defines the far clip plane
  5461. * @param result defines the target matrix
  5462. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5463. */
  5464. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5465. /**
  5466. * Stores a right-handed perspective projection into a given matrix
  5467. * @param fov defines the horizontal field of view
  5468. * @param aspect defines the aspect ratio
  5469. * @param znear defines the near clip plane
  5470. * @param zfar not used as infinity is used as far clip
  5471. * @param result defines the target matrix
  5472. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5473. */
  5474. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5475. /**
  5476. * Stores a perspective projection for WebVR info a given matrix
  5477. * @param fov defines the field of view
  5478. * @param znear defines the near clip plane
  5479. * @param zfar defines the far clip plane
  5480. * @param result defines the target matrix
  5481. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5482. */
  5483. static PerspectiveFovWebVRToRef(fov: {
  5484. upDegrees: number;
  5485. downDegrees: number;
  5486. leftDegrees: number;
  5487. rightDegrees: number;
  5488. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5489. /**
  5490. * Computes a complete transformation matrix
  5491. * @param viewport defines the viewport to use
  5492. * @param world defines the world matrix
  5493. * @param view defines the view matrix
  5494. * @param projection defines the projection matrix
  5495. * @param zmin defines the near clip plane
  5496. * @param zmax defines the far clip plane
  5497. * @returns the transformation matrix
  5498. */
  5499. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5500. /**
  5501. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5502. * @param matrix defines the matrix to use
  5503. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5504. */
  5505. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5506. /**
  5507. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5508. * @param matrix defines the matrix to use
  5509. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5510. */
  5511. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5512. /**
  5513. * Compute the transpose of a given matrix
  5514. * @param matrix defines the matrix to transpose
  5515. * @returns the new matrix
  5516. */
  5517. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5518. /**
  5519. * Compute the transpose of a matrix and store it in a target matrix
  5520. * @param matrix defines the matrix to transpose
  5521. * @param result defines the target matrix
  5522. */
  5523. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5524. /**
  5525. * Computes a reflection matrix from a plane
  5526. * @param plane defines the reflection plane
  5527. * @returns a new matrix
  5528. */
  5529. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5530. /**
  5531. * Computes a reflection matrix from a plane
  5532. * @param plane defines the reflection plane
  5533. * @param result defines the target matrix
  5534. */
  5535. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5536. /**
  5537. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5538. * @param xaxis defines the value of the 1st axis
  5539. * @param yaxis defines the value of the 2nd axis
  5540. * @param zaxis defines the value of the 3rd axis
  5541. * @param result defines the target matrix
  5542. */
  5543. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5544. /**
  5545. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5546. * @param quat defines the quaternion to use
  5547. * @param result defines the target matrix
  5548. */
  5549. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5550. }
  5551. /**
  5552. * @hidden
  5553. */
  5554. export class TmpVectors {
  5555. static Vector2: Vector2[];
  5556. static Vector3: Vector3[];
  5557. static Vector4: Vector4[];
  5558. static Quaternion: Quaternion[];
  5559. static Matrix: Matrix[];
  5560. }
  5561. }
  5562. declare module "babylonjs/Maths/math.path" {
  5563. import { DeepImmutable, Nullable } from "babylonjs/types";
  5564. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5565. /**
  5566. * Defines potential orientation for back face culling
  5567. */
  5568. export enum Orientation {
  5569. /**
  5570. * Clockwise
  5571. */
  5572. CW = 0,
  5573. /** Counter clockwise */
  5574. CCW = 1
  5575. }
  5576. /** Class used to represent a Bezier curve */
  5577. export class BezierCurve {
  5578. /**
  5579. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5580. * @param t defines the time
  5581. * @param x1 defines the left coordinate on X axis
  5582. * @param y1 defines the left coordinate on Y axis
  5583. * @param x2 defines the right coordinate on X axis
  5584. * @param y2 defines the right coordinate on Y axis
  5585. * @returns the interpolated value
  5586. */
  5587. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5588. }
  5589. /**
  5590. * Defines angle representation
  5591. */
  5592. export class Angle {
  5593. private _radians;
  5594. /**
  5595. * Creates an Angle object of "radians" radians (float).
  5596. * @param radians the angle in radians
  5597. */
  5598. constructor(radians: number);
  5599. /**
  5600. * Get value in degrees
  5601. * @returns the Angle value in degrees (float)
  5602. */
  5603. degrees(): number;
  5604. /**
  5605. * Get value in radians
  5606. * @returns the Angle value in radians (float)
  5607. */
  5608. radians(): number;
  5609. /**
  5610. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5611. * @param a defines first point as the origin
  5612. * @param b defines point
  5613. * @returns a new Angle
  5614. */
  5615. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5616. /**
  5617. * Gets a new Angle object from the given float in radians
  5618. * @param radians defines the angle value in radians
  5619. * @returns a new Angle
  5620. */
  5621. static FromRadians(radians: number): Angle;
  5622. /**
  5623. * Gets a new Angle object from the given float in degrees
  5624. * @param degrees defines the angle value in degrees
  5625. * @returns a new Angle
  5626. */
  5627. static FromDegrees(degrees: number): Angle;
  5628. }
  5629. /**
  5630. * This represents an arc in a 2d space.
  5631. */
  5632. export class Arc2 {
  5633. /** Defines the start point of the arc */
  5634. startPoint: Vector2;
  5635. /** Defines the mid point of the arc */
  5636. midPoint: Vector2;
  5637. /** Defines the end point of the arc */
  5638. endPoint: Vector2;
  5639. /**
  5640. * Defines the center point of the arc.
  5641. */
  5642. centerPoint: Vector2;
  5643. /**
  5644. * Defines the radius of the arc.
  5645. */
  5646. radius: number;
  5647. /**
  5648. * Defines the angle of the arc (from mid point to end point).
  5649. */
  5650. angle: Angle;
  5651. /**
  5652. * Defines the start angle of the arc (from start point to middle point).
  5653. */
  5654. startAngle: Angle;
  5655. /**
  5656. * Defines the orientation of the arc (clock wise/counter clock wise).
  5657. */
  5658. orientation: Orientation;
  5659. /**
  5660. * Creates an Arc object from the three given points : start, middle and end.
  5661. * @param startPoint Defines the start point of the arc
  5662. * @param midPoint Defines the midlle point of the arc
  5663. * @param endPoint Defines the end point of the arc
  5664. */
  5665. constructor(
  5666. /** Defines the start point of the arc */
  5667. startPoint: Vector2,
  5668. /** Defines the mid point of the arc */
  5669. midPoint: Vector2,
  5670. /** Defines the end point of the arc */
  5671. endPoint: Vector2);
  5672. }
  5673. /**
  5674. * Represents a 2D path made up of multiple 2D points
  5675. */
  5676. export class Path2 {
  5677. private _points;
  5678. private _length;
  5679. /**
  5680. * If the path start and end point are the same
  5681. */
  5682. closed: boolean;
  5683. /**
  5684. * Creates a Path2 object from the starting 2D coordinates x and y.
  5685. * @param x the starting points x value
  5686. * @param y the starting points y value
  5687. */
  5688. constructor(x: number, y: number);
  5689. /**
  5690. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5691. * @param x the added points x value
  5692. * @param y the added points y value
  5693. * @returns the updated Path2.
  5694. */
  5695. addLineTo(x: number, y: number): Path2;
  5696. /**
  5697. * 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.
  5698. * @param midX middle point x value
  5699. * @param midY middle point y value
  5700. * @param endX end point x value
  5701. * @param endY end point y value
  5702. * @param numberOfSegments (default: 36)
  5703. * @returns the updated Path2.
  5704. */
  5705. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5706. /**
  5707. * Closes the Path2.
  5708. * @returns the Path2.
  5709. */
  5710. close(): Path2;
  5711. /**
  5712. * Gets the sum of the distance between each sequential point in the path
  5713. * @returns the Path2 total length (float).
  5714. */
  5715. length(): number;
  5716. /**
  5717. * Gets the points which construct the path
  5718. * @returns the Path2 internal array of points.
  5719. */
  5720. getPoints(): Vector2[];
  5721. /**
  5722. * Retreives the point at the distance aways from the starting point
  5723. * @param normalizedLengthPosition the length along the path to retreive the point from
  5724. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5725. */
  5726. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5727. /**
  5728. * Creates a new path starting from an x and y position
  5729. * @param x starting x value
  5730. * @param y starting y value
  5731. * @returns a new Path2 starting at the coordinates (x, y).
  5732. */
  5733. static StartingAt(x: number, y: number): Path2;
  5734. }
  5735. /**
  5736. * Represents a 3D path made up of multiple 3D points
  5737. */
  5738. export class Path3D {
  5739. /**
  5740. * an array of Vector3, the curve axis of the Path3D
  5741. */
  5742. path: Vector3[];
  5743. private _curve;
  5744. private _distances;
  5745. private _tangents;
  5746. private _normals;
  5747. private _binormals;
  5748. private _raw;
  5749. private _alignTangentsWithPath;
  5750. private readonly _pointAtData;
  5751. /**
  5752. * new Path3D(path, normal, raw)
  5753. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5754. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5755. * @param path an array of Vector3, the curve axis of the Path3D
  5756. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5757. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5758. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5759. */
  5760. constructor(
  5761. /**
  5762. * an array of Vector3, the curve axis of the Path3D
  5763. */
  5764. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5765. /**
  5766. * Returns the Path3D array of successive Vector3 designing its curve.
  5767. * @returns the Path3D array of successive Vector3 designing its curve.
  5768. */
  5769. getCurve(): Vector3[];
  5770. /**
  5771. * Returns the Path3D array of successive Vector3 designing its curve.
  5772. * @returns the Path3D array of successive Vector3 designing its curve.
  5773. */
  5774. getPoints(): Vector3[];
  5775. /**
  5776. * @returns the computed length (float) of the path.
  5777. */
  5778. length(): number;
  5779. /**
  5780. * Returns an array populated with tangent vectors on each Path3D curve point.
  5781. * @returns an array populated with tangent vectors on each Path3D curve point.
  5782. */
  5783. getTangents(): Vector3[];
  5784. /**
  5785. * Returns an array populated with normal vectors on each Path3D curve point.
  5786. * @returns an array populated with normal vectors on each Path3D curve point.
  5787. */
  5788. getNormals(): Vector3[];
  5789. /**
  5790. * Returns an array populated with binormal vectors on each Path3D curve point.
  5791. * @returns an array populated with binormal vectors on each Path3D curve point.
  5792. */
  5793. getBinormals(): Vector3[];
  5794. /**
  5795. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5796. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5797. */
  5798. getDistances(): number[];
  5799. /**
  5800. * Returns an interpolated point along this path
  5801. * @param position the position of the point along this path, from 0.0 to 1.0
  5802. * @returns a new Vector3 as the point
  5803. */
  5804. getPointAt(position: number): Vector3;
  5805. /**
  5806. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5807. * @param position the position of the point along this path, from 0.0 to 1.0
  5808. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5809. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5810. */
  5811. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5812. /**
  5813. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5814. * @param position the position of the point along this path, from 0.0 to 1.0
  5815. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5816. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5817. */
  5818. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5819. /**
  5820. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5821. * @param position the position of the point along this path, from 0.0 to 1.0
  5822. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5823. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5824. */
  5825. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5826. /**
  5827. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5828. * @param position the position of the point along this path, from 0.0 to 1.0
  5829. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5830. */
  5831. getDistanceAt(position: number): number;
  5832. /**
  5833. * Returns the array index of the previous point of an interpolated point along this path
  5834. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5835. * @returns the array index
  5836. */
  5837. getPreviousPointIndexAt(position: number): number;
  5838. /**
  5839. * 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)
  5840. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5841. * @returns the sub position
  5842. */
  5843. getSubPositionAt(position: number): number;
  5844. /**
  5845. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5846. * @param target the vector of which to get the closest position to
  5847. * @returns the position of the closest virtual point on this path to the target vector
  5848. */
  5849. getClosestPositionTo(target: Vector3): number;
  5850. /**
  5851. * Returns a sub path (slice) of this path
  5852. * @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
  5853. * @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
  5854. * @returns a sub path (slice) of this path
  5855. */
  5856. slice(start?: number, end?: number): Path3D;
  5857. /**
  5858. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5859. * @param path path which all values are copied into the curves points
  5860. * @param firstNormal which should be projected onto the curve
  5861. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5862. * @returns the same object updated.
  5863. */
  5864. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5865. private _compute;
  5866. private _getFirstNonNullVector;
  5867. private _getLastNonNullVector;
  5868. private _normalVector;
  5869. /**
  5870. * Updates the point at data for an interpolated point along this curve
  5871. * @param position the position of the point along this curve, from 0.0 to 1.0
  5872. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5873. * @returns the (updated) point at data
  5874. */
  5875. private _updatePointAtData;
  5876. /**
  5877. * Updates the point at data from the specified parameters
  5878. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5879. * @param point the interpolated point
  5880. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5881. */
  5882. private _setPointAtData;
  5883. /**
  5884. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5885. */
  5886. private _updateInterpolationMatrix;
  5887. }
  5888. /**
  5889. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5890. * A Curve3 is designed from a series of successive Vector3.
  5891. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5892. */
  5893. export class Curve3 {
  5894. private _points;
  5895. private _length;
  5896. /**
  5897. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5898. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5899. * @param v1 (Vector3) the control point
  5900. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5901. * @param nbPoints (integer) the wanted number of points in the curve
  5902. * @returns the created Curve3
  5903. */
  5904. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5905. /**
  5906. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5907. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5908. * @param v1 (Vector3) the first control point
  5909. * @param v2 (Vector3) the second control point
  5910. * @param v3 (Vector3) the end point of the Cubic Bezier
  5911. * @param nbPoints (integer) the wanted number of points in the curve
  5912. * @returns the created Curve3
  5913. */
  5914. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5915. /**
  5916. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5917. * @param p1 (Vector3) the origin point of the Hermite Spline
  5918. * @param t1 (Vector3) the tangent vector at the origin point
  5919. * @param p2 (Vector3) the end point of the Hermite Spline
  5920. * @param t2 (Vector3) the tangent vector at the end point
  5921. * @param nbPoints (integer) the wanted number of points in the curve
  5922. * @returns the created Curve3
  5923. */
  5924. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5925. /**
  5926. * Returns a Curve3 object along a CatmullRom Spline curve :
  5927. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5928. * @param nbPoints (integer) the wanted number of points between each curve control points
  5929. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5930. * @returns the created Curve3
  5931. */
  5932. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5933. /**
  5934. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5935. * A Curve3 is designed from a series of successive Vector3.
  5936. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5937. * @param points points which make up the curve
  5938. */
  5939. constructor(points: Vector3[]);
  5940. /**
  5941. * @returns the Curve3 stored array of successive Vector3
  5942. */
  5943. getPoints(): Vector3[];
  5944. /**
  5945. * @returns the computed length (float) of the curve.
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5950. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5951. * curveA and curveB keep unchanged.
  5952. * @param curve the curve to continue from this curve
  5953. * @returns the newly constructed curve
  5954. */
  5955. continue(curve: DeepImmutable<Curve3>): Curve3;
  5956. private _computeLength;
  5957. }
  5958. }
  5959. declare module "babylonjs/Animations/easing" {
  5960. /**
  5961. * This represents the main contract an easing function should follow.
  5962. * Easing functions are used throughout the animation system.
  5963. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5964. */
  5965. export interface IEasingFunction {
  5966. /**
  5967. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5968. * of the easing function.
  5969. * The link below provides some of the most common examples of easing functions.
  5970. * @see https://easings.net/
  5971. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5972. * @returns the corresponding value on the curve defined by the easing function
  5973. */
  5974. ease(gradient: number): number;
  5975. }
  5976. /**
  5977. * Base class used for every default easing function.
  5978. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5979. */
  5980. export class EasingFunction implements IEasingFunction {
  5981. /**
  5982. * Interpolation follows the mathematical formula associated with the easing function.
  5983. */
  5984. static readonly EASINGMODE_EASEIN: number;
  5985. /**
  5986. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5987. */
  5988. static readonly EASINGMODE_EASEOUT: number;
  5989. /**
  5990. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5991. */
  5992. static readonly EASINGMODE_EASEINOUT: number;
  5993. private _easingMode;
  5994. /**
  5995. * Sets the easing mode of the current function.
  5996. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5997. */
  5998. setEasingMode(easingMode: number): void;
  5999. /**
  6000. * Gets the current easing mode.
  6001. * @returns the easing mode
  6002. */
  6003. getEasingMode(): number;
  6004. /**
  6005. * @hidden
  6006. */
  6007. easeInCore(gradient: number): number;
  6008. /**
  6009. * Given an input gradient between 0 and 1, this returns the corresponding value
  6010. * of the easing function.
  6011. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6012. * @returns the corresponding value on the curve defined by the easing function
  6013. */
  6014. ease(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with a circle shape (see link below).
  6018. * @see https://easings.net/#easeInCirc
  6019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class CircleEase extends EasingFunction implements IEasingFunction {
  6022. /** @hidden */
  6023. easeInCore(gradient: number): number;
  6024. }
  6025. /**
  6026. * Easing function with a ease back shape (see link below).
  6027. * @see https://easings.net/#easeInBack
  6028. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6029. */
  6030. export class BackEase extends EasingFunction implements IEasingFunction {
  6031. /** Defines the amplitude of the function */
  6032. amplitude: number;
  6033. /**
  6034. * Instantiates a back ease easing
  6035. * @see https://easings.net/#easeInBack
  6036. * @param amplitude Defines the amplitude of the function
  6037. */
  6038. constructor(
  6039. /** Defines the amplitude of the function */
  6040. amplitude?: number);
  6041. /** @hidden */
  6042. easeInCore(gradient: number): number;
  6043. }
  6044. /**
  6045. * Easing function with a bouncing shape (see link below).
  6046. * @see https://easings.net/#easeInBounce
  6047. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6048. */
  6049. export class BounceEase extends EasingFunction implements IEasingFunction {
  6050. /** Defines the number of bounces */
  6051. bounces: number;
  6052. /** Defines the amplitude of the bounce */
  6053. bounciness: number;
  6054. /**
  6055. * Instantiates a bounce easing
  6056. * @see https://easings.net/#easeInBounce
  6057. * @param bounces Defines the number of bounces
  6058. * @param bounciness Defines the amplitude of the bounce
  6059. */
  6060. constructor(
  6061. /** Defines the number of bounces */
  6062. bounces?: number,
  6063. /** Defines the amplitude of the bounce */
  6064. bounciness?: number);
  6065. /** @hidden */
  6066. easeInCore(gradient: number): number;
  6067. }
  6068. /**
  6069. * Easing function with a power of 3 shape (see link below).
  6070. * @see https://easings.net/#easeInCubic
  6071. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6072. */
  6073. export class CubicEase extends EasingFunction implements IEasingFunction {
  6074. /** @hidden */
  6075. easeInCore(gradient: number): number;
  6076. }
  6077. /**
  6078. * Easing function with an elastic shape (see link below).
  6079. * @see https://easings.net/#easeInElastic
  6080. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6081. */
  6082. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6083. /** Defines the number of oscillations*/
  6084. oscillations: number;
  6085. /** Defines the amplitude of the oscillations*/
  6086. springiness: number;
  6087. /**
  6088. * Instantiates an elastic easing function
  6089. * @see https://easings.net/#easeInElastic
  6090. * @param oscillations Defines the number of oscillations
  6091. * @param springiness Defines the amplitude of the oscillations
  6092. */
  6093. constructor(
  6094. /** Defines the number of oscillations*/
  6095. oscillations?: number,
  6096. /** Defines the amplitude of the oscillations*/
  6097. springiness?: number);
  6098. /** @hidden */
  6099. easeInCore(gradient: number): number;
  6100. }
  6101. /**
  6102. * Easing function with an exponential shape (see link below).
  6103. * @see https://easings.net/#easeInExpo
  6104. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6105. */
  6106. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6107. /** Defines the exponent of the function */
  6108. exponent: number;
  6109. /**
  6110. * Instantiates an exponential easing function
  6111. * @see https://easings.net/#easeInExpo
  6112. * @param exponent Defines the exponent of the function
  6113. */
  6114. constructor(
  6115. /** Defines the exponent of the function */
  6116. exponent?: number);
  6117. /** @hidden */
  6118. easeInCore(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a power shape (see link below).
  6122. * @see https://easings.net/#easeInQuad
  6123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class PowerEase extends EasingFunction implements IEasingFunction {
  6126. /** Defines the power of the function */
  6127. power: number;
  6128. /**
  6129. * Instantiates an power base easing function
  6130. * @see https://easings.net/#easeInQuad
  6131. * @param power Defines the power of the function
  6132. */
  6133. constructor(
  6134. /** Defines the power of the function */
  6135. power?: number);
  6136. /** @hidden */
  6137. easeInCore(gradient: number): number;
  6138. }
  6139. /**
  6140. * Easing function with a power of 2 shape (see link below).
  6141. * @see https://easings.net/#easeInQuad
  6142. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6143. */
  6144. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6145. /** @hidden */
  6146. easeInCore(gradient: number): number;
  6147. }
  6148. /**
  6149. * Easing function with a power of 4 shape (see link below).
  6150. * @see https://easings.net/#easeInQuart
  6151. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6152. */
  6153. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6154. /** @hidden */
  6155. easeInCore(gradient: number): number;
  6156. }
  6157. /**
  6158. * Easing function with a power of 5 shape (see link below).
  6159. * @see https://easings.net/#easeInQuint
  6160. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6161. */
  6162. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6163. /** @hidden */
  6164. easeInCore(gradient: number): number;
  6165. }
  6166. /**
  6167. * Easing function with a sin shape (see link below).
  6168. * @see https://easings.net/#easeInSine
  6169. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6170. */
  6171. export class SineEase extends EasingFunction implements IEasingFunction {
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bezier shape (see link below).
  6177. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6178. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the x component of the start tangent in the bezier curve */
  6182. x1: number;
  6183. /** Defines the y component of the start tangent in the bezier curve */
  6184. y1: number;
  6185. /** Defines the x component of the end tangent in the bezier curve */
  6186. x2: number;
  6187. /** Defines the y component of the end tangent in the bezier curve */
  6188. y2: number;
  6189. /**
  6190. * Instantiates a bezier function
  6191. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6192. * @param x1 Defines the x component of the start tangent in the bezier curve
  6193. * @param y1 Defines the y component of the start tangent in the bezier curve
  6194. * @param x2 Defines the x component of the end tangent in the bezier curve
  6195. * @param y2 Defines the y component of the end tangent in the bezier curve
  6196. */
  6197. constructor(
  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. /** @hidden */
  6207. easeInCore(gradient: number): number;
  6208. }
  6209. }
  6210. declare module "babylonjs/Maths/math.color" {
  6211. import { DeepImmutable, FloatArray } from "babylonjs/types";
  6212. /**
  6213. * Class used to hold a RBG color
  6214. */
  6215. export class Color3 {
  6216. /**
  6217. * Defines the red component (between 0 and 1, default is 0)
  6218. */
  6219. r: number;
  6220. /**
  6221. * Defines the green component (between 0 and 1, default is 0)
  6222. */
  6223. g: number;
  6224. /**
  6225. * Defines the blue component (between 0 and 1, default is 0)
  6226. */
  6227. b: number;
  6228. /**
  6229. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6230. * @param r defines the red component (between 0 and 1, default is 0)
  6231. * @param g defines the green component (between 0 and 1, default is 0)
  6232. * @param b defines the blue component (between 0 and 1, default is 0)
  6233. */
  6234. constructor(
  6235. /**
  6236. * Defines the red component (between 0 and 1, default is 0)
  6237. */
  6238. r?: number,
  6239. /**
  6240. * Defines the green component (between 0 and 1, default is 0)
  6241. */
  6242. g?: number,
  6243. /**
  6244. * Defines the blue component (between 0 and 1, default is 0)
  6245. */
  6246. b?: number);
  6247. /**
  6248. * Creates a string with the Color3 current values
  6249. * @returns the string representation of the Color3 object
  6250. */
  6251. toString(): string;
  6252. /**
  6253. * Returns the string "Color3"
  6254. * @returns "Color3"
  6255. */
  6256. getClassName(): string;
  6257. /**
  6258. * Compute the Color3 hash code
  6259. * @returns an unique number that can be used to hash Color3 objects
  6260. */
  6261. getHashCode(): number;
  6262. /**
  6263. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6264. * @param array defines the array where to store the r,g,b components
  6265. * @param index defines an optional index in the target array to define where to start storing values
  6266. * @returns the current Color3 object
  6267. */
  6268. toArray(array: FloatArray, index?: number): Color3;
  6269. /**
  6270. * Update the current color with values stored in an array from the starting index of the given array
  6271. * @param array defines the source array
  6272. * @param offset defines an offset in the source array
  6273. * @returns the current Color3 object
  6274. */
  6275. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6276. /**
  6277. * Returns a new Color4 object from the current Color3 and the given alpha
  6278. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6279. * @returns a new Color4 object
  6280. */
  6281. toColor4(alpha?: number): Color4;
  6282. /**
  6283. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6284. * @returns the new array
  6285. */
  6286. asArray(): number[];
  6287. /**
  6288. * Returns the luminance value
  6289. * @returns a float value
  6290. */
  6291. toLuminance(): number;
  6292. /**
  6293. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6294. * @param otherColor defines the second operand
  6295. * @returns the new Color3 object
  6296. */
  6297. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6298. /**
  6299. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6300. * @param otherColor defines the second operand
  6301. * @param result defines the Color3 object where to store the result
  6302. * @returns the current Color3
  6303. */
  6304. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6305. /**
  6306. * Determines equality between Color3 objects
  6307. * @param otherColor defines the second operand
  6308. * @returns true if the rgb values are equal to the given ones
  6309. */
  6310. equals(otherColor: DeepImmutable<Color3>): boolean;
  6311. /**
  6312. * Determines equality between the current Color3 object and a set of r,b,g values
  6313. * @param r defines the red component to check
  6314. * @param g defines the green component to check
  6315. * @param b defines the blue component to check
  6316. * @returns true if the rgb values are equal to the given ones
  6317. */
  6318. equalsFloats(r: number, g: number, b: number): boolean;
  6319. /**
  6320. * Multiplies in place each rgb value by scale
  6321. * @param scale defines the scaling factor
  6322. * @returns the updated Color3
  6323. */
  6324. scale(scale: number): Color3;
  6325. /**
  6326. * Multiplies the rgb values by scale and stores the result into "result"
  6327. * @param scale defines the scaling factor
  6328. * @param result defines the Color3 object where to store the result
  6329. * @returns the unmodified current Color3
  6330. */
  6331. scaleToRef(scale: number, result: Color3): Color3;
  6332. /**
  6333. * Scale the current Color3 values by a factor and add the result to a given Color3
  6334. * @param scale defines the scale factor
  6335. * @param result defines color to store the result into
  6336. * @returns the unmodified current Color3
  6337. */
  6338. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6339. /**
  6340. * Clamps the rgb values by the min and max values and stores the result into "result"
  6341. * @param min defines minimum clamping value (default is 0)
  6342. * @param max defines maximum clamping value (default is 1)
  6343. * @param result defines color to store the result into
  6344. * @returns the original Color3
  6345. */
  6346. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6347. /**
  6348. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6349. * @param otherColor defines the second operand
  6350. * @returns the new Color3
  6351. */
  6352. add(otherColor: DeepImmutable<Color3>): Color3;
  6353. /**
  6354. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6355. * @param otherColor defines the second operand
  6356. * @param result defines Color3 object to store the result into
  6357. * @returns the unmodified current Color3
  6358. */
  6359. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6360. /**
  6361. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6362. * @param otherColor defines the second operand
  6363. * @returns the new Color3
  6364. */
  6365. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6366. /**
  6367. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6368. * @param otherColor defines the second operand
  6369. * @param result defines Color3 object to store the result into
  6370. * @returns the unmodified current Color3
  6371. */
  6372. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6373. /**
  6374. * Copy the current object
  6375. * @returns a new Color3 copied the current one
  6376. */
  6377. clone(): Color3;
  6378. /**
  6379. * Copies the rgb values from the source in the current Color3
  6380. * @param source defines the source Color3 object
  6381. * @returns the updated Color3 object
  6382. */
  6383. copyFrom(source: DeepImmutable<Color3>): Color3;
  6384. /**
  6385. * Updates the Color3 rgb values from the given floats
  6386. * @param r defines the red component to read from
  6387. * @param g defines the green component to read from
  6388. * @param b defines the blue component to read from
  6389. * @returns the current Color3 object
  6390. */
  6391. copyFromFloats(r: number, g: number, b: number): Color3;
  6392. /**
  6393. * Updates the Color3 rgb values from the given floats
  6394. * @param r defines the red component to read from
  6395. * @param g defines the green component to read from
  6396. * @param b defines the blue component to read from
  6397. * @returns the current Color3 object
  6398. */
  6399. set(r: number, g: number, b: number): Color3;
  6400. /**
  6401. * Compute the Color3 hexadecimal code as a string
  6402. * @returns a string containing the hexadecimal representation of the Color3 object
  6403. */
  6404. toHexString(): string;
  6405. /**
  6406. * Computes a new Color3 converted from the current one to linear space
  6407. * @returns a new Color3 object
  6408. */
  6409. toLinearSpace(): Color3;
  6410. /**
  6411. * Converts current color in rgb space to HSV values
  6412. * @returns a new color3 representing the HSV values
  6413. */
  6414. toHSV(): Color3;
  6415. /**
  6416. * Converts current color in rgb space to HSV values
  6417. * @param result defines the Color3 where to store the HSV values
  6418. */
  6419. toHSVToRef(result: Color3): void;
  6420. /**
  6421. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6422. * @param convertedColor defines the Color3 object where to store the linear space version
  6423. * @returns the unmodified Color3
  6424. */
  6425. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6426. /**
  6427. * Computes a new Color3 converted from the current one to gamma space
  6428. * @returns a new Color3 object
  6429. */
  6430. toGammaSpace(): Color3;
  6431. /**
  6432. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6433. * @param convertedColor defines the Color3 object where to store the gamma space version
  6434. * @returns the unmodified Color3
  6435. */
  6436. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6437. private static _BlackReadOnly;
  6438. /**
  6439. * Convert Hue, saturation and value to a Color3 (RGB)
  6440. * @param hue defines the hue
  6441. * @param saturation defines the saturation
  6442. * @param value defines the value
  6443. * @param result defines the Color3 where to store the RGB values
  6444. */
  6445. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6446. /**
  6447. * Creates a new Color3 from the string containing valid hexadecimal values
  6448. * @param hex defines a string containing valid hexadecimal values
  6449. * @returns a new Color3 object
  6450. */
  6451. static FromHexString(hex: string): Color3;
  6452. /**
  6453. * Creates a new Color3 from the starting index of the given array
  6454. * @param array defines the source array
  6455. * @param offset defines an offset in the source array
  6456. * @returns a new Color3 object
  6457. */
  6458. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6459. /**
  6460. * Creates a new Color3 from the starting index element of the given array
  6461. * @param array defines the source array to read from
  6462. * @param offset defines the offset in the source array
  6463. * @param result defines the target Color3 object
  6464. */
  6465. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6466. /**
  6467. * Creates a new Color3 from integer values (< 256)
  6468. * @param r defines the red component to read from (value between 0 and 255)
  6469. * @param g defines the green component to read from (value between 0 and 255)
  6470. * @param b defines the blue component to read from (value between 0 and 255)
  6471. * @returns a new Color3 object
  6472. */
  6473. static FromInts(r: number, g: number, b: number): Color3;
  6474. /**
  6475. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6476. * @param start defines the start Color3 value
  6477. * @param end defines the end Color3 value
  6478. * @param amount defines the gradient value between start and end
  6479. * @returns a new Color3 object
  6480. */
  6481. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6482. /**
  6483. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6484. * @param left defines the start value
  6485. * @param right defines the end value
  6486. * @param amount defines the gradient factor
  6487. * @param result defines the Color3 object where to store the result
  6488. */
  6489. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6490. /**
  6491. * Returns a Color3 value containing a red color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Red(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a green color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Green(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a blue color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Blue(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a black color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Black(): Color3;
  6510. /**
  6511. * Gets a Color3 value containing a black color that must not be updated
  6512. */
  6513. static get BlackReadOnly(): DeepImmutable<Color3>;
  6514. /**
  6515. * Returns a Color3 value containing a white color
  6516. * @returns a new Color3 object
  6517. */
  6518. static White(): Color3;
  6519. /**
  6520. * Returns a Color3 value containing a purple color
  6521. * @returns a new Color3 object
  6522. */
  6523. static Purple(): Color3;
  6524. /**
  6525. * Returns a Color3 value containing a magenta color
  6526. * @returns a new Color3 object
  6527. */
  6528. static Magenta(): Color3;
  6529. /**
  6530. * Returns a Color3 value containing a yellow color
  6531. * @returns a new Color3 object
  6532. */
  6533. static Yellow(): Color3;
  6534. /**
  6535. * Returns a Color3 value containing a gray color
  6536. * @returns a new Color3 object
  6537. */
  6538. static Gray(): Color3;
  6539. /**
  6540. * Returns a Color3 value containing a teal color
  6541. * @returns a new Color3 object
  6542. */
  6543. static Teal(): Color3;
  6544. /**
  6545. * Returns a Color3 value containing a random color
  6546. * @returns a new Color3 object
  6547. */
  6548. static Random(): Color3;
  6549. }
  6550. /**
  6551. * Class used to hold a RBGA color
  6552. */
  6553. export class Color4 {
  6554. /**
  6555. * Defines the red component (between 0 and 1, default is 0)
  6556. */
  6557. r: number;
  6558. /**
  6559. * Defines the green component (between 0 and 1, default is 0)
  6560. */
  6561. g: number;
  6562. /**
  6563. * Defines the blue component (between 0 and 1, default is 0)
  6564. */
  6565. b: number;
  6566. /**
  6567. * Defines the alpha component (between 0 and 1, default is 1)
  6568. */
  6569. a: number;
  6570. /**
  6571. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6572. * @param r defines the red component (between 0 and 1, default is 0)
  6573. * @param g defines the green component (between 0 and 1, default is 0)
  6574. * @param b defines the blue component (between 0 and 1, default is 0)
  6575. * @param a defines the alpha component (between 0 and 1, default is 1)
  6576. */
  6577. constructor(
  6578. /**
  6579. * Defines the red component (between 0 and 1, default is 0)
  6580. */
  6581. r?: number,
  6582. /**
  6583. * Defines the green component (between 0 and 1, default is 0)
  6584. */
  6585. g?: number,
  6586. /**
  6587. * Defines the blue component (between 0 and 1, default is 0)
  6588. */
  6589. b?: number,
  6590. /**
  6591. * Defines the alpha component (between 0 and 1, default is 1)
  6592. */
  6593. a?: number);
  6594. /**
  6595. * Adds in place the given Color4 values to the current Color4 object
  6596. * @param right defines the second operand
  6597. * @returns the current updated Color4 object
  6598. */
  6599. addInPlace(right: DeepImmutable<Color4>): Color4;
  6600. /**
  6601. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6602. * @returns the new array
  6603. */
  6604. asArray(): number[];
  6605. /**
  6606. * Stores from the starting index in the given array the Color4 successive values
  6607. * @param array defines the array where to store the r,g,b components
  6608. * @param index defines an optional index in the target array to define where to start storing values
  6609. * @returns the current Color4 object
  6610. */
  6611. toArray(array: number[], index?: number): Color4;
  6612. /**
  6613. * Update the current color with values stored in an array from the starting index of the given array
  6614. * @param array defines the source array
  6615. * @param offset defines an offset in the source array
  6616. * @returns the current Color4 object
  6617. */
  6618. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6619. /**
  6620. * Determines equality between Color4 objects
  6621. * @param otherColor defines the second operand
  6622. * @returns true if the rgba values are equal to the given ones
  6623. */
  6624. equals(otherColor: DeepImmutable<Color4>): boolean;
  6625. /**
  6626. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6627. * @param right defines the second operand
  6628. * @returns a new Color4 object
  6629. */
  6630. add(right: DeepImmutable<Color4>): Color4;
  6631. /**
  6632. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6633. * @param right defines the second operand
  6634. * @returns a new Color4 object
  6635. */
  6636. subtract(right: DeepImmutable<Color4>): Color4;
  6637. /**
  6638. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6639. * @param right defines the second operand
  6640. * @param result defines the Color4 object where to store the result
  6641. * @returns the current Color4 object
  6642. */
  6643. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6644. /**
  6645. * Creates a new Color4 with the current Color4 values multiplied by scale
  6646. * @param scale defines the scaling factor to apply
  6647. * @returns a new Color4 object
  6648. */
  6649. scale(scale: number): Color4;
  6650. /**
  6651. * Multiplies the current Color4 values by scale and stores the result in "result"
  6652. * @param scale defines the scaling factor to apply
  6653. * @param result defines the Color4 object where to store the result
  6654. * @returns the current unmodified Color4
  6655. */
  6656. scaleToRef(scale: number, result: Color4): Color4;
  6657. /**
  6658. * Scale the current Color4 values by a factor and add the result to a given Color4
  6659. * @param scale defines the scale factor
  6660. * @param result defines the Color4 object where to store the result
  6661. * @returns the unmodified current Color4
  6662. */
  6663. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6664. /**
  6665. * Clamps the rgb values by the min and max values and stores the result into "result"
  6666. * @param min defines minimum clamping value (default is 0)
  6667. * @param max defines maximum clamping value (default is 1)
  6668. * @param result defines color to store the result into.
  6669. * @returns the cuurent Color4
  6670. */
  6671. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6672. /**
  6673. * Multipy an Color4 value by another and return a new Color4 object
  6674. * @param color defines the Color4 value to multiply by
  6675. * @returns a new Color4 object
  6676. */
  6677. multiply(color: Color4): Color4;
  6678. /**
  6679. * Multipy a Color4 value by another and push the result in a reference value
  6680. * @param color defines the Color4 value to multiply by
  6681. * @param result defines the Color4 to fill the result in
  6682. * @returns the result Color4
  6683. */
  6684. multiplyToRef(color: Color4, result: Color4): Color4;
  6685. /**
  6686. * Creates a string with the Color4 current values
  6687. * @returns the string representation of the Color4 object
  6688. */
  6689. toString(): string;
  6690. /**
  6691. * Returns the string "Color4"
  6692. * @returns "Color4"
  6693. */
  6694. getClassName(): string;
  6695. /**
  6696. * Compute the Color4 hash code
  6697. * @returns an unique number that can be used to hash Color4 objects
  6698. */
  6699. getHashCode(): number;
  6700. /**
  6701. * Creates a new Color4 copied from the current one
  6702. * @returns a new Color4 object
  6703. */
  6704. clone(): Color4;
  6705. /**
  6706. * Copies the given Color4 values into the current one
  6707. * @param source defines the source Color4 object
  6708. * @returns the current updated Color4 object
  6709. */
  6710. copyFrom(source: Color4): Color4;
  6711. /**
  6712. * Copies the given float values into the current one
  6713. * @param r defines the red component to read from
  6714. * @param g defines the green component to read from
  6715. * @param b defines the blue component to read from
  6716. * @param a defines the alpha component to read from
  6717. * @returns the current updated Color4 object
  6718. */
  6719. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6720. /**
  6721. * Copies the given float values into the current one
  6722. * @param r defines the red component to read from
  6723. * @param g defines the green component to read from
  6724. * @param b defines the blue component to read from
  6725. * @param a defines the alpha component to read from
  6726. * @returns the current updated Color4 object
  6727. */
  6728. set(r: number, g: number, b: number, a: number): Color4;
  6729. /**
  6730. * Compute the Color4 hexadecimal code as a string
  6731. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6732. * @returns a string containing the hexadecimal representation of the Color4 object
  6733. */
  6734. toHexString(returnAsColor3?: boolean): string;
  6735. /**
  6736. * Computes a new Color4 converted from the current one to linear space
  6737. * @returns a new Color4 object
  6738. */
  6739. toLinearSpace(): Color4;
  6740. /**
  6741. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6742. * @param convertedColor defines the Color4 object where to store the linear space version
  6743. * @returns the unmodified Color4
  6744. */
  6745. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6746. /**
  6747. * Computes a new Color4 converted from the current one to gamma space
  6748. * @returns a new Color4 object
  6749. */
  6750. toGammaSpace(): Color4;
  6751. /**
  6752. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6753. * @param convertedColor defines the Color4 object where to store the gamma space version
  6754. * @returns the unmodified Color4
  6755. */
  6756. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6757. /**
  6758. * Creates a new Color4 from the string containing valid hexadecimal values
  6759. * @param hex defines a string containing valid hexadecimal values
  6760. * @returns a new Color4 object
  6761. */
  6762. static FromHexString(hex: string): Color4;
  6763. /**
  6764. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6765. * @param left defines the start value
  6766. * @param right defines the end value
  6767. * @param amount defines the gradient factor
  6768. * @returns a new Color4 object
  6769. */
  6770. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6771. /**
  6772. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6773. * @param left defines the start value
  6774. * @param right defines the end value
  6775. * @param amount defines the gradient factor
  6776. * @param result defines the Color4 object where to store data
  6777. */
  6778. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6779. /**
  6780. * Creates a new Color4 from a Color3 and an alpha value
  6781. * @param color3 defines the source Color3 to read from
  6782. * @param alpha defines the alpha component (1.0 by default)
  6783. * @returns a new Color4 object
  6784. */
  6785. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6786. /**
  6787. * Creates a new Color4 from the starting index element of the given array
  6788. * @param array defines the source array to read from
  6789. * @param offset defines the offset in the source array
  6790. * @returns a new Color4 object
  6791. */
  6792. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6793. /**
  6794. * Creates a new Color4 from the starting index element of the given array
  6795. * @param array defines the source array to read from
  6796. * @param offset defines the offset in the source array
  6797. * @param result defines the target Color4 object
  6798. */
  6799. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6800. /**
  6801. * Creates a new Color3 from integer values (< 256)
  6802. * @param r defines the red component to read from (value between 0 and 255)
  6803. * @param g defines the green component to read from (value between 0 and 255)
  6804. * @param b defines the blue component to read from (value between 0 and 255)
  6805. * @param a defines the alpha component to read from (value between 0 and 255)
  6806. * @returns a new Color3 object
  6807. */
  6808. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6809. /**
  6810. * Check the content of a given array and convert it to an array containing RGBA data
  6811. * If the original array was already containing count * 4 values then it is returned directly
  6812. * @param colors defines the array to check
  6813. * @param count defines the number of RGBA data to expect
  6814. * @returns an array containing count * 4 values (RGBA)
  6815. */
  6816. static CheckColors4(colors: number[], count: number): number[];
  6817. }
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class TmpColors {
  6822. static Color3: Color3[];
  6823. static Color4: Color4[];
  6824. }
  6825. }
  6826. declare module "babylonjs/Animations/animationKey" {
  6827. /**
  6828. * Defines an interface which represents an animation key frame
  6829. */
  6830. export interface IAnimationKey {
  6831. /**
  6832. * Frame of the key frame
  6833. */
  6834. frame: number;
  6835. /**
  6836. * Value at the specifies key frame
  6837. */
  6838. value: any;
  6839. /**
  6840. * The input tangent for the cubic hermite spline
  6841. */
  6842. inTangent?: any;
  6843. /**
  6844. * The output tangent for the cubic hermite spline
  6845. */
  6846. outTangent?: any;
  6847. /**
  6848. * The animation interpolation type
  6849. */
  6850. interpolation?: AnimationKeyInterpolation;
  6851. }
  6852. /**
  6853. * Enum for the animation key frame interpolation type
  6854. */
  6855. export enum AnimationKeyInterpolation {
  6856. /**
  6857. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6858. */
  6859. STEP = 1
  6860. }
  6861. }
  6862. declare module "babylonjs/Animations/animationRange" {
  6863. /**
  6864. * Represents the range of an animation
  6865. */
  6866. export class AnimationRange {
  6867. /**The name of the animation range**/
  6868. name: string;
  6869. /**The starting frame of the animation */
  6870. from: number;
  6871. /**The ending frame of the animation*/
  6872. to: number;
  6873. /**
  6874. * Initializes the range of an animation
  6875. * @param name The name of the animation range
  6876. * @param from The starting frame of the animation
  6877. * @param to The ending frame of the animation
  6878. */
  6879. constructor(
  6880. /**The name of the animation range**/
  6881. name: string,
  6882. /**The starting frame of the animation */
  6883. from: number,
  6884. /**The ending frame of the animation*/
  6885. to: number);
  6886. /**
  6887. * Makes a copy of the animation range
  6888. * @returns A copy of the animation range
  6889. */
  6890. clone(): AnimationRange;
  6891. }
  6892. }
  6893. declare module "babylonjs/Animations/animationEvent" {
  6894. /**
  6895. * Composed of a frame, and an action function
  6896. */
  6897. export class AnimationEvent {
  6898. /** The frame for which the event is triggered **/
  6899. frame: number;
  6900. /** The event to perform when triggered **/
  6901. action: (currentFrame: number) => void;
  6902. /** Specifies if the event should be triggered only once**/
  6903. onlyOnce?: boolean | undefined;
  6904. /**
  6905. * Specifies if the animation event is done
  6906. */
  6907. isDone: boolean;
  6908. /**
  6909. * Initializes the animation event
  6910. * @param frame The frame for which the event is triggered
  6911. * @param action The event to perform when triggered
  6912. * @param onlyOnce Specifies if the event should be triggered only once
  6913. */
  6914. constructor(
  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. /** @hidden */
  6922. _clone(): AnimationEvent;
  6923. }
  6924. }
  6925. declare module "babylonjs/Behaviors/behavior" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * Interface used to define a behavior
  6929. */
  6930. export interface Behavior<T> {
  6931. /** gets or sets behavior's name */
  6932. name: string;
  6933. /**
  6934. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6935. */
  6936. init(): void;
  6937. /**
  6938. * Called when the behavior is attached to a target
  6939. * @param target defines the target where the behavior is attached to
  6940. */
  6941. attach(target: T): void;
  6942. /**
  6943. * Called when the behavior is detached from its target
  6944. */
  6945. detach(): void;
  6946. }
  6947. /**
  6948. * Interface implemented by classes supporting behaviors
  6949. */
  6950. export interface IBehaviorAware<T> {
  6951. /**
  6952. * Attach a behavior
  6953. * @param behavior defines the behavior to attach
  6954. * @returns the current host
  6955. */
  6956. addBehavior(behavior: Behavior<T>): T;
  6957. /**
  6958. * Remove a behavior from the current object
  6959. * @param behavior defines the behavior to detach
  6960. * @returns the current host
  6961. */
  6962. removeBehavior(behavior: Behavior<T>): T;
  6963. /**
  6964. * Gets a behavior using its name to search
  6965. * @param name defines the name to search
  6966. * @returns the behavior or null if not found
  6967. */
  6968. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6969. }
  6970. }
  6971. declare module "babylonjs/Meshes/buffer" {
  6972. import { Nullable, DataArray } from "babylonjs/types";
  6973. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6974. /**
  6975. * Class used to store data that will be store in GPU memory
  6976. */
  6977. export class Buffer {
  6978. private _engine;
  6979. private _buffer;
  6980. /** @hidden */
  6981. _data: Nullable<DataArray>;
  6982. private _updatable;
  6983. private _instanced;
  6984. private _divisor;
  6985. private _isAlreadyOwned;
  6986. /**
  6987. * Gets the byte stride.
  6988. */
  6989. readonly byteStride: number;
  6990. /**
  6991. * Constructor
  6992. * @param engine the engine
  6993. * @param data the data to use for this buffer
  6994. * @param updatable whether the data is updatable
  6995. * @param stride the stride (optional)
  6996. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6997. * @param instanced whether the buffer is instanced (optional)
  6998. * @param useBytes set to true if the stride in in bytes (optional)
  6999. * @param divisor sets an optional divisor for instances (1 by default)
  7000. */
  7001. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  7002. /**
  7003. * Create a new VertexBuffer based on the current buffer
  7004. * @param kind defines the vertex buffer kind (position, normal, etc.)
  7005. * @param offset defines offset in the buffer (0 by default)
  7006. * @param size defines the size in floats of attributes (position is 3 for instance)
  7007. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7008. * @param instanced defines if the vertex buffer contains indexed data
  7009. * @param useBytes defines if the offset and stride are in bytes *
  7010. * @param divisor sets an optional divisor for instances (1 by default)
  7011. * @returns the new vertex buffer
  7012. */
  7013. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7014. /**
  7015. * Gets a boolean indicating if the Buffer is updatable?
  7016. * @returns true if the buffer is updatable
  7017. */
  7018. isUpdatable(): boolean;
  7019. /**
  7020. * Gets current buffer's data
  7021. * @returns a DataArray or null
  7022. */
  7023. getData(): Nullable<DataArray>;
  7024. /**
  7025. * Gets underlying native buffer
  7026. * @returns underlying native buffer
  7027. */
  7028. getBuffer(): Nullable<DataBuffer>;
  7029. /**
  7030. * Gets the stride in float32 units (i.e. byte stride / 4).
  7031. * May not be an integer if the byte stride is not divisible by 4.
  7032. * @returns the stride in float32 units
  7033. * @deprecated Please use byteStride instead.
  7034. */
  7035. getStrideSize(): number;
  7036. /**
  7037. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7038. * @param data defines the data to store
  7039. */
  7040. create(data?: Nullable<DataArray>): void;
  7041. /** @hidden */
  7042. _rebuild(): void;
  7043. /**
  7044. * Update current buffer data
  7045. * @param data defines the data to store
  7046. */
  7047. update(data: DataArray): void;
  7048. /**
  7049. * Updates the data directly.
  7050. * @param data the new data
  7051. * @param offset the new offset
  7052. * @param vertexCount the vertex count (optional)
  7053. * @param useBytes set to true if the offset is in bytes
  7054. */
  7055. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7056. /** @hidden */
  7057. _increaseReferences(): void;
  7058. /**
  7059. * Release all resources
  7060. */
  7061. dispose(): void;
  7062. }
  7063. /**
  7064. * Specialized buffer used to store vertex data
  7065. */
  7066. export class VertexBuffer {
  7067. /** @hidden */
  7068. _buffer: Buffer;
  7069. private _kind;
  7070. private _size;
  7071. private _ownsBuffer;
  7072. private _instanced;
  7073. private _instanceDivisor;
  7074. /**
  7075. * The byte type.
  7076. */
  7077. static readonly BYTE: number;
  7078. /**
  7079. * The unsigned byte type.
  7080. */
  7081. static readonly UNSIGNED_BYTE: number;
  7082. /**
  7083. * The short type.
  7084. */
  7085. static readonly SHORT: number;
  7086. /**
  7087. * The unsigned short type.
  7088. */
  7089. static readonly UNSIGNED_SHORT: number;
  7090. /**
  7091. * The integer type.
  7092. */
  7093. static readonly INT: number;
  7094. /**
  7095. * The unsigned integer type.
  7096. */
  7097. static readonly UNSIGNED_INT: number;
  7098. /**
  7099. * The float type.
  7100. */
  7101. static readonly FLOAT: number;
  7102. /**
  7103. * Gets or sets the instance divisor when in instanced mode
  7104. */
  7105. get instanceDivisor(): number;
  7106. set instanceDivisor(value: number);
  7107. /**
  7108. * Gets the byte stride.
  7109. */
  7110. readonly byteStride: number;
  7111. /**
  7112. * Gets the byte offset.
  7113. */
  7114. readonly byteOffset: number;
  7115. /**
  7116. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7117. */
  7118. readonly normalized: boolean;
  7119. /**
  7120. * Gets the data type of each component in the array.
  7121. */
  7122. readonly type: number;
  7123. /**
  7124. * Constructor
  7125. * @param engine the engine
  7126. * @param data the data to use for this vertex buffer
  7127. * @param kind the vertex buffer kind
  7128. * @param updatable whether the data is updatable
  7129. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7130. * @param stride the stride (optional)
  7131. * @param instanced whether the buffer is instanced (optional)
  7132. * @param offset the offset of the data (optional)
  7133. * @param size the number of components (optional)
  7134. * @param type the type of the component (optional)
  7135. * @param normalized whether the data contains normalized data (optional)
  7136. * @param useBytes set to true if stride and offset are in bytes (optional)
  7137. * @param divisor defines the instance divisor to use (1 by default)
  7138. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7139. */
  7140. 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);
  7141. /** @hidden */
  7142. _rebuild(): void;
  7143. /**
  7144. * Returns the kind of the VertexBuffer (string)
  7145. * @returns a string
  7146. */
  7147. getKind(): string;
  7148. /**
  7149. * Gets a boolean indicating if the VertexBuffer is updatable?
  7150. * @returns true if the buffer is updatable
  7151. */
  7152. isUpdatable(): boolean;
  7153. /**
  7154. * Gets current buffer's data
  7155. * @returns a DataArray or null
  7156. */
  7157. getData(): Nullable<DataArray>;
  7158. /**
  7159. * Gets underlying native buffer
  7160. * @returns underlying native buffer
  7161. */
  7162. getBuffer(): Nullable<DataBuffer>;
  7163. /**
  7164. * Gets the stride in float32 units (i.e. byte stride / 4).
  7165. * May not be an integer if the byte stride is not divisible by 4.
  7166. * @returns the stride in float32 units
  7167. * @deprecated Please use byteStride instead.
  7168. */
  7169. getStrideSize(): number;
  7170. /**
  7171. * Returns the offset as a multiple of the type byte length.
  7172. * @returns the offset in bytes
  7173. * @deprecated Please use byteOffset instead.
  7174. */
  7175. getOffset(): number;
  7176. /**
  7177. * Returns the number of components per vertex attribute (integer)
  7178. * @returns the size in float
  7179. */
  7180. getSize(): number;
  7181. /**
  7182. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7183. * @returns true if this buffer is instanced
  7184. */
  7185. getIsInstanced(): boolean;
  7186. /**
  7187. * Returns the instancing divisor, zero for non-instanced (integer).
  7188. * @returns a number
  7189. */
  7190. getInstanceDivisor(): number;
  7191. /**
  7192. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7193. * @param data defines the data to store
  7194. */
  7195. create(data?: DataArray): void;
  7196. /**
  7197. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7198. * This function will create a new buffer if the current one is not updatable
  7199. * @param data defines the data to store
  7200. */
  7201. update(data: DataArray): void;
  7202. /**
  7203. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7204. * Returns the directly updated WebGLBuffer.
  7205. * @param data the new data
  7206. * @param offset the new offset
  7207. * @param useBytes set to true if the offset is in bytes
  7208. */
  7209. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7210. /**
  7211. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7212. */
  7213. dispose(): void;
  7214. /**
  7215. * Enumerates each value of this vertex buffer as numbers.
  7216. * @param count the number of values to enumerate
  7217. * @param callback the callback function called for each value
  7218. */
  7219. forEach(count: number, callback: (value: number, index: number) => void): void;
  7220. /**
  7221. * Positions
  7222. */
  7223. static readonly PositionKind: string;
  7224. /**
  7225. * Normals
  7226. */
  7227. static readonly NormalKind: string;
  7228. /**
  7229. * Tangents
  7230. */
  7231. static readonly TangentKind: string;
  7232. /**
  7233. * Texture coordinates
  7234. */
  7235. static readonly UVKind: string;
  7236. /**
  7237. * Texture coordinates 2
  7238. */
  7239. static readonly UV2Kind: string;
  7240. /**
  7241. * Texture coordinates 3
  7242. */
  7243. static readonly UV3Kind: string;
  7244. /**
  7245. * Texture coordinates 4
  7246. */
  7247. static readonly UV4Kind: string;
  7248. /**
  7249. * Texture coordinates 5
  7250. */
  7251. static readonly UV5Kind: string;
  7252. /**
  7253. * Texture coordinates 6
  7254. */
  7255. static readonly UV6Kind: string;
  7256. /**
  7257. * Colors
  7258. */
  7259. static readonly ColorKind: string;
  7260. /**
  7261. * Matrix indices (for bones)
  7262. */
  7263. static readonly MatricesIndicesKind: string;
  7264. /**
  7265. * Matrix weights (for bones)
  7266. */
  7267. static readonly MatricesWeightsKind: string;
  7268. /**
  7269. * Additional matrix indices (for bones)
  7270. */
  7271. static readonly MatricesIndicesExtraKind: string;
  7272. /**
  7273. * Additional matrix weights (for bones)
  7274. */
  7275. static readonly MatricesWeightsExtraKind: string;
  7276. /**
  7277. * Deduces the stride given a kind.
  7278. * @param kind The kind string to deduce
  7279. * @returns The deduced stride
  7280. */
  7281. static DeduceStride(kind: string): number;
  7282. /**
  7283. * Gets the byte length of the given type.
  7284. * @param type the type
  7285. * @returns the number of bytes
  7286. */
  7287. static GetTypeByteLength(type: number): number;
  7288. /**
  7289. * Enumerates each value of the given parameters as numbers.
  7290. * @param data the data to enumerate
  7291. * @param byteOffset the byte offset of the data
  7292. * @param byteStride the byte stride of the data
  7293. * @param componentCount the number of components per element
  7294. * @param componentType the type of the component
  7295. * @param count the number of values to enumerate
  7296. * @param normalized whether the data is normalized
  7297. * @param callback the callback function called for each value
  7298. */
  7299. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7300. private static _GetFloatValue;
  7301. }
  7302. }
  7303. declare module "babylonjs/Collisions/intersectionInfo" {
  7304. import { Nullable } from "babylonjs/types";
  7305. /**
  7306. * @hidden
  7307. */
  7308. export class IntersectionInfo {
  7309. bu: Nullable<number>;
  7310. bv: Nullable<number>;
  7311. distance: number;
  7312. faceId: number;
  7313. subMeshId: number;
  7314. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7315. }
  7316. }
  7317. declare module "babylonjs/Culling/boundingSphere" {
  7318. import { DeepImmutable } from "babylonjs/types";
  7319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7320. import { Plane } from "babylonjs/Maths/math.plane";
  7321. /**
  7322. * Class used to store bounding sphere information
  7323. */
  7324. export class BoundingSphere {
  7325. /**
  7326. * Gets the center of the bounding sphere in local space
  7327. */
  7328. readonly center: Vector3;
  7329. /**
  7330. * Radius of the bounding sphere in local space
  7331. */
  7332. radius: number;
  7333. /**
  7334. * Gets the center of the bounding sphere in world space
  7335. */
  7336. readonly centerWorld: Vector3;
  7337. /**
  7338. * Radius of the bounding sphere in world space
  7339. */
  7340. radiusWorld: number;
  7341. /**
  7342. * Gets the minimum vector in local space
  7343. */
  7344. readonly minimum: Vector3;
  7345. /**
  7346. * Gets the maximum vector in local space
  7347. */
  7348. readonly maximum: Vector3;
  7349. private _worldMatrix;
  7350. private static readonly TmpVector3;
  7351. /**
  7352. * Creates a new bounding sphere
  7353. * @param min defines the minimum vector (in local space)
  7354. * @param max defines the maximum vector (in local space)
  7355. * @param worldMatrix defines the new world matrix
  7356. */
  7357. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7358. /**
  7359. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7360. * @param min defines the new minimum vector (in local space)
  7361. * @param max defines the new maximum vector (in local space)
  7362. * @param worldMatrix defines the new world matrix
  7363. */
  7364. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7365. /**
  7366. * Scale the current bounding sphere by applying a scale factor
  7367. * @param factor defines the scale factor to apply
  7368. * @returns the current bounding box
  7369. */
  7370. scale(factor: number): BoundingSphere;
  7371. /**
  7372. * Gets the world matrix of the bounding box
  7373. * @returns a matrix
  7374. */
  7375. getWorldMatrix(): DeepImmutable<Matrix>;
  7376. /** @hidden */
  7377. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7378. /**
  7379. * Tests if the bounding sphere is intersecting the frustum planes
  7380. * @param frustumPlanes defines the frustum planes to test
  7381. * @returns true if there is an intersection
  7382. */
  7383. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7384. /**
  7385. * Tests if the bounding sphere center is in between the frustum planes.
  7386. * Used for optimistic fast inclusion.
  7387. * @param frustumPlanes defines the frustum planes to test
  7388. * @returns true if the sphere center is in between the frustum planes
  7389. */
  7390. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7391. /**
  7392. * Tests if a point is inside the bounding sphere
  7393. * @param point defines the point to test
  7394. * @returns true if the point is inside the bounding sphere
  7395. */
  7396. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7397. /**
  7398. * Checks if two sphere intersct
  7399. * @param sphere0 sphere 0
  7400. * @param sphere1 sphere 1
  7401. * @returns true if the speres intersect
  7402. */
  7403. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7404. }
  7405. }
  7406. declare module "babylonjs/Culling/boundingBox" {
  7407. import { DeepImmutable } from "babylonjs/types";
  7408. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7409. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7410. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7411. import { Plane } from "babylonjs/Maths/math.plane";
  7412. /**
  7413. * Class used to store bounding box information
  7414. */
  7415. export class BoundingBox implements ICullable {
  7416. /**
  7417. * Gets the 8 vectors representing the bounding box in local space
  7418. */
  7419. readonly vectors: Vector3[];
  7420. /**
  7421. * Gets the center of the bounding box in local space
  7422. */
  7423. readonly center: Vector3;
  7424. /**
  7425. * Gets the center of the bounding box in world space
  7426. */
  7427. readonly centerWorld: Vector3;
  7428. /**
  7429. * Gets the extend size in local space
  7430. */
  7431. readonly extendSize: Vector3;
  7432. /**
  7433. * Gets the extend size in world space
  7434. */
  7435. readonly extendSizeWorld: Vector3;
  7436. /**
  7437. * Gets the OBB (object bounding box) directions
  7438. */
  7439. readonly directions: Vector3[];
  7440. /**
  7441. * Gets the 8 vectors representing the bounding box in world space
  7442. */
  7443. readonly vectorsWorld: Vector3[];
  7444. /**
  7445. * Gets the minimum vector in world space
  7446. */
  7447. readonly minimumWorld: Vector3;
  7448. /**
  7449. * Gets the maximum vector in world space
  7450. */
  7451. readonly maximumWorld: Vector3;
  7452. /**
  7453. * Gets the minimum vector in local space
  7454. */
  7455. readonly minimum: Vector3;
  7456. /**
  7457. * Gets the maximum vector in local space
  7458. */
  7459. readonly maximum: Vector3;
  7460. private _worldMatrix;
  7461. private static readonly TmpVector3;
  7462. /**
  7463. * @hidden
  7464. */
  7465. _tag: number;
  7466. /**
  7467. * Creates a new bounding box
  7468. * @param min defines the minimum vector (in local space)
  7469. * @param max defines the maximum vector (in local space)
  7470. * @param worldMatrix defines the new world matrix
  7471. */
  7472. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7473. /**
  7474. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7475. * @param min defines the new minimum vector (in local space)
  7476. * @param max defines the new maximum vector (in local space)
  7477. * @param worldMatrix defines the new world matrix
  7478. */
  7479. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7480. /**
  7481. * Scale the current bounding box by applying a scale factor
  7482. * @param factor defines the scale factor to apply
  7483. * @returns the current bounding box
  7484. */
  7485. scale(factor: number): BoundingBox;
  7486. /**
  7487. * Gets the world matrix of the bounding box
  7488. * @returns a matrix
  7489. */
  7490. getWorldMatrix(): DeepImmutable<Matrix>;
  7491. /** @hidden */
  7492. _update(world: DeepImmutable<Matrix>): void;
  7493. /**
  7494. * Tests if the bounding box is intersecting the frustum planes
  7495. * @param frustumPlanes defines the frustum planes to test
  7496. * @returns true if there is an intersection
  7497. */
  7498. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7499. /**
  7500. * Tests if the bounding box is entirely inside the frustum planes
  7501. * @param frustumPlanes defines the frustum planes to test
  7502. * @returns true if there is an inclusion
  7503. */
  7504. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7505. /**
  7506. * Tests if a point is inside the bounding box
  7507. * @param point defines the point to test
  7508. * @returns true if the point is inside the bounding box
  7509. */
  7510. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7511. /**
  7512. * Tests if the bounding box intersects with a bounding sphere
  7513. * @param sphere defines the sphere to test
  7514. * @returns true if there is an intersection
  7515. */
  7516. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7517. /**
  7518. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7519. * @param min defines the min vector to use
  7520. * @param max defines the max vector to use
  7521. * @returns true if there is an intersection
  7522. */
  7523. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7524. /**
  7525. * Tests if two bounding boxes are intersections
  7526. * @param box0 defines the first box to test
  7527. * @param box1 defines the second box to test
  7528. * @returns true if there is an intersection
  7529. */
  7530. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7531. /**
  7532. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7533. * @param minPoint defines the minimum vector of the bounding box
  7534. * @param maxPoint defines the maximum vector of the bounding box
  7535. * @param sphereCenter defines the sphere center
  7536. * @param sphereRadius defines the sphere radius
  7537. * @returns true if there is an intersection
  7538. */
  7539. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7540. /**
  7541. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7542. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7543. * @param frustumPlanes defines the frustum planes to test
  7544. * @return true if there is an inclusion
  7545. */
  7546. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7547. /**
  7548. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7549. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7550. * @param frustumPlanes defines the frustum planes to test
  7551. * @return true if there is an intersection
  7552. */
  7553. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7554. }
  7555. }
  7556. declare module "babylonjs/Collisions/collider" {
  7557. import { Nullable, IndicesArray } from "babylonjs/types";
  7558. import { Vector3 } from "babylonjs/Maths/math.vector";
  7559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7560. import { Plane } from "babylonjs/Maths/math.plane";
  7561. /** @hidden */
  7562. export class Collider {
  7563. /** Define if a collision was found */
  7564. collisionFound: boolean;
  7565. /**
  7566. * Define last intersection point in local space
  7567. */
  7568. intersectionPoint: Vector3;
  7569. /**
  7570. * Define last collided mesh
  7571. */
  7572. collidedMesh: Nullable<AbstractMesh>;
  7573. private _collisionPoint;
  7574. private _planeIntersectionPoint;
  7575. private _tempVector;
  7576. private _tempVector2;
  7577. private _tempVector3;
  7578. private _tempVector4;
  7579. private _edge;
  7580. private _baseToVertex;
  7581. private _destinationPoint;
  7582. private _slidePlaneNormal;
  7583. private _displacementVector;
  7584. /** @hidden */
  7585. _radius: Vector3;
  7586. /** @hidden */
  7587. _retry: number;
  7588. private _velocity;
  7589. private _basePoint;
  7590. private _epsilon;
  7591. /** @hidden */
  7592. _velocityWorldLength: number;
  7593. /** @hidden */
  7594. _basePointWorld: Vector3;
  7595. private _velocityWorld;
  7596. private _normalizedVelocity;
  7597. /** @hidden */
  7598. _initialVelocity: Vector3;
  7599. /** @hidden */
  7600. _initialPosition: Vector3;
  7601. private _nearestDistance;
  7602. private _collisionMask;
  7603. get collisionMask(): number;
  7604. set collisionMask(mask: number);
  7605. /**
  7606. * Gets the plane normal used to compute the sliding response (in local space)
  7607. */
  7608. get slidePlaneNormal(): Vector3;
  7609. /** @hidden */
  7610. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7611. /** @hidden */
  7612. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7613. /** @hidden */
  7614. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7615. /** @hidden */
  7616. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7617. /** @hidden */
  7618. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7619. /** @hidden */
  7620. _getResponse(pos: Vector3, vel: Vector3): void;
  7621. }
  7622. }
  7623. declare module "babylonjs/Culling/boundingInfo" {
  7624. import { DeepImmutable } from "babylonjs/types";
  7625. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7626. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7627. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7628. import { Plane } from "babylonjs/Maths/math.plane";
  7629. import { Collider } from "babylonjs/Collisions/collider";
  7630. /**
  7631. * Interface for cullable objects
  7632. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7633. */
  7634. export interface ICullable {
  7635. /**
  7636. * Checks if the object or part of the object is in the frustum
  7637. * @param frustumPlanes Camera near/planes
  7638. * @returns true if the object is in frustum otherwise false
  7639. */
  7640. isInFrustum(frustumPlanes: Plane[]): boolean;
  7641. /**
  7642. * Checks if a cullable object (mesh...) is in the camera frustum
  7643. * Unlike isInFrustum this cheks the full bounding box
  7644. * @param frustumPlanes Camera near/planes
  7645. * @returns true if the object is in frustum otherwise false
  7646. */
  7647. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7648. }
  7649. /**
  7650. * Info for a bounding data of a mesh
  7651. */
  7652. export class BoundingInfo implements ICullable {
  7653. /**
  7654. * Bounding box for the mesh
  7655. */
  7656. readonly boundingBox: BoundingBox;
  7657. /**
  7658. * Bounding sphere for the mesh
  7659. */
  7660. readonly boundingSphere: BoundingSphere;
  7661. private _isLocked;
  7662. private static readonly TmpVector3;
  7663. /**
  7664. * Constructs bounding info
  7665. * @param minimum min vector of the bounding box/sphere
  7666. * @param maximum max vector of the bounding box/sphere
  7667. * @param worldMatrix defines the new world matrix
  7668. */
  7669. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7670. /**
  7671. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7672. * @param min defines the new minimum vector (in local space)
  7673. * @param max defines the new maximum vector (in local space)
  7674. * @param worldMatrix defines the new world matrix
  7675. */
  7676. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7677. /**
  7678. * min vector of the bounding box/sphere
  7679. */
  7680. get minimum(): Vector3;
  7681. /**
  7682. * max vector of the bounding box/sphere
  7683. */
  7684. get maximum(): Vector3;
  7685. /**
  7686. * If the info is locked and won't be updated to avoid perf overhead
  7687. */
  7688. get isLocked(): boolean;
  7689. set isLocked(value: boolean);
  7690. /**
  7691. * Updates the bounding sphere and box
  7692. * @param world world matrix to be used to update
  7693. */
  7694. update(world: DeepImmutable<Matrix>): void;
  7695. /**
  7696. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7697. * @param center New center of the bounding info
  7698. * @param extend New extend of the bounding info
  7699. * @returns the current bounding info
  7700. */
  7701. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7702. /**
  7703. * Scale the current bounding info by applying a scale factor
  7704. * @param factor defines the scale factor to apply
  7705. * @returns the current bounding info
  7706. */
  7707. scale(factor: number): BoundingInfo;
  7708. /**
  7709. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7710. * @param frustumPlanes defines the frustum to test
  7711. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7712. * @returns true if the bounding info is in the frustum planes
  7713. */
  7714. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7715. /**
  7716. * Gets the world distance between the min and max points of the bounding box
  7717. */
  7718. get diagonalLength(): number;
  7719. /**
  7720. * Checks if a cullable object (mesh...) is in the camera frustum
  7721. * Unlike isInFrustum this cheks the full bounding box
  7722. * @param frustumPlanes Camera near/planes
  7723. * @returns true if the object is in frustum otherwise false
  7724. */
  7725. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7726. /** @hidden */
  7727. _checkCollision(collider: Collider): boolean;
  7728. /**
  7729. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7730. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7731. * @param point the point to check intersection with
  7732. * @returns if the point intersects
  7733. */
  7734. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7735. /**
  7736. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7737. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7738. * @param boundingInfo the bounding info to check intersection with
  7739. * @param precise if the intersection should be done using OBB
  7740. * @returns if the bounding info intersects
  7741. */
  7742. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7743. }
  7744. }
  7745. declare module "babylonjs/Maths/math.functions" {
  7746. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7747. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7748. /**
  7749. * Extracts minimum and maximum values from a list of indexed positions
  7750. * @param positions defines the positions to use
  7751. * @param indices defines the indices to the positions
  7752. * @param indexStart defines the start index
  7753. * @param indexCount defines the end index
  7754. * @param bias defines bias value to add to the result
  7755. * @return minimum and maximum values
  7756. */
  7757. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7758. minimum: Vector3;
  7759. maximum: Vector3;
  7760. };
  7761. /**
  7762. * Extracts minimum and maximum values from a list of positions
  7763. * @param positions defines the positions to use
  7764. * @param start defines the start index in the positions array
  7765. * @param count defines the number of positions to handle
  7766. * @param bias defines bias value to add to the result
  7767. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7768. * @return minimum and maximum values
  7769. */
  7770. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7771. minimum: Vector3;
  7772. maximum: Vector3;
  7773. };
  7774. }
  7775. declare module "babylonjs/Misc/guid" {
  7776. /**
  7777. * Class used to manipulate GUIDs
  7778. */
  7779. export class GUID {
  7780. /**
  7781. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7782. * Be aware Math.random() could cause collisions, but:
  7783. * "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"
  7784. * @returns a pseudo random id
  7785. */
  7786. static RandomId(): string;
  7787. }
  7788. }
  7789. declare module "babylonjs/Materials/Textures/baseTexture" {
  7790. import { Observable } from "babylonjs/Misc/observable";
  7791. import { Nullable } from "babylonjs/types";
  7792. import { Scene } from "babylonjs/scene";
  7793. import { Matrix } from "babylonjs/Maths/math.vector";
  7794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7795. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7796. import "babylonjs/Misc/fileTools";
  7797. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7798. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7799. /**
  7800. * Base class of all the textures in babylon.
  7801. * It groups all the common properties the materials, post process, lights... might need
  7802. * in order to make a correct use of the texture.
  7803. */
  7804. export class BaseTexture extends ThinTexture implements IAnimatable {
  7805. /**
  7806. * Default anisotropic filtering level for the application.
  7807. * It is set to 4 as a good tradeoff between perf and quality.
  7808. */
  7809. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7810. /**
  7811. * Gets or sets the unique id of the texture
  7812. */
  7813. uniqueId: number;
  7814. /**
  7815. * Define the name of the texture.
  7816. */
  7817. name: string;
  7818. /**
  7819. * Gets or sets an object used to store user defined information.
  7820. */
  7821. metadata: any;
  7822. /**
  7823. * For internal use only. Please do not use.
  7824. */
  7825. reservedDataStore: any;
  7826. private _hasAlpha;
  7827. /**
  7828. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7829. */
  7830. get hasAlpha(): boolean;
  7831. set hasAlpha(value: boolean);
  7832. /**
  7833. * Defines if the alpha value should be determined via the rgb values.
  7834. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7835. */
  7836. getAlphaFromRGB: boolean;
  7837. /**
  7838. * Intensity or strength of the texture.
  7839. * It is commonly used by materials to fine tune the intensity of the texture
  7840. */
  7841. level: number;
  7842. /**
  7843. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7844. * This is part of the texture as textures usually maps to one uv set.
  7845. */
  7846. coordinatesIndex: number;
  7847. protected _coordinatesMode: number;
  7848. /**
  7849. * How a texture is mapped.
  7850. *
  7851. * | Value | Type | Description |
  7852. * | ----- | ----------------------------------- | ----------- |
  7853. * | 0 | EXPLICIT_MODE | |
  7854. * | 1 | SPHERICAL_MODE | |
  7855. * | 2 | PLANAR_MODE | |
  7856. * | 3 | CUBIC_MODE | |
  7857. * | 4 | PROJECTION_MODE | |
  7858. * | 5 | SKYBOX_MODE | |
  7859. * | 6 | INVCUBIC_MODE | |
  7860. * | 7 | EQUIRECTANGULAR_MODE | |
  7861. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7862. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7863. */
  7864. set coordinatesMode(value: number);
  7865. get coordinatesMode(): number;
  7866. /**
  7867. * | Value | Type | Description |
  7868. * | ----- | ------------------ | ----------- |
  7869. * | 0 | CLAMP_ADDRESSMODE | |
  7870. * | 1 | WRAP_ADDRESSMODE | |
  7871. * | 2 | MIRROR_ADDRESSMODE | |
  7872. */
  7873. get wrapU(): number;
  7874. set wrapU(value: number);
  7875. /**
  7876. * | Value | Type | Description |
  7877. * | ----- | ------------------ | ----------- |
  7878. * | 0 | CLAMP_ADDRESSMODE | |
  7879. * | 1 | WRAP_ADDRESSMODE | |
  7880. * | 2 | MIRROR_ADDRESSMODE | |
  7881. */
  7882. get wrapV(): number;
  7883. set wrapV(value: number);
  7884. /**
  7885. * | Value | Type | Description |
  7886. * | ----- | ------------------ | ----------- |
  7887. * | 0 | CLAMP_ADDRESSMODE | |
  7888. * | 1 | WRAP_ADDRESSMODE | |
  7889. * | 2 | MIRROR_ADDRESSMODE | |
  7890. */
  7891. wrapR: number;
  7892. /**
  7893. * With compliant hardware and browser (supporting anisotropic filtering)
  7894. * this defines the level of anisotropic filtering in the texture.
  7895. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7896. */
  7897. anisotropicFilteringLevel: number;
  7898. private _isCube;
  7899. /**
  7900. * Define if the texture is a cube texture or if false a 2d texture.
  7901. */
  7902. get isCube(): boolean;
  7903. set isCube(value: boolean);
  7904. /**
  7905. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7906. */
  7907. get is3D(): boolean;
  7908. set is3D(value: boolean);
  7909. /**
  7910. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7911. */
  7912. get is2DArray(): boolean;
  7913. set is2DArray(value: boolean);
  7914. private _gammaSpace;
  7915. /**
  7916. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7917. * HDR texture are usually stored in linear space.
  7918. * This only impacts the PBR and Background materials
  7919. */
  7920. get gammaSpace(): boolean;
  7921. set gammaSpace(gamma: boolean);
  7922. /**
  7923. * Gets or sets whether or not the texture contains RGBD data.
  7924. */
  7925. get isRGBD(): boolean;
  7926. set isRGBD(value: boolean);
  7927. /**
  7928. * Is Z inverted in the texture (useful in a cube texture).
  7929. */
  7930. invertZ: boolean;
  7931. /**
  7932. * Are mip maps generated for this texture or not.
  7933. */
  7934. get noMipmap(): boolean;
  7935. /**
  7936. * @hidden
  7937. */
  7938. lodLevelInAlpha: boolean;
  7939. /**
  7940. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7941. */
  7942. get lodGenerationOffset(): number;
  7943. set lodGenerationOffset(value: number);
  7944. /**
  7945. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7946. */
  7947. get lodGenerationScale(): number;
  7948. set lodGenerationScale(value: number);
  7949. /**
  7950. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7951. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7952. * average roughness values.
  7953. */
  7954. get linearSpecularLOD(): boolean;
  7955. set linearSpecularLOD(value: boolean);
  7956. /**
  7957. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7958. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7959. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7960. */
  7961. get irradianceTexture(): Nullable<BaseTexture>;
  7962. set irradianceTexture(value: Nullable<BaseTexture>);
  7963. /**
  7964. * Define if the texture is a render target.
  7965. */
  7966. isRenderTarget: boolean;
  7967. /**
  7968. * Define the unique id of the texture in the scene.
  7969. */
  7970. get uid(): string;
  7971. /** @hidden */
  7972. _prefiltered: boolean;
  7973. /**
  7974. * Return a string representation of the texture.
  7975. * @returns the texture as a string
  7976. */
  7977. toString(): string;
  7978. /**
  7979. * Get the class name of the texture.
  7980. * @returns "BaseTexture"
  7981. */
  7982. getClassName(): string;
  7983. /**
  7984. * Define the list of animation attached to the texture.
  7985. */
  7986. animations: import("babylonjs/Animations/animation").Animation[];
  7987. /**
  7988. * An event triggered when the texture is disposed.
  7989. */
  7990. onDisposeObservable: Observable<BaseTexture>;
  7991. private _onDisposeObserver;
  7992. /**
  7993. * Callback triggered when the texture has been disposed.
  7994. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7995. */
  7996. set onDispose(callback: () => void);
  7997. protected _scene: Nullable<Scene>;
  7998. /** @hidden */
  7999. _texture: Nullable<InternalTexture>;
  8000. private _uid;
  8001. /**
  8002. * Define if the texture is preventinga material to render or not.
  8003. * If not and the texture is not ready, the engine will use a default black texture instead.
  8004. */
  8005. get isBlocking(): boolean;
  8006. /**
  8007. * Instantiates a new BaseTexture.
  8008. * Base class of all the textures in babylon.
  8009. * It groups all the common properties the materials, post process, lights... might need
  8010. * in order to make a correct use of the texture.
  8011. * @param sceneOrEngine Define the scene or engine the texture blongs to
  8012. */
  8013. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8014. /**
  8015. * Get the scene the texture belongs to.
  8016. * @returns the scene or null if undefined
  8017. */
  8018. getScene(): Nullable<Scene>;
  8019. /** @hidden */
  8020. protected _getEngine(): Nullable<ThinEngine>;
  8021. /**
  8022. * Checks if the texture has the same transform matrix than another texture
  8023. * @param texture texture to check against
  8024. * @returns true if the transforms are the same, else false
  8025. */
  8026. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8027. /**
  8028. * Get the texture transform matrix used to offset tile the texture for istance.
  8029. * @returns the transformation matrix
  8030. */
  8031. getTextureMatrix(): Matrix;
  8032. /**
  8033. * Get the texture reflection matrix used to rotate/transform the reflection.
  8034. * @returns the reflection matrix
  8035. */
  8036. getReflectionTextureMatrix(): Matrix;
  8037. /**
  8038. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8039. * @returns true if ready or not blocking
  8040. */
  8041. isReadyOrNotBlocking(): boolean;
  8042. /**
  8043. * Scales the texture if is `canRescale()`
  8044. * @param ratio the resize factor we want to use to rescale
  8045. */
  8046. scale(ratio: number): void;
  8047. /**
  8048. * Get if the texture can rescale.
  8049. */
  8050. get canRescale(): boolean;
  8051. /** @hidden */
  8052. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8053. /** @hidden */
  8054. _rebuild(): void;
  8055. /**
  8056. * Clones the texture.
  8057. * @returns the cloned texture
  8058. */
  8059. clone(): Nullable<BaseTexture>;
  8060. /**
  8061. * Get the texture underlying type (INT, FLOAT...)
  8062. */
  8063. get textureType(): number;
  8064. /**
  8065. * Get the texture underlying format (RGB, RGBA...)
  8066. */
  8067. get textureFormat(): number;
  8068. /**
  8069. * Indicates that textures need to be re-calculated for all materials
  8070. */
  8071. protected _markAllSubMeshesAsTexturesDirty(): void;
  8072. /**
  8073. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8074. * This will returns an RGBA array buffer containing either in values (0-255) or
  8075. * float values (0-1) depending of the underlying buffer type.
  8076. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8077. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8078. * @param buffer defines a user defined buffer to fill with data (can be null)
  8079. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8080. * @returns The Array buffer promise containing the pixels data.
  8081. */
  8082. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8083. /** @hidden */
  8084. get _lodTextureHigh(): Nullable<BaseTexture>;
  8085. /** @hidden */
  8086. get _lodTextureMid(): Nullable<BaseTexture>;
  8087. /** @hidden */
  8088. get _lodTextureLow(): Nullable<BaseTexture>;
  8089. /**
  8090. * Dispose the texture and release its associated resources.
  8091. */
  8092. dispose(): void;
  8093. /**
  8094. * Serialize the texture into a JSON representation that can be parsed later on.
  8095. * @returns the JSON representation of the texture
  8096. */
  8097. serialize(): any;
  8098. /**
  8099. * Helper function to be called back once a list of texture contains only ready textures.
  8100. * @param textures Define the list of textures to wait for
  8101. * @param callback Define the callback triggered once the entire list will be ready
  8102. */
  8103. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8104. private static _isScene;
  8105. }
  8106. }
  8107. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  8108. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8109. /** @hidden */
  8110. export class WebGLDataBuffer extends DataBuffer {
  8111. private _buffer;
  8112. constructor(resource: WebGLBuffer);
  8113. get underlyingResource(): any;
  8114. }
  8115. }
  8116. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  8117. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8118. import { Nullable } from "babylonjs/types";
  8119. import { Effect } from "babylonjs/Materials/effect";
  8120. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  8121. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  8122. /** @hidden */
  8123. export class WebGLPipelineContext implements IPipelineContext {
  8124. private _valueCache;
  8125. private _uniforms;
  8126. engine: ThinEngine;
  8127. program: Nullable<WebGLProgram>;
  8128. context?: WebGLRenderingContext;
  8129. vertexShader?: WebGLShader;
  8130. fragmentShader?: WebGLShader;
  8131. isParallelCompiled: boolean;
  8132. onCompiled?: () => void;
  8133. transformFeedback?: WebGLTransformFeedback | null;
  8134. vertexCompilationError: Nullable<string>;
  8135. fragmentCompilationError: Nullable<string>;
  8136. programLinkError: Nullable<string>;
  8137. programValidationError: Nullable<string>;
  8138. get isAsync(): boolean;
  8139. get isReady(): boolean;
  8140. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8141. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8142. [key: string]: number;
  8143. }, uniformsNames: string[], uniforms: {
  8144. [key: string]: Nullable<WebGLUniformLocation>;
  8145. }, samplerList: string[], samplers: {
  8146. [key: string]: number;
  8147. }, attributesNames: string[], attributes: number[]): void;
  8148. /**
  8149. * Release all associated resources.
  8150. **/
  8151. dispose(): void;
  8152. /** @hidden */
  8153. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8154. /** @hidden */
  8155. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8156. /** @hidden */
  8157. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8158. /** @hidden */
  8159. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8160. /**
  8161. * Sets an interger value on a uniform variable.
  8162. * @param uniformName Name of the variable.
  8163. * @param value Value to be set.
  8164. */
  8165. setInt(uniformName: string, value: number): void;
  8166. /**
  8167. * Sets a int2 on a uniform variable.
  8168. * @param uniformName Name of the variable.
  8169. * @param x First int in int2.
  8170. * @param y Second int in int2.
  8171. */
  8172. setInt2(uniformName: string, x: number, y: number): void;
  8173. /**
  8174. * Sets a int3 on a uniform variable.
  8175. * @param uniformName Name of the variable.
  8176. * @param x First int in int3.
  8177. * @param y Second int in int3.
  8178. * @param y Third int in int3.
  8179. */
  8180. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8181. /**
  8182. * Sets a int4 on a uniform variable.
  8183. * @param uniformName Name of the variable.
  8184. * @param x First int in int4.
  8185. * @param y Second int in int4.
  8186. * @param y Third int in int4.
  8187. * @param w Fourth int in int4.
  8188. */
  8189. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8190. /**
  8191. * Sets an int array on a uniform variable.
  8192. * @param uniformName Name of the variable.
  8193. * @param array array to be set.
  8194. */
  8195. setIntArray(uniformName: string, array: Int32Array): void;
  8196. /**
  8197. * 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)
  8198. * @param uniformName Name of the variable.
  8199. * @param array array to be set.
  8200. */
  8201. setIntArray2(uniformName: string, array: Int32Array): void;
  8202. /**
  8203. * 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)
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setIntArray3(uniformName: string, array: Int32Array): void;
  8208. /**
  8209. * 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)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. */
  8213. setIntArray4(uniformName: string, array: Int32Array): void;
  8214. /**
  8215. * Sets an array on a uniform variable.
  8216. * @param uniformName Name of the variable.
  8217. * @param array array to be set.
  8218. */
  8219. setArray(uniformName: string, array: number[]): void;
  8220. /**
  8221. * 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)
  8222. * @param uniformName Name of the variable.
  8223. * @param array array to be set.
  8224. */
  8225. setArray2(uniformName: string, array: number[]): void;
  8226. /**
  8227. * 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)
  8228. * @param uniformName Name of the variable.
  8229. * @param array array to be set.
  8230. * @returns this effect.
  8231. */
  8232. setArray3(uniformName: string, array: number[]): void;
  8233. /**
  8234. * 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)
  8235. * @param uniformName Name of the variable.
  8236. * @param array array to be set.
  8237. */
  8238. setArray4(uniformName: string, array: number[]): void;
  8239. /**
  8240. * Sets matrices on a uniform variable.
  8241. * @param uniformName Name of the variable.
  8242. * @param matrices matrices to be set.
  8243. */
  8244. setMatrices(uniformName: string, matrices: Float32Array): void;
  8245. /**
  8246. * Sets matrix on a uniform variable.
  8247. * @param uniformName Name of the variable.
  8248. * @param matrix matrix to be set.
  8249. */
  8250. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8251. /**
  8252. * 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)
  8253. * @param uniformName Name of the variable.
  8254. * @param matrix matrix to be set.
  8255. */
  8256. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8257. /**
  8258. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8259. * @param uniformName Name of the variable.
  8260. * @param matrix matrix to be set.
  8261. */
  8262. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8263. /**
  8264. * Sets a float on a uniform variable.
  8265. * @param uniformName Name of the variable.
  8266. * @param value value to be set.
  8267. * @returns this effect.
  8268. */
  8269. setFloat(uniformName: string, value: number): void;
  8270. /**
  8271. * Sets a Vector2 on a uniform variable.
  8272. * @param uniformName Name of the variable.
  8273. * @param vector2 vector2 to be set.
  8274. */
  8275. setVector2(uniformName: string, vector2: IVector2Like): void;
  8276. /**
  8277. * Sets a float2 on a uniform variable.
  8278. * @param uniformName Name of the variable.
  8279. * @param x First float in float2.
  8280. * @param y Second float in float2.
  8281. */
  8282. setFloat2(uniformName: string, x: number, y: number): void;
  8283. /**
  8284. * Sets a Vector3 on a uniform variable.
  8285. * @param uniformName Name of the variable.
  8286. * @param vector3 Value to be set.
  8287. */
  8288. setVector3(uniformName: string, vector3: IVector3Like): void;
  8289. /**
  8290. * Sets a float3 on a uniform variable.
  8291. * @param uniformName Name of the variable.
  8292. * @param x First float in float3.
  8293. * @param y Second float in float3.
  8294. * @param z Third float in float3.
  8295. */
  8296. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8297. /**
  8298. * Sets a Vector4 on a uniform variable.
  8299. * @param uniformName Name of the variable.
  8300. * @param vector4 Value to be set.
  8301. */
  8302. setVector4(uniformName: string, vector4: IVector4Like): void;
  8303. /**
  8304. * Sets a float4 on a uniform variable.
  8305. * @param uniformName Name of the variable.
  8306. * @param x First float in float4.
  8307. * @param y Second float in float4.
  8308. * @param z Third float in float4.
  8309. * @param w Fourth float in float4.
  8310. * @returns this effect.
  8311. */
  8312. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8313. /**
  8314. * Sets a Color3 on a uniform variable.
  8315. * @param uniformName Name of the variable.
  8316. * @param color3 Value to be set.
  8317. */
  8318. setColor3(uniformName: string, color3: IColor3Like): void;
  8319. /**
  8320. * Sets a Color4 on a uniform variable.
  8321. * @param uniformName Name of the variable.
  8322. * @param color3 Value to be set.
  8323. * @param alpha Alpha value to be set.
  8324. */
  8325. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8326. /**
  8327. * Sets a Color4 on a uniform variable
  8328. * @param uniformName defines the name of the variable
  8329. * @param color4 defines the value to be set
  8330. */
  8331. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8332. _getVertexShaderCode(): string | null;
  8333. _getFragmentShaderCode(): string | null;
  8334. }
  8335. }
  8336. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  8337. import { FloatArray, Nullable } from "babylonjs/types";
  8338. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8339. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8340. module "babylonjs/Engines/thinEngine" {
  8341. interface ThinEngine {
  8342. /**
  8343. * Create an uniform buffer
  8344. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8345. * @param elements defines the content of the uniform buffer
  8346. * @returns the webGL uniform buffer
  8347. */
  8348. createUniformBuffer(elements: FloatArray): DataBuffer;
  8349. /**
  8350. * Create a dynamic uniform buffer
  8351. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8352. * @param elements defines the content of the uniform buffer
  8353. * @returns the webGL uniform buffer
  8354. */
  8355. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8356. /**
  8357. * Update an existing uniform buffer
  8358. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8359. * @param uniformBuffer defines the target uniform buffer
  8360. * @param elements defines the content to update
  8361. * @param offset defines the offset in the uniform buffer where update should start
  8362. * @param count defines the size of the data to update
  8363. */
  8364. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8365. /**
  8366. * Bind an uniform buffer to the current webGL context
  8367. * @param buffer defines the buffer to bind
  8368. */
  8369. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8370. /**
  8371. * Bind a buffer to the current webGL context at a given location
  8372. * @param buffer defines the buffer to bind
  8373. * @param location defines the index where to bind the buffer
  8374. * @param name Name of the uniform variable to bind
  8375. */
  8376. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8377. /**
  8378. * Bind a specific block at a given index in a specific shader program
  8379. * @param pipelineContext defines the pipeline context to use
  8380. * @param blockName defines the block name
  8381. * @param index defines the index where to bind the block
  8382. */
  8383. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8384. }
  8385. }
  8386. }
  8387. declare module "babylonjs/Materials/uniformBuffer" {
  8388. import { Nullable, FloatArray } from "babylonjs/types";
  8389. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  8390. import { Engine } from "babylonjs/Engines/engine";
  8391. import { Effect } from "babylonjs/Materials/effect";
  8392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8393. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8394. import { Color3 } from "babylonjs/Maths/math.color";
  8395. import { IMatrixLike } from "babylonjs/Maths/math.like";
  8396. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  8397. /**
  8398. * Uniform buffer objects.
  8399. *
  8400. * Handles blocks of uniform on the GPU.
  8401. *
  8402. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8403. *
  8404. * For more information, please refer to :
  8405. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8406. */
  8407. export class UniformBuffer {
  8408. /** @hidden */
  8409. static _updatedUbosInFrame: {
  8410. [name: string]: number;
  8411. };
  8412. private _engine;
  8413. private _buffer;
  8414. private _buffers;
  8415. private _bufferIndex;
  8416. private _createBufferOnWrite;
  8417. private _data;
  8418. private _bufferData;
  8419. private _dynamic?;
  8420. private _uniformLocations;
  8421. private _uniformSizes;
  8422. private _uniformArraySizes;
  8423. private _uniformLocationPointer;
  8424. private _needSync;
  8425. private _noUBO;
  8426. private _currentEffect;
  8427. private _currentEffectName;
  8428. private _name;
  8429. private _currentFrameId;
  8430. /** @hidden */
  8431. _alreadyBound: boolean;
  8432. private static _MAX_UNIFORM_SIZE;
  8433. private static _tempBuffer;
  8434. private static _tempBufferInt32View;
  8435. /**
  8436. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8437. * This is dynamic to allow compat with webgl 1 and 2.
  8438. * You will need to pass the name of the uniform as well as the value.
  8439. */
  8440. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8441. /**
  8442. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8443. * This is dynamic to allow compat with webgl 1 and 2.
  8444. * You will need to pass the name of the uniform as well as the value.
  8445. */
  8446. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8447. /**
  8448. * Lambda to Update a single float in a uniform buffer.
  8449. * This is dynamic to allow compat with webgl 1 and 2.
  8450. * You will need to pass the name of the uniform as well as the value.
  8451. */
  8452. updateFloat: (name: string, x: number) => void;
  8453. /**
  8454. * Lambda to Update a vec2 of float in a uniform buffer.
  8455. * This is dynamic to allow compat with webgl 1 and 2.
  8456. * You will need to pass the name of the uniform as well as the value.
  8457. */
  8458. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8459. /**
  8460. * Lambda to Update a vec3 of float in a uniform buffer.
  8461. * This is dynamic to allow compat with webgl 1 and 2.
  8462. * You will need to pass the name of the uniform as well as the value.
  8463. */
  8464. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8465. /**
  8466. * Lambda to Update a vec4 of float in a uniform buffer.
  8467. * This is dynamic to allow compat with webgl 1 and 2.
  8468. * You will need to pass the name of the uniform as well as the value.
  8469. */
  8470. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8471. /**
  8472. * Lambda to Update an array of float in a uniform buffer.
  8473. * This is dynamic to allow compat with webgl 1 and 2.
  8474. * You will need to pass the name of the uniform as well as the value.
  8475. */
  8476. updateFloatArray: (name: string, array: Float32Array) => void;
  8477. /**
  8478. * Lambda to Update an array of number in a uniform buffer.
  8479. * This is dynamic to allow compat with webgl 1 and 2.
  8480. * You will need to pass the name of the uniform as well as the value.
  8481. */
  8482. updateArray: (name: string, array: number[]) => void;
  8483. /**
  8484. * Lambda to Update an array of number in a uniform buffer.
  8485. * This is dynamic to allow compat with webgl 1 and 2.
  8486. * You will need to pass the name of the uniform as well as the value.
  8487. */
  8488. updateIntArray: (name: string, array: Int32Array) => void;
  8489. /**
  8490. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8491. * This is dynamic to allow compat with webgl 1 and 2.
  8492. * You will need to pass the name of the uniform as well as the value.
  8493. */
  8494. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8495. /**
  8496. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8497. * This is dynamic to allow compat with webgl 1 and 2.
  8498. * You will need to pass the name of the uniform as well as the value.
  8499. */
  8500. updateMatrices: (name: string, mat: Float32Array) => void;
  8501. /**
  8502. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8503. * This is dynamic to allow compat with webgl 1 and 2.
  8504. * You will need to pass the name of the uniform as well as the value.
  8505. */
  8506. updateVector3: (name: string, vector: Vector3) => void;
  8507. /**
  8508. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8509. * This is dynamic to allow compat with webgl 1 and 2.
  8510. * You will need to pass the name of the uniform as well as the value.
  8511. */
  8512. updateVector4: (name: string, vector: Vector4) => void;
  8513. /**
  8514. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8515. * This is dynamic to allow compat with webgl 1 and 2.
  8516. * You will need to pass the name of the uniform as well as the value.
  8517. */
  8518. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8519. /**
  8520. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8521. * This is dynamic to allow compat with webgl 1 and 2.
  8522. * You will need to pass the name of the uniform as well as the value.
  8523. */
  8524. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8525. /**
  8526. * Lambda to Update a int a uniform buffer.
  8527. * This is dynamic to allow compat with webgl 1 and 2.
  8528. * You will need to pass the name of the uniform as well as the value.
  8529. */
  8530. updateInt: (name: string, x: number, suffix?: string) => void;
  8531. /**
  8532. * Lambda to Update a vec2 of int in a uniform buffer.
  8533. * This is dynamic to allow compat with webgl 1 and 2.
  8534. * You will need to pass the name of the uniform as well as the value.
  8535. */
  8536. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8537. /**
  8538. * Lambda to Update a vec3 of int in a uniform buffer.
  8539. * This is dynamic to allow compat with webgl 1 and 2.
  8540. * You will need to pass the name of the uniform as well as the value.
  8541. */
  8542. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8543. /**
  8544. * Lambda to Update a vec4 of int in a uniform buffer.
  8545. * This is dynamic to allow compat with webgl 1 and 2.
  8546. * You will need to pass the name of the uniform as well as the value.
  8547. */
  8548. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8549. /**
  8550. * Instantiates a new Uniform buffer objects.
  8551. *
  8552. * Handles blocks of uniform on the GPU.
  8553. *
  8554. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8555. *
  8556. * For more information, please refer to :
  8557. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8558. * @param engine Define the engine the buffer is associated with
  8559. * @param data Define the data contained in the buffer
  8560. * @param dynamic Define if the buffer is updatable
  8561. * @param name to assign to the buffer (debugging purpose)
  8562. */
  8563. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8564. /**
  8565. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8566. * or just falling back on setUniformXXX calls.
  8567. */
  8568. get useUbo(): boolean;
  8569. /**
  8570. * Indicates if the WebGL underlying uniform buffer is in sync
  8571. * with the javascript cache data.
  8572. */
  8573. get isSync(): boolean;
  8574. /**
  8575. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8576. * Also, a dynamic UniformBuffer will disable cache verification and always
  8577. * update the underlying WebGL uniform buffer to the GPU.
  8578. * @returns if Dynamic, otherwise false
  8579. */
  8580. isDynamic(): boolean;
  8581. /**
  8582. * The data cache on JS side.
  8583. * @returns the underlying data as a float array
  8584. */
  8585. getData(): Float32Array;
  8586. /**
  8587. * The underlying WebGL Uniform buffer.
  8588. * @returns the webgl buffer
  8589. */
  8590. getBuffer(): Nullable<DataBuffer>;
  8591. /**
  8592. * std140 layout specifies how to align data within an UBO structure.
  8593. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8594. * for specs.
  8595. */
  8596. private _fillAlignment;
  8597. /**
  8598. * Adds an uniform in the buffer.
  8599. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8600. * for the layout to be correct !
  8601. * @param name Name of the uniform, as used in the uniform block in the shader.
  8602. * @param size Data size, or data directly.
  8603. * @param arraySize The number of elements in the array, 0 if not an array.
  8604. */
  8605. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8606. /**
  8607. * Adds a Matrix 4x4 to the uniform buffer.
  8608. * @param name Name of the uniform, as used in the uniform block in the shader.
  8609. * @param mat A 4x4 matrix.
  8610. */
  8611. addMatrix(name: string, mat: Matrix): void;
  8612. /**
  8613. * Adds a vec2 to the uniform buffer.
  8614. * @param name Name of the uniform, as used in the uniform block in the shader.
  8615. * @param x Define the x component value of the vec2
  8616. * @param y Define the y component value of the vec2
  8617. */
  8618. addFloat2(name: string, x: number, y: number): void;
  8619. /**
  8620. * Adds a vec3 to the uniform buffer.
  8621. * @param name Name of the uniform, as used in the uniform block in the shader.
  8622. * @param x Define the x component value of the vec3
  8623. * @param y Define the y component value of the vec3
  8624. * @param z Define the z component value of the vec3
  8625. */
  8626. addFloat3(name: string, x: number, y: number, z: number): void;
  8627. /**
  8628. * Adds a vec3 to the uniform buffer.
  8629. * @param name Name of the uniform, as used in the uniform block in the shader.
  8630. * @param color Define the vec3 from a Color
  8631. */
  8632. addColor3(name: string, color: Color3): void;
  8633. /**
  8634. * Adds a vec4 to the uniform buffer.
  8635. * @param name Name of the uniform, as used in the uniform block in the shader.
  8636. * @param color Define the rgb components from a Color
  8637. * @param alpha Define the a component of the vec4
  8638. */
  8639. addColor4(name: string, color: Color3, alpha: number): void;
  8640. /**
  8641. * Adds a vec3 to the uniform buffer.
  8642. * @param name Name of the uniform, as used in the uniform block in the shader.
  8643. * @param vector Define the vec3 components from a Vector
  8644. */
  8645. addVector3(name: string, vector: Vector3): void;
  8646. /**
  8647. * Adds a Matrix 3x3 to the uniform buffer.
  8648. * @param name Name of the uniform, as used in the uniform block in the shader.
  8649. */
  8650. addMatrix3x3(name: string): void;
  8651. /**
  8652. * Adds a Matrix 2x2 to the uniform buffer.
  8653. * @param name Name of the uniform, as used in the uniform block in the shader.
  8654. */
  8655. addMatrix2x2(name: string): void;
  8656. /**
  8657. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8658. */
  8659. create(): void;
  8660. /** @hidden */
  8661. _rebuild(): void;
  8662. /** @hidden */
  8663. get _numBuffers(): number;
  8664. /** @hidden */
  8665. get _indexBuffer(): number;
  8666. /** Gets the name of this buffer */
  8667. get name(): string;
  8668. /**
  8669. * Updates the WebGL Uniform Buffer on the GPU.
  8670. * If the `dynamic` flag is set to true, no cache comparison is done.
  8671. * Otherwise, the buffer will be updated only if the cache differs.
  8672. */
  8673. update(): void;
  8674. private _createNewBuffer;
  8675. private _checkNewFrame;
  8676. /**
  8677. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8678. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8679. * @param data Define the flattened data
  8680. * @param size Define the size of the data.
  8681. */
  8682. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8683. /**
  8684. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8685. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8686. * @param data Define the flattened data
  8687. * @param size Define the size of the data.
  8688. */
  8689. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8690. private _valueCache;
  8691. private _cacheMatrix;
  8692. private _updateMatrix3x3ForUniform;
  8693. private _updateMatrix3x3ForEffect;
  8694. private _updateMatrix2x2ForEffect;
  8695. private _updateMatrix2x2ForUniform;
  8696. private _updateFloatForEffect;
  8697. private _updateFloatForUniform;
  8698. private _updateFloat2ForEffect;
  8699. private _updateFloat2ForUniform;
  8700. private _updateFloat3ForEffect;
  8701. private _updateFloat3ForUniform;
  8702. private _updateFloat4ForEffect;
  8703. private _updateFloat4ForUniform;
  8704. private _updateFloatArrayForEffect;
  8705. private _updateFloatArrayForUniform;
  8706. private _updateArrayForEffect;
  8707. private _updateArrayForUniform;
  8708. private _updateIntArrayForEffect;
  8709. private _updateIntArrayForUniform;
  8710. private _updateMatrixForEffect;
  8711. private _updateMatrixForUniform;
  8712. private _updateMatricesForEffect;
  8713. private _updateMatricesForUniform;
  8714. private _updateVector3ForEffect;
  8715. private _updateVector3ForUniform;
  8716. private _updateVector4ForEffect;
  8717. private _updateVector4ForUniform;
  8718. private _updateColor3ForEffect;
  8719. private _updateColor3ForUniform;
  8720. private _updateColor4ForEffect;
  8721. private _updateColor4ForUniform;
  8722. private _updateIntForEffect;
  8723. private _updateIntForUniform;
  8724. private _updateInt2ForEffect;
  8725. private _updateInt2ForUniform;
  8726. private _updateInt3ForEffect;
  8727. private _updateInt3ForUniform;
  8728. private _updateInt4ForEffect;
  8729. private _updateInt4ForUniform;
  8730. /**
  8731. * Sets a sampler uniform on the effect.
  8732. * @param name Define the name of the sampler.
  8733. * @param texture Define the texture to set in the sampler
  8734. */
  8735. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8736. /**
  8737. * Directly updates the value of the uniform in the cache AND on the GPU.
  8738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8739. * @param data Define the flattened data
  8740. */
  8741. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8742. /**
  8743. * Binds this uniform buffer to an effect.
  8744. * @param effect Define the effect to bind the buffer to
  8745. * @param name Name of the uniform block in the shader.
  8746. */
  8747. bindToEffect(effect: Effect, name: string): void;
  8748. /**
  8749. * Disposes the uniform buffer.
  8750. */
  8751. dispose(): void;
  8752. }
  8753. }
  8754. declare module "babylonjs/Materials/materialDefines" {
  8755. /**
  8756. * Manages the defines for the Material
  8757. */
  8758. export class MaterialDefines {
  8759. /** @hidden */
  8760. protected _keys: string[];
  8761. private _isDirty;
  8762. /** @hidden */
  8763. _renderId: number;
  8764. /** @hidden */
  8765. _areLightsDirty: boolean;
  8766. /** @hidden */
  8767. _areLightsDisposed: boolean;
  8768. /** @hidden */
  8769. _areAttributesDirty: boolean;
  8770. /** @hidden */
  8771. _areTexturesDirty: boolean;
  8772. /** @hidden */
  8773. _areFresnelDirty: boolean;
  8774. /** @hidden */
  8775. _areMiscDirty: boolean;
  8776. /** @hidden */
  8777. _arePrePassDirty: boolean;
  8778. /** @hidden */
  8779. _areImageProcessingDirty: boolean;
  8780. /** @hidden */
  8781. _normals: boolean;
  8782. /** @hidden */
  8783. _uvs: boolean;
  8784. /** @hidden */
  8785. _needNormals: boolean;
  8786. /** @hidden */
  8787. _needUVs: boolean;
  8788. [id: string]: any;
  8789. /**
  8790. * Specifies if the material needs to be re-calculated
  8791. */
  8792. get isDirty(): boolean;
  8793. /**
  8794. * Marks the material to indicate that it has been re-calculated
  8795. */
  8796. markAsProcessed(): void;
  8797. /**
  8798. * Marks the material to indicate that it needs to be re-calculated
  8799. */
  8800. markAsUnprocessed(): void;
  8801. /**
  8802. * Marks the material to indicate all of its defines need to be re-calculated
  8803. */
  8804. markAllAsDirty(): void;
  8805. /**
  8806. * Marks the material to indicate that image processing needs to be re-calculated
  8807. */
  8808. markAsImageProcessingDirty(): void;
  8809. /**
  8810. * Marks the material to indicate the lights need to be re-calculated
  8811. * @param disposed Defines whether the light is dirty due to dispose or not
  8812. */
  8813. markAsLightDirty(disposed?: boolean): void;
  8814. /**
  8815. * Marks the attribute state as changed
  8816. */
  8817. markAsAttributesDirty(): void;
  8818. /**
  8819. * Marks the texture state as changed
  8820. */
  8821. markAsTexturesDirty(): void;
  8822. /**
  8823. * Marks the fresnel state as changed
  8824. */
  8825. markAsFresnelDirty(): void;
  8826. /**
  8827. * Marks the misc state as changed
  8828. */
  8829. markAsMiscDirty(): void;
  8830. /**
  8831. * Marks the prepass state as changed
  8832. */
  8833. markAsPrePassDirty(): void;
  8834. /**
  8835. * Rebuilds the material defines
  8836. */
  8837. rebuild(): void;
  8838. /**
  8839. * Specifies if two material defines are equal
  8840. * @param other - A material define instance to compare to
  8841. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8842. */
  8843. isEqual(other: MaterialDefines): boolean;
  8844. /**
  8845. * Clones this instance's defines to another instance
  8846. * @param other - material defines to clone values to
  8847. */
  8848. cloneTo(other: MaterialDefines): void;
  8849. /**
  8850. * Resets the material define values
  8851. */
  8852. reset(): void;
  8853. /**
  8854. * Converts the material define values to a string
  8855. * @returns - String of material define information
  8856. */
  8857. toString(): string;
  8858. }
  8859. }
  8860. declare module "babylonjs/Misc/iInspectable" {
  8861. /**
  8862. * Enum that determines the text-wrapping mode to use.
  8863. */
  8864. export enum InspectableType {
  8865. /**
  8866. * Checkbox for booleans
  8867. */
  8868. Checkbox = 0,
  8869. /**
  8870. * Sliders for numbers
  8871. */
  8872. Slider = 1,
  8873. /**
  8874. * Vector3
  8875. */
  8876. Vector3 = 2,
  8877. /**
  8878. * Quaternions
  8879. */
  8880. Quaternion = 3,
  8881. /**
  8882. * Color3
  8883. */
  8884. Color3 = 4,
  8885. /**
  8886. * String
  8887. */
  8888. String = 5
  8889. }
  8890. /**
  8891. * Interface used to define custom inspectable properties.
  8892. * This interface is used by the inspector to display custom property grids
  8893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8894. */
  8895. export interface IInspectable {
  8896. /**
  8897. * Gets the label to display
  8898. */
  8899. label: string;
  8900. /**
  8901. * Gets the name of the property to edit
  8902. */
  8903. propertyName: string;
  8904. /**
  8905. * Gets the type of the editor to use
  8906. */
  8907. type: InspectableType;
  8908. /**
  8909. * Gets the minimum value of the property when using in "slider" mode
  8910. */
  8911. min?: number;
  8912. /**
  8913. * Gets the maximum value of the property when using in "slider" mode
  8914. */
  8915. max?: number;
  8916. /**
  8917. * Gets the setp to use when using in "slider" mode
  8918. */
  8919. step?: number;
  8920. }
  8921. }
  8922. declare module "babylonjs/Lights/light" {
  8923. import { Nullable } from "babylonjs/types";
  8924. import { Scene } from "babylonjs/scene";
  8925. import { Vector3 } from "babylonjs/Maths/math.vector";
  8926. import { Color3 } from "babylonjs/Maths/math.color";
  8927. import { Node } from "babylonjs/node";
  8928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8929. import { Effect } from "babylonjs/Materials/effect";
  8930. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8931. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8932. /**
  8933. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8934. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8935. * 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.
  8936. */
  8937. export abstract class Light extends Node {
  8938. /**
  8939. * Falloff Default: light is falling off following the material specification:
  8940. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8941. */
  8942. static readonly FALLOFF_DEFAULT: number;
  8943. /**
  8944. * Falloff Physical: light is falling off following the inverse squared distance law.
  8945. */
  8946. static readonly FALLOFF_PHYSICAL: number;
  8947. /**
  8948. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8949. * to enhance interoperability with other engines.
  8950. */
  8951. static readonly FALLOFF_GLTF: number;
  8952. /**
  8953. * Falloff Standard: light is falling off like in the standard material
  8954. * to enhance interoperability with other materials.
  8955. */
  8956. static readonly FALLOFF_STANDARD: number;
  8957. /**
  8958. * If every light affecting the material is in this lightmapMode,
  8959. * material.lightmapTexture adds or multiplies
  8960. * (depends on material.useLightmapAsShadowmap)
  8961. * after every other light calculations.
  8962. */
  8963. static readonly LIGHTMAP_DEFAULT: number;
  8964. /**
  8965. * material.lightmapTexture as only diffuse lighting from this light
  8966. * adds only specular lighting from this light
  8967. * adds dynamic shadows
  8968. */
  8969. static readonly LIGHTMAP_SPECULAR: number;
  8970. /**
  8971. * material.lightmapTexture as only lighting
  8972. * no light calculation from this light
  8973. * only adds dynamic shadows from this light
  8974. */
  8975. static readonly LIGHTMAP_SHADOWSONLY: number;
  8976. /**
  8977. * Each light type uses the default quantity according to its type:
  8978. * point/spot lights use luminous intensity
  8979. * directional lights use illuminance
  8980. */
  8981. static readonly INTENSITYMODE_AUTOMATIC: number;
  8982. /**
  8983. * lumen (lm)
  8984. */
  8985. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8986. /**
  8987. * candela (lm/sr)
  8988. */
  8989. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8990. /**
  8991. * lux (lm/m^2)
  8992. */
  8993. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8994. /**
  8995. * nit (cd/m^2)
  8996. */
  8997. static readonly INTENSITYMODE_LUMINANCE: number;
  8998. /**
  8999. * Light type const id of the point light.
  9000. */
  9001. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9002. /**
  9003. * Light type const id of the directional light.
  9004. */
  9005. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9006. /**
  9007. * Light type const id of the spot light.
  9008. */
  9009. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9010. /**
  9011. * Light type const id of the hemispheric light.
  9012. */
  9013. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9014. /**
  9015. * Diffuse gives the basic color to an object.
  9016. */
  9017. diffuse: Color3;
  9018. /**
  9019. * Specular produces a highlight color on an object.
  9020. * Note: This is note affecting PBR materials.
  9021. */
  9022. specular: Color3;
  9023. /**
  9024. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9025. * falling off base on range or angle.
  9026. * This can be set to any values in Light.FALLOFF_x.
  9027. *
  9028. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9029. * other types of materials.
  9030. */
  9031. falloffType: number;
  9032. /**
  9033. * Strength of the light.
  9034. * Note: By default it is define in the framework own unit.
  9035. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9036. */
  9037. intensity: number;
  9038. private _range;
  9039. protected _inverseSquaredRange: number;
  9040. /**
  9041. * Defines how far from the source the light is impacting in scene units.
  9042. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9043. */
  9044. get range(): number;
  9045. /**
  9046. * Defines how far from the source the light is impacting in scene units.
  9047. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9048. */
  9049. set range(value: number);
  9050. /**
  9051. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9052. * of light.
  9053. */
  9054. private _photometricScale;
  9055. private _intensityMode;
  9056. /**
  9057. * Gets the photometric scale used to interpret the intensity.
  9058. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9059. */
  9060. get intensityMode(): number;
  9061. /**
  9062. * Sets the photometric scale used to interpret the intensity.
  9063. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9064. */
  9065. set intensityMode(value: number);
  9066. private _radius;
  9067. /**
  9068. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9069. */
  9070. get radius(): number;
  9071. /**
  9072. * sets the light radius used by PBR Materials to simulate soft area lights.
  9073. */
  9074. set radius(value: number);
  9075. private _renderPriority;
  9076. /**
  9077. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9078. * exceeding the number allowed of the materials.
  9079. */
  9080. renderPriority: number;
  9081. private _shadowEnabled;
  9082. /**
  9083. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9084. * the current shadow generator.
  9085. */
  9086. get shadowEnabled(): boolean;
  9087. /**
  9088. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9089. * the current shadow generator.
  9090. */
  9091. set shadowEnabled(value: boolean);
  9092. private _includedOnlyMeshes;
  9093. /**
  9094. * Gets the only meshes impacted by this light.
  9095. */
  9096. get includedOnlyMeshes(): AbstractMesh[];
  9097. /**
  9098. * Sets the only meshes impacted by this light.
  9099. */
  9100. set includedOnlyMeshes(value: AbstractMesh[]);
  9101. private _excludedMeshes;
  9102. /**
  9103. * Gets the meshes not impacted by this light.
  9104. */
  9105. get excludedMeshes(): AbstractMesh[];
  9106. /**
  9107. * Sets the meshes not impacted by this light.
  9108. */
  9109. set excludedMeshes(value: AbstractMesh[]);
  9110. private _excludeWithLayerMask;
  9111. /**
  9112. * Gets the layer id use to find what meshes are not impacted by the light.
  9113. * Inactive if 0
  9114. */
  9115. get excludeWithLayerMask(): number;
  9116. /**
  9117. * Sets the layer id use to find what meshes are not impacted by the light.
  9118. * Inactive if 0
  9119. */
  9120. set excludeWithLayerMask(value: number);
  9121. private _includeOnlyWithLayerMask;
  9122. /**
  9123. * Gets the layer id use to find what meshes are impacted by the light.
  9124. * Inactive if 0
  9125. */
  9126. get includeOnlyWithLayerMask(): number;
  9127. /**
  9128. * Sets the layer id use to find what meshes are impacted by the light.
  9129. * Inactive if 0
  9130. */
  9131. set includeOnlyWithLayerMask(value: number);
  9132. private _lightmapMode;
  9133. /**
  9134. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9135. */
  9136. get lightmapMode(): number;
  9137. /**
  9138. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9139. */
  9140. set lightmapMode(value: number);
  9141. /**
  9142. * Shadow generator associted to the light.
  9143. * @hidden Internal use only.
  9144. */
  9145. _shadowGenerator: Nullable<IShadowGenerator>;
  9146. /**
  9147. * @hidden Internal use only.
  9148. */
  9149. _excludedMeshesIds: string[];
  9150. /**
  9151. * @hidden Internal use only.
  9152. */
  9153. _includedOnlyMeshesIds: string[];
  9154. /**
  9155. * The current light unifom buffer.
  9156. * @hidden Internal use only.
  9157. */
  9158. _uniformBuffer: UniformBuffer;
  9159. /** @hidden */
  9160. _renderId: number;
  9161. /**
  9162. * Creates a Light object in the scene.
  9163. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9164. * @param name The firendly name of the light
  9165. * @param scene The scene the light belongs too
  9166. */
  9167. constructor(name: string, scene: Scene);
  9168. protected abstract _buildUniformLayout(): void;
  9169. /**
  9170. * Sets the passed Effect "effect" with the Light information.
  9171. * @param effect The effect to update
  9172. * @param lightIndex The index of the light in the effect to update
  9173. * @returns The light
  9174. */
  9175. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9176. /**
  9177. * Sets the passed Effect "effect" with the Light textures.
  9178. * @param effect The effect to update
  9179. * @param lightIndex The index of the light in the effect to update
  9180. * @returns The light
  9181. */
  9182. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9183. /**
  9184. * Binds the lights information from the scene to the effect for the given mesh.
  9185. * @param lightIndex Light index
  9186. * @param scene The scene where the light belongs to
  9187. * @param effect The effect we are binding the data to
  9188. * @param useSpecular Defines if specular is supported
  9189. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9190. */
  9191. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9192. /**
  9193. * Sets the passed Effect "effect" with the Light information.
  9194. * @param effect The effect to update
  9195. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9196. * @returns The light
  9197. */
  9198. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9199. /**
  9200. * Returns the string "Light".
  9201. * @returns the class name
  9202. */
  9203. getClassName(): string;
  9204. /** @hidden */
  9205. readonly _isLight: boolean;
  9206. /**
  9207. * Converts the light information to a readable string for debug purpose.
  9208. * @param fullDetails Supports for multiple levels of logging within scene loading
  9209. * @returns the human readable light info
  9210. */
  9211. toString(fullDetails?: boolean): string;
  9212. /** @hidden */
  9213. protected _syncParentEnabledState(): void;
  9214. /**
  9215. * Set the enabled state of this node.
  9216. * @param value - the new enabled state
  9217. */
  9218. setEnabled(value: boolean): void;
  9219. /**
  9220. * Returns the Light associated shadow generator if any.
  9221. * @return the associated shadow generator.
  9222. */
  9223. getShadowGenerator(): Nullable<IShadowGenerator>;
  9224. /**
  9225. * Returns a Vector3, the absolute light position in the World.
  9226. * @returns the world space position of the light
  9227. */
  9228. getAbsolutePosition(): Vector3;
  9229. /**
  9230. * Specifies if the light will affect the passed mesh.
  9231. * @param mesh The mesh to test against the light
  9232. * @return true the mesh is affected otherwise, false.
  9233. */
  9234. canAffectMesh(mesh: AbstractMesh): boolean;
  9235. /**
  9236. * Sort function to order lights for rendering.
  9237. * @param a First Light object to compare to second.
  9238. * @param b Second Light object to compare first.
  9239. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9240. */
  9241. static CompareLightsPriority(a: Light, b: Light): number;
  9242. /**
  9243. * Releases resources associated with this node.
  9244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9246. */
  9247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9248. /**
  9249. * Returns the light type ID (integer).
  9250. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9251. */
  9252. getTypeID(): number;
  9253. /**
  9254. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9255. * @returns the scaled intensity in intensity mode unit
  9256. */
  9257. getScaledIntensity(): number;
  9258. /**
  9259. * Returns a new Light object, named "name", from the current one.
  9260. * @param name The name of the cloned light
  9261. * @param newParent The parent of this light, if it has one
  9262. * @returns the new created light
  9263. */
  9264. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9265. /**
  9266. * Serializes the current light into a Serialization object.
  9267. * @returns the serialized object.
  9268. */
  9269. serialize(): any;
  9270. /**
  9271. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9272. * This new light is named "name" and added to the passed scene.
  9273. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9274. * @param name The friendly name of the light
  9275. * @param scene The scene the new light will belong to
  9276. * @returns the constructor function
  9277. */
  9278. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9279. /**
  9280. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9281. * @param parsedLight The JSON representation of the light
  9282. * @param scene The scene to create the parsed light in
  9283. * @returns the created light after parsing
  9284. */
  9285. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9286. private _hookArrayForExcluded;
  9287. private _hookArrayForIncludedOnly;
  9288. private _resyncMeshes;
  9289. /**
  9290. * Forces the meshes to update their light related information in their rendering used effects
  9291. * @hidden Internal Use Only
  9292. */
  9293. _markMeshesAsLightDirty(): void;
  9294. /**
  9295. * Recomputes the cached photometric scale if needed.
  9296. */
  9297. private _computePhotometricScale;
  9298. /**
  9299. * Returns the Photometric Scale according to the light type and intensity mode.
  9300. */
  9301. private _getPhotometricScale;
  9302. /**
  9303. * Reorder the light in the scene according to their defined priority.
  9304. * @hidden Internal Use Only
  9305. */
  9306. _reorderLightsInScene(): void;
  9307. /**
  9308. * Prepares the list of defines specific to the light type.
  9309. * @param defines the list of defines
  9310. * @param lightIndex defines the index of the light for the effect
  9311. */
  9312. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9313. }
  9314. }
  9315. declare module "babylonjs/Maths/math.axis" {
  9316. import { Vector3 } from "babylonjs/Maths/math.vector";
  9317. /** Defines supported spaces */
  9318. export enum Space {
  9319. /** Local (object) space */
  9320. LOCAL = 0,
  9321. /** World space */
  9322. WORLD = 1,
  9323. /** Bone space */
  9324. BONE = 2
  9325. }
  9326. /** Defines the 3 main axes */
  9327. export class Axis {
  9328. /** X axis */
  9329. static X: Vector3;
  9330. /** Y axis */
  9331. static Y: Vector3;
  9332. /** Z axis */
  9333. static Z: Vector3;
  9334. }
  9335. /**
  9336. * Defines cartesian components.
  9337. */
  9338. export enum Coordinate {
  9339. /** X axis */
  9340. X = 0,
  9341. /** Y axis */
  9342. Y = 1,
  9343. /** Z axis */
  9344. Z = 2
  9345. }
  9346. }
  9347. declare module "babylonjs/Lights/shadowLight" {
  9348. import { Camera } from "babylonjs/Cameras/camera";
  9349. import { Scene } from "babylonjs/scene";
  9350. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9352. import { Light } from "babylonjs/Lights/light";
  9353. /**
  9354. * Interface describing all the common properties and methods a shadow light needs to implement.
  9355. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9356. * as well as binding the different shadow properties to the effects.
  9357. */
  9358. export interface IShadowLight extends Light {
  9359. /**
  9360. * The light id in the scene (used in scene.findLighById for instance)
  9361. */
  9362. id: string;
  9363. /**
  9364. * The position the shdow will be casted from.
  9365. */
  9366. position: Vector3;
  9367. /**
  9368. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9369. */
  9370. direction: Vector3;
  9371. /**
  9372. * The transformed position. Position of the light in world space taking parenting in account.
  9373. */
  9374. transformedPosition: Vector3;
  9375. /**
  9376. * The transformed direction. Direction of the light in world space taking parenting in account.
  9377. */
  9378. transformedDirection: Vector3;
  9379. /**
  9380. * The friendly name of the light in the scene.
  9381. */
  9382. name: string;
  9383. /**
  9384. * Defines the shadow projection clipping minimum z value.
  9385. */
  9386. shadowMinZ: number;
  9387. /**
  9388. * Defines the shadow projection clipping maximum z value.
  9389. */
  9390. shadowMaxZ: number;
  9391. /**
  9392. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9393. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9394. */
  9395. computeTransformedInformation(): boolean;
  9396. /**
  9397. * Gets the scene the light belongs to.
  9398. * @returns The scene
  9399. */
  9400. getScene(): Scene;
  9401. /**
  9402. * Callback defining a custom Projection Matrix Builder.
  9403. * This can be used to override the default projection matrix computation.
  9404. */
  9405. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9406. /**
  9407. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9408. * @param matrix The materix to updated with the projection information
  9409. * @param viewMatrix The transform matrix of the light
  9410. * @param renderList The list of mesh to render in the map
  9411. * @returns The current light
  9412. */
  9413. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9414. /**
  9415. * Gets the current depth scale used in ESM.
  9416. * @returns The scale
  9417. */
  9418. getDepthScale(): number;
  9419. /**
  9420. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9421. * @returns true if a cube texture needs to be use
  9422. */
  9423. needCube(): boolean;
  9424. /**
  9425. * Detects if the projection matrix requires to be recomputed this frame.
  9426. * @returns true if it requires to be recomputed otherwise, false.
  9427. */
  9428. needProjectionMatrixCompute(): boolean;
  9429. /**
  9430. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9431. */
  9432. forceProjectionMatrixCompute(): void;
  9433. /**
  9434. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9435. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9436. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9437. */
  9438. getShadowDirection(faceIndex?: number): Vector3;
  9439. /**
  9440. * Gets the minZ used for shadow according to both the scene and the light.
  9441. * @param activeCamera The camera we are returning the min for
  9442. * @returns the depth min z
  9443. */
  9444. getDepthMinZ(activeCamera: Camera): number;
  9445. /**
  9446. * Gets the maxZ used for shadow according to both the scene and the light.
  9447. * @param activeCamera The camera we are returning the max for
  9448. * @returns the depth max z
  9449. */
  9450. getDepthMaxZ(activeCamera: Camera): number;
  9451. }
  9452. /**
  9453. * Base implementation IShadowLight
  9454. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9455. */
  9456. export abstract class ShadowLight extends Light implements IShadowLight {
  9457. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9458. protected _position: Vector3;
  9459. protected _setPosition(value: Vector3): void;
  9460. /**
  9461. * Sets the position the shadow will be casted from. Also use as the light position for both
  9462. * point and spot lights.
  9463. */
  9464. get position(): Vector3;
  9465. /**
  9466. * Sets the position the shadow will be casted from. Also use as the light position for both
  9467. * point and spot lights.
  9468. */
  9469. set position(value: Vector3);
  9470. protected _direction: Vector3;
  9471. protected _setDirection(value: Vector3): void;
  9472. /**
  9473. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9474. * Also use as the light direction on spot and directional lights.
  9475. */
  9476. get direction(): Vector3;
  9477. /**
  9478. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9479. * Also use as the light direction on spot and directional lights.
  9480. */
  9481. set direction(value: Vector3);
  9482. protected _shadowMinZ: number;
  9483. /**
  9484. * Gets the shadow projection clipping minimum z value.
  9485. */
  9486. get shadowMinZ(): number;
  9487. /**
  9488. * Sets the shadow projection clipping minimum z value.
  9489. */
  9490. set shadowMinZ(value: number);
  9491. protected _shadowMaxZ: number;
  9492. /**
  9493. * Sets the shadow projection clipping maximum z value.
  9494. */
  9495. get shadowMaxZ(): number;
  9496. /**
  9497. * Gets the shadow projection clipping maximum z value.
  9498. */
  9499. set shadowMaxZ(value: number);
  9500. /**
  9501. * Callback defining a custom Projection Matrix Builder.
  9502. * This can be used to override the default projection matrix computation.
  9503. */
  9504. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9505. /**
  9506. * The transformed position. Position of the light in world space taking parenting in account.
  9507. */
  9508. transformedPosition: Vector3;
  9509. /**
  9510. * The transformed direction. Direction of the light in world space taking parenting in account.
  9511. */
  9512. transformedDirection: Vector3;
  9513. private _needProjectionMatrixCompute;
  9514. /**
  9515. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9516. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9517. */
  9518. computeTransformedInformation(): boolean;
  9519. /**
  9520. * Return the depth scale used for the shadow map.
  9521. * @returns the depth scale.
  9522. */
  9523. getDepthScale(): number;
  9524. /**
  9525. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9526. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9527. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9528. */
  9529. getShadowDirection(faceIndex?: number): Vector3;
  9530. /**
  9531. * Returns the ShadowLight absolute position in the World.
  9532. * @returns the position vector in world space
  9533. */
  9534. getAbsolutePosition(): Vector3;
  9535. /**
  9536. * Sets the ShadowLight direction toward the passed target.
  9537. * @param target The point to target in local space
  9538. * @returns the updated ShadowLight direction
  9539. */
  9540. setDirectionToTarget(target: Vector3): Vector3;
  9541. /**
  9542. * Returns the light rotation in euler definition.
  9543. * @returns the x y z rotation in local space.
  9544. */
  9545. getRotation(): Vector3;
  9546. /**
  9547. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9548. * @returns true if a cube texture needs to be use
  9549. */
  9550. needCube(): boolean;
  9551. /**
  9552. * Detects if the projection matrix requires to be recomputed this frame.
  9553. * @returns true if it requires to be recomputed otherwise, false.
  9554. */
  9555. needProjectionMatrixCompute(): boolean;
  9556. /**
  9557. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9558. */
  9559. forceProjectionMatrixCompute(): void;
  9560. /** @hidden */
  9561. _initCache(): void;
  9562. /** @hidden */
  9563. _isSynchronized(): boolean;
  9564. /**
  9565. * Computes the world matrix of the node
  9566. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9567. * @returns the world matrix
  9568. */
  9569. computeWorldMatrix(force?: boolean): Matrix;
  9570. /**
  9571. * Gets the minZ used for shadow according to both the scene and the light.
  9572. * @param activeCamera The camera we are returning the min for
  9573. * @returns the depth min z
  9574. */
  9575. getDepthMinZ(activeCamera: Camera): number;
  9576. /**
  9577. * Gets the maxZ used for shadow according to both the scene and the light.
  9578. * @param activeCamera The camera we are returning the max for
  9579. * @returns the depth max z
  9580. */
  9581. getDepthMaxZ(activeCamera: Camera): number;
  9582. /**
  9583. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9584. * @param matrix The materix to updated with the projection information
  9585. * @param viewMatrix The transform matrix of the light
  9586. * @param renderList The list of mesh to render in the map
  9587. * @returns The current light
  9588. */
  9589. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9590. }
  9591. }
  9592. declare module "babylonjs/Materials/prePassConfiguration" {
  9593. import { Matrix } from "babylonjs/Maths/math.vector";
  9594. import { Mesh } from "babylonjs/Meshes/mesh";
  9595. import { Scene } from "babylonjs/scene";
  9596. import { Effect } from "babylonjs/Materials/effect";
  9597. /**
  9598. * Configuration needed for prepass-capable materials
  9599. */
  9600. export class PrePassConfiguration {
  9601. /**
  9602. * Previous world matrices of meshes carrying this material
  9603. * Used for computing velocity
  9604. */
  9605. previousWorldMatrices: {
  9606. [index: number]: Matrix;
  9607. };
  9608. /**
  9609. * Previous view project matrix
  9610. * Used for computing velocity
  9611. */
  9612. previousViewProjection: Matrix;
  9613. /**
  9614. * Previous bones of meshes carrying this material
  9615. * Used for computing velocity
  9616. */
  9617. previousBones: {
  9618. [index: number]: Float32Array;
  9619. };
  9620. /**
  9621. * Add the required uniforms to the current list.
  9622. * @param uniforms defines the current uniform list.
  9623. */
  9624. static AddUniforms(uniforms: string[]): void;
  9625. /**
  9626. * Add the required samplers to the current list.
  9627. * @param samplers defines the current sampler list.
  9628. */
  9629. static AddSamplers(samplers: string[]): void;
  9630. /**
  9631. * Binds the material data.
  9632. * @param effect defines the effect to update
  9633. * @param scene defines the scene the material belongs to.
  9634. * @param mesh The mesh
  9635. * @param world World matrix of this mesh
  9636. * @param isFrozen Is the material frozen
  9637. */
  9638. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9639. }
  9640. }
  9641. declare module "babylonjs/Cameras/targetCamera" {
  9642. import { Nullable } from "babylonjs/types";
  9643. import { Camera } from "babylonjs/Cameras/camera";
  9644. import { Scene } from "babylonjs/scene";
  9645. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9646. /**
  9647. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9648. * This is the base of the follow, arc rotate cameras and Free camera
  9649. * @see https://doc.babylonjs.com/features/cameras
  9650. */
  9651. export class TargetCamera extends Camera {
  9652. private static _RigCamTransformMatrix;
  9653. private static _TargetTransformMatrix;
  9654. private static _TargetFocalPoint;
  9655. private _tmpUpVector;
  9656. private _tmpTargetVector;
  9657. /**
  9658. * Define the current direction the camera is moving to
  9659. */
  9660. cameraDirection: Vector3;
  9661. /**
  9662. * Define the current rotation the camera is rotating to
  9663. */
  9664. cameraRotation: Vector2;
  9665. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9666. ignoreParentScaling: boolean;
  9667. /**
  9668. * When set, the up vector of the camera will be updated by the rotation of the camera
  9669. */
  9670. updateUpVectorFromRotation: boolean;
  9671. private _tmpQuaternion;
  9672. /**
  9673. * Define the current rotation of the camera
  9674. */
  9675. rotation: Vector3;
  9676. /**
  9677. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9678. */
  9679. rotationQuaternion: Quaternion;
  9680. /**
  9681. * Define the current speed of the camera
  9682. */
  9683. speed: number;
  9684. /**
  9685. * Add constraint to the camera to prevent it to move freely in all directions and
  9686. * around all axis.
  9687. */
  9688. noRotationConstraint: boolean;
  9689. /**
  9690. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9691. * panning
  9692. */
  9693. invertRotation: boolean;
  9694. /**
  9695. * Speed multiplier for inverse camera panning
  9696. */
  9697. inverseRotationSpeed: number;
  9698. /**
  9699. * Define the current target of the camera as an object or a position.
  9700. */
  9701. lockedTarget: any;
  9702. /** @hidden */
  9703. _currentTarget: Vector3;
  9704. /** @hidden */
  9705. _initialFocalDistance: number;
  9706. /** @hidden */
  9707. _viewMatrix: Matrix;
  9708. /** @hidden */
  9709. _camMatrix: Matrix;
  9710. /** @hidden */
  9711. _cameraTransformMatrix: Matrix;
  9712. /** @hidden */
  9713. _cameraRotationMatrix: Matrix;
  9714. /** @hidden */
  9715. _referencePoint: Vector3;
  9716. /** @hidden */
  9717. _transformedReferencePoint: Vector3;
  9718. /** @hidden */
  9719. _reset: () => void;
  9720. private _defaultUp;
  9721. /**
  9722. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9723. * This is the base of the follow, arc rotate cameras and Free camera
  9724. * @see https://doc.babylonjs.com/features/cameras
  9725. * @param name Defines the name of the camera in the scene
  9726. * @param position Defines the start position of the camera in the scene
  9727. * @param scene Defines the scene the camera belongs to
  9728. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9729. */
  9730. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9731. /**
  9732. * Gets the position in front of the camera at a given distance.
  9733. * @param distance The distance from the camera we want the position to be
  9734. * @returns the position
  9735. */
  9736. getFrontPosition(distance: number): Vector3;
  9737. /** @hidden */
  9738. _getLockedTargetPosition(): Nullable<Vector3>;
  9739. private _storedPosition;
  9740. private _storedRotation;
  9741. private _storedRotationQuaternion;
  9742. /**
  9743. * Store current camera state of the camera (fov, position, rotation, etc..)
  9744. * @returns the camera
  9745. */
  9746. storeState(): Camera;
  9747. /**
  9748. * Restored camera state. You must call storeState() first
  9749. * @returns whether it was successful or not
  9750. * @hidden
  9751. */
  9752. _restoreStateValues(): boolean;
  9753. /** @hidden */
  9754. _initCache(): void;
  9755. /** @hidden */
  9756. _updateCache(ignoreParentClass?: boolean): void;
  9757. /** @hidden */
  9758. _isSynchronizedViewMatrix(): boolean;
  9759. /** @hidden */
  9760. _computeLocalCameraSpeed(): number;
  9761. /**
  9762. * Defines the target the camera should look at.
  9763. * @param target Defines the new target as a Vector or a mesh
  9764. */
  9765. setTarget(target: Vector3): void;
  9766. /**
  9767. * Defines the target point of the camera.
  9768. * The camera looks towards it form the radius distance.
  9769. */
  9770. get target(): Vector3;
  9771. set target(value: Vector3);
  9772. /**
  9773. * Return the current target position of the camera. This value is expressed in local space.
  9774. * @returns the target position
  9775. */
  9776. getTarget(): Vector3;
  9777. /** @hidden */
  9778. _decideIfNeedsToMove(): boolean;
  9779. /** @hidden */
  9780. _updatePosition(): void;
  9781. /** @hidden */
  9782. _checkInputs(): void;
  9783. protected _updateCameraRotationMatrix(): void;
  9784. /**
  9785. * 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)
  9786. * @returns the current camera
  9787. */
  9788. private _rotateUpVectorWithCameraRotationMatrix;
  9789. private _cachedRotationZ;
  9790. private _cachedQuaternionRotationZ;
  9791. /** @hidden */
  9792. _getViewMatrix(): Matrix;
  9793. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9794. /**
  9795. * @hidden
  9796. */
  9797. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9798. /**
  9799. * @hidden
  9800. */
  9801. _updateRigCameras(): void;
  9802. private _getRigCamPositionAndTarget;
  9803. /**
  9804. * Gets the current object class name.
  9805. * @return the class name
  9806. */
  9807. getClassName(): string;
  9808. }
  9809. }
  9810. declare module "babylonjs/Cameras/cameraInputsManager" {
  9811. import { Nullable } from "babylonjs/types";
  9812. import { Camera } from "babylonjs/Cameras/camera";
  9813. /**
  9814. * @ignore
  9815. * This is a list of all the different input types that are available in the application.
  9816. * Fo instance: ArcRotateCameraGamepadInput...
  9817. */
  9818. export var CameraInputTypes: {};
  9819. /**
  9820. * This is the contract to implement in order to create a new input class.
  9821. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9822. */
  9823. export interface ICameraInput<TCamera extends Camera> {
  9824. /**
  9825. * Defines the camera the input is attached to.
  9826. */
  9827. camera: Nullable<TCamera>;
  9828. /**
  9829. * Gets the class name of the current intput.
  9830. * @returns the class name
  9831. */
  9832. getClassName(): string;
  9833. /**
  9834. * Get the friendly name associated with the input class.
  9835. * @returns the input friendly name
  9836. */
  9837. getSimpleName(): string;
  9838. /**
  9839. * Attach the input controls to a specific dom element to get the input from.
  9840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9841. */
  9842. attachControl(noPreventDefault?: boolean): void;
  9843. /**
  9844. * Detach the current controls from the specified dom element.
  9845. */
  9846. detachControl(): void;
  9847. /**
  9848. * Update the current camera state depending on the inputs that have been used this frame.
  9849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9850. */
  9851. checkInputs?: () => void;
  9852. }
  9853. /**
  9854. * Represents a map of input types to input instance or input index to input instance.
  9855. */
  9856. export interface CameraInputsMap<TCamera extends Camera> {
  9857. /**
  9858. * Accessor to the input by input type.
  9859. */
  9860. [name: string]: ICameraInput<TCamera>;
  9861. /**
  9862. * Accessor to the input by input index.
  9863. */
  9864. [idx: number]: ICameraInput<TCamera>;
  9865. }
  9866. /**
  9867. * This represents the input manager used within a camera.
  9868. * It helps dealing with all the different kind of input attached to a camera.
  9869. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9870. */
  9871. export class CameraInputsManager<TCamera extends Camera> {
  9872. /**
  9873. * Defines the list of inputs attahed to the camera.
  9874. */
  9875. attached: CameraInputsMap<TCamera>;
  9876. /**
  9877. * Defines the dom element the camera is collecting inputs from.
  9878. * This is null if the controls have not been attached.
  9879. */
  9880. attachedToElement: boolean;
  9881. /**
  9882. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9883. */
  9884. noPreventDefault: boolean;
  9885. /**
  9886. * Defined the camera the input manager belongs to.
  9887. */
  9888. camera: TCamera;
  9889. /**
  9890. * Update the current camera state depending on the inputs that have been used this frame.
  9891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9892. */
  9893. checkInputs: () => void;
  9894. /**
  9895. * Instantiate a new Camera Input Manager.
  9896. * @param camera Defines the camera the input manager blongs to
  9897. */
  9898. constructor(camera: TCamera);
  9899. /**
  9900. * Add an input method to a camera
  9901. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9902. * @param input camera input method
  9903. */
  9904. add(input: ICameraInput<TCamera>): void;
  9905. /**
  9906. * Remove a specific input method from a camera
  9907. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9908. * @param inputToRemove camera input method
  9909. */
  9910. remove(inputToRemove: ICameraInput<TCamera>): void;
  9911. /**
  9912. * Remove a specific input type from a camera
  9913. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9914. * @param inputType the type of the input to remove
  9915. */
  9916. removeByType(inputType: string): void;
  9917. private _addCheckInputs;
  9918. /**
  9919. * Attach the input controls to the currently attached dom element to listen the events from.
  9920. * @param input Defines the input to attach
  9921. */
  9922. attachInput(input: ICameraInput<TCamera>): void;
  9923. /**
  9924. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9925. * @param element Defines the dom element to collect the events from
  9926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9927. */
  9928. attachElement(noPreventDefault?: boolean): void;
  9929. /**
  9930. * Detach the current manager inputs controls from a specific dom element.
  9931. * @param element Defines the dom element to collect the events from
  9932. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9933. */
  9934. detachElement(disconnect?: boolean): void;
  9935. /**
  9936. * Rebuild the dynamic inputCheck function from the current list of
  9937. * defined inputs in the manager.
  9938. */
  9939. rebuildInputCheck(): void;
  9940. /**
  9941. * Remove all attached input methods from a camera
  9942. */
  9943. clear(): void;
  9944. /**
  9945. * Serialize the current input manager attached to a camera.
  9946. * This ensures than once parsed,
  9947. * the input associated to the camera will be identical to the current ones
  9948. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9949. */
  9950. serialize(serializedCamera: any): void;
  9951. /**
  9952. * Parses an input manager serialized JSON to restore the previous list of inputs
  9953. * and states associated to a camera.
  9954. * @param parsedCamera Defines the JSON to parse
  9955. */
  9956. parse(parsedCamera: any): void;
  9957. }
  9958. }
  9959. declare module "babylonjs/Events/keyboardEvents" {
  9960. /**
  9961. * Gather the list of keyboard event types as constants.
  9962. */
  9963. export class KeyboardEventTypes {
  9964. /**
  9965. * The keydown event is fired when a key becomes active (pressed).
  9966. */
  9967. static readonly KEYDOWN: number;
  9968. /**
  9969. * The keyup event is fired when a key has been released.
  9970. */
  9971. static readonly KEYUP: number;
  9972. }
  9973. /**
  9974. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9975. */
  9976. export class KeyboardInfo {
  9977. /**
  9978. * Defines the type of event (KeyboardEventTypes)
  9979. */
  9980. type: number;
  9981. /**
  9982. * Defines the related dom event
  9983. */
  9984. event: KeyboardEvent;
  9985. /**
  9986. * Instantiates a new keyboard info.
  9987. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9988. * @param type Defines the type of event (KeyboardEventTypes)
  9989. * @param event Defines the related dom event
  9990. */
  9991. constructor(
  9992. /**
  9993. * Defines the type of event (KeyboardEventTypes)
  9994. */
  9995. type: number,
  9996. /**
  9997. * Defines the related dom event
  9998. */
  9999. event: KeyboardEvent);
  10000. }
  10001. /**
  10002. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10003. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  10004. */
  10005. export class KeyboardInfoPre extends KeyboardInfo {
  10006. /**
  10007. * Defines the type of event (KeyboardEventTypes)
  10008. */
  10009. type: number;
  10010. /**
  10011. * Defines the related dom event
  10012. */
  10013. event: KeyboardEvent;
  10014. /**
  10015. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  10016. */
  10017. skipOnPointerObservable: boolean;
  10018. /**
  10019. * Instantiates a new keyboard pre info.
  10020. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10021. * @param type Defines the type of event (KeyboardEventTypes)
  10022. * @param event Defines the related dom event
  10023. */
  10024. constructor(
  10025. /**
  10026. * Defines the type of event (KeyboardEventTypes)
  10027. */
  10028. type: number,
  10029. /**
  10030. * Defines the related dom event
  10031. */
  10032. event: KeyboardEvent);
  10033. }
  10034. }
  10035. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  10036. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10037. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10038. /**
  10039. * Manage the keyboard inputs to control the movement of a free camera.
  10040. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  10041. */
  10042. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  10043. /**
  10044. * Defines the camera the input is attached to.
  10045. */
  10046. camera: FreeCamera;
  10047. /**
  10048. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  10049. */
  10050. keysUp: number[];
  10051. /**
  10052. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10053. */
  10054. keysUpward: number[];
  10055. /**
  10056. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10057. */
  10058. keysDown: number[];
  10059. /**
  10060. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10061. */
  10062. keysDownward: number[];
  10063. /**
  10064. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10065. */
  10066. keysLeft: number[];
  10067. /**
  10068. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10069. */
  10070. keysRight: number[];
  10071. private _keys;
  10072. private _onCanvasBlurObserver;
  10073. private _onKeyboardObserver;
  10074. private _engine;
  10075. private _scene;
  10076. /**
  10077. * Attach the input controls to a specific dom element to get the input from.
  10078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10079. */
  10080. attachControl(noPreventDefault?: boolean): void;
  10081. /**
  10082. * Detach the current controls from the specified dom element.
  10083. */
  10084. detachControl(): void;
  10085. /**
  10086. * Update the current camera state depending on the inputs that have been used this frame.
  10087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10088. */
  10089. checkInputs(): void;
  10090. /**
  10091. * Gets the class name of the current intput.
  10092. * @returns the class name
  10093. */
  10094. getClassName(): string;
  10095. /** @hidden */
  10096. _onLostFocus(): void;
  10097. /**
  10098. * Get the friendly name associated with the input class.
  10099. * @returns the input friendly name
  10100. */
  10101. getSimpleName(): string;
  10102. }
  10103. }
  10104. declare module "babylonjs/Actions/action" {
  10105. import { Observable } from "babylonjs/Misc/observable";
  10106. import { Condition } from "babylonjs/Actions/condition";
  10107. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10108. import { Nullable } from "babylonjs/types";
  10109. import { Scene } from "babylonjs/scene";
  10110. import { ActionManager } from "babylonjs/Actions/actionManager";
  10111. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10112. import { Node } from "babylonjs/node";
  10113. /**
  10114. * Interface used to define Action
  10115. */
  10116. export interface IAction {
  10117. /**
  10118. * Trigger for the action
  10119. */
  10120. trigger: number;
  10121. /** Options of the trigger */
  10122. triggerOptions: any;
  10123. /**
  10124. * Gets the trigger parameters
  10125. * @returns the trigger parameters
  10126. */
  10127. getTriggerParameter(): any;
  10128. /**
  10129. * Internal only - executes current action event
  10130. * @hidden
  10131. */
  10132. _executeCurrent(evt?: ActionEvent): void;
  10133. /**
  10134. * Serialize placeholder for child classes
  10135. * @param parent of child
  10136. * @returns the serialized object
  10137. */
  10138. serialize(parent: any): any;
  10139. /**
  10140. * Internal only
  10141. * @hidden
  10142. */
  10143. _prepare(): void;
  10144. /**
  10145. * Internal only - manager for action
  10146. * @hidden
  10147. */
  10148. _actionManager: Nullable<AbstractActionManager>;
  10149. /**
  10150. * Adds action to chain of actions, may be a DoNothingAction
  10151. * @param action defines the next action to execute
  10152. * @returns The action passed in
  10153. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10154. */
  10155. then(action: IAction): IAction;
  10156. }
  10157. /**
  10158. * The action to be carried out following a trigger
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10160. */
  10161. export class Action implements IAction {
  10162. /** the trigger, with or without parameters, for the action */
  10163. triggerOptions: any;
  10164. /**
  10165. * Trigger for the action
  10166. */
  10167. trigger: number;
  10168. /**
  10169. * Internal only - manager for action
  10170. * @hidden
  10171. */
  10172. _actionManager: ActionManager;
  10173. private _nextActiveAction;
  10174. private _child;
  10175. private _condition?;
  10176. private _triggerParameter;
  10177. /**
  10178. * An event triggered prior to action being executed.
  10179. */
  10180. onBeforeExecuteObservable: Observable<Action>;
  10181. /**
  10182. * Creates a new Action
  10183. * @param triggerOptions the trigger, with or without parameters, for the action
  10184. * @param condition an optional determinant of action
  10185. */
  10186. constructor(
  10187. /** the trigger, with or without parameters, for the action */
  10188. triggerOptions: any, condition?: Condition);
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. _prepare(): void;
  10194. /**
  10195. * Gets the trigger parameter
  10196. * @returns the trigger parameter
  10197. */
  10198. getTriggerParameter(): any;
  10199. /**
  10200. * Sets the trigger parameter
  10201. * @param value defines the new trigger parameter
  10202. */
  10203. setTriggerParameter(value: any): void;
  10204. /**
  10205. * Internal only - executes current action event
  10206. * @hidden
  10207. */
  10208. _executeCurrent(evt?: ActionEvent): void;
  10209. /**
  10210. * Execute placeholder for child classes
  10211. * @param evt optional action event
  10212. */
  10213. execute(evt?: ActionEvent): void;
  10214. /**
  10215. * Skips to next active action
  10216. */
  10217. skipToNextActiveAction(): void;
  10218. /**
  10219. * Adds action to chain of actions, may be a DoNothingAction
  10220. * @param action defines the next action to execute
  10221. * @returns The action passed in
  10222. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10223. */
  10224. then(action: Action): Action;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. _getProperty(propertyPath: string): string;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. _getEffectiveTarget(target: any, propertyPath: string): any;
  10235. /**
  10236. * Serialize placeholder for child classes
  10237. * @param parent of child
  10238. * @returns the serialized object
  10239. */
  10240. serialize(parent: any): any;
  10241. /**
  10242. * Internal only called by serialize
  10243. * @hidden
  10244. */
  10245. protected _serialize(serializedAction: any, parent?: any): any;
  10246. /**
  10247. * Internal only
  10248. * @hidden
  10249. */
  10250. static _SerializeValueAsString: (value: any) => string;
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. static _GetTargetProperty: (target: Scene | Node) => {
  10256. name: string;
  10257. targetType: string;
  10258. value: string;
  10259. };
  10260. }
  10261. }
  10262. declare module "babylonjs/Actions/condition" {
  10263. import { ActionManager } from "babylonjs/Actions/actionManager";
  10264. /**
  10265. * A Condition applied to an Action
  10266. */
  10267. export class Condition {
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Internal only
  10275. * @hidden
  10276. */
  10277. _evaluationId: number;
  10278. /**
  10279. * Internal only
  10280. * @hidden
  10281. */
  10282. _currentResult: boolean;
  10283. /**
  10284. * Creates a new Condition
  10285. * @param actionManager the manager of the action the condition is applied to
  10286. */
  10287. constructor(actionManager: ActionManager);
  10288. /**
  10289. * Check if the current condition is valid
  10290. * @returns a boolean
  10291. */
  10292. isValid(): boolean;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _getProperty(propertyPath: string): string;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _getEffectiveTarget(target: any, propertyPath: string): any;
  10303. /**
  10304. * Serialize placeholder for child classes
  10305. * @returns the serialized object
  10306. */
  10307. serialize(): any;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. protected _serialize(serializedCondition: any): any;
  10313. }
  10314. /**
  10315. * Defines specific conditional operators as extensions of Condition
  10316. */
  10317. export class ValueCondition extends Condition {
  10318. /** path to specify the property of the target the conditional operator uses */
  10319. propertyPath: string;
  10320. /** the value compared by the conditional operator against the current value of the property */
  10321. value: any;
  10322. /** the conditional operator, default ValueCondition.IsEqual */
  10323. operator: number;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. private static _IsEqual;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private static _IsDifferent;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. private static _IsGreater;
  10339. /**
  10340. * Internal only
  10341. * @hidden
  10342. */
  10343. private static _IsLesser;
  10344. /**
  10345. * returns the number for IsEqual
  10346. */
  10347. static get IsEqual(): number;
  10348. /**
  10349. * Returns the number for IsDifferent
  10350. */
  10351. static get IsDifferent(): number;
  10352. /**
  10353. * Returns the number for IsGreater
  10354. */
  10355. static get IsGreater(): number;
  10356. /**
  10357. * Returns the number for IsLesser
  10358. */
  10359. static get IsLesser(): number;
  10360. /**
  10361. * Internal only The action manager for the condition
  10362. * @hidden
  10363. */
  10364. _actionManager: ActionManager;
  10365. /**
  10366. * Internal only
  10367. * @hidden
  10368. */
  10369. private _target;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */
  10374. private _effectiveTarget;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. private _property;
  10380. /**
  10381. * Creates a new ValueCondition
  10382. * @param actionManager manager for the action the condition applies to
  10383. * @param target for the action
  10384. * @param propertyPath path to specify the property of the target the conditional operator uses
  10385. * @param value the value compared by the conditional operator against the current value of the property
  10386. * @param operator the conditional operator, default ValueCondition.IsEqual
  10387. */
  10388. constructor(actionManager: ActionManager, target: any,
  10389. /** path to specify the property of the target the conditional operator uses */
  10390. propertyPath: string,
  10391. /** the value compared by the conditional operator against the current value of the property */
  10392. value: any,
  10393. /** the conditional operator, default ValueCondition.IsEqual */
  10394. operator?: number);
  10395. /**
  10396. * Compares the given value with the property value for the specified conditional operator
  10397. * @returns the result of the comparison
  10398. */
  10399. isValid(): boolean;
  10400. /**
  10401. * Serialize the ValueCondition into a JSON compatible object
  10402. * @returns serialization object
  10403. */
  10404. serialize(): any;
  10405. /**
  10406. * Gets the name of the conditional operator for the ValueCondition
  10407. * @param operator the conditional operator
  10408. * @returns the name
  10409. */
  10410. static GetOperatorName(operator: number): string;
  10411. }
  10412. /**
  10413. * Defines a predicate condition as an extension of Condition
  10414. */
  10415. export class PredicateCondition extends Condition {
  10416. /** defines the predicate function used to validate the condition */
  10417. predicate: () => boolean;
  10418. /**
  10419. * Internal only - manager for action
  10420. * @hidden
  10421. */
  10422. _actionManager: ActionManager;
  10423. /**
  10424. * Creates a new PredicateCondition
  10425. * @param actionManager manager for the action the condition applies to
  10426. * @param predicate defines the predicate function used to validate the condition
  10427. */
  10428. constructor(actionManager: ActionManager,
  10429. /** defines the predicate function used to validate the condition */
  10430. predicate: () => boolean);
  10431. /**
  10432. * @returns the validity of the predicate condition
  10433. */
  10434. isValid(): boolean;
  10435. }
  10436. /**
  10437. * Defines a state condition as an extension of Condition
  10438. */
  10439. export class StateCondition extends Condition {
  10440. /** Value to compare with target state */
  10441. value: string;
  10442. /**
  10443. * Internal only - manager for action
  10444. * @hidden
  10445. */
  10446. _actionManager: ActionManager;
  10447. /**
  10448. * Internal only
  10449. * @hidden
  10450. */
  10451. private _target;
  10452. /**
  10453. * Creates a new StateCondition
  10454. * @param actionManager manager for the action the condition applies to
  10455. * @param target of the condition
  10456. * @param value to compare with target state
  10457. */
  10458. constructor(actionManager: ActionManager, target: any,
  10459. /** Value to compare with target state */
  10460. value: string);
  10461. /**
  10462. * Gets a boolean indicating if the current condition is met
  10463. * @returns the validity of the state
  10464. */
  10465. isValid(): boolean;
  10466. /**
  10467. * Serialize the StateCondition into a JSON compatible object
  10468. * @returns serialization object
  10469. */
  10470. serialize(): any;
  10471. }
  10472. }
  10473. declare module "babylonjs/Actions/directActions" {
  10474. import { Action } from "babylonjs/Actions/action";
  10475. import { Condition } from "babylonjs/Actions/condition";
  10476. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10477. /**
  10478. * This defines an action responsible to toggle a boolean once triggered.
  10479. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10480. */
  10481. export class SwitchBooleanAction extends Action {
  10482. /**
  10483. * The path to the boolean property in the target object
  10484. */
  10485. propertyPath: string;
  10486. private _target;
  10487. private _effectiveTarget;
  10488. private _property;
  10489. /**
  10490. * Instantiate the action
  10491. * @param triggerOptions defines the trigger options
  10492. * @param target defines the object containing the boolean
  10493. * @param propertyPath defines the path to the boolean property in the target object
  10494. * @param condition defines the trigger related conditions
  10495. */
  10496. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10497. /** @hidden */
  10498. _prepare(): void;
  10499. /**
  10500. * Execute the action toggle the boolean value.
  10501. */
  10502. execute(): void;
  10503. /**
  10504. * Serializes the actions and its related information.
  10505. * @param parent defines the object to serialize in
  10506. * @returns the serialized object
  10507. */
  10508. serialize(parent: any): any;
  10509. }
  10510. /**
  10511. * This defines an action responsible to set a the state field of the target
  10512. * to a desired value once triggered.
  10513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10514. */
  10515. export class SetStateAction extends Action {
  10516. /**
  10517. * The value to store in the state field.
  10518. */
  10519. value: string;
  10520. private _target;
  10521. /**
  10522. * Instantiate the action
  10523. * @param triggerOptions defines the trigger options
  10524. * @param target defines the object containing the state property
  10525. * @param value defines the value to store in the state field
  10526. * @param condition defines the trigger related conditions
  10527. */
  10528. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10529. /**
  10530. * Execute the action and store the value on the target state property.
  10531. */
  10532. execute(): void;
  10533. /**
  10534. * Serializes the actions and its related information.
  10535. * @param parent defines the object to serialize in
  10536. * @returns the serialized object
  10537. */
  10538. serialize(parent: any): any;
  10539. }
  10540. /**
  10541. * This defines an action responsible to set a property of the target
  10542. * to a desired value once triggered.
  10543. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10544. */
  10545. export class SetValueAction extends Action {
  10546. /**
  10547. * The path of the property to set in the target.
  10548. */
  10549. propertyPath: string;
  10550. /**
  10551. * The value to set in the property
  10552. */
  10553. value: any;
  10554. private _target;
  10555. private _effectiveTarget;
  10556. private _property;
  10557. /**
  10558. * Instantiate the action
  10559. * @param triggerOptions defines the trigger options
  10560. * @param target defines the object containing the property
  10561. * @param propertyPath defines the path of the property to set in the target
  10562. * @param value defines the value to set in the property
  10563. * @param condition defines the trigger related conditions
  10564. */
  10565. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10566. /** @hidden */
  10567. _prepare(): void;
  10568. /**
  10569. * Execute the action and set the targetted property to the desired value.
  10570. */
  10571. execute(): void;
  10572. /**
  10573. * Serializes the actions and its related information.
  10574. * @param parent defines the object to serialize in
  10575. * @returns the serialized object
  10576. */
  10577. serialize(parent: any): any;
  10578. }
  10579. /**
  10580. * This defines an action responsible to increment the target value
  10581. * to a desired value once triggered.
  10582. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10583. */
  10584. export class IncrementValueAction extends Action {
  10585. /**
  10586. * The path of the property to increment in the target.
  10587. */
  10588. propertyPath: string;
  10589. /**
  10590. * The value we should increment the property by.
  10591. */
  10592. value: any;
  10593. private _target;
  10594. private _effectiveTarget;
  10595. private _property;
  10596. /**
  10597. * Instantiate the action
  10598. * @param triggerOptions defines the trigger options
  10599. * @param target defines the object containing the property
  10600. * @param propertyPath defines the path of the property to increment in the target
  10601. * @param value defines the value value we should increment the property by
  10602. * @param condition defines the trigger related conditions
  10603. */
  10604. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10605. /** @hidden */
  10606. _prepare(): void;
  10607. /**
  10608. * Execute the action and increment the target of the value amount.
  10609. */
  10610. execute(): void;
  10611. /**
  10612. * Serializes the actions and its related information.
  10613. * @param parent defines the object to serialize in
  10614. * @returns the serialized object
  10615. */
  10616. serialize(parent: any): any;
  10617. }
  10618. /**
  10619. * This defines an action responsible to start an animation once triggered.
  10620. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10621. */
  10622. export class PlayAnimationAction extends Action {
  10623. /**
  10624. * Where the animation should start (animation frame)
  10625. */
  10626. from: number;
  10627. /**
  10628. * Where the animation should stop (animation frame)
  10629. */
  10630. to: number;
  10631. /**
  10632. * Define if the animation should loop or stop after the first play.
  10633. */
  10634. loop?: boolean;
  10635. private _target;
  10636. /**
  10637. * Instantiate the action
  10638. * @param triggerOptions defines the trigger options
  10639. * @param target defines the target animation or animation name
  10640. * @param from defines from where the animation should start (animation frame)
  10641. * @param end defines where the animation should stop (animation frame)
  10642. * @param loop defines if the animation should loop or stop after the first play
  10643. * @param condition defines the trigger related conditions
  10644. */
  10645. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10646. /** @hidden */
  10647. _prepare(): void;
  10648. /**
  10649. * Execute the action and play the animation.
  10650. */
  10651. execute(): void;
  10652. /**
  10653. * Serializes the actions and its related information.
  10654. * @param parent defines the object to serialize in
  10655. * @returns the serialized object
  10656. */
  10657. serialize(parent: any): any;
  10658. }
  10659. /**
  10660. * This defines an action responsible to stop an animation once triggered.
  10661. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class StopAnimationAction extends Action {
  10664. private _target;
  10665. /**
  10666. * Instantiate the action
  10667. * @param triggerOptions defines the trigger options
  10668. * @param target defines the target animation or animation name
  10669. * @param condition defines the trigger related conditions
  10670. */
  10671. constructor(triggerOptions: any, target: any, condition?: Condition);
  10672. /** @hidden */
  10673. _prepare(): void;
  10674. /**
  10675. * Execute the action and stop the animation.
  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 that does nothing once triggered.
  10687. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10688. */
  10689. export class DoNothingAction extends Action {
  10690. /**
  10691. * Instantiate the action
  10692. * @param triggerOptions defines the trigger options
  10693. * @param condition defines the trigger related conditions
  10694. */
  10695. constructor(triggerOptions?: any, condition?: Condition);
  10696. /**
  10697. * Execute the action and do nothing.
  10698. */
  10699. execute(): void;
  10700. /**
  10701. * Serializes the actions and its related information.
  10702. * @param parent defines the object to serialize in
  10703. * @returns the serialized object
  10704. */
  10705. serialize(parent: any): any;
  10706. }
  10707. /**
  10708. * This defines an action responsible to trigger several actions once triggered.
  10709. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10710. */
  10711. export class CombineAction extends Action {
  10712. /**
  10713. * The list of aggregated animations to run.
  10714. */
  10715. children: Action[];
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param children defines the list of aggregated animations to run
  10720. * @param condition defines the trigger related conditions
  10721. */
  10722. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10723. /** @hidden */
  10724. _prepare(): void;
  10725. /**
  10726. * Execute the action and executes all the aggregated actions.
  10727. */
  10728. execute(evt: ActionEvent): void;
  10729. /**
  10730. * Serializes the actions and its related information.
  10731. * @param parent defines the object to serialize in
  10732. * @returns the serialized object
  10733. */
  10734. serialize(parent: any): any;
  10735. }
  10736. /**
  10737. * This defines an action responsible to run code (external event) once triggered.
  10738. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10739. */
  10740. export class ExecuteCodeAction extends Action {
  10741. /**
  10742. * The callback function to run.
  10743. */
  10744. func: (evt: ActionEvent) => void;
  10745. /**
  10746. * Instantiate the action
  10747. * @param triggerOptions defines the trigger options
  10748. * @param func defines the callback function to run
  10749. * @param condition defines the trigger related conditions
  10750. */
  10751. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10752. /**
  10753. * Execute the action and run the attached code.
  10754. */
  10755. execute(evt: ActionEvent): void;
  10756. }
  10757. /**
  10758. * This defines an action responsible to set the parent property of the target once triggered.
  10759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10760. */
  10761. export class SetParentAction extends Action {
  10762. private _parent;
  10763. private _target;
  10764. /**
  10765. * Instantiate the action
  10766. * @param triggerOptions defines the trigger options
  10767. * @param target defines the target containing the parent property
  10768. * @param parent defines from where the animation should start (animation frame)
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and set the parent property.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. }
  10786. declare module "babylonjs/Actions/actionManager" {
  10787. import { Nullable } from "babylonjs/types";
  10788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10789. import { Scene } from "babylonjs/scene";
  10790. import { IAction } from "babylonjs/Actions/action";
  10791. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10792. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10793. /**
  10794. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10795. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10796. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10797. */
  10798. export class ActionManager extends AbstractActionManager {
  10799. /**
  10800. * Nothing
  10801. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10802. */
  10803. static readonly NothingTrigger: number;
  10804. /**
  10805. * On pick
  10806. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10807. */
  10808. static readonly OnPickTrigger: number;
  10809. /**
  10810. * On left pick
  10811. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10812. */
  10813. static readonly OnLeftPickTrigger: number;
  10814. /**
  10815. * On right pick
  10816. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10817. */
  10818. static readonly OnRightPickTrigger: number;
  10819. /**
  10820. * On center pick
  10821. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly OnCenterPickTrigger: number;
  10824. /**
  10825. * On pick down
  10826. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnPickDownTrigger: number;
  10829. /**
  10830. * On double pick
  10831. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnDoublePickTrigger: number;
  10834. /**
  10835. * On pick up
  10836. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10837. */
  10838. static readonly OnPickUpTrigger: number;
  10839. /**
  10840. * On pick out.
  10841. * This trigger will only be raised if you also declared a OnPickDown
  10842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10843. */
  10844. static readonly OnPickOutTrigger: number;
  10845. /**
  10846. * On long press
  10847. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10848. */
  10849. static readonly OnLongPressTrigger: number;
  10850. /**
  10851. * On pointer over
  10852. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10853. */
  10854. static readonly OnPointerOverTrigger: number;
  10855. /**
  10856. * On pointer out
  10857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10858. */
  10859. static readonly OnPointerOutTrigger: number;
  10860. /**
  10861. * On every frame
  10862. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnEveryFrameTrigger: number;
  10865. /**
  10866. * On intersection enter
  10867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnIntersectionEnterTrigger: number;
  10870. /**
  10871. * On intersection exit
  10872. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnIntersectionExitTrigger: number;
  10875. /**
  10876. * On key down
  10877. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnKeyDownTrigger: number;
  10880. /**
  10881. * On key up
  10882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnKeyUpTrigger: number;
  10885. private _scene;
  10886. /**
  10887. * Creates a new action manager
  10888. * @param scene defines the hosting scene
  10889. */
  10890. constructor(scene: Scene);
  10891. /**
  10892. * Releases all associated resources
  10893. */
  10894. dispose(): void;
  10895. /**
  10896. * Gets hosting scene
  10897. * @returns the hosting scene
  10898. */
  10899. getScene(): Scene;
  10900. /**
  10901. * Does this action manager handles actions of any of the given triggers
  10902. * @param triggers defines the triggers to be tested
  10903. * @return a boolean indicating whether one (or more) of the triggers is handled
  10904. */
  10905. hasSpecificTriggers(triggers: number[]): boolean;
  10906. /**
  10907. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10908. * speed.
  10909. * @param triggerA defines the trigger to be tested
  10910. * @param triggerB defines the trigger to be tested
  10911. * @return a boolean indicating whether one (or more) of the triggers is handled
  10912. */
  10913. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10914. /**
  10915. * Does this action manager handles actions of a given trigger
  10916. * @param trigger defines the trigger to be tested
  10917. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10918. * @return whether the trigger is handled
  10919. */
  10920. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10921. /**
  10922. * Does this action manager has pointer triggers
  10923. */
  10924. get hasPointerTriggers(): boolean;
  10925. /**
  10926. * Does this action manager has pick triggers
  10927. */
  10928. get hasPickTriggers(): boolean;
  10929. /**
  10930. * Registers an action to this action manager
  10931. * @param action defines the action to be registered
  10932. * @return the action amended (prepared) after registration
  10933. */
  10934. registerAction(action: IAction): Nullable<IAction>;
  10935. /**
  10936. * Unregisters an action to this action manager
  10937. * @param action defines the action to be unregistered
  10938. * @return a boolean indicating whether the action has been unregistered
  10939. */
  10940. unregisterAction(action: IAction): Boolean;
  10941. /**
  10942. * Process a specific trigger
  10943. * @param trigger defines the trigger to process
  10944. * @param evt defines the event details to be processed
  10945. */
  10946. processTrigger(trigger: number, evt?: IActionEvent): void;
  10947. /** @hidden */
  10948. _getEffectiveTarget(target: any, propertyPath: string): any;
  10949. /** @hidden */
  10950. _getProperty(propertyPath: string): string;
  10951. /**
  10952. * Serialize this manager to a JSON object
  10953. * @param name defines the property name to store this manager
  10954. * @returns a JSON representation of this manager
  10955. */
  10956. serialize(name: string): any;
  10957. /**
  10958. * Creates a new ActionManager from a JSON data
  10959. * @param parsedActions defines the JSON data to read from
  10960. * @param object defines the hosting mesh
  10961. * @param scene defines the hosting scene
  10962. */
  10963. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10964. /**
  10965. * Get a trigger name by index
  10966. * @param trigger defines the trigger index
  10967. * @returns a trigger name
  10968. */
  10969. static GetTriggerName(trigger: number): string;
  10970. }
  10971. }
  10972. declare module "babylonjs/Culling/ray" {
  10973. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10974. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10976. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10977. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10978. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10979. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10980. import { Plane } from "babylonjs/Maths/math.plane";
  10981. /**
  10982. * Class representing a ray with position and direction
  10983. */
  10984. export class Ray {
  10985. /** origin point */
  10986. origin: Vector3;
  10987. /** direction */
  10988. direction: Vector3;
  10989. /** length of the ray */
  10990. length: number;
  10991. private static readonly _TmpVector3;
  10992. private _tmpRay;
  10993. /**
  10994. * Creates a new ray
  10995. * @param origin origin point
  10996. * @param direction direction
  10997. * @param length length of the ray
  10998. */
  10999. constructor(
  11000. /** origin point */
  11001. origin: Vector3,
  11002. /** direction */
  11003. direction: Vector3,
  11004. /** length of the ray */
  11005. length?: number);
  11006. /**
  11007. * Checks if the ray intersects a box
  11008. * This does not account for the ray lenght by design to improve perfs.
  11009. * @param minimum bound of the box
  11010. * @param maximum bound of the box
  11011. * @param intersectionTreshold extra extend to be added to the box in all direction
  11012. * @returns if the box was hit
  11013. */
  11014. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11015. /**
  11016. * Checks if the ray intersects a box
  11017. * This does not account for the ray lenght by design to improve perfs.
  11018. * @param box the bounding box to check
  11019. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11020. * @returns if the box was hit
  11021. */
  11022. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11023. /**
  11024. * If the ray hits a sphere
  11025. * @param sphere the bounding sphere to check
  11026. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11027. * @returns true if it hits the sphere
  11028. */
  11029. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11030. /**
  11031. * If the ray hits a triange
  11032. * @param vertex0 triangle vertex
  11033. * @param vertex1 triangle vertex
  11034. * @param vertex2 triangle vertex
  11035. * @returns intersection information if hit
  11036. */
  11037. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11038. /**
  11039. * Checks if ray intersects a plane
  11040. * @param plane the plane to check
  11041. * @returns the distance away it was hit
  11042. */
  11043. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11044. /**
  11045. * Calculate the intercept of a ray on a given axis
  11046. * @param axis to check 'x' | 'y' | 'z'
  11047. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11048. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11049. */
  11050. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11051. /**
  11052. * Checks if ray intersects a mesh
  11053. * @param mesh the mesh to check
  11054. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11055. * @returns picking info of the intersecton
  11056. */
  11057. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11058. /**
  11059. * Checks if ray intersects a mesh
  11060. * @param meshes the meshes to check
  11061. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11062. * @param results array to store result in
  11063. * @returns Array of picking infos
  11064. */
  11065. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11066. private _comparePickingInfo;
  11067. private static smallnum;
  11068. private static rayl;
  11069. /**
  11070. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11071. * @param sega the first point of the segment to test the intersection against
  11072. * @param segb the second point of the segment to test the intersection against
  11073. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11074. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11075. */
  11076. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11077. /**
  11078. * Update the ray from viewport position
  11079. * @param x position
  11080. * @param y y position
  11081. * @param viewportWidth viewport width
  11082. * @param viewportHeight viewport height
  11083. * @param world world matrix
  11084. * @param view view matrix
  11085. * @param projection projection matrix
  11086. * @returns this ray updated
  11087. */
  11088. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11089. /**
  11090. * Creates a ray with origin and direction of 0,0,0
  11091. * @returns the new ray
  11092. */
  11093. static Zero(): Ray;
  11094. /**
  11095. * Creates a new ray from screen space and viewport
  11096. * @param x position
  11097. * @param y y position
  11098. * @param viewportWidth viewport width
  11099. * @param viewportHeight viewport height
  11100. * @param world world matrix
  11101. * @param view view matrix
  11102. * @param projection projection matrix
  11103. * @returns new ray
  11104. */
  11105. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11106. /**
  11107. * 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
  11108. * transformed to the given world matrix.
  11109. * @param origin The origin point
  11110. * @param end The end point
  11111. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11112. * @returns the new ray
  11113. */
  11114. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11115. /**
  11116. * Transforms a ray by a matrix
  11117. * @param ray ray to transform
  11118. * @param matrix matrix to apply
  11119. * @returns the resulting new ray
  11120. */
  11121. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11122. /**
  11123. * Transforms a ray by a matrix
  11124. * @param ray ray to transform
  11125. * @param matrix matrix to apply
  11126. * @param result ray to store result in
  11127. */
  11128. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11129. /**
  11130. * Unproject a ray from screen space to object space
  11131. * @param sourceX defines the screen space x coordinate to use
  11132. * @param sourceY defines the screen space y coordinate to use
  11133. * @param viewportWidth defines the current width of the viewport
  11134. * @param viewportHeight defines the current height of the viewport
  11135. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11136. * @param view defines the view matrix to use
  11137. * @param projection defines the projection matrix to use
  11138. */
  11139. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11140. }
  11141. /**
  11142. * Type used to define predicate used to select faces when a mesh intersection is detected
  11143. */
  11144. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11145. module "babylonjs/scene" {
  11146. interface Scene {
  11147. /** @hidden */
  11148. _tempPickingRay: Nullable<Ray>;
  11149. /** @hidden */
  11150. _cachedRayForTransform: Ray;
  11151. /** @hidden */
  11152. _pickWithRayInverseMatrix: Matrix;
  11153. /** @hidden */
  11154. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11155. /** @hidden */
  11156. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11157. /** @hidden */
  11158. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11159. }
  11160. }
  11161. }
  11162. declare module "babylonjs/sceneComponent" {
  11163. import { Scene } from "babylonjs/scene";
  11164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11165. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11166. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11167. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11168. import { Nullable } from "babylonjs/types";
  11169. import { Camera } from "babylonjs/Cameras/camera";
  11170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11171. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11172. import { AbstractScene } from "babylonjs/abstractScene";
  11173. import { Mesh } from "babylonjs/Meshes/mesh";
  11174. import { Effect } from "babylonjs/Materials/effect";
  11175. /**
  11176. * Groups all the scene component constants in one place to ease maintenance.
  11177. * @hidden
  11178. */
  11179. export class SceneComponentConstants {
  11180. static readonly NAME_EFFECTLAYER: string;
  11181. static readonly NAME_LAYER: string;
  11182. static readonly NAME_LENSFLARESYSTEM: string;
  11183. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11184. static readonly NAME_PARTICLESYSTEM: string;
  11185. static readonly NAME_GAMEPAD: string;
  11186. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11187. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11188. static readonly NAME_PREPASSRENDERER: string;
  11189. static readonly NAME_DEPTHRENDERER: string;
  11190. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11191. static readonly NAME_SPRITE: string;
  11192. static readonly NAME_SUBSURFACE: string;
  11193. static readonly NAME_OUTLINERENDERER: string;
  11194. static readonly NAME_PROCEDURALTEXTURE: string;
  11195. static readonly NAME_SHADOWGENERATOR: string;
  11196. static readonly NAME_OCTREE: string;
  11197. static readonly NAME_PHYSICSENGINE: string;
  11198. static readonly NAME_AUDIO: string;
  11199. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11200. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11201. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11202. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11203. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11204. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11205. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11206. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11207. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11208. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11209. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11210. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11211. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11212. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11213. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11215. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11216. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11217. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11218. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11219. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11220. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11221. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11222. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11223. static readonly STEP_AFTERRENDER_AUDIO: number;
  11224. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11225. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11226. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11227. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11228. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11229. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11230. static readonly STEP_POINTERMOVE_SPRITE: number;
  11231. static readonly STEP_POINTERDOWN_SPRITE: number;
  11232. static readonly STEP_POINTERUP_SPRITE: number;
  11233. }
  11234. /**
  11235. * This represents a scene component.
  11236. *
  11237. * This is used to decouple the dependency the scene is having on the different workloads like
  11238. * layers, post processes...
  11239. */
  11240. export interface ISceneComponent {
  11241. /**
  11242. * The name of the component. Each component must have a unique name.
  11243. */
  11244. name: string;
  11245. /**
  11246. * The scene the component belongs to.
  11247. */
  11248. scene: Scene;
  11249. /**
  11250. * Register the component to one instance of a scene.
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. }
  11263. /**
  11264. * This represents a SERIALIZABLE scene component.
  11265. *
  11266. * This extends Scene Component to add Serialization methods on top.
  11267. */
  11268. export interface ISceneSerializableComponent extends ISceneComponent {
  11269. /**
  11270. * Adds all the elements from the container to the scene
  11271. * @param container the container holding the elements
  11272. */
  11273. addFromContainer(container: AbstractScene): void;
  11274. /**
  11275. * Removes all the elements in the container from the scene
  11276. * @param container contains the elements to remove
  11277. * @param dispose if the removed element should be disposed (default: false)
  11278. */
  11279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11280. /**
  11281. * Serializes the component data to the specified json object
  11282. * @param serializationObject The object to serialize to
  11283. */
  11284. serialize(serializationObject: any): void;
  11285. }
  11286. /**
  11287. * Strong typing of a Mesh related stage step action
  11288. */
  11289. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11290. /**
  11291. * Strong typing of a Evaluate Sub Mesh related stage step action
  11292. */
  11293. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11294. /**
  11295. * Strong typing of a pre active Mesh related stage step action
  11296. */
  11297. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11298. /**
  11299. * Strong typing of a Camera related stage step action
  11300. */
  11301. export type CameraStageAction = (camera: Camera) => void;
  11302. /**
  11303. * Strong typing of a Camera Frame buffer related stage step action
  11304. */
  11305. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11306. /**
  11307. * Strong typing of a Render Target related stage step action
  11308. */
  11309. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11310. /**
  11311. * Strong typing of a RenderingGroup related stage step action
  11312. */
  11313. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11314. /**
  11315. * Strong typing of a Mesh Render related stage step action
  11316. */
  11317. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11318. /**
  11319. * Strong typing of a simple stage step action
  11320. */
  11321. export type SimpleStageAction = () => void;
  11322. /**
  11323. * Strong typing of a render target action.
  11324. */
  11325. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11326. /**
  11327. * Strong typing of a pointer move action.
  11328. */
  11329. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11330. /**
  11331. * Strong typing of a pointer up/down action.
  11332. */
  11333. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11334. /**
  11335. * Representation of a stage in the scene (Basically a list of ordered steps)
  11336. * @hidden
  11337. */
  11338. export class Stage<T extends Function> extends Array<{
  11339. index: number;
  11340. component: ISceneComponent;
  11341. action: T;
  11342. }> {
  11343. /**
  11344. * Hide ctor from the rest of the world.
  11345. * @param items The items to add.
  11346. */
  11347. private constructor();
  11348. /**
  11349. * Creates a new Stage.
  11350. * @returns A new instance of a Stage
  11351. */
  11352. static Create<T extends Function>(): Stage<T>;
  11353. /**
  11354. * Registers a step in an ordered way in the targeted stage.
  11355. * @param index Defines the position to register the step in
  11356. * @param component Defines the component attached to the step
  11357. * @param action Defines the action to launch during the step
  11358. */
  11359. registerStep(index: number, component: ISceneComponent, action: T): void;
  11360. /**
  11361. * Clears all the steps from the stage.
  11362. */
  11363. clear(): void;
  11364. }
  11365. }
  11366. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Observable } from "babylonjs/Misc/observable";
  11369. import { Scene } from "babylonjs/scene";
  11370. import { Sprite } from "babylonjs/Sprites/sprite";
  11371. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11372. import { Ray } from "babylonjs/Culling/ray";
  11373. import { Camera } from "babylonjs/Cameras/camera";
  11374. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11375. import { ISceneComponent } from "babylonjs/sceneComponent";
  11376. module "babylonjs/scene" {
  11377. interface Scene {
  11378. /** @hidden */
  11379. _pointerOverSprite: Nullable<Sprite>;
  11380. /** @hidden */
  11381. _pickedDownSprite: Nullable<Sprite>;
  11382. /** @hidden */
  11383. _tempSpritePickingRay: Nullable<Ray>;
  11384. /**
  11385. * All of the sprite managers added to this scene
  11386. * @see https://doc.babylonjs.com/babylon101/sprites
  11387. */
  11388. spriteManagers: Array<ISpriteManager>;
  11389. /**
  11390. * An event triggered when sprites rendering is about to start
  11391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11392. */
  11393. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11394. /**
  11395. * An event triggered when sprites rendering is done
  11396. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11397. */
  11398. onAfterSpritesRenderingObservable: Observable<Scene>;
  11399. /** @hidden */
  11400. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /** Launch a ray to try to pick a sprite in the scene
  11402. * @param x position on screen
  11403. * @param y position on screen
  11404. * @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
  11405. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11406. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11407. * @returns a PickingInfo
  11408. */
  11409. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11410. /** Use the given ray to pick a sprite in the scene
  11411. * @param ray The ray (in world space) to use to pick meshes
  11412. * @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
  11413. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11414. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11415. * @returns a PickingInfo
  11416. */
  11417. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11418. /** @hidden */
  11419. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11420. /** Launch a ray to try to pick sprites in the scene
  11421. * @param x position on screen
  11422. * @param y position on screen
  11423. * @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
  11424. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11425. * @returns a PickingInfo array
  11426. */
  11427. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11428. /** Use the given ray to pick sprites in the scene
  11429. * @param ray The ray (in world space) to use to pick meshes
  11430. * @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
  11431. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /**
  11436. * Force the sprite under the pointer
  11437. * @param sprite defines the sprite to use
  11438. */
  11439. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11440. /**
  11441. * Gets the sprite under the pointer
  11442. * @returns a Sprite or null if no sprite is under the pointer
  11443. */
  11444. getPointerOverSprite(): Nullable<Sprite>;
  11445. }
  11446. }
  11447. /**
  11448. * Defines the sprite scene component responsible to manage sprites
  11449. * in a given scene.
  11450. */
  11451. export class SpriteSceneComponent implements ISceneComponent {
  11452. /**
  11453. * The component name helpfull to identify the component in the list of scene components.
  11454. */
  11455. readonly name: string;
  11456. /**
  11457. * The scene the component belongs to.
  11458. */
  11459. scene: Scene;
  11460. /** @hidden */
  11461. private _spritePredicate;
  11462. /**
  11463. * Creates a new instance of the component for the given scene
  11464. * @param scene Defines the scene to register the component in
  11465. */
  11466. constructor(scene: Scene);
  11467. /**
  11468. * Registers the component in a given scene
  11469. */
  11470. register(): void;
  11471. /**
  11472. * Rebuilds the elements related to this component in case of
  11473. * context lost for instance.
  11474. */
  11475. rebuild(): void;
  11476. /**
  11477. * Disposes the component and the associated ressources.
  11478. */
  11479. dispose(): void;
  11480. private _pickSpriteButKeepRay;
  11481. private _pointerMove;
  11482. private _pointerDown;
  11483. private _pointerUp;
  11484. }
  11485. }
  11486. declare module "babylonjs/Misc/timingTools" {
  11487. /**
  11488. * Class used to provide helper for timing
  11489. */
  11490. export class TimingTools {
  11491. /**
  11492. * Polyfill for setImmediate
  11493. * @param action defines the action to execute after the current execution block
  11494. */
  11495. static SetImmediate(action: () => void): void;
  11496. }
  11497. }
  11498. declare module "babylonjs/Misc/instantiationTools" {
  11499. /**
  11500. * Class used to enable instatition of objects by class name
  11501. */
  11502. export class InstantiationTools {
  11503. /**
  11504. * Use this object to register external classes like custom textures or material
  11505. * to allow the laoders to instantiate them
  11506. */
  11507. static RegisteredExternalClasses: {
  11508. [key: string]: Object;
  11509. };
  11510. /**
  11511. * Tries to instantiate a new object from a given class name
  11512. * @param className defines the class name to instantiate
  11513. * @returns the new object or null if the system was not able to do the instantiation
  11514. */
  11515. static Instantiate(className: string): any;
  11516. }
  11517. }
  11518. declare module "babylonjs/Misc/copyTools" {
  11519. import { Nullable } from "babylonjs/types";
  11520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11521. /**
  11522. * Class used to host copy specific utilities
  11523. */
  11524. export class CopyTools {
  11525. /**
  11526. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11527. * @param texture defines the texture to read pixels from
  11528. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11529. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11530. * @returns The base64 encoded string or null
  11531. */
  11532. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11533. }
  11534. }
  11535. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  11536. /**
  11537. * Define options used to create a depth texture
  11538. */
  11539. export class DepthTextureCreationOptions {
  11540. /** Specifies whether or not a stencil should be allocated in the texture */
  11541. generateStencil?: boolean;
  11542. /** Specifies whether or not bilinear filtering is enable on the texture */
  11543. bilinearFiltering?: boolean;
  11544. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11545. comparisonFunction?: number;
  11546. /** Specifies if the created texture is a cube texture */
  11547. isCube?: boolean;
  11548. /** Specifies the sample count of the depth/stencil texture texture */
  11549. samples?: number;
  11550. }
  11551. }
  11552. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  11553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11554. import { Nullable } from "babylonjs/types";
  11555. import { Scene } from "babylonjs/scene";
  11556. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11557. module "babylonjs/Engines/thinEngine" {
  11558. interface ThinEngine {
  11559. /**
  11560. * Creates a depth stencil cube texture.
  11561. * This is only available in WebGL 2.
  11562. * @param size The size of face edge in the cube texture.
  11563. * @param options The options defining the cube texture.
  11564. * @returns The cube texture
  11565. */
  11566. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11567. /**
  11568. * Creates a cube texture
  11569. * @param rootUrl defines the url where the files to load is located
  11570. * @param scene defines the current scene
  11571. * @param files defines the list of files to load (1 per face)
  11572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11573. * @param onLoad defines an optional callback raised when the texture is loaded
  11574. * @param onError defines an optional callback raised if there is an issue to load the texture
  11575. * @param format defines the format of the data
  11576. * @param forcedExtension defines the extension to use to pick the right loader
  11577. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11580. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11581. * @param loaderOptions options to be passed to the loader
  11582. * @returns the cube texture as an InternalTexture
  11583. */
  11584. 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;
  11585. /**
  11586. * Creates a cube texture
  11587. * @param rootUrl defines the url where the files to load is located
  11588. * @param scene defines the current scene
  11589. * @param files defines the list of files to load (1 per face)
  11590. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11591. * @param onLoad defines an optional callback raised when the texture is loaded
  11592. * @param onError defines an optional callback raised if there is an issue to load the texture
  11593. * @param format defines the format of the data
  11594. * @param forcedExtension defines the extension to use to pick the right loader
  11595. * @returns the cube texture as an InternalTexture
  11596. */
  11597. 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;
  11598. /**
  11599. * Creates a cube texture
  11600. * @param rootUrl defines the url where the files to load is located
  11601. * @param scene defines the current scene
  11602. * @param files defines the list of files to load (1 per face)
  11603. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11604. * @param onLoad defines an optional callback raised when the texture is loaded
  11605. * @param onError defines an optional callback raised if there is an issue to load the texture
  11606. * @param format defines the format of the data
  11607. * @param forcedExtension defines the extension to use to pick the right loader
  11608. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11609. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11610. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11611. * @returns the cube texture as an InternalTexture
  11612. */
  11613. 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;
  11614. /** @hidden */
  11615. 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;
  11616. /** @hidden */
  11617. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11618. /** @hidden */
  11619. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11620. /** @hidden */
  11621. _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;
  11622. /** @hidden */
  11623. _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;
  11624. /**
  11625. * @hidden
  11626. */
  11627. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11628. }
  11629. }
  11630. }
  11631. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11632. import { Nullable } from "babylonjs/types";
  11633. import { Scene } from "babylonjs/scene";
  11634. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11636. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11637. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11638. import { Observable } from "babylonjs/Misc/observable";
  11639. /**
  11640. * Class for creating a cube texture
  11641. */
  11642. export class CubeTexture extends BaseTexture {
  11643. private _delayedOnLoad;
  11644. /**
  11645. * Observable triggered once the texture has been loaded.
  11646. */
  11647. onLoadObservable: Observable<CubeTexture>;
  11648. /**
  11649. * The url of the texture
  11650. */
  11651. url: string;
  11652. /**
  11653. * Gets or sets the center of the bounding box associated with the cube texture.
  11654. * It must define where the camera used to render the texture was set
  11655. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11656. */
  11657. boundingBoxPosition: Vector3;
  11658. private _boundingBoxSize;
  11659. /**
  11660. * Gets or sets the size of the bounding box associated with the cube texture
  11661. * When defined, the cubemap will switch to local mode
  11662. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11663. * @example https://www.babylonjs-playground.com/#RNASML
  11664. */
  11665. set boundingBoxSize(value: Vector3);
  11666. /**
  11667. * Returns the bounding box size
  11668. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11669. */
  11670. get boundingBoxSize(): Vector3;
  11671. protected _rotationY: number;
  11672. /**
  11673. * Sets texture matrix rotation angle around Y axis in radians.
  11674. */
  11675. set rotationY(value: number);
  11676. /**
  11677. * Gets texture matrix rotation angle around Y axis radians.
  11678. */
  11679. get rotationY(): number;
  11680. /**
  11681. * Are mip maps generated for this texture or not.
  11682. */
  11683. get noMipmap(): boolean;
  11684. private _noMipmap;
  11685. private _files;
  11686. protected _forcedExtension: Nullable<string>;
  11687. private _extensions;
  11688. private _textureMatrix;
  11689. private _format;
  11690. private _createPolynomials;
  11691. private _loaderOptions;
  11692. /**
  11693. * Creates a cube texture from an array of image urls
  11694. * @param files defines an array of image urls
  11695. * @param scene defines the hosting scene
  11696. * @param noMipmap specifies if mip maps are not used
  11697. * @returns a cube texture
  11698. */
  11699. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11700. /**
  11701. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11702. * @param url defines the url of the prefiltered texture
  11703. * @param scene defines the scene the texture is attached to
  11704. * @param forcedExtension defines the extension of the file if different from the url
  11705. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11706. * @return the prefiltered texture
  11707. */
  11708. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11709. /**
  11710. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11711. * as prefiltered data.
  11712. * @param rootUrl defines the url of the texture or the root name of the six images
  11713. * @param null defines the scene or engine the texture is attached to
  11714. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11715. * @param noMipmap defines if mipmaps should be created or not
  11716. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11717. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11718. * @param onError defines a callback triggered in case of error during load
  11719. * @param format defines the internal format to use for the texture once loaded
  11720. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11721. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11722. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11723. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11724. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11725. * @param loaderOptions options to be passed to the loader
  11726. * @return the cube texture
  11727. */
  11728. 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);
  11729. /**
  11730. * Get the current class name of the texture useful for serialization or dynamic coding.
  11731. * @returns "CubeTexture"
  11732. */
  11733. getClassName(): string;
  11734. /**
  11735. * Update the url (and optional buffer) of this texture if url was null during construction.
  11736. * @param url the url of the texture
  11737. * @param forcedExtension defines the extension to use
  11738. * @param onLoad callback called when the texture is loaded (defaults to null)
  11739. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11740. */
  11741. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11742. /**
  11743. * Delays loading of the cube texture
  11744. * @param forcedExtension defines the extension to use
  11745. */
  11746. delayLoad(forcedExtension?: string): void;
  11747. /**
  11748. * Returns the reflection texture matrix
  11749. * @returns the reflection texture matrix
  11750. */
  11751. getReflectionTextureMatrix(): Matrix;
  11752. /**
  11753. * Sets the reflection texture matrix
  11754. * @param value Reflection texture matrix
  11755. */
  11756. setReflectionTextureMatrix(value: Matrix): void;
  11757. /**
  11758. * Parses text to create a cube texture
  11759. * @param parsedTexture define the serialized text to read from
  11760. * @param scene defines the hosting scene
  11761. * @param rootUrl defines the root url of the cube texture
  11762. * @returns a cube texture
  11763. */
  11764. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11765. /**
  11766. * Makes a clone, or deep copy, of the cube texture
  11767. * @returns a new cube texture
  11768. */
  11769. clone(): CubeTexture;
  11770. }
  11771. }
  11772. declare module "babylonjs/Materials/colorCurves" {
  11773. import { Effect } from "babylonjs/Materials/effect";
  11774. /**
  11775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11777. * 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;
  11778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11779. */
  11780. export class ColorCurves {
  11781. private _dirty;
  11782. private _tempColor;
  11783. private _globalCurve;
  11784. private _highlightsCurve;
  11785. private _midtonesCurve;
  11786. private _shadowsCurve;
  11787. private _positiveCurve;
  11788. private _negativeCurve;
  11789. private _globalHue;
  11790. private _globalDensity;
  11791. private _globalSaturation;
  11792. private _globalExposure;
  11793. /**
  11794. * Gets the global Hue value.
  11795. * 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).
  11796. */
  11797. get globalHue(): number;
  11798. /**
  11799. * Sets the global Hue value.
  11800. * 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).
  11801. */
  11802. set globalHue(value: number);
  11803. /**
  11804. * Gets the global Density value.
  11805. * 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.
  11806. * Values less than zero provide a filter of opposite hue.
  11807. */
  11808. get globalDensity(): number;
  11809. /**
  11810. * Sets the global Density value.
  11811. * 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.
  11812. * Values less than zero provide a filter of opposite hue.
  11813. */
  11814. set globalDensity(value: number);
  11815. /**
  11816. * Gets the global Saturation value.
  11817. * 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.
  11818. */
  11819. get globalSaturation(): number;
  11820. /**
  11821. * Sets the global Saturation value.
  11822. * 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.
  11823. */
  11824. set globalSaturation(value: number);
  11825. /**
  11826. * Gets the global Exposure value.
  11827. * 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.
  11828. */
  11829. get globalExposure(): number;
  11830. /**
  11831. * Sets the global Exposure value.
  11832. * 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.
  11833. */
  11834. set globalExposure(value: number);
  11835. private _highlightsHue;
  11836. private _highlightsDensity;
  11837. private _highlightsSaturation;
  11838. private _highlightsExposure;
  11839. /**
  11840. * Gets the highlights Hue value.
  11841. * 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).
  11842. */
  11843. get highlightsHue(): number;
  11844. /**
  11845. * Sets the highlights Hue value.
  11846. * 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).
  11847. */
  11848. set highlightsHue(value: number);
  11849. /**
  11850. * Gets the highlights Density value.
  11851. * 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.
  11852. * Values less than zero provide a filter of opposite hue.
  11853. */
  11854. get highlightsDensity(): number;
  11855. /**
  11856. * Sets the highlights Density value.
  11857. * 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.
  11858. * Values less than zero provide a filter of opposite hue.
  11859. */
  11860. set highlightsDensity(value: number);
  11861. /**
  11862. * Gets the highlights Saturation value.
  11863. * 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.
  11864. */
  11865. get highlightsSaturation(): number;
  11866. /**
  11867. * Sets the highlights Saturation value.
  11868. * 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.
  11869. */
  11870. set highlightsSaturation(value: number);
  11871. /**
  11872. * Gets the highlights Exposure value.
  11873. * 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.
  11874. */
  11875. get highlightsExposure(): number;
  11876. /**
  11877. * Sets the highlights Exposure value.
  11878. * 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.
  11879. */
  11880. set highlightsExposure(value: number);
  11881. private _midtonesHue;
  11882. private _midtonesDensity;
  11883. private _midtonesSaturation;
  11884. private _midtonesExposure;
  11885. /**
  11886. * Gets the midtones Hue value.
  11887. * 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).
  11888. */
  11889. get midtonesHue(): number;
  11890. /**
  11891. * Sets the midtones Hue value.
  11892. * 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).
  11893. */
  11894. set midtonesHue(value: number);
  11895. /**
  11896. * Gets the midtones Density value.
  11897. * 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.
  11898. * Values less than zero provide a filter of opposite hue.
  11899. */
  11900. get midtonesDensity(): number;
  11901. /**
  11902. * Sets the midtones Density value.
  11903. * 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.
  11904. * Values less than zero provide a filter of opposite hue.
  11905. */
  11906. set midtonesDensity(value: number);
  11907. /**
  11908. * Gets the midtones Saturation value.
  11909. * 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.
  11910. */
  11911. get midtonesSaturation(): number;
  11912. /**
  11913. * Sets the midtones Saturation value.
  11914. * 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.
  11915. */
  11916. set midtonesSaturation(value: number);
  11917. /**
  11918. * Gets the midtones Exposure value.
  11919. * 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.
  11920. */
  11921. get midtonesExposure(): number;
  11922. /**
  11923. * Sets the midtones Exposure value.
  11924. * 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.
  11925. */
  11926. set midtonesExposure(value: number);
  11927. private _shadowsHue;
  11928. private _shadowsDensity;
  11929. private _shadowsSaturation;
  11930. private _shadowsExposure;
  11931. /**
  11932. * Gets the shadows Hue value.
  11933. * 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).
  11934. */
  11935. get shadowsHue(): number;
  11936. /**
  11937. * Sets the shadows Hue value.
  11938. * 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).
  11939. */
  11940. set shadowsHue(value: number);
  11941. /**
  11942. * Gets the shadows Density value.
  11943. * 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.
  11944. * Values less than zero provide a filter of opposite hue.
  11945. */
  11946. get shadowsDensity(): number;
  11947. /**
  11948. * Sets the shadows Density value.
  11949. * 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.
  11950. * Values less than zero provide a filter of opposite hue.
  11951. */
  11952. set shadowsDensity(value: number);
  11953. /**
  11954. * Gets the shadows Saturation value.
  11955. * 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.
  11956. */
  11957. get shadowsSaturation(): number;
  11958. /**
  11959. * Sets the shadows Saturation value.
  11960. * 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.
  11961. */
  11962. set shadowsSaturation(value: number);
  11963. /**
  11964. * Gets the shadows Exposure value.
  11965. * 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.
  11966. */
  11967. get shadowsExposure(): number;
  11968. /**
  11969. * Sets the shadows Exposure value.
  11970. * 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.
  11971. */
  11972. set shadowsExposure(value: number);
  11973. /**
  11974. * Returns the class name
  11975. * @returns The class name
  11976. */
  11977. getClassName(): string;
  11978. /**
  11979. * Binds the color curves to the shader.
  11980. * @param colorCurves The color curve to bind
  11981. * @param effect The effect to bind to
  11982. * @param positiveUniform The positive uniform shader parameter
  11983. * @param neutralUniform The neutral uniform shader parameter
  11984. * @param negativeUniform The negative uniform shader parameter
  11985. */
  11986. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11987. /**
  11988. * Prepare the list of uniforms associated with the ColorCurves effects.
  11989. * @param uniformsList The list of uniforms used in the effect
  11990. */
  11991. static PrepareUniforms(uniformsList: string[]): void;
  11992. /**
  11993. * Returns color grading data based on a hue, density, saturation and exposure value.
  11994. * @param filterHue The hue of the color filter.
  11995. * @param filterDensity The density of the color filter.
  11996. * @param saturation The saturation.
  11997. * @param exposure The exposure.
  11998. * @param result The result data container.
  11999. */
  12000. private getColorGradingDataToRef;
  12001. /**
  12002. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12003. * @param value The input slider value in range [-100,100].
  12004. * @returns Adjusted value.
  12005. */
  12006. private static applyColorGradingSliderNonlinear;
  12007. /**
  12008. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12009. * @param hue The hue (H) input.
  12010. * @param saturation The saturation (S) input.
  12011. * @param brightness The brightness (B) input.
  12012. * @result An RGBA color represented as Vector4.
  12013. */
  12014. private static fromHSBToRef;
  12015. /**
  12016. * Returns a value clamped between min and max
  12017. * @param value The value to clamp
  12018. * @param min The minimum of value
  12019. * @param max The maximum of value
  12020. * @returns The clamped value.
  12021. */
  12022. private static clamp;
  12023. /**
  12024. * Clones the current color curve instance.
  12025. * @return The cloned curves
  12026. */
  12027. clone(): ColorCurves;
  12028. /**
  12029. * Serializes the current color curve instance to a json representation.
  12030. * @return a JSON representation
  12031. */
  12032. serialize(): any;
  12033. /**
  12034. * Parses the color curve from a json representation.
  12035. * @param source the JSON source to parse
  12036. * @return The parsed curves
  12037. */
  12038. static Parse(source: any): ColorCurves;
  12039. }
  12040. }
  12041. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  12042. import { Observable } from "babylonjs/Misc/observable";
  12043. import { Nullable } from "babylonjs/types";
  12044. import { Color4 } from "babylonjs/Maths/math.color";
  12045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  12046. import { Effect } from "babylonjs/Materials/effect";
  12047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12048. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  12049. /**
  12050. * Interface to follow in your material defines to integrate easily the
  12051. * Image proccessing functions.
  12052. * @hidden
  12053. */
  12054. export interface IImageProcessingConfigurationDefines {
  12055. IMAGEPROCESSING: boolean;
  12056. VIGNETTE: boolean;
  12057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12058. VIGNETTEBLENDMODEOPAQUE: boolean;
  12059. TONEMAPPING: boolean;
  12060. TONEMAPPING_ACES: boolean;
  12061. CONTRAST: boolean;
  12062. EXPOSURE: boolean;
  12063. COLORCURVES: boolean;
  12064. COLORGRADING: boolean;
  12065. COLORGRADING3D: boolean;
  12066. SAMPLER3DGREENDEPTH: boolean;
  12067. SAMPLER3DBGRMAP: boolean;
  12068. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12069. }
  12070. /**
  12071. * @hidden
  12072. */
  12073. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12074. IMAGEPROCESSING: boolean;
  12075. VIGNETTE: boolean;
  12076. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12077. VIGNETTEBLENDMODEOPAQUE: boolean;
  12078. TONEMAPPING: boolean;
  12079. TONEMAPPING_ACES: boolean;
  12080. CONTRAST: boolean;
  12081. COLORCURVES: boolean;
  12082. COLORGRADING: boolean;
  12083. COLORGRADING3D: boolean;
  12084. SAMPLER3DGREENDEPTH: boolean;
  12085. SAMPLER3DBGRMAP: boolean;
  12086. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12087. EXPOSURE: boolean;
  12088. constructor();
  12089. }
  12090. /**
  12091. * This groups together the common properties used for image processing either in direct forward pass
  12092. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12093. * or not.
  12094. */
  12095. export class ImageProcessingConfiguration {
  12096. /**
  12097. * Default tone mapping applied in BabylonJS.
  12098. */
  12099. static readonly TONEMAPPING_STANDARD: number;
  12100. /**
  12101. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  12102. * to other engines rendering to increase portability.
  12103. */
  12104. static readonly TONEMAPPING_ACES: number;
  12105. /**
  12106. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12107. */
  12108. colorCurves: Nullable<ColorCurves>;
  12109. private _colorCurvesEnabled;
  12110. /**
  12111. * Gets wether the color curves effect is enabled.
  12112. */
  12113. get colorCurvesEnabled(): boolean;
  12114. /**
  12115. * Sets wether the color curves effect is enabled.
  12116. */
  12117. set colorCurvesEnabled(value: boolean);
  12118. private _colorGradingTexture;
  12119. /**
  12120. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12121. */
  12122. get colorGradingTexture(): Nullable<BaseTexture>;
  12123. /**
  12124. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12125. */
  12126. set colorGradingTexture(value: Nullable<BaseTexture>);
  12127. private _colorGradingEnabled;
  12128. /**
  12129. * Gets wether the color grading effect is enabled.
  12130. */
  12131. get colorGradingEnabled(): boolean;
  12132. /**
  12133. * Sets wether the color grading effect is enabled.
  12134. */
  12135. set colorGradingEnabled(value: boolean);
  12136. private _colorGradingWithGreenDepth;
  12137. /**
  12138. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12139. */
  12140. get colorGradingWithGreenDepth(): boolean;
  12141. /**
  12142. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12143. */
  12144. set colorGradingWithGreenDepth(value: boolean);
  12145. private _colorGradingBGR;
  12146. /**
  12147. * Gets wether the color grading texture contains BGR values.
  12148. */
  12149. get colorGradingBGR(): boolean;
  12150. /**
  12151. * Sets wether the color grading texture contains BGR values.
  12152. */
  12153. set colorGradingBGR(value: boolean);
  12154. /** @hidden */
  12155. _exposure: number;
  12156. /**
  12157. * Gets the Exposure used in the effect.
  12158. */
  12159. get exposure(): number;
  12160. /**
  12161. * Sets the Exposure used in the effect.
  12162. */
  12163. set exposure(value: number);
  12164. private _toneMappingEnabled;
  12165. /**
  12166. * Gets wether the tone mapping effect is enabled.
  12167. */
  12168. get toneMappingEnabled(): boolean;
  12169. /**
  12170. * Sets wether the tone mapping effect is enabled.
  12171. */
  12172. set toneMappingEnabled(value: boolean);
  12173. private _toneMappingType;
  12174. /**
  12175. * Gets the type of tone mapping effect.
  12176. */
  12177. get toneMappingType(): number;
  12178. /**
  12179. * Sets the type of tone mapping effect used in BabylonJS.
  12180. */
  12181. set toneMappingType(value: number);
  12182. protected _contrast: number;
  12183. /**
  12184. * Gets the contrast used in the effect.
  12185. */
  12186. get contrast(): number;
  12187. /**
  12188. * Sets the contrast used in the effect.
  12189. */
  12190. set contrast(value: number);
  12191. /**
  12192. * Vignette stretch size.
  12193. */
  12194. vignetteStretch: number;
  12195. /**
  12196. * Vignette centre X Offset.
  12197. */
  12198. vignetteCentreX: number;
  12199. /**
  12200. * Vignette centre Y Offset.
  12201. */
  12202. vignetteCentreY: number;
  12203. /**
  12204. * Vignette weight or intensity of the vignette effect.
  12205. */
  12206. vignetteWeight: number;
  12207. /**
  12208. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12209. * if vignetteEnabled is set to true.
  12210. */
  12211. vignetteColor: Color4;
  12212. /**
  12213. * Camera field of view used by the Vignette effect.
  12214. */
  12215. vignetteCameraFov: number;
  12216. private _vignetteBlendMode;
  12217. /**
  12218. * Gets the vignette blend mode allowing different kind of effect.
  12219. */
  12220. get vignetteBlendMode(): number;
  12221. /**
  12222. * Sets the vignette blend mode allowing different kind of effect.
  12223. */
  12224. set vignetteBlendMode(value: number);
  12225. private _vignetteEnabled;
  12226. /**
  12227. * Gets wether the vignette effect is enabled.
  12228. */
  12229. get vignetteEnabled(): boolean;
  12230. /**
  12231. * Sets wether the vignette effect is enabled.
  12232. */
  12233. set vignetteEnabled(value: boolean);
  12234. private _applyByPostProcess;
  12235. /**
  12236. * Gets wether the image processing is applied through a post process or not.
  12237. */
  12238. get applyByPostProcess(): boolean;
  12239. /**
  12240. * Sets wether the image processing is applied through a post process or not.
  12241. */
  12242. set applyByPostProcess(value: boolean);
  12243. private _isEnabled;
  12244. /**
  12245. * Gets wether the image processing is enabled or not.
  12246. */
  12247. get isEnabled(): boolean;
  12248. /**
  12249. * Sets wether the image processing is enabled or not.
  12250. */
  12251. set isEnabled(value: boolean);
  12252. /**
  12253. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12254. */
  12255. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12256. /**
  12257. * Method called each time the image processing information changes requires to recompile the effect.
  12258. */
  12259. protected _updateParameters(): void;
  12260. /**
  12261. * Gets the current class name.
  12262. * @return "ImageProcessingConfiguration"
  12263. */
  12264. getClassName(): string;
  12265. /**
  12266. * Prepare the list of uniforms associated with the Image Processing effects.
  12267. * @param uniforms The list of uniforms used in the effect
  12268. * @param defines the list of defines currently in use
  12269. */
  12270. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12271. /**
  12272. * Prepare the list of samplers associated with the Image Processing effects.
  12273. * @param samplersList The list of uniforms used in the effect
  12274. * @param defines the list of defines currently in use
  12275. */
  12276. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12277. /**
  12278. * Prepare the list of defines associated to the shader.
  12279. * @param defines the list of defines to complete
  12280. * @param forPostProcess Define if we are currently in post process mode or not
  12281. */
  12282. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12283. /**
  12284. * Returns true if all the image processing information are ready.
  12285. * @returns True if ready, otherwise, false
  12286. */
  12287. isReady(): boolean;
  12288. /**
  12289. * Binds the image processing to the shader.
  12290. * @param effect The effect to bind to
  12291. * @param overrideAspectRatio Override the aspect ratio of the effect
  12292. */
  12293. bind(effect: Effect, overrideAspectRatio?: number): void;
  12294. /**
  12295. * Clones the current image processing instance.
  12296. * @return The cloned image processing
  12297. */
  12298. clone(): ImageProcessingConfiguration;
  12299. /**
  12300. * Serializes the current image processing instance to a json representation.
  12301. * @return a JSON representation
  12302. */
  12303. serialize(): any;
  12304. /**
  12305. * Parses the image processing from a json representation.
  12306. * @param source the JSON source to parse
  12307. * @return The parsed image processing
  12308. */
  12309. static Parse(source: any): ImageProcessingConfiguration;
  12310. private static _VIGNETTEMODE_MULTIPLY;
  12311. private static _VIGNETTEMODE_OPAQUE;
  12312. /**
  12313. * Used to apply the vignette as a mix with the pixel color.
  12314. */
  12315. static get VIGNETTEMODE_MULTIPLY(): number;
  12316. /**
  12317. * Used to apply the vignette as a replacement of the pixel color.
  12318. */
  12319. static get VIGNETTEMODE_OPAQUE(): number;
  12320. }
  12321. }
  12322. declare module "babylonjs/Shaders/postprocess.vertex" {
  12323. /** @hidden */
  12324. export var postprocessVertexShader: {
  12325. name: string;
  12326. shader: string;
  12327. };
  12328. }
  12329. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  12330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12331. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12332. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  12333. /**
  12334. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12335. */
  12336. export type RenderTargetTextureSize = number | {
  12337. width: number;
  12338. height: number;
  12339. layers?: number;
  12340. };
  12341. module "babylonjs/Engines/thinEngine" {
  12342. interface ThinEngine {
  12343. /**
  12344. * Creates a new render target texture
  12345. * @param size defines the size of the texture
  12346. * @param options defines the options used to create the texture
  12347. * @returns a new render target texture stored in an InternalTexture
  12348. */
  12349. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12350. /**
  12351. * Creates a depth stencil texture.
  12352. * This is only available in WebGL 2 or with the depth texture extension available.
  12353. * @param size The size of face edge in the texture.
  12354. * @param options The options defining the texture.
  12355. * @returns The texture
  12356. */
  12357. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12358. /** @hidden */
  12359. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12360. }
  12361. }
  12362. }
  12363. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  12364. /**
  12365. * Defines the kind of connection point for node based material
  12366. */
  12367. export enum NodeMaterialBlockConnectionPointTypes {
  12368. /** Float */
  12369. Float = 1,
  12370. /** Int */
  12371. Int = 2,
  12372. /** Vector2 */
  12373. Vector2 = 4,
  12374. /** Vector3 */
  12375. Vector3 = 8,
  12376. /** Vector4 */
  12377. Vector4 = 16,
  12378. /** Color3 */
  12379. Color3 = 32,
  12380. /** Color4 */
  12381. Color4 = 64,
  12382. /** Matrix */
  12383. Matrix = 128,
  12384. /** Custom object */
  12385. Object = 256,
  12386. /** Detect type based on connection */
  12387. AutoDetect = 1024,
  12388. /** Output type that will be defined by input type */
  12389. BasedOnInput = 2048
  12390. }
  12391. }
  12392. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  12393. /**
  12394. * Enum used to define the target of a block
  12395. */
  12396. export enum NodeMaterialBlockTargets {
  12397. /** Vertex shader */
  12398. Vertex = 1,
  12399. /** Fragment shader */
  12400. Fragment = 2,
  12401. /** Neutral */
  12402. Neutral = 4,
  12403. /** Vertex and Fragment */
  12404. VertexAndFragment = 3
  12405. }
  12406. }
  12407. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  12408. /**
  12409. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12410. */
  12411. export enum NodeMaterialBlockConnectionPointMode {
  12412. /** Value is an uniform */
  12413. Uniform = 0,
  12414. /** Value is a mesh attribute */
  12415. Attribute = 1,
  12416. /** Value is a varying between vertex and fragment shaders */
  12417. Varying = 2,
  12418. /** Mode is undefined */
  12419. Undefined = 3
  12420. }
  12421. }
  12422. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  12423. /**
  12424. * Enum used to define system values e.g. values automatically provided by the system
  12425. */
  12426. export enum NodeMaterialSystemValues {
  12427. /** World */
  12428. World = 1,
  12429. /** View */
  12430. View = 2,
  12431. /** Projection */
  12432. Projection = 3,
  12433. /** ViewProjection */
  12434. ViewProjection = 4,
  12435. /** WorldView */
  12436. WorldView = 5,
  12437. /** WorldViewProjection */
  12438. WorldViewProjection = 6,
  12439. /** CameraPosition */
  12440. CameraPosition = 7,
  12441. /** Fog Color */
  12442. FogColor = 8,
  12443. /** Delta time */
  12444. DeltaTime = 9
  12445. }
  12446. }
  12447. declare module "babylonjs/Maths/math.frustum" {
  12448. import { Matrix } from "babylonjs/Maths/math.vector";
  12449. import { DeepImmutable } from "babylonjs/types";
  12450. import { Plane } from "babylonjs/Maths/math.plane";
  12451. /**
  12452. * Represents a camera frustum
  12453. */
  12454. export class Frustum {
  12455. /**
  12456. * Gets the planes representing the frustum
  12457. * @param transform matrix to be applied to the returned planes
  12458. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12459. */
  12460. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12461. /**
  12462. * Gets the near frustum plane transformed by the transform matrix
  12463. * @param transform transformation matrix to be applied to the resulting frustum plane
  12464. * @param frustumPlane the resuling frustum plane
  12465. */
  12466. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12467. /**
  12468. * Gets the far frustum plane transformed by the transform matrix
  12469. * @param transform transformation matrix to be applied to the resulting frustum plane
  12470. * @param frustumPlane the resuling frustum plane
  12471. */
  12472. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12473. /**
  12474. * Gets the left frustum plane transformed by the transform matrix
  12475. * @param transform transformation matrix to be applied to the resulting frustum plane
  12476. * @param frustumPlane the resuling frustum plane
  12477. */
  12478. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12479. /**
  12480. * Gets the right frustum plane transformed by the transform matrix
  12481. * @param transform transformation matrix to be applied to the resulting frustum plane
  12482. * @param frustumPlane the resuling frustum plane
  12483. */
  12484. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12485. /**
  12486. * Gets the top frustum plane transformed by the transform matrix
  12487. * @param transform transformation matrix to be applied to the resulting frustum plane
  12488. * @param frustumPlane the resuling frustum plane
  12489. */
  12490. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12491. /**
  12492. * Gets the bottom frustum plane transformed by the transform matrix
  12493. * @param transform transformation matrix to be applied to the resulting frustum plane
  12494. * @param frustumPlane the resuling frustum plane
  12495. */
  12496. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12497. /**
  12498. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12499. * @param transform transformation matrix to be applied to the resulting frustum planes
  12500. * @param frustumPlanes the resuling frustum planes
  12501. */
  12502. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12503. }
  12504. }
  12505. declare module "babylonjs/Maths/math.vertexFormat" {
  12506. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12507. /**
  12508. * Contains position and normal vectors for a vertex
  12509. */
  12510. export class PositionNormalVertex {
  12511. /** the position of the vertex (defaut: 0,0,0) */
  12512. position: Vector3;
  12513. /** the normal of the vertex (defaut: 0,1,0) */
  12514. normal: Vector3;
  12515. /**
  12516. * Creates a PositionNormalVertex
  12517. * @param position the position of the vertex (defaut: 0,0,0)
  12518. * @param normal the normal of the vertex (defaut: 0,1,0)
  12519. */
  12520. constructor(
  12521. /** the position of the vertex (defaut: 0,0,0) */
  12522. position?: Vector3,
  12523. /** the normal of the vertex (defaut: 0,1,0) */
  12524. normal?: Vector3);
  12525. /**
  12526. * Clones the PositionNormalVertex
  12527. * @returns the cloned PositionNormalVertex
  12528. */
  12529. clone(): PositionNormalVertex;
  12530. }
  12531. /**
  12532. * Contains position, normal and uv vectors for a vertex
  12533. */
  12534. export class PositionNormalTextureVertex {
  12535. /** the position of the vertex (defaut: 0,0,0) */
  12536. position: Vector3;
  12537. /** the normal of the vertex (defaut: 0,1,0) */
  12538. normal: Vector3;
  12539. /** the uv of the vertex (default: 0,0) */
  12540. uv: Vector2;
  12541. /**
  12542. * Creates a PositionNormalTextureVertex
  12543. * @param position the position of the vertex (defaut: 0,0,0)
  12544. * @param normal the normal of the vertex (defaut: 0,1,0)
  12545. * @param uv the uv of the vertex (default: 0,0)
  12546. */
  12547. constructor(
  12548. /** the position of the vertex (defaut: 0,0,0) */
  12549. position?: Vector3,
  12550. /** the normal of the vertex (defaut: 0,1,0) */
  12551. normal?: Vector3,
  12552. /** the uv of the vertex (default: 0,0) */
  12553. uv?: Vector2);
  12554. /**
  12555. * Clones the PositionNormalTextureVertex
  12556. * @returns the cloned PositionNormalTextureVertex
  12557. */
  12558. clone(): PositionNormalTextureVertex;
  12559. }
  12560. }
  12561. declare module "babylonjs/Maths/math" {
  12562. export * from "babylonjs/Maths/math.axis";
  12563. export * from "babylonjs/Maths/math.color";
  12564. export * from "babylonjs/Maths/math.constants";
  12565. export * from "babylonjs/Maths/math.frustum";
  12566. export * from "babylonjs/Maths/math.path";
  12567. export * from "babylonjs/Maths/math.plane";
  12568. export * from "babylonjs/Maths/math.size";
  12569. export * from "babylonjs/Maths/math.vector";
  12570. export * from "babylonjs/Maths/math.vertexFormat";
  12571. export * from "babylonjs/Maths/math.viewport";
  12572. }
  12573. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  12574. /**
  12575. * Enum defining the type of animations supported by InputBlock
  12576. */
  12577. export enum AnimatedInputBlockTypes {
  12578. /** No animation */
  12579. None = 0,
  12580. /** Time based animation. Will only work for floats */
  12581. Time = 1
  12582. }
  12583. }
  12584. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12586. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12587. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12588. import { Nullable } from "babylonjs/types";
  12589. import { Effect } from "babylonjs/Materials/effect";
  12590. import { Matrix } from "babylonjs/Maths/math.vector";
  12591. import { Scene } from "babylonjs/scene";
  12592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12594. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12595. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12596. import { Observable } from "babylonjs/Misc/observable";
  12597. /**
  12598. * Block used to expose an input value
  12599. */
  12600. export class InputBlock extends NodeMaterialBlock {
  12601. private _mode;
  12602. private _associatedVariableName;
  12603. private _storedValue;
  12604. private _valueCallback;
  12605. private _type;
  12606. private _animationType;
  12607. /** Gets or set a value used to limit the range of float values */
  12608. min: number;
  12609. /** Gets or set a value used to limit the range of float values */
  12610. max: number;
  12611. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12612. isBoolean: boolean;
  12613. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12614. matrixMode: number;
  12615. /** @hidden */
  12616. _systemValue: Nullable<NodeMaterialSystemValues>;
  12617. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12618. isConstant: boolean;
  12619. /** Gets or sets the group to use to display this block in the Inspector */
  12620. groupInInspector: string;
  12621. /** Gets an observable raised when the value is changed */
  12622. onValueChangedObservable: Observable<InputBlock>;
  12623. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12624. convertToGammaSpace: boolean;
  12625. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12626. convertToLinearSpace: boolean;
  12627. /**
  12628. * Gets or sets the connection point type (default is float)
  12629. */
  12630. get type(): NodeMaterialBlockConnectionPointTypes;
  12631. /**
  12632. * Creates a new InputBlock
  12633. * @param name defines the block name
  12634. * @param target defines the target of that block (Vertex by default)
  12635. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12636. */
  12637. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12638. /**
  12639. * Validates if a name is a reserve word.
  12640. * @param newName the new name to be given to the node.
  12641. * @returns false if the name is a reserve word, else true.
  12642. */
  12643. validateBlockName(newName: string): boolean;
  12644. /**
  12645. * Gets the output component
  12646. */
  12647. get output(): NodeMaterialConnectionPoint;
  12648. /**
  12649. * Set the source of this connection point to a vertex attribute
  12650. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12651. * @returns the current connection point
  12652. */
  12653. setAsAttribute(attributeName?: string): InputBlock;
  12654. /**
  12655. * Set the source of this connection point to a system value
  12656. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12657. * @returns the current connection point
  12658. */
  12659. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12660. /**
  12661. * Gets or sets the value of that point.
  12662. * Please note that this value will be ignored if valueCallback is defined
  12663. */
  12664. get value(): any;
  12665. set value(value: any);
  12666. /**
  12667. * Gets or sets a callback used to get the value of that point.
  12668. * Please note that setting this value will force the connection point to ignore the value property
  12669. */
  12670. get valueCallback(): () => any;
  12671. set valueCallback(value: () => any);
  12672. /**
  12673. * Gets or sets the associated variable name in the shader
  12674. */
  12675. get associatedVariableName(): string;
  12676. set associatedVariableName(value: string);
  12677. /** Gets or sets the type of animation applied to the input */
  12678. get animationType(): AnimatedInputBlockTypes;
  12679. set animationType(value: AnimatedInputBlockTypes);
  12680. /**
  12681. * Gets a boolean indicating that this connection point not defined yet
  12682. */
  12683. get isUndefined(): boolean;
  12684. /**
  12685. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12686. * In this case the connection point name must be the name of the uniform to use.
  12687. * Can only be set on inputs
  12688. */
  12689. get isUniform(): boolean;
  12690. set isUniform(value: boolean);
  12691. /**
  12692. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12693. * In this case the connection point name must be the name of the attribute to use
  12694. * Can only be set on inputs
  12695. */
  12696. get isAttribute(): boolean;
  12697. set isAttribute(value: boolean);
  12698. /**
  12699. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12700. * Can only be set on exit points
  12701. */
  12702. get isVarying(): boolean;
  12703. set isVarying(value: boolean);
  12704. /**
  12705. * Gets a boolean indicating that the current connection point is a system value
  12706. */
  12707. get isSystemValue(): boolean;
  12708. /**
  12709. * Gets or sets the current well known value or null if not defined as a system value
  12710. */
  12711. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12712. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12713. /**
  12714. * Gets the current class name
  12715. * @returns the class name
  12716. */
  12717. getClassName(): string;
  12718. /**
  12719. * Animate the input if animationType !== None
  12720. * @param scene defines the rendering scene
  12721. */
  12722. animate(scene: Scene): void;
  12723. private _emitDefine;
  12724. initialize(state: NodeMaterialBuildState): void;
  12725. /**
  12726. * Set the input block to its default value (based on its type)
  12727. */
  12728. setDefaultValue(): void;
  12729. private _emitConstant;
  12730. /** @hidden */
  12731. get _noContextSwitch(): boolean;
  12732. private _emit;
  12733. /** @hidden */
  12734. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12735. /** @hidden */
  12736. _transmit(effect: Effect, scene: Scene): void;
  12737. protected _buildBlock(state: NodeMaterialBuildState): void;
  12738. protected _dumpPropertiesCode(): string;
  12739. dispose(): void;
  12740. serialize(): any;
  12741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12742. }
  12743. }
  12744. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12745. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12746. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12747. import { Nullable } from "babylonjs/types";
  12748. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12749. import { Observable } from "babylonjs/Misc/observable";
  12750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12751. /**
  12752. * Enum used to define the compatibility state between two connection points
  12753. */
  12754. export enum NodeMaterialConnectionPointCompatibilityStates {
  12755. /** Points are compatibles */
  12756. Compatible = 0,
  12757. /** Points are incompatible because of their types */
  12758. TypeIncompatible = 1,
  12759. /** Points are incompatible because of their targets (vertex vs fragment) */
  12760. TargetIncompatible = 2
  12761. }
  12762. /**
  12763. * Defines the direction of a connection point
  12764. */
  12765. export enum NodeMaterialConnectionPointDirection {
  12766. /** Input */
  12767. Input = 0,
  12768. /** Output */
  12769. Output = 1
  12770. }
  12771. /**
  12772. * Defines a connection point for a block
  12773. */
  12774. export class NodeMaterialConnectionPoint {
  12775. /**
  12776. * Checks if two types are equivalent
  12777. * @param type1 type 1 to check
  12778. * @param type2 type 2 to check
  12779. * @returns true if both types are equivalent, else false
  12780. */
  12781. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12782. /** @hidden */
  12783. _ownerBlock: NodeMaterialBlock;
  12784. /** @hidden */
  12785. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12786. private _endpoints;
  12787. private _associatedVariableName;
  12788. private _direction;
  12789. /** @hidden */
  12790. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12791. /** @hidden */
  12792. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12793. /** @hidden */
  12794. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12795. private _type;
  12796. /** @hidden */
  12797. _enforceAssociatedVariableName: boolean;
  12798. /** Gets the direction of the point */
  12799. get direction(): NodeMaterialConnectionPointDirection;
  12800. /** Indicates that this connection point needs dual validation before being connected to another point */
  12801. needDualDirectionValidation: boolean;
  12802. /**
  12803. * Gets or sets the additional types supported by this connection point
  12804. */
  12805. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12806. /**
  12807. * Gets or sets the additional types excluded by this connection point
  12808. */
  12809. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12810. /**
  12811. * Observable triggered when this point is connected
  12812. */
  12813. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12814. /**
  12815. * Gets or sets the associated variable name in the shader
  12816. */
  12817. get associatedVariableName(): string;
  12818. set associatedVariableName(value: string);
  12819. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12820. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12821. /**
  12822. * Gets or sets the connection point type (default is float)
  12823. */
  12824. get type(): NodeMaterialBlockConnectionPointTypes;
  12825. set type(value: NodeMaterialBlockConnectionPointTypes);
  12826. /**
  12827. * Gets or sets the connection point name
  12828. */
  12829. name: string;
  12830. /**
  12831. * Gets or sets the connection point name
  12832. */
  12833. displayName: string;
  12834. /**
  12835. * Gets or sets a boolean indicating that this connection point can be omitted
  12836. */
  12837. isOptional: boolean;
  12838. /**
  12839. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12840. */
  12841. isExposedOnFrame: boolean;
  12842. /**
  12843. * Gets or sets number indicating the position that the port is exposed to on a frame
  12844. */
  12845. exposedPortPosition: number;
  12846. /**
  12847. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12848. */
  12849. define: string;
  12850. /** @hidden */
  12851. _prioritizeVertex: boolean;
  12852. private _target;
  12853. /** Gets or sets the target of that connection point */
  12854. get target(): NodeMaterialBlockTargets;
  12855. set target(value: NodeMaterialBlockTargets);
  12856. /**
  12857. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12858. */
  12859. get isConnected(): boolean;
  12860. /**
  12861. * Gets a boolean indicating that the current point is connected to an input block
  12862. */
  12863. get isConnectedToInputBlock(): boolean;
  12864. /**
  12865. * Gets a the connected input block (if any)
  12866. */
  12867. get connectInputBlock(): Nullable<InputBlock>;
  12868. /** Get the other side of the connection (if any) */
  12869. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12870. /** Get the block that owns this connection point */
  12871. get ownerBlock(): NodeMaterialBlock;
  12872. /** Get the block connected on the other side of this connection (if any) */
  12873. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12874. /** Get the block connected on the endpoints of this connection (if any) */
  12875. get connectedBlocks(): Array<NodeMaterialBlock>;
  12876. /** Gets the list of connected endpoints */
  12877. get endpoints(): NodeMaterialConnectionPoint[];
  12878. /** Gets a boolean indicating if that output point is connected to at least one input */
  12879. get hasEndpoints(): boolean;
  12880. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12881. get isConnectedInVertexShader(): boolean;
  12882. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12883. get isConnectedInFragmentShader(): boolean;
  12884. /**
  12885. * Creates a block suitable to be used as an input for this input point.
  12886. * If null is returned, a block based on the point type will be created.
  12887. * @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
  12888. */
  12889. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12890. /**
  12891. * Creates a new connection point
  12892. * @param name defines the connection point name
  12893. * @param ownerBlock defines the block hosting this connection point
  12894. * @param direction defines the direction of the connection point
  12895. */
  12896. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12897. /**
  12898. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12899. * @returns the class name
  12900. */
  12901. getClassName(): string;
  12902. /**
  12903. * Gets a boolean indicating if the current point can be connected to another point
  12904. * @param connectionPoint defines the other connection point
  12905. * @returns a boolean
  12906. */
  12907. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12908. /**
  12909. * Gets a number indicating if the current point can be connected to another point
  12910. * @param connectionPoint defines the other connection point
  12911. * @returns a number defining the compatibility state
  12912. */
  12913. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12914. /**
  12915. * Connect this point to another connection point
  12916. * @param connectionPoint defines the other connection point
  12917. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12918. * @returns the current connection point
  12919. */
  12920. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12921. /**
  12922. * Disconnect this point from one of his endpoint
  12923. * @param endpoint defines the other connection point
  12924. * @returns the current connection point
  12925. */
  12926. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12927. /**
  12928. * Serializes this point in a JSON representation
  12929. * @param isInput defines if the connection point is an input (default is true)
  12930. * @returns the serialized point object
  12931. */
  12932. serialize(isInput?: boolean): any;
  12933. /**
  12934. * Release resources
  12935. */
  12936. dispose(): void;
  12937. }
  12938. }
  12939. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12940. /**
  12941. * Enum used to define the material modes
  12942. */
  12943. export enum NodeMaterialModes {
  12944. /** Regular material */
  12945. Material = 0,
  12946. /** For post process */
  12947. PostProcess = 1,
  12948. /** For particle system */
  12949. Particle = 2,
  12950. /** For procedural texture */
  12951. ProceduralTexture = 3
  12952. }
  12953. }
  12954. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12955. /** @hidden */
  12956. export var helperFunctions: {
  12957. name: string;
  12958. shader: string;
  12959. };
  12960. }
  12961. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12964. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12967. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12968. import { Effect } from "babylonjs/Materials/effect";
  12969. import { Mesh } from "babylonjs/Meshes/mesh";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Texture } from "babylonjs/Materials/Textures/texture";
  12972. import { Scene } from "babylonjs/scene";
  12973. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12974. /**
  12975. * Block used to read a texture from a sampler
  12976. */
  12977. export class TextureBlock extends NodeMaterialBlock {
  12978. private _defineName;
  12979. private _linearDefineName;
  12980. private _gammaDefineName;
  12981. private _tempTextureRead;
  12982. private _samplerName;
  12983. private _transformedUVName;
  12984. private _textureTransformName;
  12985. private _textureInfoName;
  12986. private _mainUVName;
  12987. private _mainUVDefineName;
  12988. private _fragmentOnly;
  12989. /**
  12990. * Gets or sets the texture associated with the node
  12991. */
  12992. texture: Nullable<Texture>;
  12993. /**
  12994. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12995. */
  12996. convertToGammaSpace: boolean;
  12997. /**
  12998. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12999. */
  13000. convertToLinearSpace: boolean;
  13001. /**
  13002. * Create a new TextureBlock
  13003. * @param name defines the block name
  13004. */
  13005. constructor(name: string, fragmentOnly?: boolean);
  13006. /**
  13007. * Gets the current class name
  13008. * @returns the class name
  13009. */
  13010. getClassName(): string;
  13011. /**
  13012. * Gets the uv input component
  13013. */
  13014. get uv(): NodeMaterialConnectionPoint;
  13015. /**
  13016. * Gets the rgba output component
  13017. */
  13018. get rgba(): NodeMaterialConnectionPoint;
  13019. /**
  13020. * Gets the rgb output component
  13021. */
  13022. get rgb(): NodeMaterialConnectionPoint;
  13023. /**
  13024. * Gets the r output component
  13025. */
  13026. get r(): NodeMaterialConnectionPoint;
  13027. /**
  13028. * Gets the g output component
  13029. */
  13030. get g(): NodeMaterialConnectionPoint;
  13031. /**
  13032. * Gets the b output component
  13033. */
  13034. get b(): NodeMaterialConnectionPoint;
  13035. /**
  13036. * Gets the a output component
  13037. */
  13038. get a(): NodeMaterialConnectionPoint;
  13039. get target(): NodeMaterialBlockTargets;
  13040. autoConfigure(material: NodeMaterial): void;
  13041. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13043. isReady(): boolean;
  13044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13045. private get _isMixed();
  13046. private _injectVertexCode;
  13047. private _writeTextureRead;
  13048. private _writeOutput;
  13049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13050. protected _dumpPropertiesCode(): string;
  13051. serialize(): any;
  13052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13053. }
  13054. }
  13055. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  13056. /** @hidden */
  13057. export var reflectionFunction: {
  13058. name: string;
  13059. shader: string;
  13060. };
  13061. }
  13062. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  13063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13068. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13069. import { Effect } from "babylonjs/Materials/effect";
  13070. import { Mesh } from "babylonjs/Meshes/mesh";
  13071. import { Nullable } from "babylonjs/types";
  13072. import { Scene } from "babylonjs/scene";
  13073. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  13074. /**
  13075. * Base block used to read a reflection texture from a sampler
  13076. */
  13077. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  13078. /** @hidden */
  13079. _define3DName: string;
  13080. /** @hidden */
  13081. _defineCubicName: string;
  13082. /** @hidden */
  13083. _defineExplicitName: string;
  13084. /** @hidden */
  13085. _defineProjectionName: string;
  13086. /** @hidden */
  13087. _defineLocalCubicName: string;
  13088. /** @hidden */
  13089. _defineSphericalName: string;
  13090. /** @hidden */
  13091. _definePlanarName: string;
  13092. /** @hidden */
  13093. _defineEquirectangularName: string;
  13094. /** @hidden */
  13095. _defineMirroredEquirectangularFixedName: string;
  13096. /** @hidden */
  13097. _defineEquirectangularFixedName: string;
  13098. /** @hidden */
  13099. _defineSkyboxName: string;
  13100. /** @hidden */
  13101. _defineOppositeZ: string;
  13102. /** @hidden */
  13103. _cubeSamplerName: string;
  13104. /** @hidden */
  13105. _2DSamplerName: string;
  13106. protected _positionUVWName: string;
  13107. protected _directionWName: string;
  13108. protected _reflectionVectorName: string;
  13109. /** @hidden */
  13110. _reflectionCoordsName: string;
  13111. /** @hidden */
  13112. _reflectionMatrixName: string;
  13113. protected _reflectionColorName: string;
  13114. /**
  13115. * Gets or sets the texture associated with the node
  13116. */
  13117. texture: Nullable<BaseTexture>;
  13118. /**
  13119. * Create a new ReflectionTextureBaseBlock
  13120. * @param name defines the block name
  13121. */
  13122. constructor(name: string);
  13123. /**
  13124. * Gets the current class name
  13125. * @returns the class name
  13126. */
  13127. getClassName(): string;
  13128. /**
  13129. * Gets the world position input component
  13130. */
  13131. abstract get position(): NodeMaterialConnectionPoint;
  13132. /**
  13133. * Gets the world position input component
  13134. */
  13135. abstract get worldPosition(): NodeMaterialConnectionPoint;
  13136. /**
  13137. * Gets the world normal input component
  13138. */
  13139. abstract get worldNormal(): NodeMaterialConnectionPoint;
  13140. /**
  13141. * Gets the world input component
  13142. */
  13143. abstract get world(): NodeMaterialConnectionPoint;
  13144. /**
  13145. * Gets the camera (or eye) position component
  13146. */
  13147. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  13148. /**
  13149. * Gets the view input component
  13150. */
  13151. abstract get view(): NodeMaterialConnectionPoint;
  13152. protected _getTexture(): Nullable<BaseTexture>;
  13153. autoConfigure(material: NodeMaterial): void;
  13154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13155. isReady(): boolean;
  13156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13157. /**
  13158. * Gets the code to inject in the vertex shader
  13159. * @param state current state of the node material building
  13160. * @returns the shader code
  13161. */
  13162. handleVertexSide(state: NodeMaterialBuildState): string;
  13163. /**
  13164. * Handles the inits for the fragment code path
  13165. * @param state node material build state
  13166. */
  13167. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13168. /**
  13169. * Generates the reflection coords code for the fragment code path
  13170. * @param worldNormalVarName name of the world normal variable
  13171. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13172. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13173. * @returns the shader code
  13174. */
  13175. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13176. /**
  13177. * Generates the reflection color code for the fragment code path
  13178. * @param lodVarName name of the lod variable
  13179. * @param swizzleLookupTexture swizzle to use for the final color variable
  13180. * @returns the shader code
  13181. */
  13182. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13183. /**
  13184. * Generates the code corresponding to the connected output points
  13185. * @param state node material build state
  13186. * @param varName name of the variable to output
  13187. * @returns the shader code
  13188. */
  13189. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13190. protected _buildBlock(state: NodeMaterialBuildState): this;
  13191. protected _dumpPropertiesCode(): string;
  13192. serialize(): any;
  13193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13194. }
  13195. }
  13196. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  13197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13198. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13199. import { Nullable } from "babylonjs/types";
  13200. /**
  13201. * Defines a connection point to be used for points with a custom object type
  13202. */
  13203. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13204. private _blockType;
  13205. private _blockName;
  13206. private _nameForCheking?;
  13207. /**
  13208. * Creates a new connection point
  13209. * @param name defines the connection point name
  13210. * @param ownerBlock defines the block hosting this connection point
  13211. * @param direction defines the direction of the connection point
  13212. */
  13213. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13214. /**
  13215. * Gets a number indicating if the current point can be connected to another point
  13216. * @param connectionPoint defines the other connection point
  13217. * @returns a number defining the compatibility state
  13218. */
  13219. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13220. /**
  13221. * Creates a block suitable to be used as an input for this input point.
  13222. * If null is returned, a block based on the point type will be created.
  13223. * @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
  13224. */
  13225. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13226. }
  13227. }
  13228. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  13229. /**
  13230. * Enum defining the type of properties that can be edited in the property pages in the NME
  13231. */
  13232. export enum PropertyTypeForEdition {
  13233. /** property is a boolean */
  13234. Boolean = 0,
  13235. /** property is a float */
  13236. Float = 1,
  13237. /** property is a Vector2 */
  13238. Vector2 = 2,
  13239. /** property is a list of values */
  13240. List = 3
  13241. }
  13242. /**
  13243. * Interface that defines an option in a variable of type list
  13244. */
  13245. export interface IEditablePropertyListOption {
  13246. /** label of the option */
  13247. "label": string;
  13248. /** value of the option */
  13249. "value": number;
  13250. }
  13251. /**
  13252. * Interface that defines the options available for an editable property
  13253. */
  13254. export interface IEditablePropertyOption {
  13255. /** min value */
  13256. "min"?: number;
  13257. /** max value */
  13258. "max"?: number;
  13259. /** notifiers: indicates which actions to take when the property is changed */
  13260. "notifiers"?: {
  13261. /** the material should be rebuilt */
  13262. "rebuild"?: boolean;
  13263. /** the preview should be updated */
  13264. "update"?: boolean;
  13265. };
  13266. /** list of the options for a variable of type list */
  13267. "options"?: IEditablePropertyListOption[];
  13268. }
  13269. /**
  13270. * Interface that describes an editable property
  13271. */
  13272. export interface IPropertyDescriptionForEdition {
  13273. /** name of the property */
  13274. "propertyName": string;
  13275. /** display name of the property */
  13276. "displayName": string;
  13277. /** type of the property */
  13278. "type": PropertyTypeForEdition;
  13279. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13280. "groupName": string;
  13281. /** options for the property */
  13282. "options": IEditablePropertyOption;
  13283. }
  13284. /**
  13285. * Decorator that flags a property in a node material block as being editable
  13286. */
  13287. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13288. }
  13289. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  13290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13292. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13294. import { Nullable } from "babylonjs/types";
  13295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13296. import { Mesh } from "babylonjs/Meshes/mesh";
  13297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13298. import { Effect } from "babylonjs/Materials/effect";
  13299. import { Scene } from "babylonjs/scene";
  13300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13301. /**
  13302. * Block used to implement the refraction part of the sub surface module of the PBR material
  13303. */
  13304. export class RefractionBlock extends NodeMaterialBlock {
  13305. /** @hidden */
  13306. _define3DName: string;
  13307. /** @hidden */
  13308. _refractionMatrixName: string;
  13309. /** @hidden */
  13310. _defineLODRefractionAlpha: string;
  13311. /** @hidden */
  13312. _defineLinearSpecularRefraction: string;
  13313. /** @hidden */
  13314. _defineOppositeZ: string;
  13315. /** @hidden */
  13316. _cubeSamplerName: string;
  13317. /** @hidden */
  13318. _2DSamplerName: string;
  13319. /** @hidden */
  13320. _vRefractionMicrosurfaceInfosName: string;
  13321. /** @hidden */
  13322. _vRefractionInfosName: string;
  13323. /** @hidden */
  13324. _vRefractionFilteringInfoName: string;
  13325. private _scene;
  13326. /**
  13327. * The properties below are set by the main PBR block prior to calling methods of this class.
  13328. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13329. * It's less burden on the user side in the editor part.
  13330. */
  13331. /** @hidden */
  13332. viewConnectionPoint: NodeMaterialConnectionPoint;
  13333. /** @hidden */
  13334. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13335. /**
  13336. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13337. * Materials half opaque for instance using refraction could benefit from this control.
  13338. */
  13339. linkRefractionWithTransparency: boolean;
  13340. /**
  13341. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13342. */
  13343. invertRefractionY: boolean;
  13344. /**
  13345. * Gets or sets the texture associated with the node
  13346. */
  13347. texture: Nullable<BaseTexture>;
  13348. /**
  13349. * Create a new RefractionBlock
  13350. * @param name defines the block name
  13351. */
  13352. constructor(name: string);
  13353. /**
  13354. * Gets the current class name
  13355. * @returns the class name
  13356. */
  13357. getClassName(): string;
  13358. /**
  13359. * Gets the intensity input component
  13360. */
  13361. get intensity(): NodeMaterialConnectionPoint;
  13362. /**
  13363. * Gets the tint at distance input component
  13364. */
  13365. get tintAtDistance(): NodeMaterialConnectionPoint;
  13366. /**
  13367. * Gets the view input component
  13368. */
  13369. get view(): NodeMaterialConnectionPoint;
  13370. /**
  13371. * Gets the refraction object output component
  13372. */
  13373. get refraction(): NodeMaterialConnectionPoint;
  13374. /**
  13375. * Returns true if the block has a texture
  13376. */
  13377. get hasTexture(): boolean;
  13378. protected _getTexture(): Nullable<BaseTexture>;
  13379. autoConfigure(material: NodeMaterial): void;
  13380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13381. isReady(): boolean;
  13382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13383. /**
  13384. * Gets the main code of the block (fragment side)
  13385. * @param state current state of the node material building
  13386. * @returns the shader code
  13387. */
  13388. getCode(state: NodeMaterialBuildState): string;
  13389. protected _buildBlock(state: NodeMaterialBuildState): this;
  13390. protected _dumpPropertiesCode(): string;
  13391. serialize(): any;
  13392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13393. }
  13394. }
  13395. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  13396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13398. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13401. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13403. import { Nullable } from "babylonjs/types";
  13404. import { Scene } from "babylonjs/scene";
  13405. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13406. /**
  13407. * Base block used as input for post process
  13408. */
  13409. export class CurrentScreenBlock extends NodeMaterialBlock {
  13410. private _samplerName;
  13411. private _linearDefineName;
  13412. private _gammaDefineName;
  13413. private _mainUVName;
  13414. private _tempTextureRead;
  13415. /**
  13416. * Gets or sets the texture associated with the node
  13417. */
  13418. texture: Nullable<BaseTexture>;
  13419. /**
  13420. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13421. */
  13422. convertToGammaSpace: boolean;
  13423. /**
  13424. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13425. */
  13426. convertToLinearSpace: boolean;
  13427. /**
  13428. * Create a new CurrentScreenBlock
  13429. * @param name defines the block name
  13430. */
  13431. constructor(name: string);
  13432. /**
  13433. * Gets the current class name
  13434. * @returns the class name
  13435. */
  13436. getClassName(): string;
  13437. /**
  13438. * Gets the uv input component
  13439. */
  13440. get uv(): NodeMaterialConnectionPoint;
  13441. /**
  13442. * Gets the rgba output component
  13443. */
  13444. get rgba(): NodeMaterialConnectionPoint;
  13445. /**
  13446. * Gets the rgb output component
  13447. */
  13448. get rgb(): NodeMaterialConnectionPoint;
  13449. /**
  13450. * Gets the r output component
  13451. */
  13452. get r(): NodeMaterialConnectionPoint;
  13453. /**
  13454. * Gets the g output component
  13455. */
  13456. get g(): NodeMaterialConnectionPoint;
  13457. /**
  13458. * Gets the b output component
  13459. */
  13460. get b(): NodeMaterialConnectionPoint;
  13461. /**
  13462. * Gets the a output component
  13463. */
  13464. get a(): NodeMaterialConnectionPoint;
  13465. /**
  13466. * Initialize the block and prepare the context for build
  13467. * @param state defines the state that will be used for the build
  13468. */
  13469. initialize(state: NodeMaterialBuildState): void;
  13470. get target(): NodeMaterialBlockTargets;
  13471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13472. isReady(): boolean;
  13473. private _injectVertexCode;
  13474. private _writeTextureRead;
  13475. private _writeOutput;
  13476. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13477. serialize(): any;
  13478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13479. }
  13480. }
  13481. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  13482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13486. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13488. import { Nullable } from "babylonjs/types";
  13489. import { Scene } from "babylonjs/scene";
  13490. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13491. /**
  13492. * Base block used for the particle texture
  13493. */
  13494. export class ParticleTextureBlock extends NodeMaterialBlock {
  13495. private _samplerName;
  13496. private _linearDefineName;
  13497. private _gammaDefineName;
  13498. private _tempTextureRead;
  13499. /**
  13500. * Gets or sets the texture associated with the node
  13501. */
  13502. texture: Nullable<BaseTexture>;
  13503. /**
  13504. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13505. */
  13506. convertToGammaSpace: boolean;
  13507. /**
  13508. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13509. */
  13510. convertToLinearSpace: boolean;
  13511. /**
  13512. * Create a new ParticleTextureBlock
  13513. * @param name defines the block name
  13514. */
  13515. constructor(name: string);
  13516. /**
  13517. * Gets the current class name
  13518. * @returns the class name
  13519. */
  13520. getClassName(): string;
  13521. /**
  13522. * Gets the uv input component
  13523. */
  13524. get uv(): NodeMaterialConnectionPoint;
  13525. /**
  13526. * Gets the rgba output component
  13527. */
  13528. get rgba(): NodeMaterialConnectionPoint;
  13529. /**
  13530. * Gets the rgb output component
  13531. */
  13532. get rgb(): NodeMaterialConnectionPoint;
  13533. /**
  13534. * Gets the r output component
  13535. */
  13536. get r(): NodeMaterialConnectionPoint;
  13537. /**
  13538. * Gets the g output component
  13539. */
  13540. get g(): NodeMaterialConnectionPoint;
  13541. /**
  13542. * Gets the b output component
  13543. */
  13544. get b(): NodeMaterialConnectionPoint;
  13545. /**
  13546. * Gets the a output component
  13547. */
  13548. get a(): NodeMaterialConnectionPoint;
  13549. /**
  13550. * Initialize the block and prepare the context for build
  13551. * @param state defines the state that will be used for the build
  13552. */
  13553. initialize(state: NodeMaterialBuildState): void;
  13554. autoConfigure(material: NodeMaterial): void;
  13555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13556. isReady(): boolean;
  13557. private _writeOutput;
  13558. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13559. serialize(): any;
  13560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13561. }
  13562. }
  13563. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  13564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13566. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  13567. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  13568. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  13569. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  13570. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  13571. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  13572. import { Scene } from "babylonjs/scene";
  13573. /**
  13574. * Class used to store shared data between 2 NodeMaterialBuildState
  13575. */
  13576. export class NodeMaterialBuildStateSharedData {
  13577. /**
  13578. * Gets the list of emitted varyings
  13579. */
  13580. temps: string[];
  13581. /**
  13582. * Gets the list of emitted varyings
  13583. */
  13584. varyings: string[];
  13585. /**
  13586. * Gets the varying declaration string
  13587. */
  13588. varyingDeclaration: string;
  13589. /**
  13590. * Input blocks
  13591. */
  13592. inputBlocks: InputBlock[];
  13593. /**
  13594. * Input blocks
  13595. */
  13596. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13597. /**
  13598. * Bindable blocks (Blocks that need to set data to the effect)
  13599. */
  13600. bindableBlocks: NodeMaterialBlock[];
  13601. /**
  13602. * List of blocks that can provide a compilation fallback
  13603. */
  13604. blocksWithFallbacks: NodeMaterialBlock[];
  13605. /**
  13606. * List of blocks that can provide a define update
  13607. */
  13608. blocksWithDefines: NodeMaterialBlock[];
  13609. /**
  13610. * List of blocks that can provide a repeatable content
  13611. */
  13612. repeatableContentBlocks: NodeMaterialBlock[];
  13613. /**
  13614. * List of blocks that can provide a dynamic list of uniforms
  13615. */
  13616. dynamicUniformBlocks: NodeMaterialBlock[];
  13617. /**
  13618. * List of blocks that can block the isReady function for the material
  13619. */
  13620. blockingBlocks: NodeMaterialBlock[];
  13621. /**
  13622. * Gets the list of animated inputs
  13623. */
  13624. animatedInputs: InputBlock[];
  13625. /**
  13626. * Build Id used to avoid multiple recompilations
  13627. */
  13628. buildId: number;
  13629. /** List of emitted variables */
  13630. variableNames: {
  13631. [key: string]: number;
  13632. };
  13633. /** List of emitted defines */
  13634. defineNames: {
  13635. [key: string]: number;
  13636. };
  13637. /** Should emit comments? */
  13638. emitComments: boolean;
  13639. /** Emit build activity */
  13640. verbose: boolean;
  13641. /** Gets or sets the hosting scene */
  13642. scene: Scene;
  13643. /**
  13644. * Gets the compilation hints emitted at compilation time
  13645. */
  13646. hints: {
  13647. needWorldViewMatrix: boolean;
  13648. needWorldViewProjectionMatrix: boolean;
  13649. needAlphaBlending: boolean;
  13650. needAlphaTesting: boolean;
  13651. };
  13652. /**
  13653. * List of compilation checks
  13654. */
  13655. checks: {
  13656. emitVertex: boolean;
  13657. emitFragment: boolean;
  13658. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13659. };
  13660. /**
  13661. * Is vertex program allowed to be empty?
  13662. */
  13663. allowEmptyVertexProgram: boolean;
  13664. /** Creates a new shared data */
  13665. constructor();
  13666. /**
  13667. * Emits console errors and exceptions if there is a failing check
  13668. */
  13669. emitErrors(): void;
  13670. }
  13671. }
  13672. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13673. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13674. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13675. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13676. /**
  13677. * Class used to store node based material build state
  13678. */
  13679. export class NodeMaterialBuildState {
  13680. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13681. supportUniformBuffers: boolean;
  13682. /**
  13683. * Gets the list of emitted attributes
  13684. */
  13685. attributes: string[];
  13686. /**
  13687. * Gets the list of emitted uniforms
  13688. */
  13689. uniforms: string[];
  13690. /**
  13691. * Gets the list of emitted constants
  13692. */
  13693. constants: string[];
  13694. /**
  13695. * Gets the list of emitted samplers
  13696. */
  13697. samplers: string[];
  13698. /**
  13699. * Gets the list of emitted functions
  13700. */
  13701. functions: {
  13702. [key: string]: string;
  13703. };
  13704. /**
  13705. * Gets the list of emitted extensions
  13706. */
  13707. extensions: {
  13708. [key: string]: string;
  13709. };
  13710. /**
  13711. * Gets the target of the compilation state
  13712. */
  13713. target: NodeMaterialBlockTargets;
  13714. /**
  13715. * Gets the list of emitted counters
  13716. */
  13717. counters: {
  13718. [key: string]: number;
  13719. };
  13720. /**
  13721. * Shared data between multiple NodeMaterialBuildState instances
  13722. */
  13723. sharedData: NodeMaterialBuildStateSharedData;
  13724. /** @hidden */
  13725. _vertexState: NodeMaterialBuildState;
  13726. /** @hidden */
  13727. _attributeDeclaration: string;
  13728. /** @hidden */
  13729. _uniformDeclaration: string;
  13730. /** @hidden */
  13731. _constantDeclaration: string;
  13732. /** @hidden */
  13733. _samplerDeclaration: string;
  13734. /** @hidden */
  13735. _varyingTransfer: string;
  13736. /** @hidden */
  13737. _injectAtEnd: string;
  13738. private _repeatableContentAnchorIndex;
  13739. /** @hidden */
  13740. _builtCompilationString: string;
  13741. /**
  13742. * Gets the emitted compilation strings
  13743. */
  13744. compilationString: string;
  13745. /**
  13746. * Finalize the compilation strings
  13747. * @param state defines the current compilation state
  13748. */
  13749. finalize(state: NodeMaterialBuildState): void;
  13750. /** @hidden */
  13751. get _repeatableContentAnchor(): string;
  13752. /** @hidden */
  13753. _getFreeVariableName(prefix: string): string;
  13754. /** @hidden */
  13755. _getFreeDefineName(prefix: string): string;
  13756. /** @hidden */
  13757. _excludeVariableName(name: string): void;
  13758. /** @hidden */
  13759. _emit2DSampler(name: string): void;
  13760. /** @hidden */
  13761. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13762. /** @hidden */
  13763. _emitExtension(name: string, extension: string, define?: string): void;
  13764. /** @hidden */
  13765. _emitFunction(name: string, code: string, comments: string): void;
  13766. /** @hidden */
  13767. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13768. replaceStrings?: {
  13769. search: RegExp;
  13770. replace: string;
  13771. }[];
  13772. repeatKey?: string;
  13773. }): string;
  13774. /** @hidden */
  13775. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13776. repeatKey?: string;
  13777. removeAttributes?: boolean;
  13778. removeUniforms?: boolean;
  13779. removeVaryings?: boolean;
  13780. removeIfDef?: boolean;
  13781. replaceStrings?: {
  13782. search: RegExp;
  13783. replace: string;
  13784. }[];
  13785. }, storeKey?: string): void;
  13786. /** @hidden */
  13787. _registerTempVariable(name: string): boolean;
  13788. /** @hidden */
  13789. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13790. /** @hidden */
  13791. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13792. /** @hidden */
  13793. _emitFloat(value: number): string;
  13794. }
  13795. }
  13796. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13797. /**
  13798. * Helper class used to generate session unique ID
  13799. */
  13800. export class UniqueIdGenerator {
  13801. private static _UniqueIdCounter;
  13802. /**
  13803. * Gets an unique (relatively to the current scene) Id
  13804. */
  13805. static get UniqueId(): number;
  13806. }
  13807. }
  13808. declare module "babylonjs/Materials/effectFallbacks" {
  13809. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13810. import { Effect } from "babylonjs/Materials/effect";
  13811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13812. /**
  13813. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13814. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13815. */
  13816. export class EffectFallbacks implements IEffectFallbacks {
  13817. private _defines;
  13818. private _currentRank;
  13819. private _maxRank;
  13820. private _mesh;
  13821. /**
  13822. * Removes the fallback from the bound mesh.
  13823. */
  13824. unBindMesh(): void;
  13825. /**
  13826. * Adds a fallback on the specified property.
  13827. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13828. * @param define The name of the define in the shader
  13829. */
  13830. addFallback(rank: number, define: string): void;
  13831. /**
  13832. * Sets the mesh to use CPU skinning when needing to fallback.
  13833. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13834. * @param mesh The mesh to use the fallbacks.
  13835. */
  13836. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13837. /**
  13838. * Checks to see if more fallbacks are still availible.
  13839. */
  13840. get hasMoreFallbacks(): boolean;
  13841. /**
  13842. * Removes the defines that should be removed when falling back.
  13843. * @param currentDefines defines the current define statements for the shader.
  13844. * @param effect defines the current effect we try to compile
  13845. * @returns The resulting defines with defines of the current rank removed.
  13846. */
  13847. reduce(currentDefines: string, effect: Effect): string;
  13848. }
  13849. }
  13850. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13851. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13853. import { Nullable } from "babylonjs/types";
  13854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13855. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13856. import { Effect } from "babylonjs/Materials/effect";
  13857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13858. import { Mesh } from "babylonjs/Meshes/mesh";
  13859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13860. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13861. import { Scene } from "babylonjs/scene";
  13862. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13863. /**
  13864. * Defines a block that can be used inside a node based material
  13865. */
  13866. export class NodeMaterialBlock {
  13867. private _buildId;
  13868. private _buildTarget;
  13869. private _target;
  13870. private _isFinalMerger;
  13871. private _isInput;
  13872. private _name;
  13873. protected _isUnique: boolean;
  13874. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13875. inputsAreExclusive: boolean;
  13876. /** @hidden */
  13877. _codeVariableName: string;
  13878. /** @hidden */
  13879. _inputs: NodeMaterialConnectionPoint[];
  13880. /** @hidden */
  13881. _outputs: NodeMaterialConnectionPoint[];
  13882. /** @hidden */
  13883. _preparationId: number;
  13884. /**
  13885. * Gets the name of the block
  13886. */
  13887. get name(): string;
  13888. /**
  13889. * Sets the name of the block. Will check if the name is valid.
  13890. */
  13891. set name(newName: string);
  13892. /**
  13893. * Gets or sets the unique id of the node
  13894. */
  13895. uniqueId: number;
  13896. /**
  13897. * Gets or sets the comments associated with this block
  13898. */
  13899. comments: string;
  13900. /**
  13901. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13902. */
  13903. get isUnique(): boolean;
  13904. /**
  13905. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13906. */
  13907. get isFinalMerger(): boolean;
  13908. /**
  13909. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13910. */
  13911. get isInput(): boolean;
  13912. /**
  13913. * Gets or sets the build Id
  13914. */
  13915. get buildId(): number;
  13916. set buildId(value: number);
  13917. /**
  13918. * Gets or sets the target of the block
  13919. */
  13920. get target(): NodeMaterialBlockTargets;
  13921. set target(value: NodeMaterialBlockTargets);
  13922. /**
  13923. * Gets the list of input points
  13924. */
  13925. get inputs(): NodeMaterialConnectionPoint[];
  13926. /** Gets the list of output points */
  13927. get outputs(): NodeMaterialConnectionPoint[];
  13928. /**
  13929. * Find an input by its name
  13930. * @param name defines the name of the input to look for
  13931. * @returns the input or null if not found
  13932. */
  13933. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13934. /**
  13935. * Find an output by its name
  13936. * @param name defines the name of the outputto look for
  13937. * @returns the output or null if not found
  13938. */
  13939. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13940. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13941. visibleInInspector: boolean;
  13942. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13943. visibleOnFrame: boolean;
  13944. /**
  13945. * Creates a new NodeMaterialBlock
  13946. * @param name defines the block name
  13947. * @param target defines the target of that block (Vertex by default)
  13948. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13949. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13950. */
  13951. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13952. /**
  13953. * Initialize the block and prepare the context for build
  13954. * @param state defines the state that will be used for the build
  13955. */
  13956. initialize(state: NodeMaterialBuildState): void;
  13957. /**
  13958. * Bind data to effect. Will only be called for blocks with isBindable === true
  13959. * @param effect defines the effect to bind data to
  13960. * @param nodeMaterial defines the hosting NodeMaterial
  13961. * @param mesh defines the mesh that will be rendered
  13962. * @param subMesh defines the submesh that will be rendered
  13963. */
  13964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13965. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13966. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13967. protected _writeFloat(value: number): string;
  13968. /**
  13969. * Gets the current class name e.g. "NodeMaterialBlock"
  13970. * @returns the class name
  13971. */
  13972. getClassName(): string;
  13973. /**
  13974. * Register a new input. Must be called inside a block constructor
  13975. * @param name defines the connection point name
  13976. * @param type defines the connection point type
  13977. * @param isOptional defines a boolean indicating that this input can be omitted
  13978. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13979. * @param point an already created connection point. If not provided, create a new one
  13980. * @returns the current block
  13981. */
  13982. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13983. /**
  13984. * Register a new output. Must be called inside a block constructor
  13985. * @param name defines the connection point name
  13986. * @param type defines the connection point type
  13987. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13988. * @param point an already created connection point. If not provided, create a new one
  13989. * @returns the current block
  13990. */
  13991. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13992. /**
  13993. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13994. * @param forOutput defines an optional connection point to check compatibility with
  13995. * @returns the first available input or null
  13996. */
  13997. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13998. /**
  13999. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  14000. * @param forBlock defines an optional block to check compatibility with
  14001. * @returns the first available input or null
  14002. */
  14003. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  14004. /**
  14005. * Gets the sibling of the given output
  14006. * @param current defines the current output
  14007. * @returns the next output in the list or null
  14008. */
  14009. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  14010. /**
  14011. * Connect current block with another block
  14012. * @param other defines the block to connect with
  14013. * @param options define the various options to help pick the right connections
  14014. * @returns the current block
  14015. */
  14016. connectTo(other: NodeMaterialBlock, options?: {
  14017. input?: string;
  14018. output?: string;
  14019. outputSwizzle?: string;
  14020. }): this | undefined;
  14021. protected _buildBlock(state: NodeMaterialBuildState): void;
  14022. /**
  14023. * Add uniforms, samplers and uniform buffers at compilation time
  14024. * @param state defines the state to update
  14025. * @param nodeMaterial defines the node material requesting the update
  14026. * @param defines defines the material defines to update
  14027. * @param uniformBuffers defines the list of uniform buffer names
  14028. */
  14029. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  14030. /**
  14031. * Add potential fallbacks if shader compilation fails
  14032. * @param mesh defines the mesh to be rendered
  14033. * @param fallbacks defines the current prioritized list of fallbacks
  14034. */
  14035. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  14036. /**
  14037. * Initialize defines for shader compilation
  14038. * @param mesh defines the mesh to be rendered
  14039. * @param nodeMaterial defines the node material requesting the update
  14040. * @param defines defines the material defines to update
  14041. * @param useInstances specifies that instances should be used
  14042. */
  14043. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  14044. /**
  14045. * Update defines for shader compilation
  14046. * @param mesh defines the mesh to be rendered
  14047. * @param nodeMaterial defines the node material requesting the update
  14048. * @param defines defines the material defines to update
  14049. * @param useInstances specifies that instances should be used
  14050. * @param subMesh defines which submesh to render
  14051. */
  14052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14053. /**
  14054. * Lets the block try to connect some inputs automatically
  14055. * @param material defines the hosting NodeMaterial
  14056. */
  14057. autoConfigure(material: NodeMaterial): void;
  14058. /**
  14059. * Function called when a block is declared as repeatable content generator
  14060. * @param vertexShaderState defines the current compilation state for the vertex shader
  14061. * @param fragmentShaderState defines the current compilation state for the fragment shader
  14062. * @param mesh defines the mesh to be rendered
  14063. * @param defines defines the material defines to update
  14064. */
  14065. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  14066. /**
  14067. * Checks if the block is ready
  14068. * @param mesh defines the mesh to be rendered
  14069. * @param nodeMaterial defines the node material requesting the update
  14070. * @param defines defines the material defines to update
  14071. * @param useInstances specifies that instances should be used
  14072. * @returns true if the block is ready
  14073. */
  14074. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  14075. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  14076. private _processBuild;
  14077. /**
  14078. * Validates the new name for the block node.
  14079. * @param newName the new name to be given to the node.
  14080. * @returns false if the name is a reserve word, else true.
  14081. */
  14082. validateBlockName(newName: string): boolean;
  14083. /**
  14084. * Compile the current node and generate the shader code
  14085. * @param state defines the current compilation state (uniforms, samplers, current string)
  14086. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  14087. * @returns true if already built
  14088. */
  14089. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  14090. protected _inputRename(name: string): string;
  14091. protected _outputRename(name: string): string;
  14092. protected _dumpPropertiesCode(): string;
  14093. /** @hidden */
  14094. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  14095. /** @hidden */
  14096. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  14097. /**
  14098. * Clone the current block to a new identical block
  14099. * @param scene defines the hosting scene
  14100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  14101. * @returns a copy of the current block
  14102. */
  14103. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  14104. /**
  14105. * Serializes this block in a JSON representation
  14106. * @returns the serialized block object
  14107. */
  14108. serialize(): any;
  14109. /** @hidden */
  14110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14111. private _deserializePortDisplayNamesAndExposedOnFrame;
  14112. /**
  14113. * Release resources
  14114. */
  14115. dispose(): void;
  14116. }
  14117. }
  14118. declare module "babylonjs/Materials/pushMaterial" {
  14119. import { Nullable } from "babylonjs/types";
  14120. import { Scene } from "babylonjs/scene";
  14121. import { Matrix } from "babylonjs/Maths/math.vector";
  14122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14123. import { Mesh } from "babylonjs/Meshes/mesh";
  14124. import { Material } from "babylonjs/Materials/material";
  14125. import { Effect } from "babylonjs/Materials/effect";
  14126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14127. /**
  14128. * Base class of materials working in push mode in babylon JS
  14129. * @hidden
  14130. */
  14131. export class PushMaterial extends Material {
  14132. protected _activeEffect: Effect;
  14133. protected _normalMatrix: Matrix;
  14134. constructor(name: string, scene: Scene);
  14135. getEffect(): Effect;
  14136. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14137. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  14138. /**
  14139. * Binds the given world matrix to the active effect
  14140. *
  14141. * @param world the matrix to bind
  14142. */
  14143. bindOnlyWorldMatrix(world: Matrix): void;
  14144. /**
  14145. * Binds the given normal matrix to the active effect
  14146. *
  14147. * @param normalMatrix the matrix to bind
  14148. */
  14149. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14150. bind(world: Matrix, mesh?: Mesh): void;
  14151. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14152. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14153. }
  14154. }
  14155. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  14156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14157. /**
  14158. * Root class for all node material optimizers
  14159. */
  14160. export class NodeMaterialOptimizer {
  14161. /**
  14162. * Function used to optimize a NodeMaterial graph
  14163. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  14164. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  14165. */
  14166. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  14167. }
  14168. }
  14169. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  14170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14173. import { Scene } from "babylonjs/scene";
  14174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14175. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  14176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14177. /**
  14178. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  14179. */
  14180. export class TransformBlock extends NodeMaterialBlock {
  14181. /**
  14182. * Defines the value to use to complement W value to transform it to a Vector4
  14183. */
  14184. complementW: number;
  14185. /**
  14186. * Defines the value to use to complement z value to transform it to a Vector4
  14187. */
  14188. complementZ: number;
  14189. /**
  14190. * Creates a new TransformBlock
  14191. * @param name defines the block name
  14192. */
  14193. constructor(name: string);
  14194. /**
  14195. * Gets the current class name
  14196. * @returns the class name
  14197. */
  14198. getClassName(): string;
  14199. /**
  14200. * Gets the vector input
  14201. */
  14202. get vector(): NodeMaterialConnectionPoint;
  14203. /**
  14204. * Gets the output component
  14205. */
  14206. get output(): NodeMaterialConnectionPoint;
  14207. /**
  14208. * Gets the xyz output component
  14209. */
  14210. get xyz(): NodeMaterialConnectionPoint;
  14211. /**
  14212. * Gets the matrix transform input
  14213. */
  14214. get transform(): NodeMaterialConnectionPoint;
  14215. protected _buildBlock(state: NodeMaterialBuildState): this;
  14216. /**
  14217. * Update defines for shader compilation
  14218. * @param mesh defines the mesh to be rendered
  14219. * @param nodeMaterial defines the node material requesting the update
  14220. * @param defines defines the material defines to update
  14221. * @param useInstances specifies that instances should be used
  14222. * @param subMesh defines which submesh to render
  14223. */
  14224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14225. serialize(): any;
  14226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14227. protected _dumpPropertiesCode(): string;
  14228. }
  14229. }
  14230. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  14231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14234. /**
  14235. * Block used to output the vertex position
  14236. */
  14237. export class VertexOutputBlock extends NodeMaterialBlock {
  14238. /**
  14239. * Creates a new VertexOutputBlock
  14240. * @param name defines the block name
  14241. */
  14242. constructor(name: string);
  14243. /**
  14244. * Gets the current class name
  14245. * @returns the class name
  14246. */
  14247. getClassName(): string;
  14248. /**
  14249. * Gets the vector input component
  14250. */
  14251. get vector(): NodeMaterialConnectionPoint;
  14252. protected _buildBlock(state: NodeMaterialBuildState): this;
  14253. }
  14254. }
  14255. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  14256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14259. /**
  14260. * Block used to output the final color
  14261. */
  14262. export class FragmentOutputBlock extends NodeMaterialBlock {
  14263. /**
  14264. * Create a new FragmentOutputBlock
  14265. * @param name defines the block name
  14266. */
  14267. constructor(name: string);
  14268. /**
  14269. * Gets the current class name
  14270. * @returns the class name
  14271. */
  14272. getClassName(): string;
  14273. /**
  14274. * Gets the rgba input component
  14275. */
  14276. get rgba(): NodeMaterialConnectionPoint;
  14277. /**
  14278. * Gets the rgb input component
  14279. */
  14280. get rgb(): NodeMaterialConnectionPoint;
  14281. /**
  14282. * Gets the a input component
  14283. */
  14284. get a(): NodeMaterialConnectionPoint;
  14285. protected _buildBlock(state: NodeMaterialBuildState): this;
  14286. }
  14287. }
  14288. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  14289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14292. /**
  14293. * Block used for the particle ramp gradient section
  14294. */
  14295. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14296. /**
  14297. * Create a new ParticleRampGradientBlock
  14298. * @param name defines the block name
  14299. */
  14300. constructor(name: string);
  14301. /**
  14302. * Gets the current class name
  14303. * @returns the class name
  14304. */
  14305. getClassName(): string;
  14306. /**
  14307. * Gets the color input component
  14308. */
  14309. get color(): NodeMaterialConnectionPoint;
  14310. /**
  14311. * Gets the rampColor output component
  14312. */
  14313. get rampColor(): NodeMaterialConnectionPoint;
  14314. /**
  14315. * Initialize the block and prepare the context for build
  14316. * @param state defines the state that will be used for the build
  14317. */
  14318. initialize(state: NodeMaterialBuildState): void;
  14319. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14320. }
  14321. }
  14322. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  14323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14326. /**
  14327. * Block used for the particle blend multiply section
  14328. */
  14329. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14330. /**
  14331. * Create a new ParticleBlendMultiplyBlock
  14332. * @param name defines the block name
  14333. */
  14334. constructor(name: string);
  14335. /**
  14336. * Gets the current class name
  14337. * @returns the class name
  14338. */
  14339. getClassName(): string;
  14340. /**
  14341. * Gets the color input component
  14342. */
  14343. get color(): NodeMaterialConnectionPoint;
  14344. /**
  14345. * Gets the alphaTexture input component
  14346. */
  14347. get alphaTexture(): NodeMaterialConnectionPoint;
  14348. /**
  14349. * Gets the alphaColor input component
  14350. */
  14351. get alphaColor(): NodeMaterialConnectionPoint;
  14352. /**
  14353. * Gets the blendColor output component
  14354. */
  14355. get blendColor(): NodeMaterialConnectionPoint;
  14356. /**
  14357. * Initialize the block and prepare the context for build
  14358. * @param state defines the state that will be used for the build
  14359. */
  14360. initialize(state: NodeMaterialBuildState): void;
  14361. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14362. }
  14363. }
  14364. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  14365. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14366. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14367. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14368. /**
  14369. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14370. */
  14371. export class VectorMergerBlock extends NodeMaterialBlock {
  14372. /**
  14373. * Create a new VectorMergerBlock
  14374. * @param name defines the block name
  14375. */
  14376. constructor(name: string);
  14377. /**
  14378. * Gets the current class name
  14379. * @returns the class name
  14380. */
  14381. getClassName(): string;
  14382. /**
  14383. * Gets the xyz component (input)
  14384. */
  14385. get xyzIn(): NodeMaterialConnectionPoint;
  14386. /**
  14387. * Gets the xy component (input)
  14388. */
  14389. get xyIn(): NodeMaterialConnectionPoint;
  14390. /**
  14391. * Gets the x component (input)
  14392. */
  14393. get x(): NodeMaterialConnectionPoint;
  14394. /**
  14395. * Gets the y component (input)
  14396. */
  14397. get y(): NodeMaterialConnectionPoint;
  14398. /**
  14399. * Gets the z component (input)
  14400. */
  14401. get z(): NodeMaterialConnectionPoint;
  14402. /**
  14403. * Gets the w component (input)
  14404. */
  14405. get w(): NodeMaterialConnectionPoint;
  14406. /**
  14407. * Gets the xyzw component (output)
  14408. */
  14409. get xyzw(): NodeMaterialConnectionPoint;
  14410. /**
  14411. * Gets the xyz component (output)
  14412. */
  14413. get xyzOut(): NodeMaterialConnectionPoint;
  14414. /**
  14415. * Gets the xy component (output)
  14416. */
  14417. get xyOut(): NodeMaterialConnectionPoint;
  14418. /**
  14419. * Gets the xy component (output)
  14420. * @deprecated Please use xyOut instead.
  14421. */
  14422. get xy(): NodeMaterialConnectionPoint;
  14423. /**
  14424. * Gets the xyz component (output)
  14425. * @deprecated Please use xyzOut instead.
  14426. */
  14427. get xyz(): NodeMaterialConnectionPoint;
  14428. protected _buildBlock(state: NodeMaterialBuildState): this;
  14429. }
  14430. }
  14431. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  14432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14435. import { Vector2 } from "babylonjs/Maths/math.vector";
  14436. import { Scene } from "babylonjs/scene";
  14437. /**
  14438. * Block used to remap a float from a range to a new one
  14439. */
  14440. export class RemapBlock extends NodeMaterialBlock {
  14441. /**
  14442. * Gets or sets the source range
  14443. */
  14444. sourceRange: Vector2;
  14445. /**
  14446. * Gets or sets the target range
  14447. */
  14448. targetRange: Vector2;
  14449. /**
  14450. * Creates a new RemapBlock
  14451. * @param name defines the block name
  14452. */
  14453. constructor(name: string);
  14454. /**
  14455. * Gets the current class name
  14456. * @returns the class name
  14457. */
  14458. getClassName(): string;
  14459. /**
  14460. * Gets the input component
  14461. */
  14462. get input(): NodeMaterialConnectionPoint;
  14463. /**
  14464. * Gets the source min input component
  14465. */
  14466. get sourceMin(): NodeMaterialConnectionPoint;
  14467. /**
  14468. * Gets the source max input component
  14469. */
  14470. get sourceMax(): NodeMaterialConnectionPoint;
  14471. /**
  14472. * Gets the target min input component
  14473. */
  14474. get targetMin(): NodeMaterialConnectionPoint;
  14475. /**
  14476. * Gets the target max input component
  14477. */
  14478. get targetMax(): NodeMaterialConnectionPoint;
  14479. /**
  14480. * Gets the output component
  14481. */
  14482. get output(): NodeMaterialConnectionPoint;
  14483. protected _buildBlock(state: NodeMaterialBuildState): this;
  14484. protected _dumpPropertiesCode(): string;
  14485. serialize(): any;
  14486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14487. }
  14488. }
  14489. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  14490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14493. /**
  14494. * Block used to multiply 2 values
  14495. */
  14496. export class MultiplyBlock extends NodeMaterialBlock {
  14497. /**
  14498. * Creates a new MultiplyBlock
  14499. * @param name defines the block name
  14500. */
  14501. constructor(name: string);
  14502. /**
  14503. * Gets the current class name
  14504. * @returns the class name
  14505. */
  14506. getClassName(): string;
  14507. /**
  14508. * Gets the left operand input component
  14509. */
  14510. get left(): NodeMaterialConnectionPoint;
  14511. /**
  14512. * Gets the right operand input component
  14513. */
  14514. get right(): NodeMaterialConnectionPoint;
  14515. /**
  14516. * Gets the output component
  14517. */
  14518. get output(): NodeMaterialConnectionPoint;
  14519. protected _buildBlock(state: NodeMaterialBuildState): this;
  14520. }
  14521. }
  14522. declare module "babylonjs/Misc/gradients" {
  14523. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14524. /** Interface used by value gradients (color, factor, ...) */
  14525. export interface IValueGradient {
  14526. /**
  14527. * Gets or sets the gradient value (between 0 and 1)
  14528. */
  14529. gradient: number;
  14530. }
  14531. /** Class used to store color4 gradient */
  14532. export class ColorGradient implements IValueGradient {
  14533. /**
  14534. * Gets or sets the gradient value (between 0 and 1)
  14535. */
  14536. gradient: number;
  14537. /**
  14538. * Gets or sets first associated color
  14539. */
  14540. color1: Color4;
  14541. /**
  14542. * Gets or sets second associated color
  14543. */
  14544. color2?: Color4 | undefined;
  14545. /**
  14546. * Creates a new color4 gradient
  14547. * @param gradient gets or sets the gradient value (between 0 and 1)
  14548. * @param color1 gets or sets first associated color
  14549. * @param color2 gets or sets first second color
  14550. */
  14551. constructor(
  14552. /**
  14553. * Gets or sets the gradient value (between 0 and 1)
  14554. */
  14555. gradient: number,
  14556. /**
  14557. * Gets or sets first associated color
  14558. */
  14559. color1: Color4,
  14560. /**
  14561. * Gets or sets second associated color
  14562. */
  14563. color2?: Color4 | undefined);
  14564. /**
  14565. * Will get a color picked randomly between color1 and color2.
  14566. * If color2 is undefined then color1 will be used
  14567. * @param result defines the target Color4 to store the result in
  14568. */
  14569. getColorToRef(result: Color4): void;
  14570. }
  14571. /** Class used to store color 3 gradient */
  14572. export class Color3Gradient implements IValueGradient {
  14573. /**
  14574. * Gets or sets the gradient value (between 0 and 1)
  14575. */
  14576. gradient: number;
  14577. /**
  14578. * Gets or sets the associated color
  14579. */
  14580. color: Color3;
  14581. /**
  14582. * Creates a new color3 gradient
  14583. * @param gradient gets or sets the gradient value (between 0 and 1)
  14584. * @param color gets or sets associated color
  14585. */
  14586. constructor(
  14587. /**
  14588. * Gets or sets the gradient value (between 0 and 1)
  14589. */
  14590. gradient: number,
  14591. /**
  14592. * Gets or sets the associated color
  14593. */
  14594. color: Color3);
  14595. }
  14596. /** Class used to store factor gradient */
  14597. export class FactorGradient implements IValueGradient {
  14598. /**
  14599. * Gets or sets the gradient value (between 0 and 1)
  14600. */
  14601. gradient: number;
  14602. /**
  14603. * Gets or sets first associated factor
  14604. */
  14605. factor1: number;
  14606. /**
  14607. * Gets or sets second associated factor
  14608. */
  14609. factor2?: number | undefined;
  14610. /**
  14611. * Creates a new factor gradient
  14612. * @param gradient gets or sets the gradient value (between 0 and 1)
  14613. * @param factor1 gets or sets first associated factor
  14614. * @param factor2 gets or sets second associated factor
  14615. */
  14616. constructor(
  14617. /**
  14618. * Gets or sets the gradient value (between 0 and 1)
  14619. */
  14620. gradient: number,
  14621. /**
  14622. * Gets or sets first associated factor
  14623. */
  14624. factor1: number,
  14625. /**
  14626. * Gets or sets second associated factor
  14627. */
  14628. factor2?: number | undefined);
  14629. /**
  14630. * Will get a number picked randomly between factor1 and factor2.
  14631. * If factor2 is undefined then factor1 will be used
  14632. * @returns the picked number
  14633. */
  14634. getFactor(): number;
  14635. }
  14636. /**
  14637. * Helper used to simplify some generic gradient tasks
  14638. */
  14639. export class GradientHelper {
  14640. /**
  14641. * Gets the current gradient from an array of IValueGradient
  14642. * @param ratio defines the current ratio to get
  14643. * @param gradients defines the array of IValueGradient
  14644. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14645. */
  14646. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14647. }
  14648. }
  14649. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14650. import { Nullable } from "babylonjs/types";
  14651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14652. import { Scene } from "babylonjs/scene";
  14653. module "babylonjs/Engines/thinEngine" {
  14654. interface ThinEngine {
  14655. /**
  14656. * Creates a raw texture
  14657. * @param data defines the data to store in the texture
  14658. * @param width defines the width of the texture
  14659. * @param height defines the height of the texture
  14660. * @param format defines the format of the data
  14661. * @param generateMipMaps defines if the engine should generate the mip levels
  14662. * @param invertY defines if data must be stored with Y axis inverted
  14663. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14664. * @param compression defines the compression used (null by default)
  14665. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14666. * @returns the raw texture inside an InternalTexture
  14667. */
  14668. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14669. /**
  14670. * Update a raw texture
  14671. * @param texture defines the texture to update
  14672. * @param data defines the data to store in the texture
  14673. * @param format defines the format of the data
  14674. * @param invertY defines if data must be stored with Y axis inverted
  14675. */
  14676. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14677. /**
  14678. * Update a raw texture
  14679. * @param texture defines the texture to update
  14680. * @param data defines the data to store in the texture
  14681. * @param format defines the format of the data
  14682. * @param invertY defines if data must be stored with Y axis inverted
  14683. * @param compression defines the compression used (null by default)
  14684. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14685. */
  14686. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14687. /**
  14688. * Creates a new raw cube texture
  14689. * @param data defines the array of data to use to create each face
  14690. * @param size defines the size of the textures
  14691. * @param format defines the format of the data
  14692. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14693. * @param generateMipMaps defines if the engine should generate the mip levels
  14694. * @param invertY defines if data must be stored with Y axis inverted
  14695. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14696. * @param compression defines the compression used (null by default)
  14697. * @returns the cube texture as an InternalTexture
  14698. */
  14699. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14700. /**
  14701. * Update a raw cube texture
  14702. * @param texture defines the texture to udpdate
  14703. * @param data defines the data to store
  14704. * @param format defines the data format
  14705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14706. * @param invertY defines if data must be stored with Y axis inverted
  14707. */
  14708. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14709. /**
  14710. * Update a raw cube texture
  14711. * @param texture defines the texture to udpdate
  14712. * @param data defines the data to store
  14713. * @param format defines the data format
  14714. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14715. * @param invertY defines if data must be stored with Y axis inverted
  14716. * @param compression defines the compression used (null by default)
  14717. */
  14718. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14719. /**
  14720. * Update a raw cube texture
  14721. * @param texture defines the texture to udpdate
  14722. * @param data defines the data to store
  14723. * @param format defines the data format
  14724. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14725. * @param invertY defines if data must be stored with Y axis inverted
  14726. * @param compression defines the compression used (null by default)
  14727. * @param level defines which level of the texture to update
  14728. */
  14729. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14730. /**
  14731. * Creates a new raw cube texture from a specified url
  14732. * @param url defines the url where the data is located
  14733. * @param scene defines the current scene
  14734. * @param size defines the size of the textures
  14735. * @param format defines the format of the data
  14736. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14737. * @param noMipmap defines if the engine should avoid generating the mip levels
  14738. * @param callback defines a callback used to extract texture data from loaded data
  14739. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14740. * @param onLoad defines a callback called when texture is loaded
  14741. * @param onError defines a callback called if there is an error
  14742. * @returns the cube texture as an InternalTexture
  14743. */
  14744. 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;
  14745. /**
  14746. * Creates a new raw cube texture from a specified url
  14747. * @param url defines the url where the data is located
  14748. * @param scene defines the current scene
  14749. * @param size defines the size of the textures
  14750. * @param format defines the format of the data
  14751. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14752. * @param noMipmap defines if the engine should avoid generating the mip levels
  14753. * @param callback defines a callback used to extract texture data from loaded data
  14754. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14755. * @param onLoad defines a callback called when texture is loaded
  14756. * @param onError defines a callback called if there is an error
  14757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14758. * @param invertY defines if data must be stored with Y axis inverted
  14759. * @returns the cube texture as an InternalTexture
  14760. */
  14761. 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;
  14762. /**
  14763. * Creates a new raw 3D texture
  14764. * @param data defines the data used to create the texture
  14765. * @param width defines the width of the texture
  14766. * @param height defines the height of the texture
  14767. * @param depth defines the depth of the texture
  14768. * @param format defines the format of the texture
  14769. * @param generateMipMaps defines if the engine must generate mip levels
  14770. * @param invertY defines if data must be stored with Y axis inverted
  14771. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14772. * @param compression defines the compressed used (can be null)
  14773. * @param textureType defines the compressed used (can be null)
  14774. * @returns a new raw 3D texture (stored in an InternalTexture)
  14775. */
  14776. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14777. /**
  14778. * Update a raw 3D texture
  14779. * @param texture defines the texture to update
  14780. * @param data defines the data to store
  14781. * @param format defines the data format
  14782. * @param invertY defines if data must be stored with Y axis inverted
  14783. */
  14784. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14785. /**
  14786. * Update a raw 3D texture
  14787. * @param texture defines the texture to update
  14788. * @param data defines the data to store
  14789. * @param format defines the data format
  14790. * @param invertY defines if data must be stored with Y axis inverted
  14791. * @param compression defines the used compression (can be null)
  14792. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14793. */
  14794. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14795. /**
  14796. * Creates a new raw 2D array texture
  14797. * @param data defines the data used to create the texture
  14798. * @param width defines the width of the texture
  14799. * @param height defines the height of the texture
  14800. * @param depth defines the number of layers of the texture
  14801. * @param format defines the format of the texture
  14802. * @param generateMipMaps defines if the engine must generate mip levels
  14803. * @param invertY defines if data must be stored with Y axis inverted
  14804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14805. * @param compression defines the compressed used (can be null)
  14806. * @param textureType defines the compressed used (can be null)
  14807. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14808. */
  14809. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14810. /**
  14811. * Update a raw 2D array texture
  14812. * @param texture defines the texture to update
  14813. * @param data defines the data to store
  14814. * @param format defines the data format
  14815. * @param invertY defines if data must be stored with Y axis inverted
  14816. */
  14817. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14818. /**
  14819. * Update a raw 2D array texture
  14820. * @param texture defines the texture to update
  14821. * @param data defines the data to store
  14822. * @param format defines the data format
  14823. * @param invertY defines if data must be stored with Y axis inverted
  14824. * @param compression defines the used compression (can be null)
  14825. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14826. */
  14827. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14828. }
  14829. }
  14830. }
  14831. declare module "babylonjs/Materials/Textures/rawTexture" {
  14832. import { Texture } from "babylonjs/Materials/Textures/texture";
  14833. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14834. import { Nullable } from "babylonjs/types";
  14835. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14836. import { Scene } from "babylonjs/scene";
  14837. /**
  14838. * Raw texture can help creating a texture directly from an array of data.
  14839. * This can be super useful if you either get the data from an uncompressed source or
  14840. * if you wish to create your texture pixel by pixel.
  14841. */
  14842. export class RawTexture extends Texture {
  14843. /**
  14844. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14845. */
  14846. format: number;
  14847. /**
  14848. * Instantiates a new RawTexture.
  14849. * Raw texture can help creating a texture directly from an array of data.
  14850. * This can be super useful if you either get the data from an uncompressed source or
  14851. * if you wish to create your texture pixel by pixel.
  14852. * @param data define the array of data to use to create the texture
  14853. * @param width define the width of the texture
  14854. * @param height define the height of the texture
  14855. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14856. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14857. * @param generateMipMaps define whether mip maps should be generated or not
  14858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14860. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14861. */
  14862. constructor(data: ArrayBufferView, width: number, height: number,
  14863. /**
  14864. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14865. */
  14866. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14867. /**
  14868. * Updates the texture underlying data.
  14869. * @param data Define the new data of the texture
  14870. */
  14871. update(data: ArrayBufferView): void;
  14872. /**
  14873. * Creates a luminance texture from some data.
  14874. * @param data Define the texture data
  14875. * @param width Define the width of the texture
  14876. * @param height Define the height of the texture
  14877. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14881. * @returns the luminance texture
  14882. */
  14883. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14884. /**
  14885. * Creates a luminance alpha texture from some data.
  14886. * @param data Define the texture data
  14887. * @param width Define the width of the texture
  14888. * @param height Define the height of the texture
  14889. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14890. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14891. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14892. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14893. * @returns the luminance alpha texture
  14894. */
  14895. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14896. /**
  14897. * Creates an alpha texture from some data.
  14898. * @param data Define the texture data
  14899. * @param width Define the width of the texture
  14900. * @param height Define the height of the texture
  14901. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14905. * @returns the alpha texture
  14906. */
  14907. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14908. /**
  14909. * Creates a RGB texture from some data.
  14910. * @param data Define the texture data
  14911. * @param width Define the width of the texture
  14912. * @param height Define the height of the texture
  14913. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14917. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14918. * @returns the RGB alpha texture
  14919. */
  14920. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14921. /**
  14922. * Creates a RGBA texture from some data.
  14923. * @param data Define the texture data
  14924. * @param width Define the width of the texture
  14925. * @param height Define the height of the texture
  14926. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14927. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14928. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14929. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14930. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14931. * @returns the RGBA texture
  14932. */
  14933. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14934. /**
  14935. * Creates a R texture from some data.
  14936. * @param data Define the texture data
  14937. * @param width Define the width of the texture
  14938. * @param height Define the height of the texture
  14939. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14940. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14941. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14942. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14943. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14944. * @returns the R texture
  14945. */
  14946. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14947. }
  14948. }
  14949. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14950. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14951. import { IndicesArray, DataArray } from "babylonjs/types";
  14952. module "babylonjs/Engines/thinEngine" {
  14953. interface ThinEngine {
  14954. /**
  14955. * Update a dynamic index buffer
  14956. * @param indexBuffer defines the target index buffer
  14957. * @param indices defines the data to update
  14958. * @param offset defines the offset in the target index buffer where update should start
  14959. */
  14960. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14961. /**
  14962. * Updates a dynamic vertex buffer.
  14963. * @param vertexBuffer the vertex buffer to update
  14964. * @param data the data used to update the vertex buffer
  14965. * @param byteOffset the byte offset of the data
  14966. * @param byteLength the byte length of the data
  14967. */
  14968. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14969. }
  14970. }
  14971. }
  14972. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14973. import { Scene } from "babylonjs/scene";
  14974. import { ISceneComponent } from "babylonjs/sceneComponent";
  14975. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14976. module "babylonjs/abstractScene" {
  14977. interface AbstractScene {
  14978. /**
  14979. * The list of procedural textures added to the scene
  14980. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14981. */
  14982. proceduralTextures: Array<ProceduralTexture>;
  14983. }
  14984. }
  14985. /**
  14986. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14987. * in a given scene.
  14988. */
  14989. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14990. /**
  14991. * The component name helpfull to identify the component in the list of scene components.
  14992. */
  14993. readonly name: string;
  14994. /**
  14995. * The scene the component belongs to.
  14996. */
  14997. scene: Scene;
  14998. /**
  14999. * Creates a new instance of the component for the given scene
  15000. * @param scene Defines the scene to register the component in
  15001. */
  15002. constructor(scene: Scene);
  15003. /**
  15004. * Registers the component in a given scene
  15005. */
  15006. register(): void;
  15007. /**
  15008. * Rebuilds the elements related to this component in case of
  15009. * context lost for instance.
  15010. */
  15011. rebuild(): void;
  15012. /**
  15013. * Disposes the component and the associated ressources.
  15014. */
  15015. dispose(): void;
  15016. private _beforeClear;
  15017. }
  15018. }
  15019. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  15020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15021. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  15022. module "babylonjs/Engines/thinEngine" {
  15023. interface ThinEngine {
  15024. /**
  15025. * Creates a new render target cube texture
  15026. * @param size defines the size of the texture
  15027. * @param options defines the options used to create the texture
  15028. * @returns a new render target cube texture stored in an InternalTexture
  15029. */
  15030. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15031. }
  15032. }
  15033. }
  15034. declare module "babylonjs/Shaders/procedural.vertex" {
  15035. /** @hidden */
  15036. export var proceduralVertexShader: {
  15037. name: string;
  15038. shader: string;
  15039. };
  15040. }
  15041. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  15042. import { Observable } from "babylonjs/Misc/observable";
  15043. import { Nullable } from "babylonjs/types";
  15044. import { Scene } from "babylonjs/scene";
  15045. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  15046. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15047. import { Effect } from "babylonjs/Materials/effect";
  15048. import { Texture } from "babylonjs/Materials/Textures/texture";
  15049. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15050. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  15051. import "babylonjs/Shaders/procedural.vertex";
  15052. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  15053. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  15054. /**
  15055. * 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.
  15056. * This is the base class of any Procedural texture and contains most of the shareable code.
  15057. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15058. */
  15059. export class ProceduralTexture extends Texture {
  15060. /**
  15061. * Define if the texture is enabled or not (disabled texture will not render)
  15062. */
  15063. isEnabled: boolean;
  15064. /**
  15065. * Define if the texture must be cleared before rendering (default is true)
  15066. */
  15067. autoClear: boolean;
  15068. /**
  15069. * Callback called when the texture is generated
  15070. */
  15071. onGenerated: () => void;
  15072. /**
  15073. * Event raised when the texture is generated
  15074. */
  15075. onGeneratedObservable: Observable<ProceduralTexture>;
  15076. /**
  15077. * Event raised before the texture is generated
  15078. */
  15079. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  15080. /**
  15081. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  15082. */
  15083. nodeMaterialSource: Nullable<NodeMaterial>;
  15084. /** @hidden */
  15085. _generateMipMaps: boolean;
  15086. /** @hidden **/
  15087. _effect: Effect;
  15088. /** @hidden */
  15089. _textures: {
  15090. [key: string]: Texture;
  15091. };
  15092. /** @hidden */
  15093. protected _fallbackTexture: Nullable<Texture>;
  15094. private _size;
  15095. private _textureType;
  15096. private _currentRefreshId;
  15097. private _frameId;
  15098. private _refreshRate;
  15099. private _vertexBuffers;
  15100. private _indexBuffer;
  15101. private _uniforms;
  15102. private _samplers;
  15103. private _fragment;
  15104. private _floats;
  15105. private _ints;
  15106. private _floatsArrays;
  15107. private _colors3;
  15108. private _colors4;
  15109. private _vectors2;
  15110. private _vectors3;
  15111. private _matrices;
  15112. private _fallbackTextureUsed;
  15113. private _fullEngine;
  15114. private _cachedDefines;
  15115. private _contentUpdateId;
  15116. private _contentData;
  15117. /**
  15118. * Instantiates a new procedural texture.
  15119. * 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.
  15120. * This is the base class of any Procedural texture and contains most of the shareable code.
  15121. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15122. * @param name Define the name of the texture
  15123. * @param size Define the size of the texture to create
  15124. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15125. * @param scene Define the scene the texture belongs to
  15126. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15127. * @param generateMipMaps Define if the texture should creates mip maps or not
  15128. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15129. * @param textureType The FBO internal texture type
  15130. */
  15131. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  15132. /**
  15133. * The effect that is created when initializing the post process.
  15134. * @returns The created effect corresponding the the postprocess.
  15135. */
  15136. getEffect(): Effect;
  15137. /**
  15138. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15139. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  15140. */
  15141. getContent(): Nullable<Promise<ArrayBufferView>>;
  15142. private _createIndexBuffer;
  15143. /** @hidden */
  15144. _rebuild(): void;
  15145. /**
  15146. * Resets the texture in order to recreate its associated resources.
  15147. * This can be called in case of context loss
  15148. */
  15149. reset(): void;
  15150. protected _getDefines(): string;
  15151. /**
  15152. * Is the texture ready to be used ? (rendered at least once)
  15153. * @returns true if ready, otherwise, false.
  15154. */
  15155. isReady(): boolean;
  15156. /**
  15157. * Resets the refresh counter of the texture and start bak from scratch.
  15158. * Could be useful to regenerate the texture if it is setup to render only once.
  15159. */
  15160. resetRefreshCounter(): void;
  15161. /**
  15162. * Set the fragment shader to use in order to render the texture.
  15163. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15164. */
  15165. setFragment(fragment: any): void;
  15166. /**
  15167. * Define the refresh rate of the texture or the rendering frequency.
  15168. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15169. */
  15170. get refreshRate(): number;
  15171. set refreshRate(value: number);
  15172. /** @hidden */
  15173. _shouldRender(): boolean;
  15174. /**
  15175. * Get the size the texture is rendering at.
  15176. * @returns the size (on cube texture it is always squared)
  15177. */
  15178. getRenderSize(): RenderTargetTextureSize;
  15179. /**
  15180. * Resize the texture to new value.
  15181. * @param size Define the new size the texture should have
  15182. * @param generateMipMaps Define whether the new texture should create mip maps
  15183. */
  15184. resize(size: number, generateMipMaps: boolean): void;
  15185. private _checkUniform;
  15186. /**
  15187. * Set a texture in the shader program used to render.
  15188. * @param name Define the name of the uniform samplers as defined in the shader
  15189. * @param texture Define the texture to bind to this sampler
  15190. * @return the texture itself allowing "fluent" like uniform updates
  15191. */
  15192. setTexture(name: string, texture: Texture): ProceduralTexture;
  15193. /**
  15194. * Set a float in the shader.
  15195. * @param name Define the name of the uniform as defined in the shader
  15196. * @param value Define the value to give to the uniform
  15197. * @return the texture itself allowing "fluent" like uniform updates
  15198. */
  15199. setFloat(name: string, value: number): ProceduralTexture;
  15200. /**
  15201. * Set a int in the shader.
  15202. * @param name Define the name of the uniform as defined in the shader
  15203. * @param value Define the value to give to the uniform
  15204. * @return the texture itself allowing "fluent" like uniform updates
  15205. */
  15206. setInt(name: string, value: number): ProceduralTexture;
  15207. /**
  15208. * Set an array of floats in the shader.
  15209. * @param name Define the name of the uniform as defined in the shader
  15210. * @param value Define the value to give to the uniform
  15211. * @return the texture itself allowing "fluent" like uniform updates
  15212. */
  15213. setFloats(name: string, value: number[]): ProceduralTexture;
  15214. /**
  15215. * Set a vec3 in the shader from a Color3.
  15216. * @param name Define the name of the uniform as defined in the shader
  15217. * @param value Define the value to give to the uniform
  15218. * @return the texture itself allowing "fluent" like uniform updates
  15219. */
  15220. setColor3(name: string, value: Color3): ProceduralTexture;
  15221. /**
  15222. * Set a vec4 in the shader from a Color4.
  15223. * @param name Define the name of the uniform as defined in the shader
  15224. * @param value Define the value to give to the uniform
  15225. * @return the texture itself allowing "fluent" like uniform updates
  15226. */
  15227. setColor4(name: string, value: Color4): ProceduralTexture;
  15228. /**
  15229. * Set a vec2 in the shader from a Vector2.
  15230. * @param name Define the name of the uniform as defined in the shader
  15231. * @param value Define the value to give to the uniform
  15232. * @return the texture itself allowing "fluent" like uniform updates
  15233. */
  15234. setVector2(name: string, value: Vector2): ProceduralTexture;
  15235. /**
  15236. * Set a vec3 in the shader from a Vector3.
  15237. * @param name Define the name of the uniform as defined in the shader
  15238. * @param value Define the value to give to the uniform
  15239. * @return the texture itself allowing "fluent" like uniform updates
  15240. */
  15241. setVector3(name: string, value: Vector3): ProceduralTexture;
  15242. /**
  15243. * Set a mat4 in the shader from a MAtrix.
  15244. * @param name Define the name of the uniform as defined in the shader
  15245. * @param value Define the value to give to the uniform
  15246. * @return the texture itself allowing "fluent" like uniform updates
  15247. */
  15248. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15249. /**
  15250. * Render the texture to its associated render target.
  15251. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15252. */
  15253. render(useCameraPostProcess?: boolean): void;
  15254. /**
  15255. * Clone the texture.
  15256. * @returns the cloned texture
  15257. */
  15258. clone(): ProceduralTexture;
  15259. /**
  15260. * Dispose the texture and release its asoociated resources.
  15261. */
  15262. dispose(): void;
  15263. }
  15264. }
  15265. declare module "babylonjs/Particles/baseParticleSystem" {
  15266. import { Nullable } from "babylonjs/types";
  15267. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  15268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15269. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  15270. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  15271. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15272. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15273. import { Color4 } from "babylonjs/Maths/math.color";
  15274. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15275. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  15276. import { Animation } from "babylonjs/Animations/animation";
  15277. import { Scene } from "babylonjs/scene";
  15278. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  15279. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15280. /**
  15281. * This represents the base class for particle system in Babylon.
  15282. * 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.
  15283. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15284. * @example https://doc.babylonjs.com/babylon101/particles
  15285. */
  15286. export class BaseParticleSystem {
  15287. /**
  15288. * Source color is added to the destination color without alpha affecting the result
  15289. */
  15290. static BLENDMODE_ONEONE: number;
  15291. /**
  15292. * Blend current color and particle color using particle’s alpha
  15293. */
  15294. static BLENDMODE_STANDARD: number;
  15295. /**
  15296. * Add current color and particle color multiplied by particle’s alpha
  15297. */
  15298. static BLENDMODE_ADD: number;
  15299. /**
  15300. * Multiply current color with particle color
  15301. */
  15302. static BLENDMODE_MULTIPLY: number;
  15303. /**
  15304. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15305. */
  15306. static BLENDMODE_MULTIPLYADD: number;
  15307. /**
  15308. * List of animations used by the particle system.
  15309. */
  15310. animations: Animation[];
  15311. /**
  15312. * Gets or sets the unique id of the particle system
  15313. */
  15314. uniqueId: number;
  15315. /**
  15316. * The id of the Particle system.
  15317. */
  15318. id: string;
  15319. /**
  15320. * The friendly name of the Particle system.
  15321. */
  15322. name: string;
  15323. /**
  15324. * Snippet ID if the particle system was created from the snippet server
  15325. */
  15326. snippetId: string;
  15327. /**
  15328. * The rendering group used by the Particle system to chose when to render.
  15329. */
  15330. renderingGroupId: number;
  15331. /**
  15332. * The emitter represents the Mesh or position we are attaching the particle system to.
  15333. */
  15334. emitter: Nullable<AbstractMesh | Vector3>;
  15335. /**
  15336. * The maximum number of particles to emit per frame
  15337. */
  15338. emitRate: number;
  15339. /**
  15340. * If you want to launch only a few particles at once, that can be done, as well.
  15341. */
  15342. manualEmitCount: number;
  15343. /**
  15344. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15345. */
  15346. updateSpeed: number;
  15347. /**
  15348. * The amount of time the particle system is running (depends of the overall update speed).
  15349. */
  15350. targetStopDuration: number;
  15351. /**
  15352. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15353. */
  15354. disposeOnStop: boolean;
  15355. /**
  15356. * Minimum power of emitting particles.
  15357. */
  15358. minEmitPower: number;
  15359. /**
  15360. * Maximum power of emitting particles.
  15361. */
  15362. maxEmitPower: number;
  15363. /**
  15364. * Minimum life time of emitting particles.
  15365. */
  15366. minLifeTime: number;
  15367. /**
  15368. * Maximum life time of emitting particles.
  15369. */
  15370. maxLifeTime: number;
  15371. /**
  15372. * Minimum Size of emitting particles.
  15373. */
  15374. minSize: number;
  15375. /**
  15376. * Maximum Size of emitting particles.
  15377. */
  15378. maxSize: number;
  15379. /**
  15380. * Minimum scale of emitting particles on X axis.
  15381. */
  15382. minScaleX: number;
  15383. /**
  15384. * Maximum scale of emitting particles on X axis.
  15385. */
  15386. maxScaleX: number;
  15387. /**
  15388. * Minimum scale of emitting particles on Y axis.
  15389. */
  15390. minScaleY: number;
  15391. /**
  15392. * Maximum scale of emitting particles on Y axis.
  15393. */
  15394. maxScaleY: number;
  15395. /**
  15396. * Gets or sets the minimal initial rotation in radians.
  15397. */
  15398. minInitialRotation: number;
  15399. /**
  15400. * Gets or sets the maximal initial rotation in radians.
  15401. */
  15402. maxInitialRotation: number;
  15403. /**
  15404. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15405. */
  15406. minAngularSpeed: number;
  15407. /**
  15408. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15409. */
  15410. maxAngularSpeed: number;
  15411. /**
  15412. * The texture used to render each particle. (this can be a spritesheet)
  15413. */
  15414. particleTexture: Nullable<BaseTexture>;
  15415. /**
  15416. * The layer mask we are rendering the particles through.
  15417. */
  15418. layerMask: number;
  15419. /**
  15420. * This can help using your own shader to render the particle system.
  15421. * The according effect will be created
  15422. */
  15423. customShader: any;
  15424. /**
  15425. * By default particle system starts as soon as they are created. This prevents the
  15426. * automatic start to happen and let you decide when to start emitting particles.
  15427. */
  15428. preventAutoStart: boolean;
  15429. private _noiseTexture;
  15430. /**
  15431. * Gets or sets a texture used to add random noise to particle positions
  15432. */
  15433. get noiseTexture(): Nullable<ProceduralTexture>;
  15434. set noiseTexture(value: Nullable<ProceduralTexture>);
  15435. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15436. noiseStrength: Vector3;
  15437. /**
  15438. * Callback triggered when the particle animation is ending.
  15439. */
  15440. onAnimationEnd: Nullable<() => void>;
  15441. /**
  15442. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15443. */
  15444. blendMode: number;
  15445. /**
  15446. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15447. * to override the particles.
  15448. */
  15449. forceDepthWrite: boolean;
  15450. /** 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 */
  15451. preWarmCycles: number;
  15452. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15453. preWarmStepOffset: number;
  15454. /**
  15455. * 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)
  15456. */
  15457. spriteCellChangeSpeed: number;
  15458. /**
  15459. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15460. */
  15461. startSpriteCellID: number;
  15462. /**
  15463. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15464. */
  15465. endSpriteCellID: number;
  15466. /**
  15467. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15468. */
  15469. spriteCellWidth: number;
  15470. /**
  15471. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15472. */
  15473. spriteCellHeight: number;
  15474. /**
  15475. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15476. */
  15477. spriteRandomStartCell: boolean;
  15478. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15479. translationPivot: Vector2;
  15480. /** @hidden */
  15481. protected _isAnimationSheetEnabled: boolean;
  15482. /**
  15483. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15484. */
  15485. beginAnimationOnStart: boolean;
  15486. /**
  15487. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15488. */
  15489. beginAnimationFrom: number;
  15490. /**
  15491. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15492. */
  15493. beginAnimationTo: number;
  15494. /**
  15495. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15496. */
  15497. beginAnimationLoop: boolean;
  15498. /**
  15499. * Gets or sets a world offset applied to all particles
  15500. */
  15501. worldOffset: Vector3;
  15502. /**
  15503. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15504. */
  15505. get isAnimationSheetEnabled(): boolean;
  15506. set isAnimationSheetEnabled(value: boolean);
  15507. /**
  15508. * Get hosting scene
  15509. * @returns the scene
  15510. */
  15511. getScene(): Nullable<Scene>;
  15512. /**
  15513. * You can use gravity if you want to give an orientation to your particles.
  15514. */
  15515. gravity: Vector3;
  15516. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15517. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15518. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15519. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15520. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15521. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15522. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15523. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15524. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15525. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15526. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15527. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15528. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15529. /**
  15530. * Defines the delay in milliseconds before starting the system (0 by default)
  15531. */
  15532. startDelay: number;
  15533. /**
  15534. * Gets the current list of drag gradients.
  15535. * You must use addDragGradient and removeDragGradient to udpate this list
  15536. * @returns the list of drag gradients
  15537. */
  15538. getDragGradients(): Nullable<Array<FactorGradient>>;
  15539. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15540. limitVelocityDamping: number;
  15541. /**
  15542. * Gets the current list of limit velocity gradients.
  15543. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15544. * @returns the list of limit velocity gradients
  15545. */
  15546. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15547. /**
  15548. * Gets the current list of color gradients.
  15549. * You must use addColorGradient and removeColorGradient to udpate this list
  15550. * @returns the list of color gradients
  15551. */
  15552. getColorGradients(): Nullable<Array<ColorGradient>>;
  15553. /**
  15554. * Gets the current list of size gradients.
  15555. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15556. * @returns the list of size gradients
  15557. */
  15558. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15559. /**
  15560. * Gets the current list of color remap gradients.
  15561. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15562. * @returns the list of color remap gradients
  15563. */
  15564. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15565. /**
  15566. * Gets the current list of alpha remap gradients.
  15567. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15568. * @returns the list of alpha remap gradients
  15569. */
  15570. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15571. /**
  15572. * Gets the current list of life time gradients.
  15573. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15574. * @returns the list of life time gradients
  15575. */
  15576. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15577. /**
  15578. * Gets the current list of angular speed gradients.
  15579. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15580. * @returns the list of angular speed gradients
  15581. */
  15582. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15583. /**
  15584. * Gets the current list of velocity gradients.
  15585. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15586. * @returns the list of velocity gradients
  15587. */
  15588. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15589. /**
  15590. * Gets the current list of start size gradients.
  15591. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15592. * @returns the list of start size gradients
  15593. */
  15594. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15595. /**
  15596. * Gets the current list of emit rate gradients.
  15597. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15598. * @returns the list of emit rate gradients
  15599. */
  15600. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15601. /**
  15602. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15603. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15604. */
  15605. get direction1(): Vector3;
  15606. set direction1(value: Vector3);
  15607. /**
  15608. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15609. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15610. */
  15611. get direction2(): Vector3;
  15612. set direction2(value: Vector3);
  15613. /**
  15614. * 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.
  15615. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15616. */
  15617. get minEmitBox(): Vector3;
  15618. set minEmitBox(value: Vector3);
  15619. /**
  15620. * 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.
  15621. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15622. */
  15623. get maxEmitBox(): Vector3;
  15624. set maxEmitBox(value: Vector3);
  15625. /**
  15626. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15627. */
  15628. color1: Color4;
  15629. /**
  15630. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15631. */
  15632. color2: Color4;
  15633. /**
  15634. * Color the particle will have at the end of its lifetime
  15635. */
  15636. colorDead: Color4;
  15637. /**
  15638. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15639. */
  15640. textureMask: Color4;
  15641. /**
  15642. * The particle emitter type defines the emitter used by the particle system.
  15643. * It can be for example box, sphere, or cone...
  15644. */
  15645. particleEmitterType: IParticleEmitterType;
  15646. /** @hidden */
  15647. _isSubEmitter: boolean;
  15648. /**
  15649. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15650. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15651. */
  15652. billboardMode: number;
  15653. protected _isBillboardBased: boolean;
  15654. /**
  15655. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15656. */
  15657. get isBillboardBased(): boolean;
  15658. set isBillboardBased(value: boolean);
  15659. /**
  15660. * The scene the particle system belongs to.
  15661. */
  15662. protected _scene: Nullable<Scene>;
  15663. /**
  15664. * The engine the particle system belongs to.
  15665. */
  15666. protected _engine: ThinEngine;
  15667. /**
  15668. * Local cache of defines for image processing.
  15669. */
  15670. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15671. /**
  15672. * Default configuration related to image processing available in the standard Material.
  15673. */
  15674. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15675. /**
  15676. * Gets the image processing configuration used either in this material.
  15677. */
  15678. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15679. /**
  15680. * Sets the Default image processing configuration used either in the this material.
  15681. *
  15682. * If sets to null, the scene one is in use.
  15683. */
  15684. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15685. /**
  15686. * Attaches a new image processing configuration to the Standard Material.
  15687. * @param configuration
  15688. */
  15689. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15690. /** @hidden */
  15691. protected _reset(): void;
  15692. /** @hidden */
  15693. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15694. /**
  15695. * Instantiates a particle system.
  15696. * 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.
  15697. * @param name The name of the particle system
  15698. */
  15699. constructor(name: string);
  15700. /**
  15701. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15704. * @returns the emitter
  15705. */
  15706. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15707. /**
  15708. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15709. * @param radius The radius of the hemisphere to emit from
  15710. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15711. * @returns the emitter
  15712. */
  15713. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15714. /**
  15715. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15716. * @param radius The radius of the sphere to emit from
  15717. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15718. * @returns the emitter
  15719. */
  15720. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15721. /**
  15722. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15723. * @param radius The radius of the sphere to emit from
  15724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15726. * @returns the emitter
  15727. */
  15728. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15729. /**
  15730. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15731. * @param radius The radius of the emission cylinder
  15732. * @param height The height of the emission cylinder
  15733. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15734. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15735. * @returns the emitter
  15736. */
  15737. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15738. /**
  15739. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15740. * @param radius The radius of the cylinder to emit from
  15741. * @param height The height of the emission cylinder
  15742. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15745. * @returns the emitter
  15746. */
  15747. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15748. /**
  15749. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15750. * @param radius The radius of the cone to emit from
  15751. * @param angle The base angle of the cone
  15752. * @returns the emitter
  15753. */
  15754. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15755. /**
  15756. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15759. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15760. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15761. * @returns the emitter
  15762. */
  15763. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15764. }
  15765. }
  15766. declare module "babylonjs/Particles/subEmitter" {
  15767. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15768. import { Scene } from "babylonjs/scene";
  15769. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15770. /**
  15771. * Type of sub emitter
  15772. */
  15773. export enum SubEmitterType {
  15774. /**
  15775. * Attached to the particle over it's lifetime
  15776. */
  15777. ATTACHED = 0,
  15778. /**
  15779. * Created when the particle dies
  15780. */
  15781. END = 1
  15782. }
  15783. /**
  15784. * Sub emitter class used to emit particles from an existing particle
  15785. */
  15786. export class SubEmitter {
  15787. /**
  15788. * the particle system to be used by the sub emitter
  15789. */
  15790. particleSystem: ParticleSystem;
  15791. /**
  15792. * Type of the submitter (Default: END)
  15793. */
  15794. type: SubEmitterType;
  15795. /**
  15796. * 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)
  15797. * Note: This only is supported when using an emitter of type Mesh
  15798. */
  15799. inheritDirection: boolean;
  15800. /**
  15801. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15802. */
  15803. inheritedVelocityAmount: number;
  15804. /**
  15805. * Creates a sub emitter
  15806. * @param particleSystem the particle system to be used by the sub emitter
  15807. */
  15808. constructor(
  15809. /**
  15810. * the particle system to be used by the sub emitter
  15811. */
  15812. particleSystem: ParticleSystem);
  15813. /**
  15814. * Clones the sub emitter
  15815. * @returns the cloned sub emitter
  15816. */
  15817. clone(): SubEmitter;
  15818. /**
  15819. * Serialize current object to a JSON object
  15820. * @returns the serialized object
  15821. */
  15822. serialize(): any;
  15823. /** @hidden */
  15824. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15825. /**
  15826. * Creates a new SubEmitter from a serialized JSON version
  15827. * @param serializationObject defines the JSON object to read from
  15828. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15829. * @param rootUrl defines the rootUrl for data loading
  15830. * @returns a new SubEmitter
  15831. */
  15832. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15833. /** Release associated resources */
  15834. dispose(): void;
  15835. }
  15836. }
  15837. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15838. /** @hidden */
  15839. export var clipPlaneFragmentDeclaration: {
  15840. name: string;
  15841. shader: string;
  15842. };
  15843. }
  15844. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15845. /** @hidden */
  15846. export var imageProcessingDeclaration: {
  15847. name: string;
  15848. shader: string;
  15849. };
  15850. }
  15851. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15852. /** @hidden */
  15853. export var imageProcessingFunctions: {
  15854. name: string;
  15855. shader: string;
  15856. };
  15857. }
  15858. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15859. /** @hidden */
  15860. export var clipPlaneFragment: {
  15861. name: string;
  15862. shader: string;
  15863. };
  15864. }
  15865. declare module "babylonjs/Shaders/particles.fragment" {
  15866. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15867. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15868. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15869. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15870. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15871. /** @hidden */
  15872. export var particlesPixelShader: {
  15873. name: string;
  15874. shader: string;
  15875. };
  15876. }
  15877. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15878. /** @hidden */
  15879. export var clipPlaneVertexDeclaration: {
  15880. name: string;
  15881. shader: string;
  15882. };
  15883. }
  15884. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15885. /** @hidden */
  15886. export var clipPlaneVertex: {
  15887. name: string;
  15888. shader: string;
  15889. };
  15890. }
  15891. declare module "babylonjs/Shaders/particles.vertex" {
  15892. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15893. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15894. /** @hidden */
  15895. export var particlesVertexShader: {
  15896. name: string;
  15897. shader: string;
  15898. };
  15899. }
  15900. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15901. import { Nullable } from "babylonjs/types";
  15902. import { Plane } from "babylonjs/Maths/math";
  15903. /**
  15904. * Interface used to define entities containing multiple clip planes
  15905. */
  15906. export interface IClipPlanesHolder {
  15907. /**
  15908. * Gets or sets the active clipplane 1
  15909. */
  15910. clipPlane: Nullable<Plane>;
  15911. /**
  15912. * Gets or sets the active clipplane 2
  15913. */
  15914. clipPlane2: Nullable<Plane>;
  15915. /**
  15916. * Gets or sets the active clipplane 3
  15917. */
  15918. clipPlane3: Nullable<Plane>;
  15919. /**
  15920. * Gets or sets the active clipplane 4
  15921. */
  15922. clipPlane4: Nullable<Plane>;
  15923. /**
  15924. * Gets or sets the active clipplane 5
  15925. */
  15926. clipPlane5: Nullable<Plane>;
  15927. /**
  15928. * Gets or sets the active clipplane 6
  15929. */
  15930. clipPlane6: Nullable<Plane>;
  15931. }
  15932. }
  15933. declare module "babylonjs/Materials/thinMaterialHelper" {
  15934. import { Effect } from "babylonjs/Materials/effect";
  15935. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15936. /**
  15937. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15938. *
  15939. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15940. *
  15941. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15942. */
  15943. export class ThinMaterialHelper {
  15944. /**
  15945. * Binds the clip plane information from the holder to the effect.
  15946. * @param effect The effect we are binding the data to
  15947. * @param holder The entity containing the clip plane information
  15948. */
  15949. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15950. }
  15951. }
  15952. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15953. module "babylonjs/Engines/thinEngine" {
  15954. interface ThinEngine {
  15955. /**
  15956. * Sets alpha constants used by some alpha blending modes
  15957. * @param r defines the red component
  15958. * @param g defines the green component
  15959. * @param b defines the blue component
  15960. * @param a defines the alpha component
  15961. */
  15962. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15963. /**
  15964. * Sets the current alpha mode
  15965. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15966. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15967. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15968. */
  15969. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15970. /**
  15971. * Gets the current alpha mode
  15972. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15973. * @returns the current alpha mode
  15974. */
  15975. getAlphaMode(): number;
  15976. /**
  15977. * Sets the current alpha equation
  15978. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15979. */
  15980. setAlphaEquation(equation: number): void;
  15981. /**
  15982. * Gets the current alpha equation.
  15983. * @returns the current alpha equation
  15984. */
  15985. getAlphaEquation(): number;
  15986. }
  15987. }
  15988. }
  15989. declare module "babylonjs/Particles/particleSystem" {
  15990. import { Nullable } from "babylonjs/types";
  15991. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15992. import { Observable } from "babylonjs/Misc/observable";
  15993. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15994. import { Effect } from "babylonjs/Materials/effect";
  15995. import { IDisposable } from "babylonjs/scene";
  15996. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15997. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15998. import { Particle } from "babylonjs/Particles/particle";
  15999. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16000. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16001. import "babylonjs/Shaders/particles.fragment";
  16002. import "babylonjs/Shaders/particles.vertex";
  16003. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16004. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16005. import "babylonjs/Engines/Extensions/engine.alpha";
  16006. import { Scene } from "babylonjs/scene";
  16007. /**
  16008. * This represents a particle system in Babylon.
  16009. * 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.
  16010. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16011. * @example https://doc.babylonjs.com/babylon101/particles
  16012. */
  16013. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16014. /**
  16015. * Billboard mode will only apply to Y axis
  16016. */
  16017. static readonly BILLBOARDMODE_Y: number;
  16018. /**
  16019. * Billboard mode will apply to all axes
  16020. */
  16021. static readonly BILLBOARDMODE_ALL: number;
  16022. /**
  16023. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16024. */
  16025. static readonly BILLBOARDMODE_STRETCHED: number;
  16026. /**
  16027. * This function can be defined to provide custom update for active particles.
  16028. * This function will be called instead of regular update (age, position, color, etc.).
  16029. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16030. */
  16031. updateFunction: (particles: Particle[]) => void;
  16032. private _emitterWorldMatrix;
  16033. /**
  16034. * This function can be defined to specify initial direction for every new particle.
  16035. * It by default use the emitterType defined function
  16036. */
  16037. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16038. /**
  16039. * This function can be defined to specify initial position for every new particle.
  16040. * It by default use the emitterType defined function
  16041. */
  16042. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16043. /**
  16044. * @hidden
  16045. */
  16046. _inheritedVelocityOffset: Vector3;
  16047. /**
  16048. * An event triggered when the system is disposed
  16049. */
  16050. onDisposeObservable: Observable<IParticleSystem>;
  16051. /**
  16052. * An event triggered when the system is stopped
  16053. */
  16054. onStoppedObservable: Observable<IParticleSystem>;
  16055. private _onDisposeObserver;
  16056. /**
  16057. * Sets a callback that will be triggered when the system is disposed
  16058. */
  16059. set onDispose(callback: () => void);
  16060. private _particles;
  16061. private _epsilon;
  16062. private _capacity;
  16063. private _stockParticles;
  16064. private _newPartsExcess;
  16065. private _vertexData;
  16066. private _vertexBuffer;
  16067. private _vertexBuffers;
  16068. private _spriteBuffer;
  16069. private _indexBuffer;
  16070. private _effect;
  16071. private _customEffect;
  16072. private _cachedDefines;
  16073. private _scaledColorStep;
  16074. private _colorDiff;
  16075. private _scaledDirection;
  16076. private _scaledGravity;
  16077. private _currentRenderId;
  16078. private _alive;
  16079. private _useInstancing;
  16080. private _vertexArrayObject;
  16081. private _started;
  16082. private _stopped;
  16083. private _actualFrame;
  16084. private _scaledUpdateSpeed;
  16085. private _vertexBufferSize;
  16086. /** @hidden */
  16087. _currentEmitRateGradient: Nullable<FactorGradient>;
  16088. /** @hidden */
  16089. _currentEmitRate1: number;
  16090. /** @hidden */
  16091. _currentEmitRate2: number;
  16092. /** @hidden */
  16093. _currentStartSizeGradient: Nullable<FactorGradient>;
  16094. /** @hidden */
  16095. _currentStartSize1: number;
  16096. /** @hidden */
  16097. _currentStartSize2: number;
  16098. private readonly _rawTextureWidth;
  16099. private _rampGradientsTexture;
  16100. private _useRampGradients;
  16101. /** Gets or sets a matrix to use to compute projection */
  16102. defaultProjectionMatrix: Matrix;
  16103. /** Gets or sets a matrix to use to compute view */
  16104. defaultViewMatrix: Matrix;
  16105. /** Gets or sets a boolean indicating that ramp gradients must be used
  16106. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16107. */
  16108. get useRampGradients(): boolean;
  16109. set useRampGradients(value: boolean);
  16110. /**
  16111. * 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.
  16112. * 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: [])
  16113. */
  16114. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16115. private _subEmitters;
  16116. /**
  16117. * @hidden
  16118. * If the particle systems emitter should be disposed when the particle system is disposed
  16119. */
  16120. _disposeEmitterOnDispose: boolean;
  16121. /**
  16122. * The current active Sub-systems, this property is used by the root particle system only.
  16123. */
  16124. activeSubSystems: Array<ParticleSystem>;
  16125. /**
  16126. * Specifies if the particles are updated in emitter local space or world space
  16127. */
  16128. isLocal: boolean;
  16129. private _rootParticleSystem;
  16130. /**
  16131. * Gets the current list of active particles
  16132. */
  16133. get particles(): Particle[];
  16134. /**
  16135. * Gets the number of particles active at the same time.
  16136. * @returns The number of active particles.
  16137. */
  16138. getActiveCount(): number;
  16139. /**
  16140. * Returns the string "ParticleSystem"
  16141. * @returns a string containing the class name
  16142. */
  16143. getClassName(): string;
  16144. /**
  16145. * Gets a boolean indicating that the system is stopping
  16146. * @returns true if the system is currently stopping
  16147. */
  16148. isStopping(): boolean;
  16149. /**
  16150. * Gets the custom effect used to render the particles
  16151. * @param blendMode Blend mode for which the effect should be retrieved
  16152. * @returns The effect
  16153. */
  16154. getCustomEffect(blendMode?: number): Nullable<Effect>;
  16155. /**
  16156. * Sets the custom effect used to render the particles
  16157. * @param effect The effect to set
  16158. * @param blendMode Blend mode for which the effect should be set
  16159. */
  16160. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  16161. /** @hidden */
  16162. private _onBeforeDrawParticlesObservable;
  16163. /**
  16164. * Observable that will be called just before the particles are drawn
  16165. */
  16166. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  16167. /**
  16168. * Gets the name of the particle vertex shader
  16169. */
  16170. get vertexShaderName(): string;
  16171. /**
  16172. * Instantiates a particle system.
  16173. * 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.
  16174. * @param name The name of the particle system
  16175. * @param capacity The max number of particles alive at the same time
  16176. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  16177. * @param customEffect a custom effect used to change the way particles are rendered by default
  16178. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16179. * @param epsilon Offset used to render the particles
  16180. */
  16181. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16182. private _addFactorGradient;
  16183. private _removeFactorGradient;
  16184. /**
  16185. * Adds a new life time gradient
  16186. * @param gradient defines the gradient to use (between 0 and 1)
  16187. * @param factor defines the life time factor to affect to the specified gradient
  16188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16189. * @returns the current particle system
  16190. */
  16191. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16192. /**
  16193. * Remove a specific life time gradient
  16194. * @param gradient defines the gradient to remove
  16195. * @returns the current particle system
  16196. */
  16197. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16198. /**
  16199. * Adds a new size gradient
  16200. * @param gradient defines the gradient to use (between 0 and 1)
  16201. * @param factor defines the size factor to affect to the specified gradient
  16202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16203. * @returns the current particle system
  16204. */
  16205. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16206. /**
  16207. * Remove a specific size gradient
  16208. * @param gradient defines the gradient to remove
  16209. * @returns the current particle system
  16210. */
  16211. removeSizeGradient(gradient: number): IParticleSystem;
  16212. /**
  16213. * Adds a new color remap gradient
  16214. * @param gradient defines the gradient to use (between 0 and 1)
  16215. * @param min defines the color remap minimal range
  16216. * @param max defines the color remap maximal range
  16217. * @returns the current particle system
  16218. */
  16219. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16220. /**
  16221. * Remove a specific color remap gradient
  16222. * @param gradient defines the gradient to remove
  16223. * @returns the current particle system
  16224. */
  16225. removeColorRemapGradient(gradient: number): IParticleSystem;
  16226. /**
  16227. * Adds a new alpha remap gradient
  16228. * @param gradient defines the gradient to use (between 0 and 1)
  16229. * @param min defines the alpha remap minimal range
  16230. * @param max defines the alpha remap maximal range
  16231. * @returns the current particle system
  16232. */
  16233. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16234. /**
  16235. * Remove a specific alpha remap gradient
  16236. * @param gradient defines the gradient to remove
  16237. * @returns the current particle system
  16238. */
  16239. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16240. /**
  16241. * Adds a new angular speed gradient
  16242. * @param gradient defines the gradient to use (between 0 and 1)
  16243. * @param factor defines the angular speed to affect to the specified gradient
  16244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16245. * @returns the current particle system
  16246. */
  16247. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16248. /**
  16249. * Remove a specific angular speed gradient
  16250. * @param gradient defines the gradient to remove
  16251. * @returns the current particle system
  16252. */
  16253. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16254. /**
  16255. * Adds a new velocity gradient
  16256. * @param gradient defines the gradient to use (between 0 and 1)
  16257. * @param factor defines the velocity to affect to the specified gradient
  16258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16259. * @returns the current particle system
  16260. */
  16261. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16262. /**
  16263. * Remove a specific velocity gradient
  16264. * @param gradient defines the gradient to remove
  16265. * @returns the current particle system
  16266. */
  16267. removeVelocityGradient(gradient: number): IParticleSystem;
  16268. /**
  16269. * Adds a new limit velocity gradient
  16270. * @param gradient defines the gradient to use (between 0 and 1)
  16271. * @param factor defines the limit velocity value to affect to the specified gradient
  16272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16273. * @returns the current particle system
  16274. */
  16275. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16276. /**
  16277. * Remove a specific limit velocity gradient
  16278. * @param gradient defines the gradient to remove
  16279. * @returns the current particle system
  16280. */
  16281. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16282. /**
  16283. * Adds a new drag gradient
  16284. * @param gradient defines the gradient to use (between 0 and 1)
  16285. * @param factor defines the drag value to affect to the specified gradient
  16286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16287. * @returns the current particle system
  16288. */
  16289. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16290. /**
  16291. * Remove a specific drag gradient
  16292. * @param gradient defines the gradient to remove
  16293. * @returns the current particle system
  16294. */
  16295. removeDragGradient(gradient: number): IParticleSystem;
  16296. /**
  16297. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16298. * @param gradient defines the gradient to use (between 0 and 1)
  16299. * @param factor defines the emit rate value to affect to the specified gradient
  16300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16301. * @returns the current particle system
  16302. */
  16303. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16304. /**
  16305. * Remove a specific emit rate gradient
  16306. * @param gradient defines the gradient to remove
  16307. * @returns the current particle system
  16308. */
  16309. removeEmitRateGradient(gradient: number): IParticleSystem;
  16310. /**
  16311. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16312. * @param gradient defines the gradient to use (between 0 and 1)
  16313. * @param factor defines the start size value to affect to the specified gradient
  16314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16315. * @returns the current particle system
  16316. */
  16317. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16318. /**
  16319. * Remove a specific start size gradient
  16320. * @param gradient defines the gradient to remove
  16321. * @returns the current particle system
  16322. */
  16323. removeStartSizeGradient(gradient: number): IParticleSystem;
  16324. private _createRampGradientTexture;
  16325. /**
  16326. * Gets the current list of ramp gradients.
  16327. * You must use addRampGradient and removeRampGradient to udpate this list
  16328. * @returns the list of ramp gradients
  16329. */
  16330. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16331. /** Force the system to rebuild all gradients that need to be resync */
  16332. forceRefreshGradients(): void;
  16333. private _syncRampGradientTexture;
  16334. /**
  16335. * Adds a new ramp gradient used to remap particle colors
  16336. * @param gradient defines the gradient to use (between 0 and 1)
  16337. * @param color defines the color to affect to the specified gradient
  16338. * @returns the current particle system
  16339. */
  16340. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16341. /**
  16342. * Remove a specific ramp gradient
  16343. * @param gradient defines the gradient to remove
  16344. * @returns the current particle system
  16345. */
  16346. removeRampGradient(gradient: number): ParticleSystem;
  16347. /**
  16348. * Adds a new color gradient
  16349. * @param gradient defines the gradient to use (between 0 and 1)
  16350. * @param color1 defines the color to affect to the specified gradient
  16351. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16352. * @returns this particle system
  16353. */
  16354. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16355. /**
  16356. * Remove a specific color gradient
  16357. * @param gradient defines the gradient to remove
  16358. * @returns this particle system
  16359. */
  16360. removeColorGradient(gradient: number): IParticleSystem;
  16361. private _fetchR;
  16362. protected _reset(): void;
  16363. private _resetEffect;
  16364. private _createVertexBuffers;
  16365. private _createIndexBuffer;
  16366. /**
  16367. * Gets the maximum number of particles active at the same time.
  16368. * @returns The max number of active particles.
  16369. */
  16370. getCapacity(): number;
  16371. /**
  16372. * Gets whether there are still active particles in the system.
  16373. * @returns True if it is alive, otherwise false.
  16374. */
  16375. isAlive(): boolean;
  16376. /**
  16377. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16378. * @returns True if it has been started, otherwise false.
  16379. */
  16380. isStarted(): boolean;
  16381. private _prepareSubEmitterInternalArray;
  16382. /**
  16383. * Starts the particle system and begins to emit
  16384. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16385. */
  16386. start(delay?: number): void;
  16387. /**
  16388. * Stops the particle system.
  16389. * @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.
  16390. */
  16391. stop(stopSubEmitters?: boolean): void;
  16392. /**
  16393. * Remove all active particles
  16394. */
  16395. reset(): void;
  16396. /**
  16397. * @hidden (for internal use only)
  16398. */
  16399. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16400. /**
  16401. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16402. * Its lifetime will start back at 0.
  16403. */
  16404. recycleParticle: (particle: Particle) => void;
  16405. private _stopSubEmitters;
  16406. private _createParticle;
  16407. private _removeFromRoot;
  16408. private _emitFromParticle;
  16409. private _update;
  16410. /** @hidden */
  16411. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16412. /** @hidden */
  16413. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16414. /**
  16415. * Fill the defines array according to the current settings of the particle system
  16416. * @param defines Array to be updated
  16417. * @param blendMode blend mode to take into account when updating the array
  16418. */
  16419. fillDefines(defines: Array<string>, blendMode: number): void;
  16420. /**
  16421. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16422. * @param uniforms Uniforms array to fill
  16423. * @param attributes Attributes array to fill
  16424. * @param samplers Samplers array to fill
  16425. */
  16426. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16427. /** @hidden */
  16428. private _getEffect;
  16429. /**
  16430. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16431. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16432. */
  16433. animate(preWarmOnly?: boolean): void;
  16434. private _appendParticleVertices;
  16435. /**
  16436. * Rebuilds the particle system.
  16437. */
  16438. rebuild(): void;
  16439. /**
  16440. * Is this system ready to be used/rendered
  16441. * @return true if the system is ready
  16442. */
  16443. isReady(): boolean;
  16444. private _render;
  16445. /**
  16446. * Renders the particle system in its current state.
  16447. * @returns the current number of particles
  16448. */
  16449. render(): number;
  16450. /**
  16451. * Disposes the particle system and free the associated resources
  16452. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16453. */
  16454. dispose(disposeTexture?: boolean): void;
  16455. /**
  16456. * Clones the particle system.
  16457. * @param name The name of the cloned object
  16458. * @param newEmitter The new emitter to use
  16459. * @returns the cloned particle system
  16460. */
  16461. clone(name: string, newEmitter: any): ParticleSystem;
  16462. /**
  16463. * Serializes the particle system to a JSON object
  16464. * @param serializeTexture defines if the texture must be serialized as well
  16465. * @returns the JSON object
  16466. */
  16467. serialize(serializeTexture?: boolean): any;
  16468. /** @hidden */
  16469. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16470. /** @hidden */
  16471. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16472. /**
  16473. * Parses a JSON object to create a particle system.
  16474. * @param parsedParticleSystem The JSON object to parse
  16475. * @param sceneOrEngine The scene or the engine to create the particle system in
  16476. * @param rootUrl The root url to use to load external dependencies like texture
  16477. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16478. * @returns the Parsed particle system
  16479. */
  16480. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16481. }
  16482. }
  16483. declare module "babylonjs/Particles/particle" {
  16484. import { Nullable } from "babylonjs/types";
  16485. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  16486. import { Color4 } from "babylonjs/Maths/math.color";
  16487. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16488. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16489. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  16490. /**
  16491. * A particle represents one of the element emitted by a particle system.
  16492. * This is mainly define by its coordinates, direction, velocity and age.
  16493. */
  16494. export class Particle {
  16495. /**
  16496. * The particle system the particle belongs to.
  16497. */
  16498. particleSystem: ParticleSystem;
  16499. private static _Count;
  16500. /**
  16501. * Unique ID of the particle
  16502. */
  16503. id: number;
  16504. /**
  16505. * The world position of the particle in the scene.
  16506. */
  16507. position: Vector3;
  16508. /**
  16509. * The world direction of the particle in the scene.
  16510. */
  16511. direction: Vector3;
  16512. /**
  16513. * The color of the particle.
  16514. */
  16515. color: Color4;
  16516. /**
  16517. * The color change of the particle per step.
  16518. */
  16519. colorStep: Color4;
  16520. /**
  16521. * Defines how long will the life of the particle be.
  16522. */
  16523. lifeTime: number;
  16524. /**
  16525. * The current age of the particle.
  16526. */
  16527. age: number;
  16528. /**
  16529. * The current size of the particle.
  16530. */
  16531. size: number;
  16532. /**
  16533. * The current scale of the particle.
  16534. */
  16535. scale: Vector2;
  16536. /**
  16537. * The current angle of the particle.
  16538. */
  16539. angle: number;
  16540. /**
  16541. * Defines how fast is the angle changing.
  16542. */
  16543. angularSpeed: number;
  16544. /**
  16545. * Defines the cell index used by the particle to be rendered from a sprite.
  16546. */
  16547. cellIndex: number;
  16548. /**
  16549. * The information required to support color remapping
  16550. */
  16551. remapData: Vector4;
  16552. /** @hidden */
  16553. _randomCellOffset?: number;
  16554. /** @hidden */
  16555. _initialDirection: Nullable<Vector3>;
  16556. /** @hidden */
  16557. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16558. /** @hidden */
  16559. _initialStartSpriteCellID: number;
  16560. /** @hidden */
  16561. _initialEndSpriteCellID: number;
  16562. /** @hidden */
  16563. _currentColorGradient: Nullable<ColorGradient>;
  16564. /** @hidden */
  16565. _currentColor1: Color4;
  16566. /** @hidden */
  16567. _currentColor2: Color4;
  16568. /** @hidden */
  16569. _currentSizeGradient: Nullable<FactorGradient>;
  16570. /** @hidden */
  16571. _currentSize1: number;
  16572. /** @hidden */
  16573. _currentSize2: number;
  16574. /** @hidden */
  16575. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16576. /** @hidden */
  16577. _currentAngularSpeed1: number;
  16578. /** @hidden */
  16579. _currentAngularSpeed2: number;
  16580. /** @hidden */
  16581. _currentVelocityGradient: Nullable<FactorGradient>;
  16582. /** @hidden */
  16583. _currentVelocity1: number;
  16584. /** @hidden */
  16585. _currentVelocity2: number;
  16586. /** @hidden */
  16587. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16588. /** @hidden */
  16589. _currentLimitVelocity1: number;
  16590. /** @hidden */
  16591. _currentLimitVelocity2: number;
  16592. /** @hidden */
  16593. _currentDragGradient: Nullable<FactorGradient>;
  16594. /** @hidden */
  16595. _currentDrag1: number;
  16596. /** @hidden */
  16597. _currentDrag2: number;
  16598. /** @hidden */
  16599. _randomNoiseCoordinates1: Vector3;
  16600. /** @hidden */
  16601. _randomNoiseCoordinates2: Vector3;
  16602. /** @hidden */
  16603. _localPosition?: Vector3;
  16604. /**
  16605. * Creates a new instance Particle
  16606. * @param particleSystem the particle system the particle belongs to
  16607. */
  16608. constructor(
  16609. /**
  16610. * The particle system the particle belongs to.
  16611. */
  16612. particleSystem: ParticleSystem);
  16613. private updateCellInfoFromSystem;
  16614. /**
  16615. * Defines how the sprite cell index is updated for the particle
  16616. */
  16617. updateCellIndex(): void;
  16618. /** @hidden */
  16619. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16620. /** @hidden */
  16621. _inheritParticleInfoToSubEmitters(): void;
  16622. /** @hidden */
  16623. _reset(): void;
  16624. /**
  16625. * Copy the properties of particle to another one.
  16626. * @param other the particle to copy the information to.
  16627. */
  16628. copyTo(other: Particle): void;
  16629. }
  16630. }
  16631. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16633. import { Effect } from "babylonjs/Materials/effect";
  16634. import { Particle } from "babylonjs/Particles/particle";
  16635. import { Nullable } from "babylonjs/types";
  16636. import { Scene } from "babylonjs/scene";
  16637. /**
  16638. * Particle emitter represents a volume emitting particles.
  16639. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16640. */
  16641. export interface IParticleEmitterType {
  16642. /**
  16643. * Called by the particle System when the direction is computed for the created particle.
  16644. * @param worldMatrix is the world matrix of the particle system
  16645. * @param directionToUpdate is the direction vector to update with the result
  16646. * @param particle is the particle we are computed the direction for
  16647. * @param isLocal defines if the direction should be set in local space
  16648. */
  16649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16650. /**
  16651. * Called by the particle System when the position is computed for the created particle.
  16652. * @param worldMatrix is the world matrix of the particle system
  16653. * @param positionToUpdate is the position vector to update with the result
  16654. * @param particle is the particle we are computed the position for
  16655. * @param isLocal defines if the position should be set in local space
  16656. */
  16657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16658. /**
  16659. * Clones the current emitter and returns a copy of it
  16660. * @returns the new emitter
  16661. */
  16662. clone(): IParticleEmitterType;
  16663. /**
  16664. * Called by the GPUParticleSystem to setup the update shader
  16665. * @param effect defines the update shader
  16666. */
  16667. applyToShader(effect: Effect): void;
  16668. /**
  16669. * Returns a string to use to update the GPU particles update shader
  16670. * @returns the effect defines string
  16671. */
  16672. getEffectDefines(): string;
  16673. /**
  16674. * Returns a string representing the class name
  16675. * @returns a string containing the class name
  16676. */
  16677. getClassName(): string;
  16678. /**
  16679. * Serializes the particle system to a JSON object.
  16680. * @returns the JSON object
  16681. */
  16682. serialize(): any;
  16683. /**
  16684. * Parse properties from a JSON object
  16685. * @param serializationObject defines the JSON object
  16686. * @param scene defines the hosting scene
  16687. */
  16688. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16689. }
  16690. }
  16691. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16692. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16693. import { Effect } from "babylonjs/Materials/effect";
  16694. import { Particle } from "babylonjs/Particles/particle";
  16695. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16696. /**
  16697. * Particle emitter emitting particles from the inside of a box.
  16698. * It emits the particles randomly between 2 given directions.
  16699. */
  16700. export class BoxParticleEmitter implements IParticleEmitterType {
  16701. /**
  16702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16703. */
  16704. direction1: Vector3;
  16705. /**
  16706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16707. */
  16708. direction2: Vector3;
  16709. /**
  16710. * 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.
  16711. */
  16712. minEmitBox: Vector3;
  16713. /**
  16714. * 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.
  16715. */
  16716. maxEmitBox: Vector3;
  16717. /**
  16718. * Creates a new instance BoxParticleEmitter
  16719. */
  16720. constructor();
  16721. /**
  16722. * Called by the particle System when the direction is computed for the created particle.
  16723. * @param worldMatrix is the world matrix of the particle system
  16724. * @param directionToUpdate is the direction vector to update with the result
  16725. * @param particle is the particle we are computed the direction for
  16726. * @param isLocal defines if the direction should be set in local space
  16727. */
  16728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16729. /**
  16730. * Called by the particle System when the position is computed for the created particle.
  16731. * @param worldMatrix is the world matrix of the particle system
  16732. * @param positionToUpdate is the position vector to update with the result
  16733. * @param particle is the particle we are computed the position for
  16734. * @param isLocal defines if the position should be set in local space
  16735. */
  16736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16737. /**
  16738. * Clones the current emitter and returns a copy of it
  16739. * @returns the new emitter
  16740. */
  16741. clone(): BoxParticleEmitter;
  16742. /**
  16743. * Called by the GPUParticleSystem to setup the update shader
  16744. * @param effect defines the update shader
  16745. */
  16746. applyToShader(effect: Effect): void;
  16747. /**
  16748. * Returns a string to use to update the GPU particles update shader
  16749. * @returns a string containng the defines string
  16750. */
  16751. getEffectDefines(): string;
  16752. /**
  16753. * Returns the string "BoxParticleEmitter"
  16754. * @returns a string containing the class name
  16755. */
  16756. getClassName(): string;
  16757. /**
  16758. * Serializes the particle system to a JSON object.
  16759. * @returns the JSON object
  16760. */
  16761. serialize(): any;
  16762. /**
  16763. * Parse properties from a JSON object
  16764. * @param serializationObject defines the JSON object
  16765. */
  16766. parse(serializationObject: any): void;
  16767. }
  16768. }
  16769. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16770. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16771. import { Effect } from "babylonjs/Materials/effect";
  16772. import { Particle } from "babylonjs/Particles/particle";
  16773. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16774. /**
  16775. * Particle emitter emitting particles from the inside of a cone.
  16776. * It emits the particles alongside the cone volume from the base to the particle.
  16777. * The emission direction might be randomized.
  16778. */
  16779. export class ConeParticleEmitter implements IParticleEmitterType {
  16780. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16781. directionRandomizer: number;
  16782. private _radius;
  16783. private _angle;
  16784. private _height;
  16785. /**
  16786. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16787. */
  16788. radiusRange: number;
  16789. /**
  16790. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16791. */
  16792. heightRange: number;
  16793. /**
  16794. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16795. */
  16796. emitFromSpawnPointOnly: boolean;
  16797. /**
  16798. * Gets or sets the radius of the emission cone
  16799. */
  16800. get radius(): number;
  16801. set radius(value: number);
  16802. /**
  16803. * Gets or sets the angle of the emission cone
  16804. */
  16805. get angle(): number;
  16806. set angle(value: number);
  16807. private _buildHeight;
  16808. /**
  16809. * Creates a new instance ConeParticleEmitter
  16810. * @param radius the radius of the emission cone (1 by default)
  16811. * @param angle the cone base angle (PI by default)
  16812. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16813. */
  16814. constructor(radius?: number, angle?: number,
  16815. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16816. directionRandomizer?: number);
  16817. /**
  16818. * Called by the particle System when the direction is computed for the created particle.
  16819. * @param worldMatrix is the world matrix of the particle system
  16820. * @param directionToUpdate is the direction vector to update with the result
  16821. * @param particle is the particle we are computed the direction for
  16822. * @param isLocal defines if the direction should be set in local space
  16823. */
  16824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16825. /**
  16826. * Called by the particle System when the position is computed for the created particle.
  16827. * @param worldMatrix is the world matrix of the particle system
  16828. * @param positionToUpdate is the position vector to update with the result
  16829. * @param particle is the particle we are computed the position for
  16830. * @param isLocal defines if the position should be set in local space
  16831. */
  16832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16833. /**
  16834. * Clones the current emitter and returns a copy of it
  16835. * @returns the new emitter
  16836. */
  16837. clone(): ConeParticleEmitter;
  16838. /**
  16839. * Called by the GPUParticleSystem to setup the update shader
  16840. * @param effect defines the update shader
  16841. */
  16842. applyToShader(effect: Effect): void;
  16843. /**
  16844. * Returns a string to use to update the GPU particles update shader
  16845. * @returns a string containng the defines string
  16846. */
  16847. getEffectDefines(): string;
  16848. /**
  16849. * Returns the string "ConeParticleEmitter"
  16850. * @returns a string containing the class name
  16851. */
  16852. getClassName(): string;
  16853. /**
  16854. * Serializes the particle system to a JSON object.
  16855. * @returns the JSON object
  16856. */
  16857. serialize(): any;
  16858. /**
  16859. * Parse properties from a JSON object
  16860. * @param serializationObject defines the JSON object
  16861. */
  16862. parse(serializationObject: any): void;
  16863. }
  16864. }
  16865. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16866. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16867. import { Effect } from "babylonjs/Materials/effect";
  16868. import { Particle } from "babylonjs/Particles/particle";
  16869. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16870. /**
  16871. * Particle emitter emitting particles from the inside of a cylinder.
  16872. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16873. */
  16874. export class CylinderParticleEmitter implements IParticleEmitterType {
  16875. /**
  16876. * The radius of the emission cylinder.
  16877. */
  16878. radius: number;
  16879. /**
  16880. * The height of the emission cylinder.
  16881. */
  16882. height: number;
  16883. /**
  16884. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16885. */
  16886. radiusRange: number;
  16887. /**
  16888. * How much to randomize the particle direction [0-1].
  16889. */
  16890. directionRandomizer: number;
  16891. /**
  16892. * Creates a new instance CylinderParticleEmitter
  16893. * @param radius the radius of the emission cylinder (1 by default)
  16894. * @param height the height of the emission cylinder (1 by default)
  16895. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16897. */
  16898. constructor(
  16899. /**
  16900. * The radius of the emission cylinder.
  16901. */
  16902. radius?: number,
  16903. /**
  16904. * The height of the emission cylinder.
  16905. */
  16906. height?: number,
  16907. /**
  16908. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16909. */
  16910. radiusRange?: number,
  16911. /**
  16912. * How much to randomize the particle direction [0-1].
  16913. */
  16914. directionRandomizer?: number);
  16915. /**
  16916. * Called by the particle System when the direction is computed for the created particle.
  16917. * @param worldMatrix is the world matrix of the particle system
  16918. * @param directionToUpdate is the direction vector to update with the result
  16919. * @param particle is the particle we are computed the direction for
  16920. * @param isLocal defines if the direction should be set in local space
  16921. */
  16922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16923. /**
  16924. * Called by the particle System when the position is computed for the created particle.
  16925. * @param worldMatrix is the world matrix of the particle system
  16926. * @param positionToUpdate is the position vector to update with the result
  16927. * @param particle is the particle we are computed the position for
  16928. * @param isLocal defines if the position should be set in local space
  16929. */
  16930. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16931. /**
  16932. * Clones the current emitter and returns a copy of it
  16933. * @returns the new emitter
  16934. */
  16935. clone(): CylinderParticleEmitter;
  16936. /**
  16937. * Called by the GPUParticleSystem to setup the update shader
  16938. * @param effect defines the update shader
  16939. */
  16940. applyToShader(effect: Effect): void;
  16941. /**
  16942. * Returns a string to use to update the GPU particles update shader
  16943. * @returns a string containng the defines string
  16944. */
  16945. getEffectDefines(): string;
  16946. /**
  16947. * Returns the string "CylinderParticleEmitter"
  16948. * @returns a string containing the class name
  16949. */
  16950. getClassName(): string;
  16951. /**
  16952. * Serializes the particle system to a JSON object.
  16953. * @returns the JSON object
  16954. */
  16955. serialize(): any;
  16956. /**
  16957. * Parse properties from a JSON object
  16958. * @param serializationObject defines the JSON object
  16959. */
  16960. parse(serializationObject: any): void;
  16961. }
  16962. /**
  16963. * Particle emitter emitting particles from the inside of a cylinder.
  16964. * It emits the particles randomly between two vectors.
  16965. */
  16966. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16967. /**
  16968. * The min limit of the emission direction.
  16969. */
  16970. direction1: Vector3;
  16971. /**
  16972. * The max limit of the emission direction.
  16973. */
  16974. direction2: Vector3;
  16975. /**
  16976. * Creates a new instance CylinderDirectedParticleEmitter
  16977. * @param radius the radius of the emission cylinder (1 by default)
  16978. * @param height the height of the emission cylinder (1 by default)
  16979. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16980. * @param direction1 the min limit of the emission direction (up vector by default)
  16981. * @param direction2 the max limit of the emission direction (up vector by default)
  16982. */
  16983. constructor(radius?: number, height?: number, radiusRange?: number,
  16984. /**
  16985. * The min limit of the emission direction.
  16986. */
  16987. direction1?: Vector3,
  16988. /**
  16989. * The max limit of the emission direction.
  16990. */
  16991. direction2?: Vector3);
  16992. /**
  16993. * Called by the particle System when the direction is computed for the created particle.
  16994. * @param worldMatrix is the world matrix of the particle system
  16995. * @param directionToUpdate is the direction vector to update with the result
  16996. * @param particle is the particle we are computed the direction for
  16997. */
  16998. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16999. /**
  17000. * Clones the current emitter and returns a copy of it
  17001. * @returns the new emitter
  17002. */
  17003. clone(): CylinderDirectedParticleEmitter;
  17004. /**
  17005. * Called by the GPUParticleSystem to setup the update shader
  17006. * @param effect defines the update shader
  17007. */
  17008. applyToShader(effect: Effect): void;
  17009. /**
  17010. * Returns a string to use to update the GPU particles update shader
  17011. * @returns a string containng the defines string
  17012. */
  17013. getEffectDefines(): string;
  17014. /**
  17015. * Returns the string "CylinderDirectedParticleEmitter"
  17016. * @returns a string containing the class name
  17017. */
  17018. getClassName(): string;
  17019. /**
  17020. * Serializes the particle system to a JSON object.
  17021. * @returns the JSON object
  17022. */
  17023. serialize(): any;
  17024. /**
  17025. * Parse properties from a JSON object
  17026. * @param serializationObject defines the JSON object
  17027. */
  17028. parse(serializationObject: any): void;
  17029. }
  17030. }
  17031. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  17032. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17033. import { Effect } from "babylonjs/Materials/effect";
  17034. import { Particle } from "babylonjs/Particles/particle";
  17035. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17036. /**
  17037. * Particle emitter emitting particles from the inside of a hemisphere.
  17038. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17039. */
  17040. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17041. /**
  17042. * The radius of the emission hemisphere.
  17043. */
  17044. radius: number;
  17045. /**
  17046. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17047. */
  17048. radiusRange: number;
  17049. /**
  17050. * How much to randomize the particle direction [0-1].
  17051. */
  17052. directionRandomizer: number;
  17053. /**
  17054. * Creates a new instance HemisphericParticleEmitter
  17055. * @param radius the radius of the emission hemisphere (1 by default)
  17056. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17057. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17058. */
  17059. constructor(
  17060. /**
  17061. * The radius of the emission hemisphere.
  17062. */
  17063. radius?: number,
  17064. /**
  17065. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17066. */
  17067. radiusRange?: number,
  17068. /**
  17069. * How much to randomize the particle direction [0-1].
  17070. */
  17071. directionRandomizer?: number);
  17072. /**
  17073. * Called by the particle System when the direction is computed for the created particle.
  17074. * @param worldMatrix is the world matrix of the particle system
  17075. * @param directionToUpdate is the direction vector to update with the result
  17076. * @param particle is the particle we are computed the direction for
  17077. * @param isLocal defines if the direction should be set in local space
  17078. */
  17079. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17080. /**
  17081. * Called by the particle System when the position is computed for the created particle.
  17082. * @param worldMatrix is the world matrix of the particle system
  17083. * @param positionToUpdate is the position vector to update with the result
  17084. * @param particle is the particle we are computed the position for
  17085. * @param isLocal defines if the position should be set in local space
  17086. */
  17087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17088. /**
  17089. * Clones the current emitter and returns a copy of it
  17090. * @returns the new emitter
  17091. */
  17092. clone(): HemisphericParticleEmitter;
  17093. /**
  17094. * Called by the GPUParticleSystem to setup the update shader
  17095. * @param effect defines the update shader
  17096. */
  17097. applyToShader(effect: Effect): void;
  17098. /**
  17099. * Returns a string to use to update the GPU particles update shader
  17100. * @returns a string containng the defines string
  17101. */
  17102. getEffectDefines(): string;
  17103. /**
  17104. * Returns the string "HemisphericParticleEmitter"
  17105. * @returns a string containing the class name
  17106. */
  17107. getClassName(): string;
  17108. /**
  17109. * Serializes the particle system to a JSON object.
  17110. * @returns the JSON object
  17111. */
  17112. serialize(): any;
  17113. /**
  17114. * Parse properties from a JSON object
  17115. * @param serializationObject defines the JSON object
  17116. */
  17117. parse(serializationObject: any): void;
  17118. }
  17119. }
  17120. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  17121. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17122. import { Effect } from "babylonjs/Materials/effect";
  17123. import { Particle } from "babylonjs/Particles/particle";
  17124. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17125. /**
  17126. * Particle emitter emitting particles from a point.
  17127. * It emits the particles randomly between 2 given directions.
  17128. */
  17129. export class PointParticleEmitter implements IParticleEmitterType {
  17130. /**
  17131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17132. */
  17133. direction1: Vector3;
  17134. /**
  17135. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17136. */
  17137. direction2: Vector3;
  17138. /**
  17139. * Creates a new instance PointParticleEmitter
  17140. */
  17141. constructor();
  17142. /**
  17143. * Called by the particle System when the direction is computed for the created particle.
  17144. * @param worldMatrix is the world matrix of the particle system
  17145. * @param directionToUpdate is the direction vector to update with the result
  17146. * @param particle is the particle we are computed the direction for
  17147. * @param isLocal defines if the direction should be set in local space
  17148. */
  17149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17150. /**
  17151. * Called by the particle System when the position is computed for the created particle.
  17152. * @param worldMatrix is the world matrix of the particle system
  17153. * @param positionToUpdate is the position vector to update with the result
  17154. * @param particle is the particle we are computed the position for
  17155. * @param isLocal defines if the position should be set in local space
  17156. */
  17157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17158. /**
  17159. * Clones the current emitter and returns a copy of it
  17160. * @returns the new emitter
  17161. */
  17162. clone(): PointParticleEmitter;
  17163. /**
  17164. * Called by the GPUParticleSystem to setup the update shader
  17165. * @param effect defines the update shader
  17166. */
  17167. applyToShader(effect: Effect): void;
  17168. /**
  17169. * Returns a string to use to update the GPU particles update shader
  17170. * @returns a string containng the defines string
  17171. */
  17172. getEffectDefines(): string;
  17173. /**
  17174. * Returns the string "PointParticleEmitter"
  17175. * @returns a string containing the class name
  17176. */
  17177. getClassName(): string;
  17178. /**
  17179. * Serializes the particle system to a JSON object.
  17180. * @returns the JSON object
  17181. */
  17182. serialize(): any;
  17183. /**
  17184. * Parse properties from a JSON object
  17185. * @param serializationObject defines the JSON object
  17186. */
  17187. parse(serializationObject: any): void;
  17188. }
  17189. }
  17190. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  17191. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17192. import { Effect } from "babylonjs/Materials/effect";
  17193. import { Particle } from "babylonjs/Particles/particle";
  17194. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17195. /**
  17196. * Particle emitter emitting particles from the inside of a sphere.
  17197. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17198. */
  17199. export class SphereParticleEmitter implements IParticleEmitterType {
  17200. /**
  17201. * The radius of the emission sphere.
  17202. */
  17203. radius: number;
  17204. /**
  17205. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17206. */
  17207. radiusRange: number;
  17208. /**
  17209. * How much to randomize the particle direction [0-1].
  17210. */
  17211. directionRandomizer: number;
  17212. /**
  17213. * Creates a new instance SphereParticleEmitter
  17214. * @param radius the radius of the emission sphere (1 by default)
  17215. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17216. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17217. */
  17218. constructor(
  17219. /**
  17220. * The radius of the emission sphere.
  17221. */
  17222. radius?: number,
  17223. /**
  17224. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17225. */
  17226. radiusRange?: number,
  17227. /**
  17228. * How much to randomize the particle direction [0-1].
  17229. */
  17230. directionRandomizer?: number);
  17231. /**
  17232. * Called by the particle System when the direction is computed for the created particle.
  17233. * @param worldMatrix is the world matrix of the particle system
  17234. * @param directionToUpdate is the direction vector to update with the result
  17235. * @param particle is the particle we are computed the direction for
  17236. * @param isLocal defines if the direction should be set in local space
  17237. */
  17238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17239. /**
  17240. * Called by the particle System when the position is computed for the created particle.
  17241. * @param worldMatrix is the world matrix of the particle system
  17242. * @param positionToUpdate is the position vector to update with the result
  17243. * @param particle is the particle we are computed the position for
  17244. * @param isLocal defines if the position should be set in local space
  17245. */
  17246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17247. /**
  17248. * Clones the current emitter and returns a copy of it
  17249. * @returns the new emitter
  17250. */
  17251. clone(): SphereParticleEmitter;
  17252. /**
  17253. * Called by the GPUParticleSystem to setup the update shader
  17254. * @param effect defines the update shader
  17255. */
  17256. applyToShader(effect: Effect): void;
  17257. /**
  17258. * Returns a string to use to update the GPU particles update shader
  17259. * @returns a string containng the defines string
  17260. */
  17261. getEffectDefines(): string;
  17262. /**
  17263. * Returns the string "SphereParticleEmitter"
  17264. * @returns a string containing the class name
  17265. */
  17266. getClassName(): string;
  17267. /**
  17268. * Serializes the particle system to a JSON object.
  17269. * @returns the JSON object
  17270. */
  17271. serialize(): any;
  17272. /**
  17273. * Parse properties from a JSON object
  17274. * @param serializationObject defines the JSON object
  17275. */
  17276. parse(serializationObject: any): void;
  17277. }
  17278. /**
  17279. * Particle emitter emitting particles from the inside of a sphere.
  17280. * It emits the particles randomly between two vectors.
  17281. */
  17282. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17283. /**
  17284. * The min limit of the emission direction.
  17285. */
  17286. direction1: Vector3;
  17287. /**
  17288. * The max limit of the emission direction.
  17289. */
  17290. direction2: Vector3;
  17291. /**
  17292. * Creates a new instance SphereDirectedParticleEmitter
  17293. * @param radius the radius of the emission sphere (1 by default)
  17294. * @param direction1 the min limit of the emission direction (up vector by default)
  17295. * @param direction2 the max limit of the emission direction (up vector by default)
  17296. */
  17297. constructor(radius?: number,
  17298. /**
  17299. * The min limit of the emission direction.
  17300. */
  17301. direction1?: Vector3,
  17302. /**
  17303. * The max limit of the emission direction.
  17304. */
  17305. direction2?: Vector3);
  17306. /**
  17307. * Called by the particle System when the direction is computed for the created particle.
  17308. * @param worldMatrix is the world matrix of the particle system
  17309. * @param directionToUpdate is the direction vector to update with the result
  17310. * @param particle is the particle we are computed the direction for
  17311. */
  17312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17313. /**
  17314. * Clones the current emitter and returns a copy of it
  17315. * @returns the new emitter
  17316. */
  17317. clone(): SphereDirectedParticleEmitter;
  17318. /**
  17319. * Called by the GPUParticleSystem to setup the update shader
  17320. * @param effect defines the update shader
  17321. */
  17322. applyToShader(effect: Effect): void;
  17323. /**
  17324. * Returns a string to use to update the GPU particles update shader
  17325. * @returns a string containng the defines string
  17326. */
  17327. getEffectDefines(): string;
  17328. /**
  17329. * Returns the string "SphereDirectedParticleEmitter"
  17330. * @returns a string containing the class name
  17331. */
  17332. getClassName(): string;
  17333. /**
  17334. * Serializes the particle system to a JSON object.
  17335. * @returns the JSON object
  17336. */
  17337. serialize(): any;
  17338. /**
  17339. * Parse properties from a JSON object
  17340. * @param serializationObject defines the JSON object
  17341. */
  17342. parse(serializationObject: any): void;
  17343. }
  17344. }
  17345. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  17346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17347. import { Effect } from "babylonjs/Materials/effect";
  17348. import { Particle } from "babylonjs/Particles/particle";
  17349. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17350. import { Nullable } from "babylonjs/types";
  17351. /**
  17352. * Particle emitter emitting particles from a custom list of positions.
  17353. */
  17354. export class CustomParticleEmitter implements IParticleEmitterType {
  17355. /**
  17356. * Gets or sets the position generator that will create the inital position of each particle.
  17357. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17358. */
  17359. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  17360. /**
  17361. * Gets or sets the destination generator that will create the final destination of each particle.
  17362. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17363. */
  17364. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  17365. /**
  17366. * Creates a new instance CustomParticleEmitter
  17367. */
  17368. constructor();
  17369. /**
  17370. * Called by the particle System when the direction is computed for the created particle.
  17371. * @param worldMatrix is the world matrix of the particle system
  17372. * @param directionToUpdate is the direction vector to update with the result
  17373. * @param particle is the particle we are computed the direction for
  17374. * @param isLocal defines if the direction should be set in local space
  17375. */
  17376. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17377. /**
  17378. * Called by the particle System when the position is computed for the created particle.
  17379. * @param worldMatrix is the world matrix of the particle system
  17380. * @param positionToUpdate is the position vector to update with the result
  17381. * @param particle is the particle we are computed the position for
  17382. * @param isLocal defines if the position should be set in local space
  17383. */
  17384. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17385. /**
  17386. * Clones the current emitter and returns a copy of it
  17387. * @returns the new emitter
  17388. */
  17389. clone(): CustomParticleEmitter;
  17390. /**
  17391. * Called by the GPUParticleSystem to setup the update shader
  17392. * @param effect defines the update shader
  17393. */
  17394. applyToShader(effect: Effect): void;
  17395. /**
  17396. * Returns a string to use to update the GPU particles update shader
  17397. * @returns a string containng the defines string
  17398. */
  17399. getEffectDefines(): string;
  17400. /**
  17401. * Returns the string "PointParticleEmitter"
  17402. * @returns a string containing the class name
  17403. */
  17404. getClassName(): string;
  17405. /**
  17406. * Serializes the particle system to a JSON object.
  17407. * @returns the JSON object
  17408. */
  17409. serialize(): any;
  17410. /**
  17411. * Parse properties from a JSON object
  17412. * @param serializationObject defines the JSON object
  17413. */
  17414. parse(serializationObject: any): void;
  17415. }
  17416. }
  17417. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  17418. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17419. import { Effect } from "babylonjs/Materials/effect";
  17420. import { Particle } from "babylonjs/Particles/particle";
  17421. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17422. import { Nullable } from "babylonjs/types";
  17423. import { Scene } from "babylonjs/scene";
  17424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17425. /**
  17426. * Particle emitter emitting particles from the inside of a box.
  17427. * It emits the particles randomly between 2 given directions.
  17428. */
  17429. export class MeshParticleEmitter implements IParticleEmitterType {
  17430. private _indices;
  17431. private _positions;
  17432. private _normals;
  17433. private _storedNormal;
  17434. private _mesh;
  17435. /**
  17436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17437. */
  17438. direction1: Vector3;
  17439. /**
  17440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17441. */
  17442. direction2: Vector3;
  17443. /**
  17444. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17445. */
  17446. useMeshNormalsForDirection: boolean;
  17447. /** Defines the mesh to use as source */
  17448. get mesh(): Nullable<AbstractMesh>;
  17449. set mesh(value: Nullable<AbstractMesh>);
  17450. /**
  17451. * Creates a new instance MeshParticleEmitter
  17452. * @param mesh defines the mesh to use as source
  17453. */
  17454. constructor(mesh?: Nullable<AbstractMesh>);
  17455. /**
  17456. * Called by the particle System when the direction is computed for the created particle.
  17457. * @param worldMatrix is the world matrix of the particle system
  17458. * @param directionToUpdate is the direction vector to update with the result
  17459. * @param particle is the particle we are computed the direction for
  17460. * @param isLocal defines if the direction should be set in local space
  17461. */
  17462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17463. /**
  17464. * Called by the particle System when the position is computed for the created particle.
  17465. * @param worldMatrix is the world matrix of the particle system
  17466. * @param positionToUpdate is the position vector to update with the result
  17467. * @param particle is the particle we are computed the position for
  17468. * @param isLocal defines if the position should be set in local space
  17469. */
  17470. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17471. /**
  17472. * Clones the current emitter and returns a copy of it
  17473. * @returns the new emitter
  17474. */
  17475. clone(): MeshParticleEmitter;
  17476. /**
  17477. * Called by the GPUParticleSystem to setup the update shader
  17478. * @param effect defines the update shader
  17479. */
  17480. applyToShader(effect: Effect): void;
  17481. /**
  17482. * Returns a string to use to update the GPU particles update shader
  17483. * @returns a string containng the defines string
  17484. */
  17485. getEffectDefines(): string;
  17486. /**
  17487. * Returns the string "BoxParticleEmitter"
  17488. * @returns a string containing the class name
  17489. */
  17490. getClassName(): string;
  17491. /**
  17492. * Serializes the particle system to a JSON object.
  17493. * @returns the JSON object
  17494. */
  17495. serialize(): any;
  17496. /**
  17497. * Parse properties from a JSON object
  17498. * @param serializationObject defines the JSON object
  17499. * @param scene defines the hosting scene
  17500. */
  17501. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17502. }
  17503. }
  17504. declare module "babylonjs/Particles/EmitterTypes/index" {
  17505. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  17506. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  17507. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  17508. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  17509. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17510. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  17511. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  17512. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  17513. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  17514. }
  17515. declare module "babylonjs/Particles/IParticleSystem" {
  17516. import { Nullable } from "babylonjs/types";
  17517. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17518. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17520. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17521. import { Scene } from "babylonjs/scene";
  17522. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17523. import { Effect } from "babylonjs/Materials/effect";
  17524. import { Observable } from "babylonjs/Misc/observable";
  17525. import { Animation } from "babylonjs/Animations/animation";
  17526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17527. /**
  17528. * Interface representing a particle system in Babylon.js.
  17529. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17530. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17531. */
  17532. export interface IParticleSystem {
  17533. /**
  17534. * List of animations used by the particle system.
  17535. */
  17536. animations: Animation[];
  17537. /**
  17538. * The id of the Particle system.
  17539. */
  17540. id: string;
  17541. /**
  17542. * The name of the Particle system.
  17543. */
  17544. name: string;
  17545. /**
  17546. * The emitter represents the Mesh or position we are attaching the particle system to.
  17547. */
  17548. emitter: Nullable<AbstractMesh | Vector3>;
  17549. /**
  17550. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17551. */
  17552. isBillboardBased: boolean;
  17553. /**
  17554. * The rendering group used by the Particle system to chose when to render.
  17555. */
  17556. renderingGroupId: number;
  17557. /**
  17558. * The layer mask we are rendering the particles through.
  17559. */
  17560. layerMask: number;
  17561. /**
  17562. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17563. */
  17564. updateSpeed: number;
  17565. /**
  17566. * The amount of time the particle system is running (depends of the overall update speed).
  17567. */
  17568. targetStopDuration: number;
  17569. /**
  17570. * The texture used to render each particle. (this can be a spritesheet)
  17571. */
  17572. particleTexture: Nullable<BaseTexture>;
  17573. /**
  17574. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17575. */
  17576. blendMode: number;
  17577. /**
  17578. * Minimum life time of emitting particles.
  17579. */
  17580. minLifeTime: number;
  17581. /**
  17582. * Maximum life time of emitting particles.
  17583. */
  17584. maxLifeTime: number;
  17585. /**
  17586. * Minimum Size of emitting particles.
  17587. */
  17588. minSize: number;
  17589. /**
  17590. * Maximum Size of emitting particles.
  17591. */
  17592. maxSize: number;
  17593. /**
  17594. * Minimum scale of emitting particles on X axis.
  17595. */
  17596. minScaleX: number;
  17597. /**
  17598. * Maximum scale of emitting particles on X axis.
  17599. */
  17600. maxScaleX: number;
  17601. /**
  17602. * Minimum scale of emitting particles on Y axis.
  17603. */
  17604. minScaleY: number;
  17605. /**
  17606. * Maximum scale of emitting particles on Y axis.
  17607. */
  17608. maxScaleY: number;
  17609. /**
  17610. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17611. */
  17612. color1: Color4;
  17613. /**
  17614. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17615. */
  17616. color2: Color4;
  17617. /**
  17618. * Color the particle will have at the end of its lifetime.
  17619. */
  17620. colorDead: Color4;
  17621. /**
  17622. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17623. */
  17624. emitRate: number;
  17625. /**
  17626. * You can use gravity if you want to give an orientation to your particles.
  17627. */
  17628. gravity: Vector3;
  17629. /**
  17630. * Minimum power of emitting particles.
  17631. */
  17632. minEmitPower: number;
  17633. /**
  17634. * Maximum power of emitting particles.
  17635. */
  17636. maxEmitPower: number;
  17637. /**
  17638. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17639. */
  17640. minAngularSpeed: number;
  17641. /**
  17642. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17643. */
  17644. maxAngularSpeed: number;
  17645. /**
  17646. * Gets or sets the minimal initial rotation in radians.
  17647. */
  17648. minInitialRotation: number;
  17649. /**
  17650. * Gets or sets the maximal initial rotation in radians.
  17651. */
  17652. maxInitialRotation: number;
  17653. /**
  17654. * The particle emitter type defines the emitter used by the particle system.
  17655. * It can be for example box, sphere, or cone...
  17656. */
  17657. particleEmitterType: Nullable<IParticleEmitterType>;
  17658. /**
  17659. * Defines the delay in milliseconds before starting the system (0 by default)
  17660. */
  17661. startDelay: number;
  17662. /**
  17663. * 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
  17664. */
  17665. preWarmCycles: number;
  17666. /**
  17667. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17668. */
  17669. preWarmStepOffset: number;
  17670. /**
  17671. * 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)
  17672. */
  17673. spriteCellChangeSpeed: number;
  17674. /**
  17675. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17676. */
  17677. startSpriteCellID: number;
  17678. /**
  17679. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17680. */
  17681. endSpriteCellID: number;
  17682. /**
  17683. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17684. */
  17685. spriteCellWidth: number;
  17686. /**
  17687. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17688. */
  17689. spriteCellHeight: number;
  17690. /**
  17691. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17692. */
  17693. spriteRandomStartCell: boolean;
  17694. /**
  17695. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17696. */
  17697. isAnimationSheetEnabled: boolean;
  17698. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17699. translationPivot: Vector2;
  17700. /**
  17701. * Gets or sets a texture used to add random noise to particle positions
  17702. */
  17703. noiseTexture: Nullable<BaseTexture>;
  17704. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17705. noiseStrength: Vector3;
  17706. /**
  17707. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17708. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17709. */
  17710. billboardMode: number;
  17711. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17712. limitVelocityDamping: number;
  17713. /**
  17714. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17715. */
  17716. beginAnimationOnStart: boolean;
  17717. /**
  17718. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17719. */
  17720. beginAnimationFrom: number;
  17721. /**
  17722. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17723. */
  17724. beginAnimationTo: number;
  17725. /**
  17726. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17727. */
  17728. beginAnimationLoop: boolean;
  17729. /**
  17730. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17731. */
  17732. disposeOnStop: boolean;
  17733. /**
  17734. * Specifies if the particles are updated in emitter local space or world space
  17735. */
  17736. isLocal: boolean;
  17737. /** Snippet ID if the particle system was created from the snippet server */
  17738. snippetId: string;
  17739. /** Gets or sets a matrix to use to compute projection */
  17740. defaultProjectionMatrix: Matrix;
  17741. /**
  17742. * Gets the maximum number of particles active at the same time.
  17743. * @returns The max number of active particles.
  17744. */
  17745. getCapacity(): number;
  17746. /**
  17747. * Gets the number of particles active at the same time.
  17748. * @returns The number of active particles.
  17749. */
  17750. getActiveCount(): number;
  17751. /**
  17752. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17753. * @returns True if it has been started, otherwise false.
  17754. */
  17755. isStarted(): boolean;
  17756. /**
  17757. * Animates the particle system for this frame.
  17758. */
  17759. animate(): void;
  17760. /**
  17761. * Renders the particle system in its current state.
  17762. * @returns the current number of particles
  17763. */
  17764. render(): number;
  17765. /**
  17766. * Dispose the particle system and frees its associated resources.
  17767. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17768. */
  17769. dispose(disposeTexture?: boolean): void;
  17770. /**
  17771. * An event triggered when the system is disposed
  17772. */
  17773. onDisposeObservable: Observable<IParticleSystem>;
  17774. /**
  17775. * An event triggered when the system is stopped
  17776. */
  17777. onStoppedObservable: Observable<IParticleSystem>;
  17778. /**
  17779. * Clones the particle system.
  17780. * @param name The name of the cloned object
  17781. * @param newEmitter The new emitter to use
  17782. * @returns the cloned particle system
  17783. */
  17784. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17785. /**
  17786. * Serializes the particle system to a JSON object
  17787. * @param serializeTexture defines if the texture must be serialized as well
  17788. * @returns the JSON object
  17789. */
  17790. serialize(serializeTexture: boolean): any;
  17791. /**
  17792. * Rebuild the particle system
  17793. */
  17794. rebuild(): void;
  17795. /** Force the system to rebuild all gradients that need to be resync */
  17796. forceRefreshGradients(): void;
  17797. /**
  17798. * Starts the particle system and begins to emit
  17799. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17800. */
  17801. start(delay?: number): void;
  17802. /**
  17803. * Stops the particle system.
  17804. */
  17805. stop(): void;
  17806. /**
  17807. * Remove all active particles
  17808. */
  17809. reset(): void;
  17810. /**
  17811. * Gets a boolean indicating that the system is stopping
  17812. * @returns true if the system is currently stopping
  17813. */
  17814. isStopping(): boolean;
  17815. /**
  17816. * Is this system ready to be used/rendered
  17817. * @return true if the system is ready
  17818. */
  17819. isReady(): boolean;
  17820. /**
  17821. * Returns the string "ParticleSystem"
  17822. * @returns a string containing the class name
  17823. */
  17824. getClassName(): string;
  17825. /**
  17826. * Gets the custom effect used to render the particles
  17827. * @param blendMode Blend mode for which the effect should be retrieved
  17828. * @returns The effect
  17829. */
  17830. getCustomEffect(blendMode: number): Nullable<Effect>;
  17831. /**
  17832. * Sets the custom effect used to render the particles
  17833. * @param effect The effect to set
  17834. * @param blendMode Blend mode for which the effect should be set
  17835. */
  17836. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17837. /**
  17838. * Fill the defines array according to the current settings of the particle system
  17839. * @param defines Array to be updated
  17840. * @param blendMode blend mode to take into account when updating the array
  17841. */
  17842. fillDefines(defines: Array<string>, blendMode: number): void;
  17843. /**
  17844. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17845. * @param uniforms Uniforms array to fill
  17846. * @param attributes Attributes array to fill
  17847. * @param samplers Samplers array to fill
  17848. */
  17849. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17850. /**
  17851. * Observable that will be called just before the particles are drawn
  17852. */
  17853. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17854. /**
  17855. * Gets the name of the particle vertex shader
  17856. */
  17857. vertexShaderName: string;
  17858. /**
  17859. * Adds a new color gradient
  17860. * @param gradient defines the gradient to use (between 0 and 1)
  17861. * @param color1 defines the color to affect to the specified gradient
  17862. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17863. * @returns the current particle system
  17864. */
  17865. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17866. /**
  17867. * Remove a specific color gradient
  17868. * @param gradient defines the gradient to remove
  17869. * @returns the current particle system
  17870. */
  17871. removeColorGradient(gradient: number): IParticleSystem;
  17872. /**
  17873. * Adds a new size gradient
  17874. * @param gradient defines the gradient to use (between 0 and 1)
  17875. * @param factor defines the size factor to affect to the specified gradient
  17876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17877. * @returns the current particle system
  17878. */
  17879. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17880. /**
  17881. * Remove a specific size gradient
  17882. * @param gradient defines the gradient to remove
  17883. * @returns the current particle system
  17884. */
  17885. removeSizeGradient(gradient: number): IParticleSystem;
  17886. /**
  17887. * Gets the current list of color gradients.
  17888. * You must use addColorGradient and removeColorGradient to udpate this list
  17889. * @returns the list of color gradients
  17890. */
  17891. getColorGradients(): Nullable<Array<ColorGradient>>;
  17892. /**
  17893. * Gets the current list of size gradients.
  17894. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17895. * @returns the list of size gradients
  17896. */
  17897. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17898. /**
  17899. * Gets the current list of angular speed gradients.
  17900. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17901. * @returns the list of angular speed gradients
  17902. */
  17903. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17904. /**
  17905. * Adds a new angular speed gradient
  17906. * @param gradient defines the gradient to use (between 0 and 1)
  17907. * @param factor defines the angular speed to affect to the specified gradient
  17908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17909. * @returns the current particle system
  17910. */
  17911. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17912. /**
  17913. * Remove a specific angular speed gradient
  17914. * @param gradient defines the gradient to remove
  17915. * @returns the current particle system
  17916. */
  17917. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17918. /**
  17919. * Gets the current list of velocity gradients.
  17920. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17921. * @returns the list of velocity gradients
  17922. */
  17923. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17924. /**
  17925. * Adds a new velocity gradient
  17926. * @param gradient defines the gradient to use (between 0 and 1)
  17927. * @param factor defines the velocity to affect to the specified gradient
  17928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17929. * @returns the current particle system
  17930. */
  17931. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17932. /**
  17933. * Remove a specific velocity gradient
  17934. * @param gradient defines the gradient to remove
  17935. * @returns the current particle system
  17936. */
  17937. removeVelocityGradient(gradient: number): IParticleSystem;
  17938. /**
  17939. * Gets the current list of limit velocity gradients.
  17940. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17941. * @returns the list of limit velocity gradients
  17942. */
  17943. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17944. /**
  17945. * Adds a new limit velocity gradient
  17946. * @param gradient defines the gradient to use (between 0 and 1)
  17947. * @param factor defines the limit velocity to affect to the specified gradient
  17948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17949. * @returns the current particle system
  17950. */
  17951. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17952. /**
  17953. * Remove a specific limit velocity gradient
  17954. * @param gradient defines the gradient to remove
  17955. * @returns the current particle system
  17956. */
  17957. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17958. /**
  17959. * Adds a new drag gradient
  17960. * @param gradient defines the gradient to use (between 0 and 1)
  17961. * @param factor defines the drag to affect to the specified gradient
  17962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17963. * @returns the current particle system
  17964. */
  17965. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17966. /**
  17967. * Remove a specific drag gradient
  17968. * @param gradient defines the gradient to remove
  17969. * @returns the current particle system
  17970. */
  17971. removeDragGradient(gradient: number): IParticleSystem;
  17972. /**
  17973. * Gets the current list of drag gradients.
  17974. * You must use addDragGradient and removeDragGradient to udpate this list
  17975. * @returns the list of drag gradients
  17976. */
  17977. getDragGradients(): Nullable<Array<FactorGradient>>;
  17978. /**
  17979. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17980. * @param gradient defines the gradient to use (between 0 and 1)
  17981. * @param factor defines the emit rate to affect to the specified gradient
  17982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17983. * @returns the current particle system
  17984. */
  17985. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17986. /**
  17987. * Remove a specific emit rate gradient
  17988. * @param gradient defines the gradient to remove
  17989. * @returns the current particle system
  17990. */
  17991. removeEmitRateGradient(gradient: number): IParticleSystem;
  17992. /**
  17993. * Gets the current list of emit rate gradients.
  17994. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17995. * @returns the list of emit rate gradients
  17996. */
  17997. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17998. /**
  17999. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18000. * @param gradient defines the gradient to use (between 0 and 1)
  18001. * @param factor defines the start size to affect to the specified gradient
  18002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18003. * @returns the current particle system
  18004. */
  18005. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18006. /**
  18007. * Remove a specific start size gradient
  18008. * @param gradient defines the gradient to remove
  18009. * @returns the current particle system
  18010. */
  18011. removeStartSizeGradient(gradient: number): IParticleSystem;
  18012. /**
  18013. * Gets the current list of start size gradients.
  18014. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18015. * @returns the list of start size gradients
  18016. */
  18017. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18018. /**
  18019. * Adds a new life time gradient
  18020. * @param gradient defines the gradient to use (between 0 and 1)
  18021. * @param factor defines the life time factor to affect to the specified gradient
  18022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18023. * @returns the current particle system
  18024. */
  18025. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18026. /**
  18027. * Remove a specific life time gradient
  18028. * @param gradient defines the gradient to remove
  18029. * @returns the current particle system
  18030. */
  18031. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18032. /**
  18033. * Gets the current list of life time gradients.
  18034. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18035. * @returns the list of life time gradients
  18036. */
  18037. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18038. /**
  18039. * Gets the current list of color gradients.
  18040. * You must use addColorGradient and removeColorGradient to udpate this list
  18041. * @returns the list of color gradients
  18042. */
  18043. getColorGradients(): Nullable<Array<ColorGradient>>;
  18044. /**
  18045. * Adds a new ramp gradient used to remap particle colors
  18046. * @param gradient defines the gradient to use (between 0 and 1)
  18047. * @param color defines the color to affect to the specified gradient
  18048. * @returns the current particle system
  18049. */
  18050. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18051. /**
  18052. * Gets the current list of ramp gradients.
  18053. * You must use addRampGradient and removeRampGradient to udpate this list
  18054. * @returns the list of ramp gradients
  18055. */
  18056. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18057. /** Gets or sets a boolean indicating that ramp gradients must be used
  18058. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18059. */
  18060. useRampGradients: boolean;
  18061. /**
  18062. * Adds a new color remap gradient
  18063. * @param gradient defines the gradient to use (between 0 and 1)
  18064. * @param min defines the color remap minimal range
  18065. * @param max defines the color remap maximal range
  18066. * @returns the current particle system
  18067. */
  18068. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18069. /**
  18070. * Gets the current list of color remap gradients.
  18071. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18072. * @returns the list of color remap gradients
  18073. */
  18074. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18075. /**
  18076. * Adds a new alpha remap gradient
  18077. * @param gradient defines the gradient to use (between 0 and 1)
  18078. * @param min defines the alpha remap minimal range
  18079. * @param max defines the alpha remap maximal range
  18080. * @returns the current particle system
  18081. */
  18082. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18083. /**
  18084. * Gets the current list of alpha remap gradients.
  18085. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18086. * @returns the list of alpha remap gradients
  18087. */
  18088. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18089. /**
  18090. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18091. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18092. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18093. * @returns the emitter
  18094. */
  18095. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18096. /**
  18097. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18098. * @param radius The radius of the hemisphere to emit from
  18099. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18100. * @returns the emitter
  18101. */
  18102. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18103. /**
  18104. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18105. * @param radius The radius of the sphere to emit from
  18106. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18107. * @returns the emitter
  18108. */
  18109. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18110. /**
  18111. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18112. * @param radius The radius of the sphere to emit from
  18113. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18114. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18115. * @returns the emitter
  18116. */
  18117. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18118. /**
  18119. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18120. * @param radius The radius of the emission cylinder
  18121. * @param height The height of the emission cylinder
  18122. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18123. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18124. * @returns the emitter
  18125. */
  18126. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18127. /**
  18128. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18129. * @param radius The radius of the cylinder to emit from
  18130. * @param height The height of the emission cylinder
  18131. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18134. * @returns the emitter
  18135. */
  18136. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18137. /**
  18138. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18139. * @param radius The radius of the cone to emit from
  18140. * @param angle The base angle of the cone
  18141. * @returns the emitter
  18142. */
  18143. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18144. /**
  18145. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18148. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18149. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18150. * @returns the emitter
  18151. */
  18152. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18153. /**
  18154. * Get hosting scene
  18155. * @returns the scene
  18156. */
  18157. getScene(): Nullable<Scene>;
  18158. }
  18159. }
  18160. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  18161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18164. /**
  18165. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  18166. */
  18167. export class ColorSplitterBlock extends NodeMaterialBlock {
  18168. /**
  18169. * Create a new ColorSplitterBlock
  18170. * @param name defines the block name
  18171. */
  18172. constructor(name: string);
  18173. /**
  18174. * Gets the current class name
  18175. * @returns the class name
  18176. */
  18177. getClassName(): string;
  18178. /**
  18179. * Gets the rgba component (input)
  18180. */
  18181. get rgba(): NodeMaterialConnectionPoint;
  18182. /**
  18183. * Gets the rgb component (input)
  18184. */
  18185. get rgbIn(): NodeMaterialConnectionPoint;
  18186. /**
  18187. * Gets the rgb component (output)
  18188. */
  18189. get rgbOut(): NodeMaterialConnectionPoint;
  18190. /**
  18191. * Gets the r component (output)
  18192. */
  18193. get r(): NodeMaterialConnectionPoint;
  18194. /**
  18195. * Gets the g component (output)
  18196. */
  18197. get g(): NodeMaterialConnectionPoint;
  18198. /**
  18199. * Gets the b component (output)
  18200. */
  18201. get b(): NodeMaterialConnectionPoint;
  18202. /**
  18203. * Gets the a component (output)
  18204. */
  18205. get a(): NodeMaterialConnectionPoint;
  18206. protected _inputRename(name: string): string;
  18207. protected _outputRename(name: string): string;
  18208. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  18209. }
  18210. }
  18211. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  18212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18213. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18215. import { Scene } from "babylonjs/scene";
  18216. /**
  18217. * Operations supported by the Trigonometry block
  18218. */
  18219. export enum TrigonometryBlockOperations {
  18220. /** Cos */
  18221. Cos = 0,
  18222. /** Sin */
  18223. Sin = 1,
  18224. /** Abs */
  18225. Abs = 2,
  18226. /** Exp */
  18227. Exp = 3,
  18228. /** Exp2 */
  18229. Exp2 = 4,
  18230. /** Round */
  18231. Round = 5,
  18232. /** Floor */
  18233. Floor = 6,
  18234. /** Ceiling */
  18235. Ceiling = 7,
  18236. /** Square root */
  18237. Sqrt = 8,
  18238. /** Log */
  18239. Log = 9,
  18240. /** Tangent */
  18241. Tan = 10,
  18242. /** Arc tangent */
  18243. ArcTan = 11,
  18244. /** Arc cosinus */
  18245. ArcCos = 12,
  18246. /** Arc sinus */
  18247. ArcSin = 13,
  18248. /** Fraction */
  18249. Fract = 14,
  18250. /** Sign */
  18251. Sign = 15,
  18252. /** To radians (from degrees) */
  18253. Radians = 16,
  18254. /** To degrees (from radians) */
  18255. Degrees = 17
  18256. }
  18257. /**
  18258. * Block used to apply trigonometry operation to floats
  18259. */
  18260. export class TrigonometryBlock extends NodeMaterialBlock {
  18261. /**
  18262. * Gets or sets the operation applied by the block
  18263. */
  18264. operation: TrigonometryBlockOperations;
  18265. /**
  18266. * Creates a new TrigonometryBlock
  18267. * @param name defines the block name
  18268. */
  18269. constructor(name: string);
  18270. /**
  18271. * Gets the current class name
  18272. * @returns the class name
  18273. */
  18274. getClassName(): string;
  18275. /**
  18276. * Gets the input component
  18277. */
  18278. get input(): NodeMaterialConnectionPoint;
  18279. /**
  18280. * Gets the output component
  18281. */
  18282. get output(): NodeMaterialConnectionPoint;
  18283. protected _buildBlock(state: NodeMaterialBuildState): this;
  18284. serialize(): any;
  18285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  18286. protected _dumpPropertiesCode(): string;
  18287. }
  18288. }
  18289. declare module "babylonjs/Materials/Node/nodeMaterial" {
  18290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18291. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  18292. import { Scene } from "babylonjs/scene";
  18293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18294. import { Matrix } from "babylonjs/Maths/math.vector";
  18295. import { Mesh } from "babylonjs/Meshes/mesh";
  18296. import { Engine } from "babylonjs/Engines/engine";
  18297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18298. import { Observable } from "babylonjs/Misc/observable";
  18299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18300. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18301. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  18302. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  18303. import { Nullable } from "babylonjs/types";
  18304. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  18305. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  18306. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  18307. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  18308. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  18309. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  18310. import { Effect } from "babylonjs/Materials/effect";
  18311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18312. import { Camera } from "babylonjs/Cameras/camera";
  18313. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  18314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18315. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  18316. /**
  18317. * Interface used to configure the node material editor
  18318. */
  18319. export interface INodeMaterialEditorOptions {
  18320. /** Define the URl to load node editor script */
  18321. editorURL?: string;
  18322. }
  18323. /** @hidden */
  18324. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18325. NORMAL: boolean;
  18326. TANGENT: boolean;
  18327. UV1: boolean;
  18328. /** BONES */
  18329. NUM_BONE_INFLUENCERS: number;
  18330. BonesPerMesh: number;
  18331. BONETEXTURE: boolean;
  18332. /** MORPH TARGETS */
  18333. MORPHTARGETS: boolean;
  18334. MORPHTARGETS_NORMAL: boolean;
  18335. MORPHTARGETS_TANGENT: boolean;
  18336. MORPHTARGETS_UV: boolean;
  18337. NUM_MORPH_INFLUENCERS: number;
  18338. /** IMAGE PROCESSING */
  18339. IMAGEPROCESSING: boolean;
  18340. VIGNETTE: boolean;
  18341. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18342. VIGNETTEBLENDMODEOPAQUE: boolean;
  18343. TONEMAPPING: boolean;
  18344. TONEMAPPING_ACES: boolean;
  18345. CONTRAST: boolean;
  18346. EXPOSURE: boolean;
  18347. COLORCURVES: boolean;
  18348. COLORGRADING: boolean;
  18349. COLORGRADING3D: boolean;
  18350. SAMPLER3DGREENDEPTH: boolean;
  18351. SAMPLER3DBGRMAP: boolean;
  18352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18353. /** MISC. */
  18354. BUMPDIRECTUV: number;
  18355. constructor();
  18356. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  18357. }
  18358. /**
  18359. * Class used to configure NodeMaterial
  18360. */
  18361. export interface INodeMaterialOptions {
  18362. /**
  18363. * Defines if blocks should emit comments
  18364. */
  18365. emitComments: boolean;
  18366. }
  18367. /**
  18368. * Class used to create a node based material built by assembling shader blocks
  18369. */
  18370. export class NodeMaterial extends PushMaterial {
  18371. private static _BuildIdGenerator;
  18372. private _options;
  18373. private _vertexCompilationState;
  18374. private _fragmentCompilationState;
  18375. private _sharedData;
  18376. private _buildId;
  18377. private _buildWasSuccessful;
  18378. private _cachedWorldViewMatrix;
  18379. private _cachedWorldViewProjectionMatrix;
  18380. private _optimizers;
  18381. private _animationFrame;
  18382. /** Define the Url to load node editor script */
  18383. static EditorURL: string;
  18384. /** Define the Url to load snippets */
  18385. static SnippetUrl: string;
  18386. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  18387. static IgnoreTexturesAtLoadTime: boolean;
  18388. private BJSNODEMATERIALEDITOR;
  18389. /** Get the inspector from bundle or global */
  18390. private _getGlobalNodeMaterialEditor;
  18391. /**
  18392. * Snippet ID if the material was created from the snippet server
  18393. */
  18394. snippetId: string;
  18395. /**
  18396. * Gets or sets data used by visual editor
  18397. * @see https://nme.babylonjs.com
  18398. */
  18399. editorData: any;
  18400. /**
  18401. * 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)
  18402. */
  18403. ignoreAlpha: boolean;
  18404. /**
  18405. * Defines the maximum number of lights that can be used in the material
  18406. */
  18407. maxSimultaneousLights: number;
  18408. /**
  18409. * Observable raised when the material is built
  18410. */
  18411. onBuildObservable: Observable<NodeMaterial>;
  18412. /**
  18413. * Gets or sets the root nodes of the material vertex shader
  18414. */
  18415. _vertexOutputNodes: NodeMaterialBlock[];
  18416. /**
  18417. * Gets or sets the root nodes of the material fragment (pixel) shader
  18418. */
  18419. _fragmentOutputNodes: NodeMaterialBlock[];
  18420. /** Gets or sets options to control the node material overall behavior */
  18421. get options(): INodeMaterialOptions;
  18422. set options(options: INodeMaterialOptions);
  18423. /**
  18424. * Default configuration related to image processing available in the standard Material.
  18425. */
  18426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18427. /**
  18428. * Gets the image processing configuration used either in this material.
  18429. */
  18430. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18431. /**
  18432. * Sets the Default image processing configuration used either in the this material.
  18433. *
  18434. * If sets to null, the scene one is in use.
  18435. */
  18436. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18437. /**
  18438. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18439. */
  18440. attachedBlocks: NodeMaterialBlock[];
  18441. /**
  18442. * Specifies the mode of the node material
  18443. * @hidden
  18444. */
  18445. _mode: NodeMaterialModes;
  18446. /**
  18447. * Gets the mode property
  18448. */
  18449. get mode(): NodeMaterialModes;
  18450. /**
  18451. * A free comment about the material
  18452. */
  18453. comment: string;
  18454. /**
  18455. * Create a new node based material
  18456. * @param name defines the material name
  18457. * @param scene defines the hosting scene
  18458. * @param options defines creation option
  18459. */
  18460. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18461. /**
  18462. * Gets the current class name of the material e.g. "NodeMaterial"
  18463. * @returns the class name
  18464. */
  18465. getClassName(): string;
  18466. /**
  18467. * Keep track of the image processing observer to allow dispose and replace.
  18468. */
  18469. private _imageProcessingObserver;
  18470. /**
  18471. * Attaches a new image processing configuration to the Standard Material.
  18472. * @param configuration
  18473. */
  18474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18475. /**
  18476. * Get a block by its name
  18477. * @param name defines the name of the block to retrieve
  18478. * @returns the required block or null if not found
  18479. */
  18480. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18481. /**
  18482. * Get a block by its name
  18483. * @param predicate defines the predicate used to find the good candidate
  18484. * @returns the required block or null if not found
  18485. */
  18486. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18487. /**
  18488. * Get an input block by its name
  18489. * @param predicate defines the predicate used to find the good candidate
  18490. * @returns the required input block or null if not found
  18491. */
  18492. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18493. /**
  18494. * Gets the list of input blocks attached to this material
  18495. * @returns an array of InputBlocks
  18496. */
  18497. getInputBlocks(): InputBlock[];
  18498. /**
  18499. * Adds a new optimizer to the list of optimizers
  18500. * @param optimizer defines the optimizers to add
  18501. * @returns the current material
  18502. */
  18503. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18504. /**
  18505. * Remove an optimizer from the list of optimizers
  18506. * @param optimizer defines the optimizers to remove
  18507. * @returns the current material
  18508. */
  18509. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18510. /**
  18511. * Add a new block to the list of output nodes
  18512. * @param node defines the node to add
  18513. * @returns the current material
  18514. */
  18515. addOutputNode(node: NodeMaterialBlock): this;
  18516. /**
  18517. * Remove a block from the list of root nodes
  18518. * @param node defines the node to remove
  18519. * @returns the current material
  18520. */
  18521. removeOutputNode(node: NodeMaterialBlock): this;
  18522. private _addVertexOutputNode;
  18523. private _removeVertexOutputNode;
  18524. private _addFragmentOutputNode;
  18525. private _removeFragmentOutputNode;
  18526. /**
  18527. * Specifies if the material will require alpha blending
  18528. * @returns a boolean specifying if alpha blending is needed
  18529. */
  18530. needAlphaBlending(): boolean;
  18531. /**
  18532. * Specifies if this material should be rendered in alpha test mode
  18533. * @returns a boolean specifying if an alpha test is needed.
  18534. */
  18535. needAlphaTesting(): boolean;
  18536. private _initializeBlock;
  18537. private _resetDualBlocks;
  18538. /**
  18539. * Remove a block from the current node material
  18540. * @param block defines the block to remove
  18541. */
  18542. removeBlock(block: NodeMaterialBlock): void;
  18543. /**
  18544. * Build the material and generates the inner effect
  18545. * @param verbose defines if the build should log activity
  18546. */
  18547. build(verbose?: boolean): void;
  18548. /**
  18549. * Runs an otpimization phase to try to improve the shader code
  18550. */
  18551. optimize(): void;
  18552. private _prepareDefinesForAttributes;
  18553. /**
  18554. * Create a post process from the material
  18555. * @param camera The camera to apply the render pass to.
  18556. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18558. * @param engine The engine which the post process will be applied. (default: current engine)
  18559. * @param reusable If the post process can be reused on the same frame. (default: false)
  18560. * @param textureType Type of textures used when performing the post process. (default: 0)
  18561. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18562. * @returns the post process created
  18563. */
  18564. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18565. /**
  18566. * Create the post process effect from the material
  18567. * @param postProcess The post process to create the effect for
  18568. */
  18569. createEffectForPostProcess(postProcess: PostProcess): void;
  18570. private _createEffectForPostProcess;
  18571. /**
  18572. * Create a new procedural texture based on this node material
  18573. * @param size defines the size of the texture
  18574. * @param scene defines the hosting scene
  18575. * @returns the new procedural texture attached to this node material
  18576. */
  18577. createProceduralTexture(size: number | {
  18578. width: number;
  18579. height: number;
  18580. layers?: number;
  18581. }, scene: Scene): Nullable<ProceduralTexture>;
  18582. private _createEffectForParticles;
  18583. private _checkInternals;
  18584. /**
  18585. * Create the effect to be used as the custom effect for a particle system
  18586. * @param particleSystem Particle system to create the effect for
  18587. * @param onCompiled defines a function to call when the effect creation is successful
  18588. * @param onError defines a function to call when the effect creation has failed
  18589. */
  18590. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18591. private _processDefines;
  18592. /**
  18593. * Get if the submesh is ready to be used and all its information available.
  18594. * Child classes can use it to update shaders
  18595. * @param mesh defines the mesh to check
  18596. * @param subMesh defines which submesh to check
  18597. * @param useInstances specifies that instances should be used
  18598. * @returns a boolean indicating that the submesh is ready or not
  18599. */
  18600. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18601. /**
  18602. * Get a string representing the shaders built by the current node graph
  18603. */
  18604. get compiledShaders(): string;
  18605. /**
  18606. * Binds the world matrix to the material
  18607. * @param world defines the world transformation matrix
  18608. */
  18609. bindOnlyWorldMatrix(world: Matrix): void;
  18610. /**
  18611. * Binds the submesh to this material by preparing the effect and shader to draw
  18612. * @param world defines the world transformation matrix
  18613. * @param mesh defines the mesh containing the submesh
  18614. * @param subMesh defines the submesh to bind the material to
  18615. */
  18616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18617. /**
  18618. * Gets the active textures from the material
  18619. * @returns an array of textures
  18620. */
  18621. getActiveTextures(): BaseTexture[];
  18622. /**
  18623. * Gets the list of texture blocks
  18624. * @returns an array of texture blocks
  18625. */
  18626. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18627. /**
  18628. * Specifies if the material uses a texture
  18629. * @param texture defines the texture to check against the material
  18630. * @returns a boolean specifying if the material uses the texture
  18631. */
  18632. hasTexture(texture: BaseTexture): boolean;
  18633. /**
  18634. * Disposes the material
  18635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18638. */
  18639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18640. /** Creates the node editor window. */
  18641. private _createNodeEditor;
  18642. /**
  18643. * Launch the node material editor
  18644. * @param config Define the configuration of the editor
  18645. * @return a promise fulfilled when the node editor is visible
  18646. */
  18647. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18648. /**
  18649. * Clear the current material
  18650. */
  18651. clear(): void;
  18652. /**
  18653. * Clear the current material and set it to a default state
  18654. */
  18655. setToDefault(): void;
  18656. /**
  18657. * Clear the current material and set it to a default state for post process
  18658. */
  18659. setToDefaultPostProcess(): void;
  18660. /**
  18661. * Clear the current material and set it to a default state for procedural texture
  18662. */
  18663. setToDefaultProceduralTexture(): void;
  18664. /**
  18665. * Clear the current material and set it to a default state for particle
  18666. */
  18667. setToDefaultParticle(): void;
  18668. /**
  18669. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18670. * @param url defines the url to load from
  18671. * @returns a promise that will fullfil when the material is fully loaded
  18672. */
  18673. loadAsync(url: string): Promise<void>;
  18674. private _gatherBlocks;
  18675. /**
  18676. * Generate a string containing the code declaration required to create an equivalent of this material
  18677. * @returns a string
  18678. */
  18679. generateCode(): string;
  18680. /**
  18681. * Serializes this material in a JSON representation
  18682. * @returns the serialized material object
  18683. */
  18684. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18685. private _restoreConnections;
  18686. /**
  18687. * Clear the current graph and load a new one from a serialization object
  18688. * @param source defines the JSON representation of the material
  18689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18690. * @param merge defines whether or not the source must be merged or replace the current content
  18691. */
  18692. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18693. /**
  18694. * Makes a duplicate of the current material.
  18695. * @param name - name to use for the new material.
  18696. */
  18697. clone(name: string): NodeMaterial;
  18698. /**
  18699. * Creates a node material from parsed material data
  18700. * @param source defines the JSON representation of the material
  18701. * @param scene defines the hosting scene
  18702. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18703. * @returns a new node material
  18704. */
  18705. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18706. /**
  18707. * Creates a node material from a snippet saved in a remote file
  18708. * @param name defines the name of the material to create
  18709. * @param url defines the url to load from
  18710. * @param scene defines the hosting scene
  18711. * @returns a promise that will resolve to the new node material
  18712. */
  18713. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18714. /**
  18715. * Creates a node material from a snippet saved by the node material editor
  18716. * @param snippetId defines the snippet to load
  18717. * @param scene defines the hosting scene
  18718. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18719. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18720. * @returns a promise that will resolve to the new node material
  18721. */
  18722. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18723. /**
  18724. * Creates a new node material set to default basic configuration
  18725. * @param name defines the name of the material
  18726. * @param scene defines the hosting scene
  18727. * @returns a new NodeMaterial
  18728. */
  18729. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18730. }
  18731. }
  18732. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18734. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18735. import { Nullable } from "babylonjs/types";
  18736. module "babylonjs/Engines/thinEngine" {
  18737. interface ThinEngine {
  18738. /**
  18739. * Unbind a list of render target textures from the webGL context
  18740. * This is used only when drawBuffer extension or webGL2 are active
  18741. * @param textures defines the render target textures to unbind
  18742. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18743. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18744. */
  18745. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18746. /**
  18747. * Create a multi render target texture
  18748. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18749. * @param size defines the size of the texture
  18750. * @param options defines the creation options
  18751. * @returns the cube texture as an InternalTexture
  18752. */
  18753. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18754. /**
  18755. * Update the sample count for a given multiple render target texture
  18756. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18757. * @param textures defines the textures to update
  18758. * @param samples defines the sample count to set
  18759. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18760. */
  18761. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18762. /**
  18763. * Select a subsets of attachments to draw to.
  18764. * @param attachments gl attachments
  18765. */
  18766. bindAttachments(attachments: number[]): void;
  18767. /**
  18768. * Creates a layout object to draw/clear on specific textures in a MRT
  18769. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18770. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18771. */
  18772. buildTextureLayout(textureStatus: boolean[]): number[];
  18773. /**
  18774. * Restores the webgl state to only draw on the main color attachment
  18775. */
  18776. restoreSingleAttachment(): void;
  18777. }
  18778. }
  18779. }
  18780. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18781. import { Scene } from "babylonjs/scene";
  18782. import { Engine } from "babylonjs/Engines/engine";
  18783. import { Texture } from "babylonjs/Materials/Textures/texture";
  18784. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18785. import "babylonjs/Engines/Extensions/engine.multiRender";
  18786. /**
  18787. * Creation options of the multi render target texture.
  18788. */
  18789. export interface IMultiRenderTargetOptions {
  18790. /**
  18791. * Define if the texture needs to create mip maps after render.
  18792. */
  18793. generateMipMaps?: boolean;
  18794. /**
  18795. * Define the types of all the draw buffers we want to create
  18796. */
  18797. types?: number[];
  18798. /**
  18799. * Define the sampling modes of all the draw buffers we want to create
  18800. */
  18801. samplingModes?: number[];
  18802. /**
  18803. * Define if a depth buffer is required
  18804. */
  18805. generateDepthBuffer?: boolean;
  18806. /**
  18807. * Define if a stencil buffer is required
  18808. */
  18809. generateStencilBuffer?: boolean;
  18810. /**
  18811. * Define if a depth texture is required instead of a depth buffer
  18812. */
  18813. generateDepthTexture?: boolean;
  18814. /**
  18815. * Define the number of desired draw buffers
  18816. */
  18817. textureCount?: number;
  18818. /**
  18819. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18820. */
  18821. doNotChangeAspectRatio?: boolean;
  18822. /**
  18823. * Define the default type of the buffers we are creating
  18824. */
  18825. defaultType?: number;
  18826. }
  18827. /**
  18828. * A multi render target, like a render target provides the ability to render to a texture.
  18829. * Unlike the render target, it can render to several draw buffers in one draw.
  18830. * This is specially interesting in deferred rendering or for any effects requiring more than
  18831. * just one color from a single pass.
  18832. */
  18833. export class MultiRenderTarget extends RenderTargetTexture {
  18834. private _internalTextures;
  18835. private _textures;
  18836. private _multiRenderTargetOptions;
  18837. private _count;
  18838. /**
  18839. * Get if draw buffers are currently supported by the used hardware and browser.
  18840. */
  18841. get isSupported(): boolean;
  18842. /**
  18843. * Get the list of textures generated by the multi render target.
  18844. */
  18845. get textures(): Texture[];
  18846. /**
  18847. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18848. */
  18849. get count(): number;
  18850. /**
  18851. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18852. */
  18853. get depthTexture(): Texture;
  18854. /**
  18855. * Set the wrapping mode on U of all the textures we are rendering to.
  18856. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18857. */
  18858. set wrapU(wrap: number);
  18859. /**
  18860. * Set the wrapping mode on V of all the textures we are rendering to.
  18861. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18862. */
  18863. set wrapV(wrap: number);
  18864. /**
  18865. * Instantiate a new multi render target texture.
  18866. * A multi render target, like a render target provides the ability to render to a texture.
  18867. * Unlike the render target, it can render to several draw buffers in one draw.
  18868. * This is specially interesting in deferred rendering or for any effects requiring more than
  18869. * just one color from a single pass.
  18870. * @param name Define the name of the texture
  18871. * @param size Define the size of the buffers to render to
  18872. * @param count Define the number of target we are rendering into
  18873. * @param scene Define the scene the texture belongs to
  18874. * @param options Define the options used to create the multi render target
  18875. */
  18876. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18877. private _initTypes;
  18878. /** @hidden */
  18879. _rebuild(forceFullRebuild?: boolean): void;
  18880. private _createInternalTextures;
  18881. private _createTextures;
  18882. /**
  18883. * Replaces a texture within the MRT.
  18884. * @param texture The new texture to insert in the MRT
  18885. * @param index The index of the texture to replace
  18886. */
  18887. replaceTexture(texture: Texture, index: number): void;
  18888. /**
  18889. * Define the number of samples used if MSAA is enabled.
  18890. */
  18891. get samples(): number;
  18892. set samples(value: number);
  18893. /**
  18894. * Resize all the textures in the multi render target.
  18895. * Be careful as it will recreate all the data in the new texture.
  18896. * @param size Define the new size
  18897. */
  18898. resize(size: any): void;
  18899. /**
  18900. * Changes the number of render targets in this MRT
  18901. * Be careful as it will recreate all the data in the new texture.
  18902. * @param count new texture count
  18903. * @param options Specifies texture types and sampling modes for new textures
  18904. */
  18905. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18906. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18907. /**
  18908. * Dispose the render targets and their associated resources
  18909. */
  18910. dispose(): void;
  18911. /**
  18912. * Release all the underlying texture used as draw buffers.
  18913. */
  18914. releaseInternalTextures(): void;
  18915. }
  18916. }
  18917. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18918. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18919. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18920. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18921. /** @hidden */
  18922. export var imageProcessingPixelShader: {
  18923. name: string;
  18924. shader: string;
  18925. };
  18926. }
  18927. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18928. import { Nullable } from "babylonjs/types";
  18929. import { Color4 } from "babylonjs/Maths/math.color";
  18930. import { Camera } from "babylonjs/Cameras/camera";
  18931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18932. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18933. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18934. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18935. import { Engine } from "babylonjs/Engines/engine";
  18936. import "babylonjs/Shaders/imageProcessing.fragment";
  18937. import "babylonjs/Shaders/postprocess.vertex";
  18938. /**
  18939. * ImageProcessingPostProcess
  18940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18941. */
  18942. export class ImageProcessingPostProcess extends PostProcess {
  18943. /**
  18944. * Default configuration related to image processing available in the PBR Material.
  18945. */
  18946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18947. /**
  18948. * Gets the image processing configuration used either in this material.
  18949. */
  18950. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18951. /**
  18952. * Sets the Default image processing configuration used either in the this material.
  18953. *
  18954. * If sets to null, the scene one is in use.
  18955. */
  18956. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18957. /**
  18958. * Keep track of the image processing observer to allow dispose and replace.
  18959. */
  18960. private _imageProcessingObserver;
  18961. /**
  18962. * Attaches a new image processing configuration to the PBR Material.
  18963. * @param configuration
  18964. */
  18965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18966. /**
  18967. * If the post process is supported.
  18968. */
  18969. get isSupported(): boolean;
  18970. /**
  18971. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18972. */
  18973. get colorCurves(): Nullable<ColorCurves>;
  18974. /**
  18975. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18976. */
  18977. set colorCurves(value: Nullable<ColorCurves>);
  18978. /**
  18979. * Gets wether the color curves effect is enabled.
  18980. */
  18981. get colorCurvesEnabled(): boolean;
  18982. /**
  18983. * Sets wether the color curves effect is enabled.
  18984. */
  18985. set colorCurvesEnabled(value: boolean);
  18986. /**
  18987. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18988. */
  18989. get colorGradingTexture(): Nullable<BaseTexture>;
  18990. /**
  18991. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18992. */
  18993. set colorGradingTexture(value: Nullable<BaseTexture>);
  18994. /**
  18995. * Gets wether the color grading effect is enabled.
  18996. */
  18997. get colorGradingEnabled(): boolean;
  18998. /**
  18999. * Gets wether the color grading effect is enabled.
  19000. */
  19001. set colorGradingEnabled(value: boolean);
  19002. /**
  19003. * Gets exposure used in the effect.
  19004. */
  19005. get exposure(): number;
  19006. /**
  19007. * Sets exposure used in the effect.
  19008. */
  19009. set exposure(value: number);
  19010. /**
  19011. * Gets wether tonemapping is enabled or not.
  19012. */
  19013. get toneMappingEnabled(): boolean;
  19014. /**
  19015. * Sets wether tonemapping is enabled or not
  19016. */
  19017. set toneMappingEnabled(value: boolean);
  19018. /**
  19019. * Gets the type of tone mapping effect.
  19020. */
  19021. get toneMappingType(): number;
  19022. /**
  19023. * Sets the type of tone mapping effect.
  19024. */
  19025. set toneMappingType(value: number);
  19026. /**
  19027. * Gets contrast used in the effect.
  19028. */
  19029. get contrast(): number;
  19030. /**
  19031. * Sets contrast used in the effect.
  19032. */
  19033. set contrast(value: number);
  19034. /**
  19035. * Gets Vignette stretch size.
  19036. */
  19037. get vignetteStretch(): number;
  19038. /**
  19039. * Sets Vignette stretch size.
  19040. */
  19041. set vignetteStretch(value: number);
  19042. /**
  19043. * Gets Vignette centre X Offset.
  19044. */
  19045. get vignetteCentreX(): number;
  19046. /**
  19047. * Sets Vignette centre X Offset.
  19048. */
  19049. set vignetteCentreX(value: number);
  19050. /**
  19051. * Gets Vignette centre Y Offset.
  19052. */
  19053. get vignetteCentreY(): number;
  19054. /**
  19055. * Sets Vignette centre Y Offset.
  19056. */
  19057. set vignetteCentreY(value: number);
  19058. /**
  19059. * Gets Vignette weight or intensity of the vignette effect.
  19060. */
  19061. get vignetteWeight(): number;
  19062. /**
  19063. * Sets Vignette weight or intensity of the vignette effect.
  19064. */
  19065. set vignetteWeight(value: number);
  19066. /**
  19067. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19068. * if vignetteEnabled is set to true.
  19069. */
  19070. get vignetteColor(): Color4;
  19071. /**
  19072. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19073. * if vignetteEnabled is set to true.
  19074. */
  19075. set vignetteColor(value: Color4);
  19076. /**
  19077. * Gets Camera field of view used by the Vignette effect.
  19078. */
  19079. get vignetteCameraFov(): number;
  19080. /**
  19081. * Sets Camera field of view used by the Vignette effect.
  19082. */
  19083. set vignetteCameraFov(value: number);
  19084. /**
  19085. * Gets the vignette blend mode allowing different kind of effect.
  19086. */
  19087. get vignetteBlendMode(): number;
  19088. /**
  19089. * Sets the vignette blend mode allowing different kind of effect.
  19090. */
  19091. set vignetteBlendMode(value: number);
  19092. /**
  19093. * Gets wether the vignette effect is enabled.
  19094. */
  19095. get vignetteEnabled(): boolean;
  19096. /**
  19097. * Sets wether the vignette effect is enabled.
  19098. */
  19099. set vignetteEnabled(value: boolean);
  19100. private _fromLinearSpace;
  19101. /**
  19102. * Gets wether the input of the processing is in Gamma or Linear Space.
  19103. */
  19104. get fromLinearSpace(): boolean;
  19105. /**
  19106. * Sets wether the input of the processing is in Gamma or Linear Space.
  19107. */
  19108. set fromLinearSpace(value: boolean);
  19109. /**
  19110. * Defines cache preventing GC.
  19111. */
  19112. private _defines;
  19113. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19114. /**
  19115. * "ImageProcessingPostProcess"
  19116. * @returns "ImageProcessingPostProcess"
  19117. */
  19118. getClassName(): string;
  19119. /**
  19120. * @hidden
  19121. */
  19122. _updateParameters(): void;
  19123. dispose(camera?: Camera): void;
  19124. }
  19125. }
  19126. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  19127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19128. /**
  19129. * Interface for defining prepass effects in the prepass post-process pipeline
  19130. */
  19131. export interface PrePassEffectConfiguration {
  19132. /**
  19133. * Name of the effect
  19134. */
  19135. name: string;
  19136. /**
  19137. * Post process to attach for this effect
  19138. */
  19139. postProcess?: PostProcess;
  19140. /**
  19141. * Textures required in the MRT
  19142. */
  19143. texturesRequired: number[];
  19144. /**
  19145. * Is the effect enabled
  19146. */
  19147. enabled: boolean;
  19148. /**
  19149. * Disposes the effect configuration
  19150. */
  19151. dispose?: () => void;
  19152. /**
  19153. * Creates the associated post process
  19154. */
  19155. createPostProcess?: () => PostProcess;
  19156. }
  19157. }
  19158. declare module "babylonjs/Materials/fresnelParameters" {
  19159. import { DeepImmutable } from "babylonjs/types";
  19160. import { Color3 } from "babylonjs/Maths/math.color";
  19161. /**
  19162. * Options to be used when creating a FresnelParameters.
  19163. */
  19164. export type IFresnelParametersCreationOptions = {
  19165. /**
  19166. * Define the color used on edges (grazing angle)
  19167. */
  19168. leftColor?: Color3;
  19169. /**
  19170. * Define the color used on center
  19171. */
  19172. rightColor?: Color3;
  19173. /**
  19174. * Define bias applied to computed fresnel term
  19175. */
  19176. bias?: number;
  19177. /**
  19178. * Defined the power exponent applied to fresnel term
  19179. */
  19180. power?: number;
  19181. /**
  19182. * Define if the fresnel effect is enable or not.
  19183. */
  19184. isEnabled?: boolean;
  19185. };
  19186. /**
  19187. * Serialized format for FresnelParameters.
  19188. */
  19189. export type IFresnelParametersSerialized = {
  19190. /**
  19191. * Define the color used on edges (grazing angle) [as an array]
  19192. */
  19193. leftColor: number[];
  19194. /**
  19195. * Define the color used on center [as an array]
  19196. */
  19197. rightColor: number[];
  19198. /**
  19199. * Define bias applied to computed fresnel term
  19200. */
  19201. bias: number;
  19202. /**
  19203. * Defined the power exponent applied to fresnel term
  19204. */
  19205. power?: number;
  19206. /**
  19207. * Define if the fresnel effect is enable or not.
  19208. */
  19209. isEnabled: boolean;
  19210. };
  19211. /**
  19212. * This represents all the required information to add a fresnel effect on a material:
  19213. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19214. */
  19215. export class FresnelParameters {
  19216. private _isEnabled;
  19217. /**
  19218. * Define if the fresnel effect is enable or not.
  19219. */
  19220. get isEnabled(): boolean;
  19221. set isEnabled(value: boolean);
  19222. /**
  19223. * Define the color used on edges (grazing angle)
  19224. */
  19225. leftColor: Color3;
  19226. /**
  19227. * Define the color used on center
  19228. */
  19229. rightColor: Color3;
  19230. /**
  19231. * Define bias applied to computed fresnel term
  19232. */
  19233. bias: number;
  19234. /**
  19235. * Defined the power exponent applied to fresnel term
  19236. */
  19237. power: number;
  19238. /**
  19239. * Creates a new FresnelParameters object.
  19240. *
  19241. * @param options provide your own settings to optionally to override defaults
  19242. */
  19243. constructor(options?: IFresnelParametersCreationOptions);
  19244. /**
  19245. * Clones the current fresnel and its valuues
  19246. * @returns a clone fresnel configuration
  19247. */
  19248. clone(): FresnelParameters;
  19249. /**
  19250. * Determines equality between FresnelParameters objects
  19251. * @param otherFresnelParameters defines the second operand
  19252. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19253. */
  19254. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19255. /**
  19256. * Serializes the current fresnel parameters to a JSON representation.
  19257. * @return the JSON serialization
  19258. */
  19259. serialize(): IFresnelParametersSerialized;
  19260. /**
  19261. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19262. * @param parsedFresnelParameters Define the JSON representation
  19263. * @returns the parsed parameters
  19264. */
  19265. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19266. }
  19267. }
  19268. declare module "babylonjs/Materials/materialFlags" {
  19269. /**
  19270. * This groups all the flags used to control the materials channel.
  19271. */
  19272. export class MaterialFlags {
  19273. private static _DiffuseTextureEnabled;
  19274. /**
  19275. * Are diffuse textures enabled in the application.
  19276. */
  19277. static get DiffuseTextureEnabled(): boolean;
  19278. static set DiffuseTextureEnabled(value: boolean);
  19279. private static _DetailTextureEnabled;
  19280. /**
  19281. * Are detail textures enabled in the application.
  19282. */
  19283. static get DetailTextureEnabled(): boolean;
  19284. static set DetailTextureEnabled(value: boolean);
  19285. private static _AmbientTextureEnabled;
  19286. /**
  19287. * Are ambient textures enabled in the application.
  19288. */
  19289. static get AmbientTextureEnabled(): boolean;
  19290. static set AmbientTextureEnabled(value: boolean);
  19291. private static _OpacityTextureEnabled;
  19292. /**
  19293. * Are opacity textures enabled in the application.
  19294. */
  19295. static get OpacityTextureEnabled(): boolean;
  19296. static set OpacityTextureEnabled(value: boolean);
  19297. private static _ReflectionTextureEnabled;
  19298. /**
  19299. * Are reflection textures enabled in the application.
  19300. */
  19301. static get ReflectionTextureEnabled(): boolean;
  19302. static set ReflectionTextureEnabled(value: boolean);
  19303. private static _EmissiveTextureEnabled;
  19304. /**
  19305. * Are emissive textures enabled in the application.
  19306. */
  19307. static get EmissiveTextureEnabled(): boolean;
  19308. static set EmissiveTextureEnabled(value: boolean);
  19309. private static _SpecularTextureEnabled;
  19310. /**
  19311. * Are specular textures enabled in the application.
  19312. */
  19313. static get SpecularTextureEnabled(): boolean;
  19314. static set SpecularTextureEnabled(value: boolean);
  19315. private static _BumpTextureEnabled;
  19316. /**
  19317. * Are bump textures enabled in the application.
  19318. */
  19319. static get BumpTextureEnabled(): boolean;
  19320. static set BumpTextureEnabled(value: boolean);
  19321. private static _LightmapTextureEnabled;
  19322. /**
  19323. * Are lightmap textures enabled in the application.
  19324. */
  19325. static get LightmapTextureEnabled(): boolean;
  19326. static set LightmapTextureEnabled(value: boolean);
  19327. private static _RefractionTextureEnabled;
  19328. /**
  19329. * Are refraction textures enabled in the application.
  19330. */
  19331. static get RefractionTextureEnabled(): boolean;
  19332. static set RefractionTextureEnabled(value: boolean);
  19333. private static _ColorGradingTextureEnabled;
  19334. /**
  19335. * Are color grading textures enabled in the application.
  19336. */
  19337. static get ColorGradingTextureEnabled(): boolean;
  19338. static set ColorGradingTextureEnabled(value: boolean);
  19339. private static _FresnelEnabled;
  19340. /**
  19341. * Are fresnels enabled in the application.
  19342. */
  19343. static get FresnelEnabled(): boolean;
  19344. static set FresnelEnabled(value: boolean);
  19345. private static _ClearCoatTextureEnabled;
  19346. /**
  19347. * Are clear coat textures enabled in the application.
  19348. */
  19349. static get ClearCoatTextureEnabled(): boolean;
  19350. static set ClearCoatTextureEnabled(value: boolean);
  19351. private static _ClearCoatBumpTextureEnabled;
  19352. /**
  19353. * Are clear coat bump textures enabled in the application.
  19354. */
  19355. static get ClearCoatBumpTextureEnabled(): boolean;
  19356. static set ClearCoatBumpTextureEnabled(value: boolean);
  19357. private static _ClearCoatTintTextureEnabled;
  19358. /**
  19359. * Are clear coat tint textures enabled in the application.
  19360. */
  19361. static get ClearCoatTintTextureEnabled(): boolean;
  19362. static set ClearCoatTintTextureEnabled(value: boolean);
  19363. private static _SheenTextureEnabled;
  19364. /**
  19365. * Are sheen textures enabled in the application.
  19366. */
  19367. static get SheenTextureEnabled(): boolean;
  19368. static set SheenTextureEnabled(value: boolean);
  19369. private static _AnisotropicTextureEnabled;
  19370. /**
  19371. * Are anisotropic textures enabled in the application.
  19372. */
  19373. static get AnisotropicTextureEnabled(): boolean;
  19374. static set AnisotropicTextureEnabled(value: boolean);
  19375. private static _ThicknessTextureEnabled;
  19376. /**
  19377. * Are thickness textures enabled in the application.
  19378. */
  19379. static get ThicknessTextureEnabled(): boolean;
  19380. static set ThicknessTextureEnabled(value: boolean);
  19381. }
  19382. }
  19383. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  19384. /** @hidden */
  19385. export var defaultFragmentDeclaration: {
  19386. name: string;
  19387. shader: string;
  19388. };
  19389. }
  19390. declare module "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration" {
  19391. /** @hidden */
  19392. export var sceneUboDeclaration: {
  19393. name: string;
  19394. shader: string;
  19395. };
  19396. }
  19397. declare module "babylonjs/Shaders/ShadersInclude/meshUboDeclaration" {
  19398. /** @hidden */
  19399. export var meshUboDeclaration: {
  19400. name: string;
  19401. shader: string;
  19402. };
  19403. }
  19404. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  19405. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  19406. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  19407. /** @hidden */
  19408. export var defaultUboDeclaration: {
  19409. name: string;
  19410. shader: string;
  19411. };
  19412. }
  19413. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  19414. /** @hidden */
  19415. export var prePassDeclaration: {
  19416. name: string;
  19417. shader: string;
  19418. };
  19419. }
  19420. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  19421. /** @hidden */
  19422. export var lightFragmentDeclaration: {
  19423. name: string;
  19424. shader: string;
  19425. };
  19426. }
  19427. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  19428. /** @hidden */
  19429. export var lightUboDeclaration: {
  19430. name: string;
  19431. shader: string;
  19432. };
  19433. }
  19434. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  19435. /** @hidden */
  19436. export var lightsFragmentFunctions: {
  19437. name: string;
  19438. shader: string;
  19439. };
  19440. }
  19441. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  19442. /** @hidden */
  19443. export var shadowsFragmentFunctions: {
  19444. name: string;
  19445. shader: string;
  19446. };
  19447. }
  19448. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  19449. /** @hidden */
  19450. export var fresnelFunction: {
  19451. name: string;
  19452. shader: string;
  19453. };
  19454. }
  19455. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  19456. /** @hidden */
  19457. export var bumpFragmentMainFunctions: {
  19458. name: string;
  19459. shader: string;
  19460. };
  19461. }
  19462. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  19463. /** @hidden */
  19464. export var bumpFragmentFunctions: {
  19465. name: string;
  19466. shader: string;
  19467. };
  19468. }
  19469. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  19470. /** @hidden */
  19471. export var logDepthDeclaration: {
  19472. name: string;
  19473. shader: string;
  19474. };
  19475. }
  19476. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  19477. /** @hidden */
  19478. export var fogFragmentDeclaration: {
  19479. name: string;
  19480. shader: string;
  19481. };
  19482. }
  19483. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  19484. /** @hidden */
  19485. export var bumpFragment: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  19491. /** @hidden */
  19492. export var depthPrePass: {
  19493. name: string;
  19494. shader: string;
  19495. };
  19496. }
  19497. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  19498. /** @hidden */
  19499. export var lightFragment: {
  19500. name: string;
  19501. shader: string;
  19502. };
  19503. }
  19504. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  19505. /** @hidden */
  19506. export var logDepthFragment: {
  19507. name: string;
  19508. shader: string;
  19509. };
  19510. }
  19511. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  19512. /** @hidden */
  19513. export var fogFragment: {
  19514. name: string;
  19515. shader: string;
  19516. };
  19517. }
  19518. declare module "babylonjs/Shaders/default.fragment" {
  19519. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  19520. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19521. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  19522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19523. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19524. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19525. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  19526. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  19527. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  19528. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  19529. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19530. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19531. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  19532. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  19533. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19534. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19535. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  19536. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19537. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  19538. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  19539. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  19540. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  19541. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  19542. /** @hidden */
  19543. export var defaultPixelShader: {
  19544. name: string;
  19545. shader: string;
  19546. };
  19547. }
  19548. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  19549. /** @hidden */
  19550. export var defaultVertexDeclaration: {
  19551. name: string;
  19552. shader: string;
  19553. };
  19554. }
  19555. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  19556. /** @hidden */
  19557. export var bonesDeclaration: {
  19558. name: string;
  19559. shader: string;
  19560. };
  19561. }
  19562. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  19563. /** @hidden */
  19564. export var prePassVertexDeclaration: {
  19565. name: string;
  19566. shader: string;
  19567. };
  19568. }
  19569. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  19570. /** @hidden */
  19571. export var bumpVertexDeclaration: {
  19572. name: string;
  19573. shader: string;
  19574. };
  19575. }
  19576. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  19577. /** @hidden */
  19578. export var fogVertexDeclaration: {
  19579. name: string;
  19580. shader: string;
  19581. };
  19582. }
  19583. declare module "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration" {
  19584. /** @hidden */
  19585. export var lightVxFragmentDeclaration: {
  19586. name: string;
  19587. shader: string;
  19588. };
  19589. }
  19590. declare module "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration" {
  19591. /** @hidden */
  19592. export var lightVxUboDeclaration: {
  19593. name: string;
  19594. shader: string;
  19595. };
  19596. }
  19597. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  19598. /** @hidden */
  19599. export var morphTargetsVertexGlobalDeclaration: {
  19600. name: string;
  19601. shader: string;
  19602. };
  19603. }
  19604. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  19605. /** @hidden */
  19606. export var morphTargetsVertexDeclaration: {
  19607. name: string;
  19608. shader: string;
  19609. };
  19610. }
  19611. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19612. /** @hidden */
  19613. export var morphTargetsVertex: {
  19614. name: string;
  19615. shader: string;
  19616. };
  19617. }
  19618. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19619. /** @hidden */
  19620. export var instancesVertex: {
  19621. name: string;
  19622. shader: string;
  19623. };
  19624. }
  19625. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19626. /** @hidden */
  19627. export var bonesVertex: {
  19628. name: string;
  19629. shader: string;
  19630. };
  19631. }
  19632. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19633. /** @hidden */
  19634. export var prePassVertex: {
  19635. name: string;
  19636. shader: string;
  19637. };
  19638. }
  19639. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19640. /** @hidden */
  19641. export var bumpVertex: {
  19642. name: string;
  19643. shader: string;
  19644. };
  19645. }
  19646. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19647. /** @hidden */
  19648. export var fogVertex: {
  19649. name: string;
  19650. shader: string;
  19651. };
  19652. }
  19653. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19654. /** @hidden */
  19655. export var shadowsVertex: {
  19656. name: string;
  19657. shader: string;
  19658. };
  19659. }
  19660. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19661. /** @hidden */
  19662. export var pointCloudVertex: {
  19663. name: string;
  19664. shader: string;
  19665. };
  19666. }
  19667. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19668. /** @hidden */
  19669. export var logDepthVertex: {
  19670. name: string;
  19671. shader: string;
  19672. };
  19673. }
  19674. declare module "babylonjs/Shaders/default.vertex" {
  19675. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19676. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19677. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19678. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19679. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19680. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19681. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19682. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19683. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  19684. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  19685. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19686. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19687. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19689. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19690. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19691. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19692. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19693. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19694. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19695. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19696. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19697. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19698. /** @hidden */
  19699. export var defaultVertexShader: {
  19700. name: string;
  19701. shader: string;
  19702. };
  19703. }
  19704. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19705. import { Nullable } from "babylonjs/types";
  19706. import { Scene } from "babylonjs/scene";
  19707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19709. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19710. /**
  19711. * @hidden
  19712. */
  19713. export interface IMaterialDetailMapDefines {
  19714. DETAIL: boolean;
  19715. DETAILDIRECTUV: number;
  19716. DETAIL_NORMALBLENDMETHOD: number;
  19717. /** @hidden */
  19718. _areTexturesDirty: boolean;
  19719. }
  19720. /**
  19721. * Define the code related to the detail map parameters of a material
  19722. *
  19723. * Inspired from:
  19724. * 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
  19725. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19726. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19727. */
  19728. export class DetailMapConfiguration {
  19729. private _texture;
  19730. /**
  19731. * The detail texture of the material.
  19732. */
  19733. texture: Nullable<BaseTexture>;
  19734. /**
  19735. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19736. * Bigger values mean stronger blending
  19737. */
  19738. diffuseBlendLevel: number;
  19739. /**
  19740. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19741. * Bigger values mean stronger blending. Only used with PBR materials
  19742. */
  19743. roughnessBlendLevel: number;
  19744. /**
  19745. * Defines how strong the bump effect from the detail map is
  19746. * Bigger values mean stronger effect
  19747. */
  19748. bumpLevel: number;
  19749. private _normalBlendMethod;
  19750. /**
  19751. * The method used to blend the bump and detail normals together
  19752. */
  19753. normalBlendMethod: number;
  19754. private _isEnabled;
  19755. /**
  19756. * Enable or disable the detail map on this material
  19757. */
  19758. isEnabled: boolean;
  19759. /** @hidden */
  19760. private _internalMarkAllSubMeshesAsTexturesDirty;
  19761. /** @hidden */
  19762. _markAllSubMeshesAsTexturesDirty(): void;
  19763. /**
  19764. * Instantiate a new detail map
  19765. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19766. */
  19767. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19768. /**
  19769. * Gets whether the submesh is ready to be used or not.
  19770. * @param defines the list of "defines" to update.
  19771. * @param scene defines the scene the material belongs to.
  19772. * @returns - boolean indicating that the submesh is ready or not.
  19773. */
  19774. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19775. /**
  19776. * Update the defines for detail map usage
  19777. * @param defines the list of "defines" to update.
  19778. * @param scene defines the scene the material belongs to.
  19779. */
  19780. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19781. /**
  19782. * Binds the material data.
  19783. * @param uniformBuffer defines the Uniform buffer to fill in.
  19784. * @param scene defines the scene the material belongs to.
  19785. * @param isFrozen defines whether the material is frozen or not.
  19786. */
  19787. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19788. /**
  19789. * Checks to see if a texture is used in the material.
  19790. * @param texture - Base texture to use.
  19791. * @returns - Boolean specifying if a texture is used in the material.
  19792. */
  19793. hasTexture(texture: BaseTexture): boolean;
  19794. /**
  19795. * Returns an array of the actively used textures.
  19796. * @param activeTextures Array of BaseTextures
  19797. */
  19798. getActiveTextures(activeTextures: BaseTexture[]): void;
  19799. /**
  19800. * Returns the animatable textures.
  19801. * @param animatables Array of animatable textures.
  19802. */
  19803. getAnimatables(animatables: IAnimatable[]): void;
  19804. /**
  19805. * Disposes the resources of the material.
  19806. * @param forceDisposeTextures - Forces the disposal of all textures.
  19807. */
  19808. dispose(forceDisposeTextures?: boolean): void;
  19809. /**
  19810. * Get the current class name useful for serialization or dynamic coding.
  19811. * @returns "DetailMap"
  19812. */
  19813. getClassName(): string;
  19814. /**
  19815. * Add the required uniforms to the current list.
  19816. * @param uniforms defines the current uniform list.
  19817. */
  19818. static AddUniforms(uniforms: string[]): void;
  19819. /**
  19820. * Add the required samplers to the current list.
  19821. * @param samplers defines the current sampler list.
  19822. */
  19823. static AddSamplers(samplers: string[]): void;
  19824. /**
  19825. * Add the required uniforms to the current buffer.
  19826. * @param uniformBuffer defines the current uniform buffer.
  19827. */
  19828. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19829. /**
  19830. * Makes a duplicate of the current instance into another one.
  19831. * @param detailMap define the instance where to copy the info
  19832. */
  19833. copyTo(detailMap: DetailMapConfiguration): void;
  19834. /**
  19835. * Serializes this detail map instance
  19836. * @returns - An object with the serialized instance.
  19837. */
  19838. serialize(): any;
  19839. /**
  19840. * Parses a detail map setting from a serialized object.
  19841. * @param source - Serialized object.
  19842. * @param scene Defines the scene we are parsing for
  19843. * @param rootUrl Defines the rootUrl to load from
  19844. */
  19845. parse(source: any, scene: Scene, rootUrl: string): void;
  19846. }
  19847. }
  19848. declare module "babylonjs/Materials/standardMaterial" {
  19849. import { SmartArray } from "babylonjs/Misc/smartArray";
  19850. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19851. import { Nullable } from "babylonjs/types";
  19852. import { Scene } from "babylonjs/scene";
  19853. import { Matrix } from "babylonjs/Maths/math.vector";
  19854. import { Color3 } from "babylonjs/Maths/math.color";
  19855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19857. import { Mesh } from "babylonjs/Meshes/mesh";
  19858. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19859. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19861. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19862. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19863. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19866. import "babylonjs/Shaders/default.fragment";
  19867. import "babylonjs/Shaders/default.vertex";
  19868. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19869. /** @hidden */
  19870. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19871. MAINUV1: boolean;
  19872. MAINUV2: boolean;
  19873. DIFFUSE: boolean;
  19874. DIFFUSEDIRECTUV: number;
  19875. DETAIL: boolean;
  19876. DETAILDIRECTUV: number;
  19877. DETAIL_NORMALBLENDMETHOD: number;
  19878. AMBIENT: boolean;
  19879. AMBIENTDIRECTUV: number;
  19880. OPACITY: boolean;
  19881. OPACITYDIRECTUV: number;
  19882. OPACITYRGB: boolean;
  19883. REFLECTION: boolean;
  19884. EMISSIVE: boolean;
  19885. EMISSIVEDIRECTUV: number;
  19886. SPECULAR: boolean;
  19887. SPECULARDIRECTUV: number;
  19888. BUMP: boolean;
  19889. BUMPDIRECTUV: number;
  19890. PARALLAX: boolean;
  19891. PARALLAXOCCLUSION: boolean;
  19892. SPECULAROVERALPHA: boolean;
  19893. CLIPPLANE: boolean;
  19894. CLIPPLANE2: boolean;
  19895. CLIPPLANE3: boolean;
  19896. CLIPPLANE4: boolean;
  19897. CLIPPLANE5: boolean;
  19898. CLIPPLANE6: boolean;
  19899. ALPHATEST: boolean;
  19900. DEPTHPREPASS: boolean;
  19901. ALPHAFROMDIFFUSE: boolean;
  19902. POINTSIZE: boolean;
  19903. FOG: boolean;
  19904. SPECULARTERM: boolean;
  19905. DIFFUSEFRESNEL: boolean;
  19906. OPACITYFRESNEL: boolean;
  19907. REFLECTIONFRESNEL: boolean;
  19908. REFRACTIONFRESNEL: boolean;
  19909. EMISSIVEFRESNEL: boolean;
  19910. FRESNEL: boolean;
  19911. NORMAL: boolean;
  19912. UV1: boolean;
  19913. UV2: boolean;
  19914. VERTEXCOLOR: boolean;
  19915. VERTEXALPHA: boolean;
  19916. NUM_BONE_INFLUENCERS: number;
  19917. BonesPerMesh: number;
  19918. BONETEXTURE: boolean;
  19919. BONES_VELOCITY_ENABLED: boolean;
  19920. INSTANCES: boolean;
  19921. THIN_INSTANCES: boolean;
  19922. GLOSSINESS: boolean;
  19923. ROUGHNESS: boolean;
  19924. EMISSIVEASILLUMINATION: boolean;
  19925. LINKEMISSIVEWITHDIFFUSE: boolean;
  19926. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19927. LIGHTMAP: boolean;
  19928. LIGHTMAPDIRECTUV: number;
  19929. OBJECTSPACE_NORMALMAP: boolean;
  19930. USELIGHTMAPASSHADOWMAP: boolean;
  19931. REFLECTIONMAP_3D: boolean;
  19932. REFLECTIONMAP_SPHERICAL: boolean;
  19933. REFLECTIONMAP_PLANAR: boolean;
  19934. REFLECTIONMAP_CUBIC: boolean;
  19935. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19936. REFLECTIONMAP_PROJECTION: boolean;
  19937. REFLECTIONMAP_SKYBOX: boolean;
  19938. REFLECTIONMAP_EXPLICIT: boolean;
  19939. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19940. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19941. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19942. INVERTCUBICMAP: boolean;
  19943. LOGARITHMICDEPTH: boolean;
  19944. REFRACTION: boolean;
  19945. REFRACTIONMAP_3D: boolean;
  19946. REFLECTIONOVERALPHA: boolean;
  19947. TWOSIDEDLIGHTING: boolean;
  19948. SHADOWFLOAT: boolean;
  19949. MORPHTARGETS: boolean;
  19950. MORPHTARGETS_NORMAL: boolean;
  19951. MORPHTARGETS_TANGENT: boolean;
  19952. MORPHTARGETS_UV: boolean;
  19953. NUM_MORPH_INFLUENCERS: number;
  19954. NONUNIFORMSCALING: boolean;
  19955. PREMULTIPLYALPHA: boolean;
  19956. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19957. ALPHABLEND: boolean;
  19958. PREPASS: boolean;
  19959. PREPASS_IRRADIANCE: boolean;
  19960. PREPASS_IRRADIANCE_INDEX: number;
  19961. PREPASS_ALBEDO: boolean;
  19962. PREPASS_ALBEDO_INDEX: number;
  19963. PREPASS_DEPTHNORMAL: boolean;
  19964. PREPASS_DEPTHNORMAL_INDEX: number;
  19965. PREPASS_POSITION: boolean;
  19966. PREPASS_POSITION_INDEX: number;
  19967. PREPASS_VELOCITY: boolean;
  19968. PREPASS_VELOCITY_INDEX: number;
  19969. PREPASS_REFLECTIVITY: boolean;
  19970. PREPASS_REFLECTIVITY_INDEX: number;
  19971. SCENE_MRT_COUNT: number;
  19972. RGBDLIGHTMAP: boolean;
  19973. RGBDREFLECTION: boolean;
  19974. RGBDREFRACTION: boolean;
  19975. IMAGEPROCESSING: boolean;
  19976. VIGNETTE: boolean;
  19977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19978. VIGNETTEBLENDMODEOPAQUE: boolean;
  19979. TONEMAPPING: boolean;
  19980. TONEMAPPING_ACES: boolean;
  19981. CONTRAST: boolean;
  19982. COLORCURVES: boolean;
  19983. COLORGRADING: boolean;
  19984. COLORGRADING3D: boolean;
  19985. SAMPLER3DGREENDEPTH: boolean;
  19986. SAMPLER3DBGRMAP: boolean;
  19987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19988. MULTIVIEW: boolean;
  19989. /**
  19990. * If the reflection texture on this material is in linear color space
  19991. * @hidden
  19992. */
  19993. IS_REFLECTION_LINEAR: boolean;
  19994. /**
  19995. * If the refraction texture on this material is in linear color space
  19996. * @hidden
  19997. */
  19998. IS_REFRACTION_LINEAR: boolean;
  19999. EXPOSURE: boolean;
  20000. constructor();
  20001. setReflectionMode(modeToEnable: string): void;
  20002. }
  20003. /**
  20004. * This is the default material used in Babylon. It is the best trade off between quality
  20005. * and performances.
  20006. * @see https://doc.babylonjs.com/babylon101/materials
  20007. */
  20008. export class StandardMaterial extends PushMaterial {
  20009. private _diffuseTexture;
  20010. /**
  20011. * The basic texture of the material as viewed under a light.
  20012. */
  20013. diffuseTexture: Nullable<BaseTexture>;
  20014. private _ambientTexture;
  20015. /**
  20016. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  20017. */
  20018. ambientTexture: Nullable<BaseTexture>;
  20019. private _opacityTexture;
  20020. /**
  20021. * Define the transparency of the material from a texture.
  20022. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  20023. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  20024. */
  20025. opacityTexture: Nullable<BaseTexture>;
  20026. private _reflectionTexture;
  20027. /**
  20028. * Define the texture used to display the reflection.
  20029. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20030. */
  20031. reflectionTexture: Nullable<BaseTexture>;
  20032. private _emissiveTexture;
  20033. /**
  20034. * Define texture of the material as if self lit.
  20035. * This will be mixed in the final result even in the absence of light.
  20036. */
  20037. emissiveTexture: Nullable<BaseTexture>;
  20038. private _specularTexture;
  20039. /**
  20040. * Define how the color and intensity of the highlight given by the light in the material.
  20041. */
  20042. specularTexture: Nullable<BaseTexture>;
  20043. private _bumpTexture;
  20044. /**
  20045. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  20046. * 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.
  20047. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  20048. */
  20049. bumpTexture: Nullable<BaseTexture>;
  20050. private _lightmapTexture;
  20051. /**
  20052. * Complex lighting can be computationally expensive to compute at runtime.
  20053. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  20054. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  20055. */
  20056. lightmapTexture: Nullable<BaseTexture>;
  20057. private _refractionTexture;
  20058. /**
  20059. * Define the texture used to display the refraction.
  20060. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20061. */
  20062. refractionTexture: Nullable<BaseTexture>;
  20063. /**
  20064. * The color of the material lit by the environmental background lighting.
  20065. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  20066. */
  20067. ambientColor: Color3;
  20068. /**
  20069. * The basic color of the material as viewed under a light.
  20070. */
  20071. diffuseColor: Color3;
  20072. /**
  20073. * Define how the color and intensity of the highlight given by the light in the material.
  20074. */
  20075. specularColor: Color3;
  20076. /**
  20077. * Define the color of the material as if self lit.
  20078. * This will be mixed in the final result even in the absence of light.
  20079. */
  20080. emissiveColor: Color3;
  20081. /**
  20082. * Defines how sharp are the highlights in the material.
  20083. * The bigger the value the sharper giving a more glossy feeling to the result.
  20084. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  20085. */
  20086. specularPower: number;
  20087. private _useAlphaFromDiffuseTexture;
  20088. /**
  20089. * Does the transparency come from the diffuse texture alpha channel.
  20090. */
  20091. useAlphaFromDiffuseTexture: boolean;
  20092. private _useEmissiveAsIllumination;
  20093. /**
  20094. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  20095. */
  20096. useEmissiveAsIllumination: boolean;
  20097. private _linkEmissiveWithDiffuse;
  20098. /**
  20099. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  20100. * the emissive level when the final color is close to one.
  20101. */
  20102. linkEmissiveWithDiffuse: boolean;
  20103. private _useSpecularOverAlpha;
  20104. /**
  20105. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  20106. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20107. */
  20108. useSpecularOverAlpha: boolean;
  20109. private _useReflectionOverAlpha;
  20110. /**
  20111. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  20112. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20113. */
  20114. useReflectionOverAlpha: boolean;
  20115. private _disableLighting;
  20116. /**
  20117. * Does lights from the scene impacts this material.
  20118. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  20119. */
  20120. disableLighting: boolean;
  20121. private _useObjectSpaceNormalMap;
  20122. /**
  20123. * Allows using an object space normal map (instead of tangent space).
  20124. */
  20125. useObjectSpaceNormalMap: boolean;
  20126. private _useParallax;
  20127. /**
  20128. * Is parallax enabled or not.
  20129. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20130. */
  20131. useParallax: boolean;
  20132. private _useParallaxOcclusion;
  20133. /**
  20134. * Is parallax occlusion enabled or not.
  20135. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  20136. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20137. */
  20138. useParallaxOcclusion: boolean;
  20139. /**
  20140. * 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.
  20141. */
  20142. parallaxScaleBias: number;
  20143. private _roughness;
  20144. /**
  20145. * Helps to define how blurry the reflections should appears in the material.
  20146. */
  20147. roughness: number;
  20148. /**
  20149. * In case of refraction, define the value of the index of refraction.
  20150. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20151. */
  20152. indexOfRefraction: number;
  20153. /**
  20154. * Invert the refraction texture alongside the y axis.
  20155. * It can be useful with procedural textures or probe for instance.
  20156. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20157. */
  20158. invertRefractionY: boolean;
  20159. /**
  20160. * Defines the alpha limits in alpha test mode.
  20161. */
  20162. alphaCutOff: number;
  20163. private _useLightmapAsShadowmap;
  20164. /**
  20165. * In case of light mapping, define whether the map contains light or shadow informations.
  20166. */
  20167. useLightmapAsShadowmap: boolean;
  20168. private _diffuseFresnelParameters;
  20169. /**
  20170. * Define the diffuse fresnel parameters of the material.
  20171. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20172. */
  20173. diffuseFresnelParameters: FresnelParameters;
  20174. private _opacityFresnelParameters;
  20175. /**
  20176. * Define the opacity fresnel parameters of the material.
  20177. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20178. */
  20179. opacityFresnelParameters: FresnelParameters;
  20180. private _reflectionFresnelParameters;
  20181. /**
  20182. * Define the reflection fresnel parameters of the material.
  20183. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20184. */
  20185. reflectionFresnelParameters: FresnelParameters;
  20186. private _refractionFresnelParameters;
  20187. /**
  20188. * Define the refraction fresnel parameters of the material.
  20189. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20190. */
  20191. refractionFresnelParameters: FresnelParameters;
  20192. private _emissiveFresnelParameters;
  20193. /**
  20194. * Define the emissive fresnel parameters of the material.
  20195. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20196. */
  20197. emissiveFresnelParameters: FresnelParameters;
  20198. private _useReflectionFresnelFromSpecular;
  20199. /**
  20200. * If true automatically deducts the fresnels values from the material specularity.
  20201. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20202. */
  20203. useReflectionFresnelFromSpecular: boolean;
  20204. private _useGlossinessFromSpecularMapAlpha;
  20205. /**
  20206. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20207. */
  20208. useGlossinessFromSpecularMapAlpha: boolean;
  20209. private _maxSimultaneousLights;
  20210. /**
  20211. * Defines the maximum number of lights that can be used in the material
  20212. */
  20213. maxSimultaneousLights: number;
  20214. private _invertNormalMapX;
  20215. /**
  20216. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20217. */
  20218. invertNormalMapX: boolean;
  20219. private _invertNormalMapY;
  20220. /**
  20221. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20222. */
  20223. invertNormalMapY: boolean;
  20224. private _twoSidedLighting;
  20225. /**
  20226. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20227. */
  20228. twoSidedLighting: boolean;
  20229. /**
  20230. * Default configuration related to image processing available in the standard Material.
  20231. */
  20232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20233. /**
  20234. * Gets the image processing configuration used either in this material.
  20235. */
  20236. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20237. /**
  20238. * Sets the Default image processing configuration used either in the this material.
  20239. *
  20240. * If sets to null, the scene one is in use.
  20241. */
  20242. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20243. /**
  20244. * Keep track of the image processing observer to allow dispose and replace.
  20245. */
  20246. private _imageProcessingObserver;
  20247. /**
  20248. * Attaches a new image processing configuration to the Standard Material.
  20249. * @param configuration
  20250. */
  20251. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20252. /**
  20253. * Defines additionnal PrePass parameters for the material.
  20254. */
  20255. readonly prePassConfiguration: PrePassConfiguration;
  20256. /**
  20257. * Gets wether the color curves effect is enabled.
  20258. */
  20259. get cameraColorCurvesEnabled(): boolean;
  20260. /**
  20261. * Sets wether the color curves effect is enabled.
  20262. */
  20263. set cameraColorCurvesEnabled(value: boolean);
  20264. /**
  20265. * Gets wether the color grading effect is enabled.
  20266. */
  20267. get cameraColorGradingEnabled(): boolean;
  20268. /**
  20269. * Gets wether the color grading effect is enabled.
  20270. */
  20271. set cameraColorGradingEnabled(value: boolean);
  20272. /**
  20273. * Gets wether tonemapping is enabled or not.
  20274. */
  20275. get cameraToneMappingEnabled(): boolean;
  20276. /**
  20277. * Sets wether tonemapping is enabled or not
  20278. */
  20279. set cameraToneMappingEnabled(value: boolean);
  20280. /**
  20281. * The camera exposure used on this material.
  20282. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20283. * This corresponds to a photographic exposure.
  20284. */
  20285. get cameraExposure(): number;
  20286. /**
  20287. * The camera exposure used on this material.
  20288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20289. * This corresponds to a photographic exposure.
  20290. */
  20291. set cameraExposure(value: number);
  20292. /**
  20293. * Gets The camera contrast used on this material.
  20294. */
  20295. get cameraContrast(): number;
  20296. /**
  20297. * Sets The camera contrast used on this material.
  20298. */
  20299. set cameraContrast(value: number);
  20300. /**
  20301. * Gets the Color Grading 2D Lookup Texture.
  20302. */
  20303. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20304. /**
  20305. * Sets the Color Grading 2D Lookup Texture.
  20306. */
  20307. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20308. /**
  20309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20311. * 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;
  20312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20313. */
  20314. get cameraColorCurves(): Nullable<ColorCurves>;
  20315. /**
  20316. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20317. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20318. * 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;
  20319. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20320. */
  20321. set cameraColorCurves(value: Nullable<ColorCurves>);
  20322. /**
  20323. * Can this material render to several textures at once
  20324. */
  20325. get canRenderToMRT(): boolean;
  20326. /**
  20327. * Defines the detail map parameters for the material.
  20328. */
  20329. readonly detailMap: DetailMapConfiguration;
  20330. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20331. protected _worldViewProjectionMatrix: Matrix;
  20332. protected _globalAmbientColor: Color3;
  20333. protected _useLogarithmicDepth: boolean;
  20334. protected _rebuildInParallel: boolean;
  20335. /**
  20336. * Instantiates a new standard material.
  20337. * This is the default material used in Babylon. It is the best trade off between quality
  20338. * and performances.
  20339. * @see https://doc.babylonjs.com/babylon101/materials
  20340. * @param name Define the name of the material in the scene
  20341. * @param scene Define the scene the material belong to
  20342. */
  20343. constructor(name: string, scene: Scene);
  20344. /**
  20345. * Gets a boolean indicating that current material needs to register RTT
  20346. */
  20347. get hasRenderTargetTextures(): boolean;
  20348. /**
  20349. * Gets the current class name of the material e.g. "StandardMaterial"
  20350. * Mainly use in serialization.
  20351. * @returns the class name
  20352. */
  20353. getClassName(): string;
  20354. /**
  20355. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20356. * You can try switching to logarithmic depth.
  20357. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20358. */
  20359. get useLogarithmicDepth(): boolean;
  20360. set useLogarithmicDepth(value: boolean);
  20361. /**
  20362. * Specifies if the material will require alpha blending
  20363. * @returns a boolean specifying if alpha blending is needed
  20364. */
  20365. needAlphaBlending(): boolean;
  20366. /**
  20367. * Specifies if this material should be rendered in alpha test mode
  20368. * @returns a boolean specifying if an alpha test is needed.
  20369. */
  20370. needAlphaTesting(): boolean;
  20371. /**
  20372. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20373. */
  20374. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20375. /**
  20376. * Specifies whether or not there is a usable alpha channel for transparency.
  20377. */
  20378. protected _hasAlphaChannel(): boolean;
  20379. /**
  20380. * Get the texture used for alpha test purpose.
  20381. * @returns the diffuse texture in case of the standard material.
  20382. */
  20383. getAlphaTestTexture(): Nullable<BaseTexture>;
  20384. /**
  20385. * Get if the submesh is ready to be used and all its information available.
  20386. * Child classes can use it to update shaders
  20387. * @param mesh defines the mesh to check
  20388. * @param subMesh defines which submesh to check
  20389. * @param useInstances specifies that instances should be used
  20390. * @returns a boolean indicating that the submesh is ready or not
  20391. */
  20392. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20393. /**
  20394. * Builds the material UBO layouts.
  20395. * Used internally during the effect preparation.
  20396. */
  20397. buildUniformLayout(): void;
  20398. /**
  20399. * Unbinds the material from the mesh
  20400. */
  20401. unbind(): void;
  20402. /**
  20403. * Binds the submesh to this material by preparing the effect and shader to draw
  20404. * @param world defines the world transformation matrix
  20405. * @param mesh defines the mesh containing the submesh
  20406. * @param subMesh defines the submesh to bind the material to
  20407. */
  20408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20409. /**
  20410. * Get the list of animatables in the material.
  20411. * @returns the list of animatables object used in the material
  20412. */
  20413. getAnimatables(): IAnimatable[];
  20414. /**
  20415. * Gets the active textures from the material
  20416. * @returns an array of textures
  20417. */
  20418. getActiveTextures(): BaseTexture[];
  20419. /**
  20420. * Specifies if the material uses a texture
  20421. * @param texture defines the texture to check against the material
  20422. * @returns a boolean specifying if the material uses the texture
  20423. */
  20424. hasTexture(texture: BaseTexture): boolean;
  20425. /**
  20426. * Disposes the material
  20427. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20428. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20429. */
  20430. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20431. /**
  20432. * Makes a duplicate of the material, and gives it a new name
  20433. * @param name defines the new name for the duplicated material
  20434. * @returns the cloned material
  20435. */
  20436. clone(name: string): StandardMaterial;
  20437. /**
  20438. * Serializes this material in a JSON representation
  20439. * @returns the serialized material object
  20440. */
  20441. serialize(): any;
  20442. /**
  20443. * Creates a standard material from parsed material data
  20444. * @param source defines the JSON representation of the material
  20445. * @param scene defines the hosting scene
  20446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20447. * @returns a new standard material
  20448. */
  20449. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20450. /**
  20451. * Are diffuse textures enabled in the application.
  20452. */
  20453. static get DiffuseTextureEnabled(): boolean;
  20454. static set DiffuseTextureEnabled(value: boolean);
  20455. /**
  20456. * Are detail textures enabled in the application.
  20457. */
  20458. static get DetailTextureEnabled(): boolean;
  20459. static set DetailTextureEnabled(value: boolean);
  20460. /**
  20461. * Are ambient textures enabled in the application.
  20462. */
  20463. static get AmbientTextureEnabled(): boolean;
  20464. static set AmbientTextureEnabled(value: boolean);
  20465. /**
  20466. * Are opacity textures enabled in the application.
  20467. */
  20468. static get OpacityTextureEnabled(): boolean;
  20469. static set OpacityTextureEnabled(value: boolean);
  20470. /**
  20471. * Are reflection textures enabled in the application.
  20472. */
  20473. static get ReflectionTextureEnabled(): boolean;
  20474. static set ReflectionTextureEnabled(value: boolean);
  20475. /**
  20476. * Are emissive textures enabled in the application.
  20477. */
  20478. static get EmissiveTextureEnabled(): boolean;
  20479. static set EmissiveTextureEnabled(value: boolean);
  20480. /**
  20481. * Are specular textures enabled in the application.
  20482. */
  20483. static get SpecularTextureEnabled(): boolean;
  20484. static set SpecularTextureEnabled(value: boolean);
  20485. /**
  20486. * Are bump textures enabled in the application.
  20487. */
  20488. static get BumpTextureEnabled(): boolean;
  20489. static set BumpTextureEnabled(value: boolean);
  20490. /**
  20491. * Are lightmap textures enabled in the application.
  20492. */
  20493. static get LightmapTextureEnabled(): boolean;
  20494. static set LightmapTextureEnabled(value: boolean);
  20495. /**
  20496. * Are refraction textures enabled in the application.
  20497. */
  20498. static get RefractionTextureEnabled(): boolean;
  20499. static set RefractionTextureEnabled(value: boolean);
  20500. /**
  20501. * Are color grading textures enabled in the application.
  20502. */
  20503. static get ColorGradingTextureEnabled(): boolean;
  20504. static set ColorGradingTextureEnabled(value: boolean);
  20505. /**
  20506. * Are fresnels enabled in the application.
  20507. */
  20508. static get FresnelEnabled(): boolean;
  20509. static set FresnelEnabled(value: boolean);
  20510. }
  20511. }
  20512. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  20513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20514. /** @hidden */
  20515. export var rgbdDecodePixelShader: {
  20516. name: string;
  20517. shader: string;
  20518. };
  20519. }
  20520. declare module "babylonjs/Shaders/pass.fragment" {
  20521. /** @hidden */
  20522. export var passPixelShader: {
  20523. name: string;
  20524. shader: string;
  20525. };
  20526. }
  20527. declare module "babylonjs/Shaders/passCube.fragment" {
  20528. /** @hidden */
  20529. export var passCubePixelShader: {
  20530. name: string;
  20531. shader: string;
  20532. };
  20533. }
  20534. declare module "babylonjs/PostProcesses/passPostProcess" {
  20535. import { Nullable } from "babylonjs/types";
  20536. import { Camera } from "babylonjs/Cameras/camera";
  20537. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20538. import { Engine } from "babylonjs/Engines/engine";
  20539. import "babylonjs/Shaders/pass.fragment";
  20540. import "babylonjs/Shaders/passCube.fragment";
  20541. import { Scene } from "babylonjs/scene";
  20542. /**
  20543. * PassPostProcess which produces an output the same as it's input
  20544. */
  20545. export class PassPostProcess extends PostProcess {
  20546. /**
  20547. * Gets a string identifying the name of the class
  20548. * @returns "PassPostProcess" string
  20549. */
  20550. getClassName(): string;
  20551. /**
  20552. * Creates the PassPostProcess
  20553. * @param name The name of the effect.
  20554. * @param options The required width/height ratio to downsize to before computing the render pass.
  20555. * @param camera The camera to apply the render pass to.
  20556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20557. * @param engine The engine which the post process will be applied. (default: current engine)
  20558. * @param reusable If the post process can be reused on the same frame. (default: false)
  20559. * @param textureType The type of texture to be used when performing the post processing.
  20560. * @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)
  20561. */
  20562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20563. /** @hidden */
  20564. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20565. }
  20566. /**
  20567. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20568. */
  20569. export class PassCubePostProcess extends PostProcess {
  20570. private _face;
  20571. /**
  20572. * Gets or sets the cube face to display.
  20573. * * 0 is +X
  20574. * * 1 is -X
  20575. * * 2 is +Y
  20576. * * 3 is -Y
  20577. * * 4 is +Z
  20578. * * 5 is -Z
  20579. */
  20580. get face(): number;
  20581. set face(value: number);
  20582. /**
  20583. * Gets a string identifying the name of the class
  20584. * @returns "PassCubePostProcess" string
  20585. */
  20586. getClassName(): string;
  20587. /**
  20588. * Creates the PassCubePostProcess
  20589. * @param name The name of the effect.
  20590. * @param options The required width/height ratio to downsize to before computing the render pass.
  20591. * @param camera The camera to apply the render pass to.
  20592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20593. * @param engine The engine which the post process will be applied. (default: current engine)
  20594. * @param reusable If the post process can be reused on the same frame. (default: false)
  20595. * @param textureType The type of texture to be used when performing the post processing.
  20596. * @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)
  20597. */
  20598. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20599. /** @hidden */
  20600. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20601. }
  20602. }
  20603. declare module "babylonjs/Misc/textureTools" {
  20604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20605. import { Texture } from "babylonjs/Materials/Textures/texture";
  20606. import { Scene } from "babylonjs/scene";
  20607. /**
  20608. * Class used to host texture specific utilities
  20609. */
  20610. export class TextureTools {
  20611. /**
  20612. * Uses the GPU to create a copy texture rescaled at a given size
  20613. * @param texture Texture to copy from
  20614. * @param width defines the desired width
  20615. * @param height defines the desired height
  20616. * @param useBilinearMode defines if bilinear mode has to be used
  20617. * @return the generated texture
  20618. */
  20619. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20620. /**
  20621. * Apply a post process to a texture
  20622. * @param postProcessName name of the fragment post process
  20623. * @param internalTexture the texture to encode
  20624. * @param scene the scene hosting the texture
  20625. * @param type type of the output texture. If not provided, use the one from internalTexture
  20626. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20627. * @param format format of the output texture. If not provided, use the one from internalTexture
  20628. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20629. */
  20630. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20631. }
  20632. }
  20633. declare module "babylonjs/Misc/rgbdTextureTools" {
  20634. import "babylonjs/Shaders/rgbdDecode.fragment";
  20635. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20636. import { Texture } from "babylonjs/Materials/Textures/texture";
  20637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20638. import { Scene } from "babylonjs/scene";
  20639. /**
  20640. * Class used to host RGBD texture specific utilities
  20641. */
  20642. export class RGBDTextureTools {
  20643. /**
  20644. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20645. * @param texture the texture to expand.
  20646. */
  20647. static ExpandRGBDTexture(texture: Texture): void;
  20648. /**
  20649. * Encode the texture to RGBD if possible.
  20650. * @param internalTexture the texture to encode
  20651. * @param scene the scene hosting the texture
  20652. * @param outputTextureType type of the texture in which the encoding is performed
  20653. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20654. */
  20655. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20656. }
  20657. }
  20658. declare module "babylonjs/Misc/brdfTextureTools" {
  20659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20660. import { Scene } from "babylonjs/scene";
  20661. /**
  20662. * Class used to host texture specific utilities
  20663. */
  20664. export class BRDFTextureTools {
  20665. /**
  20666. * Prevents texture cache collision
  20667. */
  20668. private static _instanceNumber;
  20669. /**
  20670. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20671. * @param scene defines the hosting scene
  20672. * @returns the environment BRDF texture
  20673. */
  20674. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20675. private static _environmentBRDFBase64Texture;
  20676. }
  20677. }
  20678. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  20679. import { Nullable } from "babylonjs/types";
  20680. import { Color3 } from "babylonjs/Maths/math.color";
  20681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20682. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20683. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20684. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20686. import { Engine } from "babylonjs/Engines/engine";
  20687. import { Scene } from "babylonjs/scene";
  20688. /**
  20689. * @hidden
  20690. */
  20691. export interface IMaterialClearCoatDefines {
  20692. CLEARCOAT: boolean;
  20693. CLEARCOAT_DEFAULTIOR: boolean;
  20694. CLEARCOAT_TEXTURE: boolean;
  20695. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20696. CLEARCOAT_TEXTUREDIRECTUV: number;
  20697. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20698. CLEARCOAT_BUMP: boolean;
  20699. CLEARCOAT_BUMPDIRECTUV: number;
  20700. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20701. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20702. CLEARCOAT_REMAP_F0: boolean;
  20703. CLEARCOAT_TINT: boolean;
  20704. CLEARCOAT_TINT_TEXTURE: boolean;
  20705. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20706. /** @hidden */
  20707. _areTexturesDirty: boolean;
  20708. }
  20709. /**
  20710. * Define the code related to the clear coat parameters of the pbr material.
  20711. */
  20712. export class PBRClearCoatConfiguration {
  20713. /**
  20714. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20715. * The default fits with a polyurethane material.
  20716. * @hidden
  20717. */
  20718. static readonly _DefaultIndexOfRefraction: number;
  20719. private _isEnabled;
  20720. /**
  20721. * Defines if the clear coat is enabled in the material.
  20722. */
  20723. isEnabled: boolean;
  20724. /**
  20725. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20726. */
  20727. intensity: number;
  20728. /**
  20729. * Defines the clear coat layer roughness.
  20730. */
  20731. roughness: number;
  20732. private _indexOfRefraction;
  20733. /**
  20734. * Defines the index of refraction of the clear coat.
  20735. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20736. * The default fits with a polyurethane material.
  20737. * Changing the default value is more performance intensive.
  20738. */
  20739. indexOfRefraction: number;
  20740. private _texture;
  20741. /**
  20742. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20743. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20744. * if textureRoughness is not empty, else no texture roughness is used
  20745. */
  20746. texture: Nullable<BaseTexture>;
  20747. private _useRoughnessFromMainTexture;
  20748. /**
  20749. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20750. * If false, the green channel from textureRoughness is used for roughness
  20751. */
  20752. useRoughnessFromMainTexture: boolean;
  20753. private _textureRoughness;
  20754. /**
  20755. * Stores the clear coat roughness in a texture (green channel)
  20756. * Not used if useRoughnessFromMainTexture is true
  20757. */
  20758. textureRoughness: Nullable<BaseTexture>;
  20759. private _remapF0OnInterfaceChange;
  20760. /**
  20761. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20762. */
  20763. remapF0OnInterfaceChange: boolean;
  20764. private _bumpTexture;
  20765. /**
  20766. * Define the clear coat specific bump texture.
  20767. */
  20768. bumpTexture: Nullable<BaseTexture>;
  20769. private _isTintEnabled;
  20770. /**
  20771. * Defines if the clear coat tint is enabled in the material.
  20772. */
  20773. isTintEnabled: boolean;
  20774. /**
  20775. * Defines the clear coat tint of the material.
  20776. * This is only use if tint is enabled
  20777. */
  20778. tintColor: Color3;
  20779. /**
  20780. * Defines the distance at which the tint color should be found in the
  20781. * clear coat media.
  20782. * This is only use if tint is enabled
  20783. */
  20784. tintColorAtDistance: number;
  20785. /**
  20786. * Defines the clear coat layer thickness.
  20787. * This is only use if tint is enabled
  20788. */
  20789. tintThickness: number;
  20790. private _tintTexture;
  20791. /**
  20792. * Stores the clear tint values in a texture.
  20793. * rgb is tint
  20794. * a is a thickness factor
  20795. */
  20796. tintTexture: Nullable<BaseTexture>;
  20797. /** @hidden */
  20798. private _internalMarkAllSubMeshesAsTexturesDirty;
  20799. /** @hidden */
  20800. _markAllSubMeshesAsTexturesDirty(): void;
  20801. /**
  20802. * Instantiate a new istance of clear coat configuration.
  20803. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20804. */
  20805. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20806. /**
  20807. * Gets wehter the submesh is ready to be used or not.
  20808. * @param defines the list of "defines" to update.
  20809. * @param scene defines the scene the material belongs to.
  20810. * @param engine defines the engine the material belongs to.
  20811. * @param disableBumpMap defines wether the material disables bump or not.
  20812. * @returns - boolean indicating that the submesh is ready or not.
  20813. */
  20814. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20815. /**
  20816. * Checks to see if a texture is used in the material.
  20817. * @param defines the list of "defines" to update.
  20818. * @param scene defines the scene to the material belongs to.
  20819. */
  20820. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20821. /**
  20822. * Binds the material data.
  20823. * @param uniformBuffer defines the Uniform buffer to fill in.
  20824. * @param scene defines the scene the material belongs to.
  20825. * @param engine defines the engine the material belongs to.
  20826. * @param disableBumpMap defines wether the material disables bump or not.
  20827. * @param isFrozen defines wether the material is frozen or not.
  20828. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20829. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20830. * @param subMesh the submesh to bind data for
  20831. */
  20832. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20833. /**
  20834. * Checks to see if a texture is used in the material.
  20835. * @param texture - Base texture to use.
  20836. * @returns - Boolean specifying if a texture is used in the material.
  20837. */
  20838. hasTexture(texture: BaseTexture): boolean;
  20839. /**
  20840. * Returns an array of the actively used textures.
  20841. * @param activeTextures Array of BaseTextures
  20842. */
  20843. getActiveTextures(activeTextures: BaseTexture[]): void;
  20844. /**
  20845. * Returns the animatable textures.
  20846. * @param animatables Array of animatable textures.
  20847. */
  20848. getAnimatables(animatables: IAnimatable[]): void;
  20849. /**
  20850. * Disposes the resources of the material.
  20851. * @param forceDisposeTextures - Forces the disposal of all textures.
  20852. */
  20853. dispose(forceDisposeTextures?: boolean): void;
  20854. /**
  20855. * Get the current class name of the texture useful for serialization or dynamic coding.
  20856. * @returns "PBRClearCoatConfiguration"
  20857. */
  20858. getClassName(): string;
  20859. /**
  20860. * Add fallbacks to the effect fallbacks list.
  20861. * @param defines defines the Base texture to use.
  20862. * @param fallbacks defines the current fallback list.
  20863. * @param currentRank defines the current fallback rank.
  20864. * @returns the new fallback rank.
  20865. */
  20866. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20867. /**
  20868. * Add the required uniforms to the current list.
  20869. * @param uniforms defines the current uniform list.
  20870. */
  20871. static AddUniforms(uniforms: string[]): void;
  20872. /**
  20873. * Add the required samplers to the current list.
  20874. * @param samplers defines the current sampler list.
  20875. */
  20876. static AddSamplers(samplers: string[]): void;
  20877. /**
  20878. * Add the required uniforms to the current buffer.
  20879. * @param uniformBuffer defines the current uniform buffer.
  20880. */
  20881. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20882. /**
  20883. * Makes a duplicate of the current configuration into another one.
  20884. * @param clearCoatConfiguration define the config where to copy the info
  20885. */
  20886. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20887. /**
  20888. * Serializes this clear coat configuration.
  20889. * @returns - An object with the serialized config.
  20890. */
  20891. serialize(): any;
  20892. /**
  20893. * Parses a anisotropy Configuration from a serialized object.
  20894. * @param source - Serialized object.
  20895. * @param scene Defines the scene we are parsing for
  20896. * @param rootUrl Defines the rootUrl to load from
  20897. */
  20898. parse(source: any, scene: Scene, rootUrl: string): void;
  20899. }
  20900. }
  20901. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20902. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20904. import { Vector2 } from "babylonjs/Maths/math.vector";
  20905. import { Scene } from "babylonjs/scene";
  20906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20907. import { Nullable } from "babylonjs/types";
  20908. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20909. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20910. /**
  20911. * @hidden
  20912. */
  20913. export interface IMaterialAnisotropicDefines {
  20914. ANISOTROPIC: boolean;
  20915. ANISOTROPIC_TEXTURE: boolean;
  20916. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20917. MAINUV1: boolean;
  20918. _areTexturesDirty: boolean;
  20919. _needUVs: boolean;
  20920. }
  20921. /**
  20922. * Define the code related to the anisotropic parameters of the pbr material.
  20923. */
  20924. export class PBRAnisotropicConfiguration {
  20925. private _isEnabled;
  20926. /**
  20927. * Defines if the anisotropy is enabled in the material.
  20928. */
  20929. isEnabled: boolean;
  20930. /**
  20931. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20932. */
  20933. intensity: number;
  20934. /**
  20935. * Defines if the effect is along the tangents, bitangents or in between.
  20936. * By default, the effect is "strectching" the highlights along the tangents.
  20937. */
  20938. direction: Vector2;
  20939. private _texture;
  20940. /**
  20941. * Stores the anisotropy values in a texture.
  20942. * rg is direction (like normal from -1 to 1)
  20943. * b is a intensity
  20944. */
  20945. texture: Nullable<BaseTexture>;
  20946. /** @hidden */
  20947. private _internalMarkAllSubMeshesAsTexturesDirty;
  20948. /** @hidden */
  20949. _markAllSubMeshesAsTexturesDirty(): void;
  20950. /**
  20951. * Instantiate a new istance of anisotropy configuration.
  20952. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20953. */
  20954. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20955. /**
  20956. * Specifies that the submesh is ready to be used.
  20957. * @param defines the list of "defines" to update.
  20958. * @param scene defines the scene the material belongs to.
  20959. * @returns - boolean indicating that the submesh is ready or not.
  20960. */
  20961. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20962. /**
  20963. * Checks to see if a texture is used in the material.
  20964. * @param defines the list of "defines" to update.
  20965. * @param mesh the mesh we are preparing the defines for.
  20966. * @param scene defines the scene the material belongs to.
  20967. */
  20968. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20969. /**
  20970. * Binds the material data.
  20971. * @param uniformBuffer defines the Uniform buffer to fill in.
  20972. * @param scene defines the scene the material belongs to.
  20973. * @param isFrozen defines wether the material is frozen or not.
  20974. */
  20975. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20976. /**
  20977. * Checks to see if a texture is used in the material.
  20978. * @param texture - Base texture to use.
  20979. * @returns - Boolean specifying if a texture is used in the material.
  20980. */
  20981. hasTexture(texture: BaseTexture): boolean;
  20982. /**
  20983. * Returns an array of the actively used textures.
  20984. * @param activeTextures Array of BaseTextures
  20985. */
  20986. getActiveTextures(activeTextures: BaseTexture[]): void;
  20987. /**
  20988. * Returns the animatable textures.
  20989. * @param animatables Array of animatable textures.
  20990. */
  20991. getAnimatables(animatables: IAnimatable[]): void;
  20992. /**
  20993. * Disposes the resources of the material.
  20994. * @param forceDisposeTextures - Forces the disposal of all textures.
  20995. */
  20996. dispose(forceDisposeTextures?: boolean): void;
  20997. /**
  20998. * Get the current class name of the texture useful for serialization or dynamic coding.
  20999. * @returns "PBRAnisotropicConfiguration"
  21000. */
  21001. getClassName(): string;
  21002. /**
  21003. * Add fallbacks to the effect fallbacks list.
  21004. * @param defines defines the Base texture to use.
  21005. * @param fallbacks defines the current fallback list.
  21006. * @param currentRank defines the current fallback rank.
  21007. * @returns the new fallback rank.
  21008. */
  21009. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21010. /**
  21011. * Add the required uniforms to the current list.
  21012. * @param uniforms defines the current uniform list.
  21013. */
  21014. static AddUniforms(uniforms: string[]): void;
  21015. /**
  21016. * Add the required uniforms to the current buffer.
  21017. * @param uniformBuffer defines the current uniform buffer.
  21018. */
  21019. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21020. /**
  21021. * Add the required samplers to the current list.
  21022. * @param samplers defines the current sampler list.
  21023. */
  21024. static AddSamplers(samplers: string[]): void;
  21025. /**
  21026. * Makes a duplicate of the current configuration into another one.
  21027. * @param anisotropicConfiguration define the config where to copy the info
  21028. */
  21029. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  21030. /**
  21031. * Serializes this anisotropy configuration.
  21032. * @returns - An object with the serialized config.
  21033. */
  21034. serialize(): any;
  21035. /**
  21036. * Parses a anisotropy Configuration from a serialized object.
  21037. * @param source - Serialized object.
  21038. * @param scene Defines the scene we are parsing for
  21039. * @param rootUrl Defines the rootUrl to load from
  21040. */
  21041. parse(source: any, scene: Scene, rootUrl: string): void;
  21042. }
  21043. }
  21044. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  21045. import { Scene } from "babylonjs/scene";
  21046. /**
  21047. * @hidden
  21048. */
  21049. export interface IMaterialBRDFDefines {
  21050. BRDF_V_HEIGHT_CORRELATED: boolean;
  21051. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21052. SPHERICAL_HARMONICS: boolean;
  21053. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21054. /** @hidden */
  21055. _areMiscDirty: boolean;
  21056. }
  21057. /**
  21058. * Define the code related to the BRDF parameters of the pbr material.
  21059. */
  21060. export class PBRBRDFConfiguration {
  21061. /**
  21062. * Default value used for the energy conservation.
  21063. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21064. */
  21065. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  21066. /**
  21067. * Default value used for the Smith Visibility Height Correlated mode.
  21068. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21069. */
  21070. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  21071. /**
  21072. * Default value used for the IBL diffuse part.
  21073. * This can help switching back to the polynomials mode globally which is a tiny bit
  21074. * less GPU intensive at the drawback of a lower quality.
  21075. */
  21076. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  21077. /**
  21078. * Default value used for activating energy conservation for the specular workflow.
  21079. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21080. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21081. */
  21082. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  21083. private _useEnergyConservation;
  21084. /**
  21085. * Defines if the material uses energy conservation.
  21086. */
  21087. useEnergyConservation: boolean;
  21088. private _useSmithVisibilityHeightCorrelated;
  21089. /**
  21090. * LEGACY Mode set to false
  21091. * Defines if the material uses height smith correlated visibility term.
  21092. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  21093. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  21094. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  21095. * Not relying on height correlated will also disable energy conservation.
  21096. */
  21097. useSmithVisibilityHeightCorrelated: boolean;
  21098. private _useSphericalHarmonics;
  21099. /**
  21100. * LEGACY Mode set to false
  21101. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  21102. * diffuse part of the IBL.
  21103. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  21104. * to the ground truth.
  21105. */
  21106. useSphericalHarmonics: boolean;
  21107. private _useSpecularGlossinessInputEnergyConservation;
  21108. /**
  21109. * Defines if the material uses energy conservation, when the specular workflow is active.
  21110. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21111. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21112. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  21113. */
  21114. useSpecularGlossinessInputEnergyConservation: boolean;
  21115. /** @hidden */
  21116. private _internalMarkAllSubMeshesAsMiscDirty;
  21117. /** @hidden */
  21118. _markAllSubMeshesAsMiscDirty(): void;
  21119. /**
  21120. * Instantiate a new istance of clear coat configuration.
  21121. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  21122. */
  21123. constructor(markAllSubMeshesAsMiscDirty: () => void);
  21124. /**
  21125. * Checks to see if a texture is used in the material.
  21126. * @param defines the list of "defines" to update.
  21127. */
  21128. prepareDefines(defines: IMaterialBRDFDefines): void;
  21129. /**
  21130. * Get the current class name of the texture useful for serialization or dynamic coding.
  21131. * @returns "PBRClearCoatConfiguration"
  21132. */
  21133. getClassName(): string;
  21134. /**
  21135. * Makes a duplicate of the current configuration into another one.
  21136. * @param brdfConfiguration define the config where to copy the info
  21137. */
  21138. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  21139. /**
  21140. * Serializes this BRDF configuration.
  21141. * @returns - An object with the serialized config.
  21142. */
  21143. serialize(): any;
  21144. /**
  21145. * Parses a anisotropy Configuration from a serialized object.
  21146. * @param source - Serialized object.
  21147. * @param scene Defines the scene we are parsing for
  21148. * @param rootUrl Defines the rootUrl to load from
  21149. */
  21150. parse(source: any, scene: Scene, rootUrl: string): void;
  21151. }
  21152. }
  21153. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  21154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21155. import { Color3 } from "babylonjs/Maths/math.color";
  21156. import { Scene } from "babylonjs/scene";
  21157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21158. import { Nullable } from "babylonjs/types";
  21159. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21160. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21161. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21162. /**
  21163. * @hidden
  21164. */
  21165. export interface IMaterialSheenDefines {
  21166. SHEEN: boolean;
  21167. SHEEN_TEXTURE: boolean;
  21168. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21169. SHEEN_TEXTUREDIRECTUV: number;
  21170. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21171. SHEEN_LINKWITHALBEDO: boolean;
  21172. SHEEN_ROUGHNESS: boolean;
  21173. SHEEN_ALBEDOSCALING: boolean;
  21174. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21175. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21176. /** @hidden */
  21177. _areTexturesDirty: boolean;
  21178. }
  21179. /**
  21180. * Define the code related to the Sheen parameters of the pbr material.
  21181. */
  21182. export class PBRSheenConfiguration {
  21183. private _isEnabled;
  21184. /**
  21185. * Defines if the material uses sheen.
  21186. */
  21187. isEnabled: boolean;
  21188. private _linkSheenWithAlbedo;
  21189. /**
  21190. * Defines if the sheen is linked to the sheen color.
  21191. */
  21192. linkSheenWithAlbedo: boolean;
  21193. /**
  21194. * Defines the sheen intensity.
  21195. */
  21196. intensity: number;
  21197. /**
  21198. * Defines the sheen color.
  21199. */
  21200. color: Color3;
  21201. private _texture;
  21202. /**
  21203. * Stores the sheen tint values in a texture.
  21204. * rgb is tint
  21205. * 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)
  21206. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21207. */
  21208. texture: Nullable<BaseTexture>;
  21209. private _useRoughnessFromMainTexture;
  21210. /**
  21211. * Indicates that the alpha channel of the texture property will be used for roughness.
  21212. * Has no effect if the roughness (and texture!) property is not defined
  21213. */
  21214. useRoughnessFromMainTexture: boolean;
  21215. private _roughness;
  21216. /**
  21217. * Defines the sheen roughness.
  21218. * It is not taken into account if linkSheenWithAlbedo is true.
  21219. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21220. */
  21221. roughness: Nullable<number>;
  21222. private _textureRoughness;
  21223. /**
  21224. * Stores the sheen roughness in a texture.
  21225. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21226. */
  21227. textureRoughness: Nullable<BaseTexture>;
  21228. private _albedoScaling;
  21229. /**
  21230. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21231. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21232. * making it easier to setup and tweak the effect
  21233. */
  21234. albedoScaling: boolean;
  21235. /** @hidden */
  21236. private _internalMarkAllSubMeshesAsTexturesDirty;
  21237. /** @hidden */
  21238. _markAllSubMeshesAsTexturesDirty(): void;
  21239. /**
  21240. * Instantiate a new istance of clear coat configuration.
  21241. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21242. */
  21243. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21244. /**
  21245. * Specifies that the submesh is ready to be used.
  21246. * @param defines the list of "defines" to update.
  21247. * @param scene defines the scene the material belongs to.
  21248. * @returns - boolean indicating that the submesh is ready or not.
  21249. */
  21250. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21251. /**
  21252. * Checks to see if a texture is used in the material.
  21253. * @param defines the list of "defines" to update.
  21254. * @param scene defines the scene the material belongs to.
  21255. */
  21256. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21257. /**
  21258. * Binds the material data.
  21259. * @param uniformBuffer defines the Uniform buffer to fill in.
  21260. * @param scene defines the scene the material belongs to.
  21261. * @param isFrozen defines wether the material is frozen or not.
  21262. * @param subMesh the submesh to bind data for
  21263. */
  21264. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21265. /**
  21266. * Checks to see if a texture is used in the material.
  21267. * @param texture - Base texture to use.
  21268. * @returns - Boolean specifying if a texture is used in the material.
  21269. */
  21270. hasTexture(texture: BaseTexture): boolean;
  21271. /**
  21272. * Returns an array of the actively used textures.
  21273. * @param activeTextures Array of BaseTextures
  21274. */
  21275. getActiveTextures(activeTextures: BaseTexture[]): void;
  21276. /**
  21277. * Returns the animatable textures.
  21278. * @param animatables Array of animatable textures.
  21279. */
  21280. getAnimatables(animatables: IAnimatable[]): void;
  21281. /**
  21282. * Disposes the resources of the material.
  21283. * @param forceDisposeTextures - Forces the disposal of all textures.
  21284. */
  21285. dispose(forceDisposeTextures?: boolean): void;
  21286. /**
  21287. * Get the current class name of the texture useful for serialization or dynamic coding.
  21288. * @returns "PBRSheenConfiguration"
  21289. */
  21290. getClassName(): string;
  21291. /**
  21292. * Add fallbacks to the effect fallbacks list.
  21293. * @param defines defines the Base texture to use.
  21294. * @param fallbacks defines the current fallback list.
  21295. * @param currentRank defines the current fallback rank.
  21296. * @returns the new fallback rank.
  21297. */
  21298. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21299. /**
  21300. * Add the required uniforms to the current list.
  21301. * @param uniforms defines the current uniform list.
  21302. */
  21303. static AddUniforms(uniforms: string[]): void;
  21304. /**
  21305. * Add the required uniforms to the current buffer.
  21306. * @param uniformBuffer defines the current uniform buffer.
  21307. */
  21308. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21309. /**
  21310. * Add the required samplers to the current list.
  21311. * @param samplers defines the current sampler list.
  21312. */
  21313. static AddSamplers(samplers: string[]): void;
  21314. /**
  21315. * Makes a duplicate of the current configuration into another one.
  21316. * @param sheenConfiguration define the config where to copy the info
  21317. */
  21318. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21319. /**
  21320. * Serializes this BRDF configuration.
  21321. * @returns - An object with the serialized config.
  21322. */
  21323. serialize(): any;
  21324. /**
  21325. * Parses a anisotropy Configuration from a serialized object.
  21326. * @param source - Serialized object.
  21327. * @param scene Defines the scene we are parsing for
  21328. * @param rootUrl Defines the rootUrl to load from
  21329. */
  21330. parse(source: any, scene: Scene, rootUrl: string): void;
  21331. }
  21332. }
  21333. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  21334. import { Nullable } from "babylonjs/types";
  21335. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21336. import { Color3 } from "babylonjs/Maths/math.color";
  21337. import { SmartArray } from "babylonjs/Misc/smartArray";
  21338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21339. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21340. import { Effect } from "babylonjs/Materials/effect";
  21341. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21342. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21343. import { Engine } from "babylonjs/Engines/engine";
  21344. import { Scene } from "babylonjs/scene";
  21345. /**
  21346. * @hidden
  21347. */
  21348. export interface IMaterialSubSurfaceDefines {
  21349. SUBSURFACE: boolean;
  21350. SS_REFRACTION: boolean;
  21351. SS_TRANSLUCENCY: boolean;
  21352. SS_SCATTERING: boolean;
  21353. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21354. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21355. SS_REFRACTIONMAP_3D: boolean;
  21356. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21357. SS_LODINREFRACTIONALPHA: boolean;
  21358. SS_GAMMAREFRACTION: boolean;
  21359. SS_RGBDREFRACTION: boolean;
  21360. SS_LINEARSPECULARREFRACTION: boolean;
  21361. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21362. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21363. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21364. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21365. /** @hidden */
  21366. _areTexturesDirty: boolean;
  21367. }
  21368. /**
  21369. * Define the code related to the sub surface parameters of the pbr material.
  21370. */
  21371. export class PBRSubSurfaceConfiguration {
  21372. private _isRefractionEnabled;
  21373. /**
  21374. * Defines if the refraction is enabled in the material.
  21375. */
  21376. isRefractionEnabled: boolean;
  21377. private _isTranslucencyEnabled;
  21378. /**
  21379. * Defines if the translucency is enabled in the material.
  21380. */
  21381. isTranslucencyEnabled: boolean;
  21382. private _isScatteringEnabled;
  21383. /**
  21384. * Defines if the sub surface scattering is enabled in the material.
  21385. */
  21386. isScatteringEnabled: boolean;
  21387. private _scatteringDiffusionProfileIndex;
  21388. /**
  21389. * Diffusion profile for subsurface scattering.
  21390. * Useful for better scattering in the skins or foliages.
  21391. */
  21392. get scatteringDiffusionProfile(): Nullable<Color3>;
  21393. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21394. /**
  21395. * Defines the refraction intensity of the material.
  21396. * The refraction when enabled replaces the Diffuse part of the material.
  21397. * The intensity helps transitionning between diffuse and refraction.
  21398. */
  21399. refractionIntensity: number;
  21400. /**
  21401. * Defines the translucency intensity of the material.
  21402. * When translucency has been enabled, this defines how much of the "translucency"
  21403. * is addded to the diffuse part of the material.
  21404. */
  21405. translucencyIntensity: number;
  21406. /**
  21407. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21408. */
  21409. useAlbedoToTintRefraction: boolean;
  21410. private _thicknessTexture;
  21411. /**
  21412. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21413. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21414. * 0 would mean minimumThickness
  21415. * 1 would mean maximumThickness
  21416. * The other channels might be use as a mask to vary the different effects intensity.
  21417. */
  21418. thicknessTexture: Nullable<BaseTexture>;
  21419. private _refractionTexture;
  21420. /**
  21421. * Defines the texture to use for refraction.
  21422. */
  21423. refractionTexture: Nullable<BaseTexture>;
  21424. private _indexOfRefraction;
  21425. /**
  21426. * Index of refraction of the material base layer.
  21427. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21428. *
  21429. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21430. *
  21431. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21432. */
  21433. indexOfRefraction: number;
  21434. private _volumeIndexOfRefraction;
  21435. /**
  21436. * Index of refraction of the material's volume.
  21437. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21438. *
  21439. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21440. * the volume will use the same IOR as the surface.
  21441. */
  21442. get volumeIndexOfRefraction(): number;
  21443. set volumeIndexOfRefraction(value: number);
  21444. private _invertRefractionY;
  21445. /**
  21446. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21447. */
  21448. invertRefractionY: boolean;
  21449. private _linkRefractionWithTransparency;
  21450. /**
  21451. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21452. * Materials half opaque for instance using refraction could benefit from this control.
  21453. */
  21454. linkRefractionWithTransparency: boolean;
  21455. /**
  21456. * Defines the minimum thickness stored in the thickness map.
  21457. * If no thickness map is defined, this value will be used to simulate thickness.
  21458. */
  21459. minimumThickness: number;
  21460. /**
  21461. * Defines the maximum thickness stored in the thickness map.
  21462. */
  21463. maximumThickness: number;
  21464. /**
  21465. * Defines the volume tint of the material.
  21466. * This is used for both translucency and scattering.
  21467. */
  21468. tintColor: Color3;
  21469. /**
  21470. * Defines the distance at which the tint color should be found in the media.
  21471. * This is used for refraction only.
  21472. */
  21473. tintColorAtDistance: number;
  21474. /**
  21475. * Defines how far each channel transmit through the media.
  21476. * It is defined as a color to simplify it selection.
  21477. */
  21478. diffusionDistance: Color3;
  21479. private _useMaskFromThicknessTexture;
  21480. /**
  21481. * Stores the intensity of the different subsurface effects in the thickness texture.
  21482. * * the green channel is the translucency intensity.
  21483. * * the blue channel is the scattering intensity.
  21484. * * the alpha channel is the refraction intensity.
  21485. */
  21486. useMaskFromThicknessTexture: boolean;
  21487. private _scene;
  21488. private _useMaskFromThicknessTextureGltf;
  21489. /**
  21490. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21491. * matches the channel-packing that is used by glTF.
  21492. * * the red channel is the transmission/translucency intensity.
  21493. * * the green channel is the thickness.
  21494. */
  21495. useMaskFromThicknessTextureGltf: boolean;
  21496. /** @hidden */
  21497. private _internalMarkAllSubMeshesAsTexturesDirty;
  21498. private _internalMarkScenePrePassDirty;
  21499. /** @hidden */
  21500. _markAllSubMeshesAsTexturesDirty(): void;
  21501. /** @hidden */
  21502. _markScenePrePassDirty(): void;
  21503. /**
  21504. * Instantiate a new istance of sub surface configuration.
  21505. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21506. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21507. * @param scene The scene
  21508. */
  21509. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21510. /**
  21511. * Gets wehter the submesh is ready to be used or not.
  21512. * @param defines the list of "defines" to update.
  21513. * @param scene defines the scene the material belongs to.
  21514. * @returns - boolean indicating that the submesh is ready or not.
  21515. */
  21516. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21517. /**
  21518. * Checks to see if a texture is used in the material.
  21519. * @param defines the list of "defines" to update.
  21520. * @param scene defines the scene to the material belongs to.
  21521. */
  21522. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21523. /**
  21524. * Binds the material data.
  21525. * @param uniformBuffer defines the Uniform buffer to fill in.
  21526. * @param scene defines the scene the material belongs to.
  21527. * @param engine defines the engine the material belongs to.
  21528. * @param isFrozen defines whether the material is frozen or not.
  21529. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21530. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21531. */
  21532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21533. /**
  21534. * Unbinds the material from the mesh.
  21535. * @param activeEffect defines the effect that should be unbound from.
  21536. * @returns true if unbound, otherwise false
  21537. */
  21538. unbind(activeEffect: Effect): boolean;
  21539. /**
  21540. * Returns the texture used for refraction or null if none is used.
  21541. * @param scene defines the scene the material belongs to.
  21542. * @returns - Refraction texture if present. If no refraction texture and refraction
  21543. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21544. */
  21545. private _getRefractionTexture;
  21546. /**
  21547. * Returns true if alpha blending should be disabled.
  21548. */
  21549. get disableAlphaBlending(): boolean;
  21550. /**
  21551. * Fills the list of render target textures.
  21552. * @param renderTargets the list of render targets to update
  21553. */
  21554. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21555. /**
  21556. * Checks to see if a texture is used in the material.
  21557. * @param texture - Base texture to use.
  21558. * @returns - Boolean specifying if a texture is used in the material.
  21559. */
  21560. hasTexture(texture: BaseTexture): boolean;
  21561. /**
  21562. * Gets a boolean indicating that current material needs to register RTT
  21563. * @returns true if this uses a render target otherwise false.
  21564. */
  21565. hasRenderTargetTextures(): boolean;
  21566. /**
  21567. * Returns an array of the actively used textures.
  21568. * @param activeTextures Array of BaseTextures
  21569. */
  21570. getActiveTextures(activeTextures: BaseTexture[]): void;
  21571. /**
  21572. * Returns the animatable textures.
  21573. * @param animatables Array of animatable textures.
  21574. */
  21575. getAnimatables(animatables: IAnimatable[]): void;
  21576. /**
  21577. * Disposes the resources of the material.
  21578. * @param forceDisposeTextures - Forces the disposal of all textures.
  21579. */
  21580. dispose(forceDisposeTextures?: boolean): void;
  21581. /**
  21582. * Get the current class name of the texture useful for serialization or dynamic coding.
  21583. * @returns "PBRSubSurfaceConfiguration"
  21584. */
  21585. getClassName(): string;
  21586. /**
  21587. * Add fallbacks to the effect fallbacks list.
  21588. * @param defines defines the Base texture to use.
  21589. * @param fallbacks defines the current fallback list.
  21590. * @param currentRank defines the current fallback rank.
  21591. * @returns the new fallback rank.
  21592. */
  21593. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21594. /**
  21595. * Add the required uniforms to the current list.
  21596. * @param uniforms defines the current uniform list.
  21597. */
  21598. static AddUniforms(uniforms: string[]): void;
  21599. /**
  21600. * Add the required samplers to the current list.
  21601. * @param samplers defines the current sampler list.
  21602. */
  21603. static AddSamplers(samplers: string[]): void;
  21604. /**
  21605. * Add the required uniforms to the current buffer.
  21606. * @param uniformBuffer defines the current uniform buffer.
  21607. */
  21608. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21609. /**
  21610. * Makes a duplicate of the current configuration into another one.
  21611. * @param configuration define the config where to copy the info
  21612. */
  21613. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21614. /**
  21615. * Serializes this Sub Surface configuration.
  21616. * @returns - An object with the serialized config.
  21617. */
  21618. serialize(): any;
  21619. /**
  21620. * Parses a anisotropy Configuration from a serialized object.
  21621. * @param source - Serialized object.
  21622. * @param scene Defines the scene we are parsing for
  21623. * @param rootUrl Defines the rootUrl to load from
  21624. */
  21625. parse(source: any, scene: Scene, rootUrl: string): void;
  21626. }
  21627. }
  21628. declare module "babylonjs/Maths/sphericalPolynomial" {
  21629. import { Vector3 } from "babylonjs/Maths/math.vector";
  21630. import { Color3 } from "babylonjs/Maths/math.color";
  21631. /**
  21632. * Class representing spherical harmonics coefficients to the 3rd degree
  21633. */
  21634. export class SphericalHarmonics {
  21635. /**
  21636. * Defines whether or not the harmonics have been prescaled for rendering.
  21637. */
  21638. preScaled: boolean;
  21639. /**
  21640. * The l0,0 coefficients of the spherical harmonics
  21641. */
  21642. l00: Vector3;
  21643. /**
  21644. * The l1,-1 coefficients of the spherical harmonics
  21645. */
  21646. l1_1: Vector3;
  21647. /**
  21648. * The l1,0 coefficients of the spherical harmonics
  21649. */
  21650. l10: Vector3;
  21651. /**
  21652. * The l1,1 coefficients of the spherical harmonics
  21653. */
  21654. l11: Vector3;
  21655. /**
  21656. * The l2,-2 coefficients of the spherical harmonics
  21657. */
  21658. l2_2: Vector3;
  21659. /**
  21660. * The l2,-1 coefficients of the spherical harmonics
  21661. */
  21662. l2_1: Vector3;
  21663. /**
  21664. * The l2,0 coefficients of the spherical harmonics
  21665. */
  21666. l20: Vector3;
  21667. /**
  21668. * The l2,1 coefficients of the spherical harmonics
  21669. */
  21670. l21: Vector3;
  21671. /**
  21672. * The l2,2 coefficients of the spherical harmonics
  21673. */
  21674. l22: Vector3;
  21675. /**
  21676. * Adds a light to the spherical harmonics
  21677. * @param direction the direction of the light
  21678. * @param color the color of the light
  21679. * @param deltaSolidAngle the delta solid angle of the light
  21680. */
  21681. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21682. /**
  21683. * Scales the spherical harmonics by the given amount
  21684. * @param scale the amount to scale
  21685. */
  21686. scaleInPlace(scale: number): void;
  21687. /**
  21688. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21689. *
  21690. * ```
  21691. * E_lm = A_l * L_lm
  21692. * ```
  21693. *
  21694. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21695. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21696. * the scaling factors are given in equation 9.
  21697. */
  21698. convertIncidentRadianceToIrradiance(): void;
  21699. /**
  21700. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21701. *
  21702. * ```
  21703. * L = (1/pi) * E * rho
  21704. * ```
  21705. *
  21706. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21707. */
  21708. convertIrradianceToLambertianRadiance(): void;
  21709. /**
  21710. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21711. * required operations at run time.
  21712. *
  21713. * This is simply done by scaling back the SH with Ylm constants parameter.
  21714. * The trigonometric part being applied by the shader at run time.
  21715. */
  21716. preScaleForRendering(): void;
  21717. /**
  21718. * Constructs a spherical harmonics from an array.
  21719. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21720. * @returns the spherical harmonics
  21721. */
  21722. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21723. /**
  21724. * Gets the spherical harmonics from polynomial
  21725. * @param polynomial the spherical polynomial
  21726. * @returns the spherical harmonics
  21727. */
  21728. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21729. }
  21730. /**
  21731. * Class representing spherical polynomial coefficients to the 3rd degree
  21732. */
  21733. export class SphericalPolynomial {
  21734. private _harmonics;
  21735. /**
  21736. * The spherical harmonics used to create the polynomials.
  21737. */
  21738. get preScaledHarmonics(): SphericalHarmonics;
  21739. /**
  21740. * The x coefficients of the spherical polynomial
  21741. */
  21742. x: Vector3;
  21743. /**
  21744. * The y coefficients of the spherical polynomial
  21745. */
  21746. y: Vector3;
  21747. /**
  21748. * The z coefficients of the spherical polynomial
  21749. */
  21750. z: Vector3;
  21751. /**
  21752. * The xx coefficients of the spherical polynomial
  21753. */
  21754. xx: Vector3;
  21755. /**
  21756. * The yy coefficients of the spherical polynomial
  21757. */
  21758. yy: Vector3;
  21759. /**
  21760. * The zz coefficients of the spherical polynomial
  21761. */
  21762. zz: Vector3;
  21763. /**
  21764. * The xy coefficients of the spherical polynomial
  21765. */
  21766. xy: Vector3;
  21767. /**
  21768. * The yz coefficients of the spherical polynomial
  21769. */
  21770. yz: Vector3;
  21771. /**
  21772. * The zx coefficients of the spherical polynomial
  21773. */
  21774. zx: Vector3;
  21775. /**
  21776. * Adds an ambient color to the spherical polynomial
  21777. * @param color the color to add
  21778. */
  21779. addAmbient(color: Color3): void;
  21780. /**
  21781. * Scales the spherical polynomial by the given amount
  21782. * @param scale the amount to scale
  21783. */
  21784. scaleInPlace(scale: number): void;
  21785. /**
  21786. * Gets the spherical polynomial from harmonics
  21787. * @param harmonics the spherical harmonics
  21788. * @returns the spherical polynomial
  21789. */
  21790. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21791. /**
  21792. * Constructs a spherical polynomial from an array.
  21793. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21794. * @returns the spherical polynomial
  21795. */
  21796. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21797. }
  21798. }
  21799. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21800. import { Nullable } from "babylonjs/types";
  21801. /**
  21802. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21803. */
  21804. export interface CubeMapInfo {
  21805. /**
  21806. * The pixel array for the front face.
  21807. * This is stored in format, left to right, up to down format.
  21808. */
  21809. front: Nullable<ArrayBufferView>;
  21810. /**
  21811. * The pixel array for the back face.
  21812. * This is stored in format, left to right, up to down format.
  21813. */
  21814. back: Nullable<ArrayBufferView>;
  21815. /**
  21816. * The pixel array for the left face.
  21817. * This is stored in format, left to right, up to down format.
  21818. */
  21819. left: Nullable<ArrayBufferView>;
  21820. /**
  21821. * The pixel array for the right face.
  21822. * This is stored in format, left to right, up to down format.
  21823. */
  21824. right: Nullable<ArrayBufferView>;
  21825. /**
  21826. * The pixel array for the up face.
  21827. * This is stored in format, left to right, up to down format.
  21828. */
  21829. up: Nullable<ArrayBufferView>;
  21830. /**
  21831. * The pixel array for the down face.
  21832. * This is stored in format, left to right, up to down format.
  21833. */
  21834. down: Nullable<ArrayBufferView>;
  21835. /**
  21836. * The size of the cubemap stored.
  21837. *
  21838. * Each faces will be size * size pixels.
  21839. */
  21840. size: number;
  21841. /**
  21842. * The format of the texture.
  21843. *
  21844. * RGBA, RGB.
  21845. */
  21846. format: number;
  21847. /**
  21848. * The type of the texture data.
  21849. *
  21850. * UNSIGNED_INT, FLOAT.
  21851. */
  21852. type: number;
  21853. /**
  21854. * Specifies whether the texture is in gamma space.
  21855. */
  21856. gammaSpace: boolean;
  21857. }
  21858. /**
  21859. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21860. */
  21861. export class PanoramaToCubeMapTools {
  21862. private static FACE_LEFT;
  21863. private static FACE_RIGHT;
  21864. private static FACE_FRONT;
  21865. private static FACE_BACK;
  21866. private static FACE_DOWN;
  21867. private static FACE_UP;
  21868. /**
  21869. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21870. *
  21871. * @param float32Array The source data.
  21872. * @param inputWidth The width of the input panorama.
  21873. * @param inputHeight The height of the input panorama.
  21874. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21875. * @return The cubemap data
  21876. */
  21877. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21878. private static CreateCubemapTexture;
  21879. private static CalcProjectionSpherical;
  21880. }
  21881. }
  21882. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21883. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21885. import { Nullable } from "babylonjs/types";
  21886. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21887. /**
  21888. * Helper class dealing with the extraction of spherical polynomial dataArray
  21889. * from a cube map.
  21890. */
  21891. export class CubeMapToSphericalPolynomialTools {
  21892. private static FileFaces;
  21893. /**
  21894. * Converts a texture to the according Spherical Polynomial data.
  21895. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21896. *
  21897. * @param texture The texture to extract the information from.
  21898. * @return The Spherical Polynomial data.
  21899. */
  21900. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21901. /**
  21902. * Converts a cubemap to the according Spherical Polynomial data.
  21903. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21904. *
  21905. * @param cubeInfo The Cube map to extract the information from.
  21906. * @return The Spherical Polynomial data.
  21907. */
  21908. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21909. }
  21910. }
  21911. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21912. import { Nullable } from "babylonjs/types";
  21913. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21914. module "babylonjs/Materials/Textures/baseTexture" {
  21915. interface BaseTexture {
  21916. /**
  21917. * Get the polynomial representation of the texture data.
  21918. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21919. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21920. */
  21921. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21922. }
  21923. }
  21924. }
  21925. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21926. /** @hidden */
  21927. export var pbrFragmentDeclaration: {
  21928. name: string;
  21929. shader: string;
  21930. };
  21931. }
  21932. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21933. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  21934. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  21935. /** @hidden */
  21936. export var pbrUboDeclaration: {
  21937. name: string;
  21938. shader: string;
  21939. };
  21940. }
  21941. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21942. /** @hidden */
  21943. export var pbrFragmentExtraDeclaration: {
  21944. name: string;
  21945. shader: string;
  21946. };
  21947. }
  21948. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21949. /** @hidden */
  21950. export var pbrFragmentSamplersDeclaration: {
  21951. name: string;
  21952. shader: string;
  21953. };
  21954. }
  21955. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21956. /** @hidden */
  21957. export var subSurfaceScatteringFunctions: {
  21958. name: string;
  21959. shader: string;
  21960. };
  21961. }
  21962. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21963. /** @hidden */
  21964. export var importanceSampling: {
  21965. name: string;
  21966. shader: string;
  21967. };
  21968. }
  21969. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21970. /** @hidden */
  21971. export var pbrHelperFunctions: {
  21972. name: string;
  21973. shader: string;
  21974. };
  21975. }
  21976. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21977. /** @hidden */
  21978. export var harmonicsFunctions: {
  21979. name: string;
  21980. shader: string;
  21981. };
  21982. }
  21983. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21984. /** @hidden */
  21985. export var pbrDirectLightingSetupFunctions: {
  21986. name: string;
  21987. shader: string;
  21988. };
  21989. }
  21990. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21991. /** @hidden */
  21992. export var pbrDirectLightingFalloffFunctions: {
  21993. name: string;
  21994. shader: string;
  21995. };
  21996. }
  21997. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21998. /** @hidden */
  21999. export var pbrBRDFFunctions: {
  22000. name: string;
  22001. shader: string;
  22002. };
  22003. }
  22004. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  22005. /** @hidden */
  22006. export var hdrFilteringFunctions: {
  22007. name: string;
  22008. shader: string;
  22009. };
  22010. }
  22011. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  22012. /** @hidden */
  22013. export var pbrDirectLightingFunctions: {
  22014. name: string;
  22015. shader: string;
  22016. };
  22017. }
  22018. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  22019. /** @hidden */
  22020. export var pbrIBLFunctions: {
  22021. name: string;
  22022. shader: string;
  22023. };
  22024. }
  22025. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  22026. /** @hidden */
  22027. export var pbrBlockAlbedoOpacity: {
  22028. name: string;
  22029. shader: string;
  22030. };
  22031. }
  22032. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  22033. /** @hidden */
  22034. export var pbrBlockReflectivity: {
  22035. name: string;
  22036. shader: string;
  22037. };
  22038. }
  22039. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  22040. /** @hidden */
  22041. export var pbrBlockAmbientOcclusion: {
  22042. name: string;
  22043. shader: string;
  22044. };
  22045. }
  22046. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  22047. /** @hidden */
  22048. export var pbrBlockAlphaFresnel: {
  22049. name: string;
  22050. shader: string;
  22051. };
  22052. }
  22053. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  22054. /** @hidden */
  22055. export var pbrBlockAnisotropic: {
  22056. name: string;
  22057. shader: string;
  22058. };
  22059. }
  22060. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  22061. /** @hidden */
  22062. export var pbrBlockReflection: {
  22063. name: string;
  22064. shader: string;
  22065. };
  22066. }
  22067. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  22068. /** @hidden */
  22069. export var pbrBlockSheen: {
  22070. name: string;
  22071. shader: string;
  22072. };
  22073. }
  22074. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  22075. /** @hidden */
  22076. export var pbrBlockClearcoat: {
  22077. name: string;
  22078. shader: string;
  22079. };
  22080. }
  22081. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  22082. /** @hidden */
  22083. export var pbrBlockSubSurface: {
  22084. name: string;
  22085. shader: string;
  22086. };
  22087. }
  22088. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  22089. /** @hidden */
  22090. export var pbrBlockNormalGeometric: {
  22091. name: string;
  22092. shader: string;
  22093. };
  22094. }
  22095. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  22096. /** @hidden */
  22097. export var pbrBlockNormalFinal: {
  22098. name: string;
  22099. shader: string;
  22100. };
  22101. }
  22102. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  22103. /** @hidden */
  22104. export var pbrBlockLightmapInit: {
  22105. name: string;
  22106. shader: string;
  22107. };
  22108. }
  22109. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  22110. /** @hidden */
  22111. export var pbrBlockGeometryInfo: {
  22112. name: string;
  22113. shader: string;
  22114. };
  22115. }
  22116. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  22117. /** @hidden */
  22118. export var pbrBlockReflectance0: {
  22119. name: string;
  22120. shader: string;
  22121. };
  22122. }
  22123. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  22124. /** @hidden */
  22125. export var pbrBlockReflectance: {
  22126. name: string;
  22127. shader: string;
  22128. };
  22129. }
  22130. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  22131. /** @hidden */
  22132. export var pbrBlockDirectLighting: {
  22133. name: string;
  22134. shader: string;
  22135. };
  22136. }
  22137. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  22138. /** @hidden */
  22139. export var pbrBlockFinalLitComponents: {
  22140. name: string;
  22141. shader: string;
  22142. };
  22143. }
  22144. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  22145. /** @hidden */
  22146. export var pbrBlockFinalUnlitComponents: {
  22147. name: string;
  22148. shader: string;
  22149. };
  22150. }
  22151. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  22152. /** @hidden */
  22153. export var pbrBlockFinalColorComposition: {
  22154. name: string;
  22155. shader: string;
  22156. };
  22157. }
  22158. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  22159. /** @hidden */
  22160. export var pbrBlockImageProcessing: {
  22161. name: string;
  22162. shader: string;
  22163. };
  22164. }
  22165. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  22166. /** @hidden */
  22167. export var pbrDebug: {
  22168. name: string;
  22169. shader: string;
  22170. };
  22171. }
  22172. declare module "babylonjs/Shaders/pbr.fragment" {
  22173. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  22174. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  22175. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22176. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  22177. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  22178. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  22179. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  22180. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  22181. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  22182. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22183. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  22184. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22185. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  22186. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  22187. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  22188. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  22189. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  22190. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22191. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  22192. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  22193. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  22194. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  22195. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  22196. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  22197. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22198. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22199. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  22200. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  22201. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  22202. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  22203. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  22204. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  22205. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  22206. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  22207. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  22208. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  22209. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  22210. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  22211. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22212. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  22213. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  22214. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  22215. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  22216. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  22217. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  22218. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  22219. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  22220. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  22221. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  22222. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  22223. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  22224. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  22225. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  22226. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  22227. /** @hidden */
  22228. export var pbrPixelShader: {
  22229. name: string;
  22230. shader: string;
  22231. };
  22232. }
  22233. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  22234. /** @hidden */
  22235. export var pbrVertexDeclaration: {
  22236. name: string;
  22237. shader: string;
  22238. };
  22239. }
  22240. declare module "babylonjs/Shaders/pbr.vertex" {
  22241. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  22242. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22243. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22244. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22245. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  22246. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22247. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  22248. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  22249. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  22250. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  22251. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  22252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22253. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22254. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22256. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22257. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22258. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  22259. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22260. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  22261. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  22262. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  22263. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  22264. /** @hidden */
  22265. export var pbrVertexShader: {
  22266. name: string;
  22267. shader: string;
  22268. };
  22269. }
  22270. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  22271. import { Nullable } from "babylonjs/types";
  22272. import { Scene } from "babylonjs/scene";
  22273. import { Matrix } from "babylonjs/Maths/math.vector";
  22274. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22276. import { Mesh } from "babylonjs/Meshes/mesh";
  22277. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  22278. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  22279. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  22280. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  22281. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  22282. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  22283. import { Color3 } from "babylonjs/Maths/math.color";
  22284. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22285. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  22286. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22287. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22289. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22290. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  22291. import "babylonjs/Shaders/pbr.fragment";
  22292. import "babylonjs/Shaders/pbr.vertex";
  22293. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  22294. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22295. /**
  22296. * Manages the defines for the PBR Material.
  22297. * @hidden
  22298. */
  22299. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  22300. PBR: boolean;
  22301. NUM_SAMPLES: string;
  22302. REALTIME_FILTERING: boolean;
  22303. MAINUV1: boolean;
  22304. MAINUV2: boolean;
  22305. UV1: boolean;
  22306. UV2: boolean;
  22307. ALBEDO: boolean;
  22308. GAMMAALBEDO: boolean;
  22309. ALBEDODIRECTUV: number;
  22310. VERTEXCOLOR: boolean;
  22311. DETAIL: boolean;
  22312. DETAILDIRECTUV: number;
  22313. DETAIL_NORMALBLENDMETHOD: number;
  22314. AMBIENT: boolean;
  22315. AMBIENTDIRECTUV: number;
  22316. AMBIENTINGRAYSCALE: boolean;
  22317. OPACITY: boolean;
  22318. VERTEXALPHA: boolean;
  22319. OPACITYDIRECTUV: number;
  22320. OPACITYRGB: boolean;
  22321. ALPHATEST: boolean;
  22322. DEPTHPREPASS: boolean;
  22323. ALPHABLEND: boolean;
  22324. ALPHAFROMALBEDO: boolean;
  22325. ALPHATESTVALUE: string;
  22326. SPECULAROVERALPHA: boolean;
  22327. RADIANCEOVERALPHA: boolean;
  22328. ALPHAFRESNEL: boolean;
  22329. LINEARALPHAFRESNEL: boolean;
  22330. PREMULTIPLYALPHA: boolean;
  22331. EMISSIVE: boolean;
  22332. EMISSIVEDIRECTUV: number;
  22333. REFLECTIVITY: boolean;
  22334. REFLECTIVITYDIRECTUV: number;
  22335. SPECULARTERM: boolean;
  22336. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22337. MICROSURFACEAUTOMATIC: boolean;
  22338. LODBASEDMICROSFURACE: boolean;
  22339. MICROSURFACEMAP: boolean;
  22340. MICROSURFACEMAPDIRECTUV: number;
  22341. METALLICWORKFLOW: boolean;
  22342. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22343. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22344. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22345. AOSTOREINMETALMAPRED: boolean;
  22346. METALLIC_REFLECTANCE: boolean;
  22347. METALLIC_REFLECTANCEDIRECTUV: number;
  22348. ENVIRONMENTBRDF: boolean;
  22349. ENVIRONMENTBRDF_RGBD: boolean;
  22350. NORMAL: boolean;
  22351. TANGENT: boolean;
  22352. BUMP: boolean;
  22353. BUMPDIRECTUV: number;
  22354. OBJECTSPACE_NORMALMAP: boolean;
  22355. PARALLAX: boolean;
  22356. PARALLAXOCCLUSION: boolean;
  22357. NORMALXYSCALE: boolean;
  22358. LIGHTMAP: boolean;
  22359. LIGHTMAPDIRECTUV: number;
  22360. USELIGHTMAPASSHADOWMAP: boolean;
  22361. GAMMALIGHTMAP: boolean;
  22362. RGBDLIGHTMAP: boolean;
  22363. REFLECTION: boolean;
  22364. REFLECTIONMAP_3D: boolean;
  22365. REFLECTIONMAP_SPHERICAL: boolean;
  22366. REFLECTIONMAP_PLANAR: boolean;
  22367. REFLECTIONMAP_CUBIC: boolean;
  22368. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22369. REFLECTIONMAP_PROJECTION: boolean;
  22370. REFLECTIONMAP_SKYBOX: boolean;
  22371. REFLECTIONMAP_EXPLICIT: boolean;
  22372. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22373. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22374. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22375. INVERTCUBICMAP: boolean;
  22376. USESPHERICALFROMREFLECTIONMAP: boolean;
  22377. USEIRRADIANCEMAP: boolean;
  22378. SPHERICAL_HARMONICS: boolean;
  22379. USESPHERICALINVERTEX: boolean;
  22380. REFLECTIONMAP_OPPOSITEZ: boolean;
  22381. LODINREFLECTIONALPHA: boolean;
  22382. GAMMAREFLECTION: boolean;
  22383. RGBDREFLECTION: boolean;
  22384. LINEARSPECULARREFLECTION: boolean;
  22385. RADIANCEOCCLUSION: boolean;
  22386. HORIZONOCCLUSION: boolean;
  22387. INSTANCES: boolean;
  22388. THIN_INSTANCES: boolean;
  22389. PREPASS: boolean;
  22390. PREPASS_IRRADIANCE: boolean;
  22391. PREPASS_IRRADIANCE_INDEX: number;
  22392. PREPASS_ALBEDO: boolean;
  22393. PREPASS_ALBEDO_INDEX: number;
  22394. PREPASS_DEPTHNORMAL: boolean;
  22395. PREPASS_DEPTHNORMAL_INDEX: number;
  22396. PREPASS_POSITION: boolean;
  22397. PREPASS_POSITION_INDEX: number;
  22398. PREPASS_VELOCITY: boolean;
  22399. PREPASS_VELOCITY_INDEX: number;
  22400. PREPASS_REFLECTIVITY: boolean;
  22401. PREPASS_REFLECTIVITY_INDEX: number;
  22402. SCENE_MRT_COUNT: number;
  22403. NUM_BONE_INFLUENCERS: number;
  22404. BonesPerMesh: number;
  22405. BONETEXTURE: boolean;
  22406. BONES_VELOCITY_ENABLED: boolean;
  22407. NONUNIFORMSCALING: boolean;
  22408. MORPHTARGETS: boolean;
  22409. MORPHTARGETS_NORMAL: boolean;
  22410. MORPHTARGETS_TANGENT: boolean;
  22411. MORPHTARGETS_UV: boolean;
  22412. NUM_MORPH_INFLUENCERS: number;
  22413. IMAGEPROCESSING: boolean;
  22414. VIGNETTE: boolean;
  22415. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22416. VIGNETTEBLENDMODEOPAQUE: boolean;
  22417. TONEMAPPING: boolean;
  22418. TONEMAPPING_ACES: boolean;
  22419. CONTRAST: boolean;
  22420. COLORCURVES: boolean;
  22421. COLORGRADING: boolean;
  22422. COLORGRADING3D: boolean;
  22423. SAMPLER3DGREENDEPTH: boolean;
  22424. SAMPLER3DBGRMAP: boolean;
  22425. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22426. EXPOSURE: boolean;
  22427. MULTIVIEW: boolean;
  22428. USEPHYSICALLIGHTFALLOFF: boolean;
  22429. USEGLTFLIGHTFALLOFF: boolean;
  22430. TWOSIDEDLIGHTING: boolean;
  22431. SHADOWFLOAT: boolean;
  22432. CLIPPLANE: boolean;
  22433. CLIPPLANE2: boolean;
  22434. CLIPPLANE3: boolean;
  22435. CLIPPLANE4: boolean;
  22436. CLIPPLANE5: boolean;
  22437. CLIPPLANE6: boolean;
  22438. POINTSIZE: boolean;
  22439. FOG: boolean;
  22440. LOGARITHMICDEPTH: boolean;
  22441. FORCENORMALFORWARD: boolean;
  22442. SPECULARAA: boolean;
  22443. CLEARCOAT: boolean;
  22444. CLEARCOAT_DEFAULTIOR: boolean;
  22445. CLEARCOAT_TEXTURE: boolean;
  22446. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22447. CLEARCOAT_TEXTUREDIRECTUV: number;
  22448. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22449. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22450. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22451. CLEARCOAT_BUMP: boolean;
  22452. CLEARCOAT_BUMPDIRECTUV: number;
  22453. CLEARCOAT_REMAP_F0: boolean;
  22454. CLEARCOAT_TINT: boolean;
  22455. CLEARCOAT_TINT_TEXTURE: boolean;
  22456. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22457. ANISOTROPIC: boolean;
  22458. ANISOTROPIC_TEXTURE: boolean;
  22459. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22460. BRDF_V_HEIGHT_CORRELATED: boolean;
  22461. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22462. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22463. SHEEN: boolean;
  22464. SHEEN_TEXTURE: boolean;
  22465. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22466. SHEEN_TEXTUREDIRECTUV: number;
  22467. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22468. SHEEN_LINKWITHALBEDO: boolean;
  22469. SHEEN_ROUGHNESS: boolean;
  22470. SHEEN_ALBEDOSCALING: boolean;
  22471. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22472. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22473. SUBSURFACE: boolean;
  22474. SS_REFRACTION: boolean;
  22475. SS_TRANSLUCENCY: boolean;
  22476. SS_SCATTERING: boolean;
  22477. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22478. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22479. SS_REFRACTIONMAP_3D: boolean;
  22480. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22481. SS_LODINREFRACTIONALPHA: boolean;
  22482. SS_GAMMAREFRACTION: boolean;
  22483. SS_RGBDREFRACTION: boolean;
  22484. SS_LINEARSPECULARREFRACTION: boolean;
  22485. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22486. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22487. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22488. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22489. UNLIT: boolean;
  22490. DEBUGMODE: number;
  22491. /**
  22492. * Initializes the PBR Material defines.
  22493. */
  22494. constructor();
  22495. /**
  22496. * Resets the PBR Material defines.
  22497. */
  22498. reset(): void;
  22499. }
  22500. /**
  22501. * The Physically based material base class of BJS.
  22502. *
  22503. * This offers the main features of a standard PBR material.
  22504. * For more information, please refer to the documentation :
  22505. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22506. */
  22507. export abstract class PBRBaseMaterial extends PushMaterial {
  22508. /**
  22509. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22510. */
  22511. static readonly PBRMATERIAL_OPAQUE: number;
  22512. /**
  22513. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22514. */
  22515. static readonly PBRMATERIAL_ALPHATEST: number;
  22516. /**
  22517. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22518. */
  22519. static readonly PBRMATERIAL_ALPHABLEND: number;
  22520. /**
  22521. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22522. * They are also discarded below the alpha cutoff threshold to improve performances.
  22523. */
  22524. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22525. /**
  22526. * Defines the default value of how much AO map is occluding the analytical lights
  22527. * (point spot...).
  22528. */
  22529. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22530. /**
  22531. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22532. */
  22533. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22534. /**
  22535. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22536. * to enhance interoperability with other engines.
  22537. */
  22538. static readonly LIGHTFALLOFF_GLTF: number;
  22539. /**
  22540. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22541. * to enhance interoperability with other materials.
  22542. */
  22543. static readonly LIGHTFALLOFF_STANDARD: number;
  22544. /**
  22545. * Intensity of the direct lights e.g. the four lights available in your scene.
  22546. * This impacts both the direct diffuse and specular highlights.
  22547. */
  22548. protected _directIntensity: number;
  22549. /**
  22550. * Intensity of the emissive part of the material.
  22551. * This helps controlling the emissive effect without modifying the emissive color.
  22552. */
  22553. protected _emissiveIntensity: number;
  22554. /**
  22555. * Intensity of the environment e.g. how much the environment will light the object
  22556. * either through harmonics for rough material or through the refelction for shiny ones.
  22557. */
  22558. protected _environmentIntensity: number;
  22559. /**
  22560. * This is a special control allowing the reduction of the specular highlights coming from the
  22561. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22562. */
  22563. protected _specularIntensity: number;
  22564. /**
  22565. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22566. */
  22567. private _lightingInfos;
  22568. /**
  22569. * Debug Control allowing disabling the bump map on this material.
  22570. */
  22571. protected _disableBumpMap: boolean;
  22572. /**
  22573. * AKA Diffuse Texture in standard nomenclature.
  22574. */
  22575. protected _albedoTexture: Nullable<BaseTexture>;
  22576. /**
  22577. * AKA Occlusion Texture in other nomenclature.
  22578. */
  22579. protected _ambientTexture: Nullable<BaseTexture>;
  22580. /**
  22581. * AKA Occlusion Texture Intensity in other nomenclature.
  22582. */
  22583. protected _ambientTextureStrength: number;
  22584. /**
  22585. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22586. * 1 means it completely occludes it
  22587. * 0 mean it has no impact
  22588. */
  22589. protected _ambientTextureImpactOnAnalyticalLights: number;
  22590. /**
  22591. * Stores the alpha values in a texture.
  22592. */
  22593. protected _opacityTexture: Nullable<BaseTexture>;
  22594. /**
  22595. * Stores the reflection values in a texture.
  22596. */
  22597. protected _reflectionTexture: Nullable<BaseTexture>;
  22598. /**
  22599. * Stores the emissive values in a texture.
  22600. */
  22601. protected _emissiveTexture: Nullable<BaseTexture>;
  22602. /**
  22603. * AKA Specular texture in other nomenclature.
  22604. */
  22605. protected _reflectivityTexture: Nullable<BaseTexture>;
  22606. /**
  22607. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22608. */
  22609. protected _metallicTexture: Nullable<BaseTexture>;
  22610. /**
  22611. * Specifies the metallic scalar of the metallic/roughness workflow.
  22612. * Can also be used to scale the metalness values of the metallic texture.
  22613. */
  22614. protected _metallic: Nullable<number>;
  22615. /**
  22616. * Specifies the roughness scalar of the metallic/roughness workflow.
  22617. * Can also be used to scale the roughness values of the metallic texture.
  22618. */
  22619. protected _roughness: Nullable<number>;
  22620. /**
  22621. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22622. * By default the indexOfrefraction is used to compute F0;
  22623. *
  22624. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22625. *
  22626. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22627. * F90 = metallicReflectanceColor;
  22628. */
  22629. protected _metallicF0Factor: number;
  22630. /**
  22631. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22632. * By default the F90 is always 1;
  22633. *
  22634. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22635. *
  22636. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22637. * F90 = metallicReflectanceColor;
  22638. */
  22639. protected _metallicReflectanceColor: Color3;
  22640. /**
  22641. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22642. * This is multiply against the scalar values defined in the material.
  22643. */
  22644. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22645. /**
  22646. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22647. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22648. */
  22649. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22650. /**
  22651. * Stores surface normal data used to displace a mesh in a texture.
  22652. */
  22653. protected _bumpTexture: Nullable<BaseTexture>;
  22654. /**
  22655. * Stores the pre-calculated light information of a mesh in a texture.
  22656. */
  22657. protected _lightmapTexture: Nullable<BaseTexture>;
  22658. /**
  22659. * The color of a material in ambient lighting.
  22660. */
  22661. protected _ambientColor: Color3;
  22662. /**
  22663. * AKA Diffuse Color in other nomenclature.
  22664. */
  22665. protected _albedoColor: Color3;
  22666. /**
  22667. * AKA Specular Color in other nomenclature.
  22668. */
  22669. protected _reflectivityColor: Color3;
  22670. /**
  22671. * The color applied when light is reflected from a material.
  22672. */
  22673. protected _reflectionColor: Color3;
  22674. /**
  22675. * The color applied when light is emitted from a material.
  22676. */
  22677. protected _emissiveColor: Color3;
  22678. /**
  22679. * AKA Glossiness in other nomenclature.
  22680. */
  22681. protected _microSurface: number;
  22682. /**
  22683. * Specifies that the material will use the light map as a show map.
  22684. */
  22685. protected _useLightmapAsShadowmap: boolean;
  22686. /**
  22687. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22688. * makes the reflect vector face the model (under horizon).
  22689. */
  22690. protected _useHorizonOcclusion: boolean;
  22691. /**
  22692. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22693. * too much the area relying on ambient texture to define their ambient occlusion.
  22694. */
  22695. protected _useRadianceOcclusion: boolean;
  22696. /**
  22697. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22698. */
  22699. protected _useAlphaFromAlbedoTexture: boolean;
  22700. /**
  22701. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  22702. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22703. */
  22704. protected _useSpecularOverAlpha: boolean;
  22705. /**
  22706. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22707. */
  22708. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22709. /**
  22710. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22711. */
  22712. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22713. /**
  22714. * Specifies if the metallic texture contains the roughness information in its green channel.
  22715. */
  22716. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22717. /**
  22718. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22719. */
  22720. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22721. /**
  22722. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22723. */
  22724. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22725. /**
  22726. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22727. */
  22728. protected _useAmbientInGrayScale: boolean;
  22729. /**
  22730. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22731. * The material will try to infer what glossiness each pixel should be.
  22732. */
  22733. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22734. /**
  22735. * Defines the falloff type used in this material.
  22736. * It by default is Physical.
  22737. */
  22738. protected _lightFalloff: number;
  22739. /**
  22740. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22741. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22742. */
  22743. protected _useRadianceOverAlpha: boolean;
  22744. /**
  22745. * Allows using an object space normal map (instead of tangent space).
  22746. */
  22747. protected _useObjectSpaceNormalMap: boolean;
  22748. /**
  22749. * Allows using the bump map in parallax mode.
  22750. */
  22751. protected _useParallax: boolean;
  22752. /**
  22753. * Allows using the bump map in parallax occlusion mode.
  22754. */
  22755. protected _useParallaxOcclusion: boolean;
  22756. /**
  22757. * Controls the scale bias of the parallax mode.
  22758. */
  22759. protected _parallaxScaleBias: number;
  22760. /**
  22761. * If sets to true, disables all the lights affecting the material.
  22762. */
  22763. protected _disableLighting: boolean;
  22764. /**
  22765. * Number of Simultaneous lights allowed on the material.
  22766. */
  22767. protected _maxSimultaneousLights: number;
  22768. /**
  22769. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22770. */
  22771. protected _invertNormalMapX: boolean;
  22772. /**
  22773. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22774. */
  22775. protected _invertNormalMapY: boolean;
  22776. /**
  22777. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22778. */
  22779. protected _twoSidedLighting: boolean;
  22780. /**
  22781. * Defines the alpha limits in alpha test mode.
  22782. */
  22783. protected _alphaCutOff: number;
  22784. /**
  22785. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22786. */
  22787. protected _forceAlphaTest: boolean;
  22788. /**
  22789. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22790. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22791. */
  22792. protected _useAlphaFresnel: boolean;
  22793. /**
  22794. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22795. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22796. */
  22797. protected _useLinearAlphaFresnel: boolean;
  22798. /**
  22799. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22800. * from cos thetav and roughness:
  22801. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22802. */
  22803. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22804. /**
  22805. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22806. */
  22807. protected _forceIrradianceInFragment: boolean;
  22808. private _realTimeFiltering;
  22809. /**
  22810. * Enables realtime filtering on the texture.
  22811. */
  22812. get realTimeFiltering(): boolean;
  22813. set realTimeFiltering(b: boolean);
  22814. private _realTimeFilteringQuality;
  22815. /**
  22816. * Quality switch for realtime filtering
  22817. */
  22818. get realTimeFilteringQuality(): number;
  22819. set realTimeFilteringQuality(n: number);
  22820. /**
  22821. * Can this material render to several textures at once
  22822. */
  22823. get canRenderToMRT(): boolean;
  22824. /**
  22825. * Force normal to face away from face.
  22826. */
  22827. protected _forceNormalForward: boolean;
  22828. /**
  22829. * Enables specular anti aliasing in the PBR shader.
  22830. * It will both interacts on the Geometry for analytical and IBL lighting.
  22831. * It also prefilter the roughness map based on the bump values.
  22832. */
  22833. protected _enableSpecularAntiAliasing: boolean;
  22834. /**
  22835. * Default configuration related to image processing available in the PBR Material.
  22836. */
  22837. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22838. /**
  22839. * Keep track of the image processing observer to allow dispose and replace.
  22840. */
  22841. private _imageProcessingObserver;
  22842. /**
  22843. * Attaches a new image processing configuration to the PBR Material.
  22844. * @param configuration
  22845. */
  22846. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22847. /**
  22848. * Stores the available render targets.
  22849. */
  22850. private _renderTargets;
  22851. /**
  22852. * Sets the global ambient color for the material used in lighting calculations.
  22853. */
  22854. private _globalAmbientColor;
  22855. /**
  22856. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22857. */
  22858. private _useLogarithmicDepth;
  22859. /**
  22860. * If set to true, no lighting calculations will be applied.
  22861. */
  22862. private _unlit;
  22863. private _debugMode;
  22864. /**
  22865. * @hidden
  22866. * This is reserved for the inspector.
  22867. * Defines the material debug mode.
  22868. * It helps seeing only some components of the material while troubleshooting.
  22869. */
  22870. debugMode: number;
  22871. /**
  22872. * @hidden
  22873. * This is reserved for the inspector.
  22874. * Specify from where on screen the debug mode should start.
  22875. * The value goes from -1 (full screen) to 1 (not visible)
  22876. * It helps with side by side comparison against the final render
  22877. * This defaults to -1
  22878. */
  22879. private debugLimit;
  22880. /**
  22881. * @hidden
  22882. * This is reserved for the inspector.
  22883. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22884. * You can use the factor to better multiply the final value.
  22885. */
  22886. private debugFactor;
  22887. /**
  22888. * Defines the clear coat layer parameters for the material.
  22889. */
  22890. readonly clearCoat: PBRClearCoatConfiguration;
  22891. /**
  22892. * Defines the anisotropic parameters for the material.
  22893. */
  22894. readonly anisotropy: PBRAnisotropicConfiguration;
  22895. /**
  22896. * Defines the BRDF parameters for the material.
  22897. */
  22898. readonly brdf: PBRBRDFConfiguration;
  22899. /**
  22900. * Defines the Sheen parameters for the material.
  22901. */
  22902. readonly sheen: PBRSheenConfiguration;
  22903. /**
  22904. * Defines the SubSurface parameters for the material.
  22905. */
  22906. readonly subSurface: PBRSubSurfaceConfiguration;
  22907. /**
  22908. * Defines additionnal PrePass parameters for the material.
  22909. */
  22910. readonly prePassConfiguration: PrePassConfiguration;
  22911. /**
  22912. * Defines the detail map parameters for the material.
  22913. */
  22914. readonly detailMap: DetailMapConfiguration;
  22915. protected _rebuildInParallel: boolean;
  22916. /**
  22917. * Instantiates a new PBRMaterial instance.
  22918. *
  22919. * @param name The material name
  22920. * @param scene The scene the material will be use in.
  22921. */
  22922. constructor(name: string, scene: Scene);
  22923. /**
  22924. * Gets a boolean indicating that current material needs to register RTT
  22925. */
  22926. get hasRenderTargetTextures(): boolean;
  22927. /**
  22928. * Gets the name of the material class.
  22929. */
  22930. getClassName(): string;
  22931. /**
  22932. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22933. */
  22934. get useLogarithmicDepth(): boolean;
  22935. /**
  22936. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22937. */
  22938. set useLogarithmicDepth(value: boolean);
  22939. /**
  22940. * Returns true if alpha blending should be disabled.
  22941. */
  22942. protected get _disableAlphaBlending(): boolean;
  22943. /**
  22944. * Specifies whether or not this material should be rendered in alpha blend mode.
  22945. */
  22946. needAlphaBlending(): boolean;
  22947. /**
  22948. * Specifies whether or not this material should be rendered in alpha test mode.
  22949. */
  22950. needAlphaTesting(): boolean;
  22951. /**
  22952. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22953. */
  22954. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22955. /**
  22956. * Specifies whether or not there is a usable alpha channel for transparency.
  22957. */
  22958. protected _hasAlphaChannel(): boolean;
  22959. /**
  22960. * Gets the texture used for the alpha test.
  22961. */
  22962. getAlphaTestTexture(): Nullable<BaseTexture>;
  22963. /**
  22964. * Specifies that the submesh is ready to be used.
  22965. * @param mesh - BJS mesh.
  22966. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22967. * @param useInstances - Specifies that instances should be used.
  22968. * @returns - boolean indicating that the submesh is ready or not.
  22969. */
  22970. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22971. /**
  22972. * Specifies if the material uses metallic roughness workflow.
  22973. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22974. */
  22975. isMetallicWorkflow(): boolean;
  22976. private _prepareEffect;
  22977. private _prepareDefines;
  22978. /**
  22979. * Force shader compilation
  22980. */
  22981. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22982. /**
  22983. * Initializes the uniform buffer layout for the shader.
  22984. */
  22985. buildUniformLayout(): void;
  22986. /**
  22987. * Unbinds the material from the mesh
  22988. */
  22989. unbind(): void;
  22990. /**
  22991. * Binds the submesh data.
  22992. * @param world - The world matrix.
  22993. * @param mesh - The BJS mesh.
  22994. * @param subMesh - A submesh of the BJS mesh.
  22995. */
  22996. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22997. /**
  22998. * Returns the animatable textures.
  22999. * @returns - Array of animatable textures.
  23000. */
  23001. getAnimatables(): IAnimatable[];
  23002. /**
  23003. * Returns the texture used for reflections.
  23004. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  23005. */
  23006. private _getReflectionTexture;
  23007. /**
  23008. * Returns an array of the actively used textures.
  23009. * @returns - Array of BaseTextures
  23010. */
  23011. getActiveTextures(): BaseTexture[];
  23012. /**
  23013. * Checks to see if a texture is used in the material.
  23014. * @param texture - Base texture to use.
  23015. * @returns - Boolean specifying if a texture is used in the material.
  23016. */
  23017. hasTexture(texture: BaseTexture): boolean;
  23018. /**
  23019. * Sets the required values to the prepass renderer.
  23020. * @param prePassRenderer defines the prepass renderer to setup
  23021. */
  23022. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23023. /**
  23024. * Disposes the resources of the material.
  23025. * @param forceDisposeEffect - Forces the disposal of effects.
  23026. * @param forceDisposeTextures - Forces the disposal of all textures.
  23027. */
  23028. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23029. }
  23030. }
  23031. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  23032. import { Nullable } from "babylonjs/types";
  23033. import { Scene } from "babylonjs/scene";
  23034. import { Color3 } from "babylonjs/Maths/math.color";
  23035. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23036. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23038. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  23039. /**
  23040. * The Physically based material of BJS.
  23041. *
  23042. * This offers the main features of a standard PBR material.
  23043. * For more information, please refer to the documentation :
  23044. * https://doc.babylonjs.com/how_to/physically_based_rendering
  23045. */
  23046. export class PBRMaterial extends PBRBaseMaterial {
  23047. /**
  23048. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23049. */
  23050. static readonly PBRMATERIAL_OPAQUE: number;
  23051. /**
  23052. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23053. */
  23054. static readonly PBRMATERIAL_ALPHATEST: number;
  23055. /**
  23056. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23057. */
  23058. static readonly PBRMATERIAL_ALPHABLEND: number;
  23059. /**
  23060. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23061. * They are also discarded below the alpha cutoff threshold to improve performances.
  23062. */
  23063. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  23064. /**
  23065. * Defines the default value of how much AO map is occluding the analytical lights
  23066. * (point spot...).
  23067. */
  23068. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  23069. /**
  23070. * Intensity of the direct lights e.g. the four lights available in your scene.
  23071. * This impacts both the direct diffuse and specular highlights.
  23072. */
  23073. directIntensity: number;
  23074. /**
  23075. * Intensity of the emissive part of the material.
  23076. * This helps controlling the emissive effect without modifying the emissive color.
  23077. */
  23078. emissiveIntensity: number;
  23079. /**
  23080. * Intensity of the environment e.g. how much the environment will light the object
  23081. * either through harmonics for rough material or through the refelction for shiny ones.
  23082. */
  23083. environmentIntensity: number;
  23084. /**
  23085. * This is a special control allowing the reduction of the specular highlights coming from the
  23086. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  23087. */
  23088. specularIntensity: number;
  23089. /**
  23090. * Debug Control allowing disabling the bump map on this material.
  23091. */
  23092. disableBumpMap: boolean;
  23093. /**
  23094. * AKA Diffuse Texture in standard nomenclature.
  23095. */
  23096. albedoTexture: BaseTexture;
  23097. /**
  23098. * AKA Occlusion Texture in other nomenclature.
  23099. */
  23100. ambientTexture: BaseTexture;
  23101. /**
  23102. * AKA Occlusion Texture Intensity in other nomenclature.
  23103. */
  23104. ambientTextureStrength: number;
  23105. /**
  23106. * Defines how much the AO map is occluding the analytical lights (point spot...).
  23107. * 1 means it completely occludes it
  23108. * 0 mean it has no impact
  23109. */
  23110. ambientTextureImpactOnAnalyticalLights: number;
  23111. /**
  23112. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  23113. */
  23114. opacityTexture: BaseTexture;
  23115. /**
  23116. * Stores the reflection values in a texture.
  23117. */
  23118. reflectionTexture: Nullable<BaseTexture>;
  23119. /**
  23120. * Stores the emissive values in a texture.
  23121. */
  23122. emissiveTexture: BaseTexture;
  23123. /**
  23124. * AKA Specular texture in other nomenclature.
  23125. */
  23126. reflectivityTexture: BaseTexture;
  23127. /**
  23128. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23129. */
  23130. metallicTexture: BaseTexture;
  23131. /**
  23132. * Specifies the metallic scalar of the metallic/roughness workflow.
  23133. * Can also be used to scale the metalness values of the metallic texture.
  23134. */
  23135. metallic: Nullable<number>;
  23136. /**
  23137. * Specifies the roughness scalar of the metallic/roughness workflow.
  23138. * Can also be used to scale the roughness values of the metallic texture.
  23139. */
  23140. roughness: Nullable<number>;
  23141. /**
  23142. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  23143. * By default the indexOfrefraction is used to compute F0;
  23144. *
  23145. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  23146. *
  23147. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  23148. * F90 = metallicReflectanceColor;
  23149. */
  23150. metallicF0Factor: number;
  23151. /**
  23152. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  23153. * By default the F90 is always 1;
  23154. *
  23155. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  23156. *
  23157. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  23158. * F90 = metallicReflectanceColor;
  23159. */
  23160. metallicReflectanceColor: Color3;
  23161. /**
  23162. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  23163. * This is multiply against the scalar values defined in the material.
  23164. */
  23165. metallicReflectanceTexture: Nullable<BaseTexture>;
  23166. /**
  23167. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  23168. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23169. */
  23170. microSurfaceTexture: BaseTexture;
  23171. /**
  23172. * Stores surface normal data used to displace a mesh in a texture.
  23173. */
  23174. bumpTexture: BaseTexture;
  23175. /**
  23176. * Stores the pre-calculated light information of a mesh in a texture.
  23177. */
  23178. lightmapTexture: BaseTexture;
  23179. /**
  23180. * Stores the refracted light information in a texture.
  23181. */
  23182. get refractionTexture(): Nullable<BaseTexture>;
  23183. set refractionTexture(value: Nullable<BaseTexture>);
  23184. /**
  23185. * The color of a material in ambient lighting.
  23186. */
  23187. ambientColor: Color3;
  23188. /**
  23189. * AKA Diffuse Color in other nomenclature.
  23190. */
  23191. albedoColor: Color3;
  23192. /**
  23193. * AKA Specular Color in other nomenclature.
  23194. */
  23195. reflectivityColor: Color3;
  23196. /**
  23197. * The color reflected from the material.
  23198. */
  23199. reflectionColor: Color3;
  23200. /**
  23201. * The color emitted from the material.
  23202. */
  23203. emissiveColor: Color3;
  23204. /**
  23205. * AKA Glossiness in other nomenclature.
  23206. */
  23207. microSurface: number;
  23208. /**
  23209. * Index of refraction of the material base layer.
  23210. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  23211. *
  23212. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  23213. *
  23214. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  23215. */
  23216. get indexOfRefraction(): number;
  23217. set indexOfRefraction(value: number);
  23218. /**
  23219. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  23220. */
  23221. get invertRefractionY(): boolean;
  23222. set invertRefractionY(value: boolean);
  23223. /**
  23224. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  23225. * Materials half opaque for instance using refraction could benefit from this control.
  23226. */
  23227. get linkRefractionWithTransparency(): boolean;
  23228. set linkRefractionWithTransparency(value: boolean);
  23229. /**
  23230. * If true, the light map contains occlusion information instead of lighting info.
  23231. */
  23232. useLightmapAsShadowmap: boolean;
  23233. /**
  23234. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23235. */
  23236. useAlphaFromAlbedoTexture: boolean;
  23237. /**
  23238. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23239. */
  23240. forceAlphaTest: boolean;
  23241. /**
  23242. * Defines the alpha limits in alpha test mode.
  23243. */
  23244. alphaCutOff: number;
  23245. /**
  23246. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23247. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23248. */
  23249. useSpecularOverAlpha: boolean;
  23250. /**
  23251. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23252. */
  23253. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23254. /**
  23255. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23256. */
  23257. useRoughnessFromMetallicTextureAlpha: boolean;
  23258. /**
  23259. * Specifies if the metallic texture contains the roughness information in its green channel.
  23260. */
  23261. useRoughnessFromMetallicTextureGreen: boolean;
  23262. /**
  23263. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23264. */
  23265. useMetallnessFromMetallicTextureBlue: boolean;
  23266. /**
  23267. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23268. */
  23269. useAmbientOcclusionFromMetallicTextureRed: boolean;
  23270. /**
  23271. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23272. */
  23273. useAmbientInGrayScale: boolean;
  23274. /**
  23275. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23276. * The material will try to infer what glossiness each pixel should be.
  23277. */
  23278. useAutoMicroSurfaceFromReflectivityMap: boolean;
  23279. /**
  23280. * BJS is using an harcoded light falloff based on a manually sets up range.
  23281. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23282. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23283. */
  23284. get usePhysicalLightFalloff(): boolean;
  23285. /**
  23286. * BJS is using an harcoded light falloff based on a manually sets up range.
  23287. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23288. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23289. */
  23290. set usePhysicalLightFalloff(value: boolean);
  23291. /**
  23292. * In order to support the falloff compatibility with gltf, a special mode has been added
  23293. * to reproduce the gltf light falloff.
  23294. */
  23295. get useGLTFLightFalloff(): boolean;
  23296. /**
  23297. * In order to support the falloff compatibility with gltf, a special mode has been added
  23298. * to reproduce the gltf light falloff.
  23299. */
  23300. set useGLTFLightFalloff(value: boolean);
  23301. /**
  23302. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23303. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23304. */
  23305. useRadianceOverAlpha: boolean;
  23306. /**
  23307. * Allows using an object space normal map (instead of tangent space).
  23308. */
  23309. useObjectSpaceNormalMap: boolean;
  23310. /**
  23311. * Allows using the bump map in parallax mode.
  23312. */
  23313. useParallax: boolean;
  23314. /**
  23315. * Allows using the bump map in parallax occlusion mode.
  23316. */
  23317. useParallaxOcclusion: boolean;
  23318. /**
  23319. * Controls the scale bias of the parallax mode.
  23320. */
  23321. parallaxScaleBias: number;
  23322. /**
  23323. * If sets to true, disables all the lights affecting the material.
  23324. */
  23325. disableLighting: boolean;
  23326. /**
  23327. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23328. */
  23329. forceIrradianceInFragment: boolean;
  23330. /**
  23331. * Number of Simultaneous lights allowed on the material.
  23332. */
  23333. maxSimultaneousLights: number;
  23334. /**
  23335. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23336. */
  23337. invertNormalMapX: boolean;
  23338. /**
  23339. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23340. */
  23341. invertNormalMapY: boolean;
  23342. /**
  23343. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23344. */
  23345. twoSidedLighting: boolean;
  23346. /**
  23347. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23348. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23349. */
  23350. useAlphaFresnel: boolean;
  23351. /**
  23352. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23353. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23354. */
  23355. useLinearAlphaFresnel: boolean;
  23356. /**
  23357. * Let user defines the brdf lookup texture used for IBL.
  23358. * A default 8bit version is embedded but you could point at :
  23359. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23360. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23361. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23362. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23363. */
  23364. environmentBRDFTexture: Nullable<BaseTexture>;
  23365. /**
  23366. * Force normal to face away from face.
  23367. */
  23368. forceNormalForward: boolean;
  23369. /**
  23370. * Enables specular anti aliasing in the PBR shader.
  23371. * It will both interacts on the Geometry for analytical and IBL lighting.
  23372. * It also prefilter the roughness map based on the bump values.
  23373. */
  23374. enableSpecularAntiAliasing: boolean;
  23375. /**
  23376. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23377. * makes the reflect vector face the model (under horizon).
  23378. */
  23379. useHorizonOcclusion: boolean;
  23380. /**
  23381. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23382. * too much the area relying on ambient texture to define their ambient occlusion.
  23383. */
  23384. useRadianceOcclusion: boolean;
  23385. /**
  23386. * If set to true, no lighting calculations will be applied.
  23387. */
  23388. unlit: boolean;
  23389. /**
  23390. * Gets the image processing configuration used either in this material.
  23391. */
  23392. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23393. /**
  23394. * Sets the Default image processing configuration used either in the this material.
  23395. *
  23396. * If sets to null, the scene one is in use.
  23397. */
  23398. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23399. /**
  23400. * Gets wether the color curves effect is enabled.
  23401. */
  23402. get cameraColorCurvesEnabled(): boolean;
  23403. /**
  23404. * Sets wether the color curves effect is enabled.
  23405. */
  23406. set cameraColorCurvesEnabled(value: boolean);
  23407. /**
  23408. * Gets wether the color grading effect is enabled.
  23409. */
  23410. get cameraColorGradingEnabled(): boolean;
  23411. /**
  23412. * Gets wether the color grading effect is enabled.
  23413. */
  23414. set cameraColorGradingEnabled(value: boolean);
  23415. /**
  23416. * Gets wether tonemapping is enabled or not.
  23417. */
  23418. get cameraToneMappingEnabled(): boolean;
  23419. /**
  23420. * Sets wether tonemapping is enabled or not
  23421. */
  23422. set cameraToneMappingEnabled(value: boolean);
  23423. /**
  23424. * The camera exposure used on this material.
  23425. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23426. * This corresponds to a photographic exposure.
  23427. */
  23428. get cameraExposure(): number;
  23429. /**
  23430. * The camera exposure used on this material.
  23431. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23432. * This corresponds to a photographic exposure.
  23433. */
  23434. set cameraExposure(value: number);
  23435. /**
  23436. * Gets The camera contrast used on this material.
  23437. */
  23438. get cameraContrast(): number;
  23439. /**
  23440. * Sets The camera contrast used on this material.
  23441. */
  23442. set cameraContrast(value: number);
  23443. /**
  23444. * Gets the Color Grading 2D Lookup Texture.
  23445. */
  23446. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23447. /**
  23448. * Sets the Color Grading 2D Lookup Texture.
  23449. */
  23450. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23451. /**
  23452. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23453. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23454. * 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;
  23455. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23456. */
  23457. get cameraColorCurves(): Nullable<ColorCurves>;
  23458. /**
  23459. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23460. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23461. * 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;
  23462. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23463. */
  23464. set cameraColorCurves(value: Nullable<ColorCurves>);
  23465. /**
  23466. * Instantiates a new PBRMaterial instance.
  23467. *
  23468. * @param name The material name
  23469. * @param scene The scene the material will be use in.
  23470. */
  23471. constructor(name: string, scene: Scene);
  23472. /**
  23473. * Returns the name of this material class.
  23474. */
  23475. getClassName(): string;
  23476. /**
  23477. * Makes a duplicate of the current material.
  23478. * @param name - name to use for the new material.
  23479. */
  23480. clone(name: string): PBRMaterial;
  23481. /**
  23482. * Serializes this PBR Material.
  23483. * @returns - An object with the serialized material.
  23484. */
  23485. serialize(): any;
  23486. /**
  23487. * Parses a PBR Material from a serialized object.
  23488. * @param source - Serialized object.
  23489. * @param scene - BJS scene instance.
  23490. * @param rootUrl - url for the scene object
  23491. * @returns - PBRMaterial
  23492. */
  23493. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23494. }
  23495. }
  23496. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  23497. /** @hidden */
  23498. export var mrtFragmentDeclaration: {
  23499. name: string;
  23500. shader: string;
  23501. };
  23502. }
  23503. declare module "babylonjs/Shaders/geometry.fragment" {
  23504. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  23505. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  23506. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  23507. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  23508. /** @hidden */
  23509. export var geometryPixelShader: {
  23510. name: string;
  23511. shader: string;
  23512. };
  23513. }
  23514. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  23515. /** @hidden */
  23516. export var instancesDeclaration: {
  23517. name: string;
  23518. shader: string;
  23519. };
  23520. }
  23521. declare module "babylonjs/Shaders/geometry.vertex" {
  23522. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  23523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  23524. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  23525. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  23526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  23527. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  23528. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  23529. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  23530. /** @hidden */
  23531. export var geometryVertexShader: {
  23532. name: string;
  23533. shader: string;
  23534. };
  23535. }
  23536. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  23537. import { Matrix } from "babylonjs/Maths/math.vector";
  23538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23540. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23541. import { Effect } from "babylonjs/Materials/effect";
  23542. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23543. import { Scene } from "babylonjs/scene";
  23544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23545. import { Nullable } from "babylonjs/types";
  23546. import "babylonjs/Shaders/geometry.fragment";
  23547. import "babylonjs/Shaders/geometry.vertex";
  23548. /** @hidden */
  23549. interface ISavedTransformationMatrix {
  23550. world: Matrix;
  23551. viewProjection: Matrix;
  23552. }
  23553. /**
  23554. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23555. */
  23556. export class GeometryBufferRenderer {
  23557. /**
  23558. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  23559. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  23560. */
  23561. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  23562. /**
  23563. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23564. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23565. */
  23566. static readonly POSITION_TEXTURE_TYPE: number;
  23567. /**
  23568. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23569. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23570. */
  23571. static readonly VELOCITY_TEXTURE_TYPE: number;
  23572. /**
  23573. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23574. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23575. */
  23576. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23577. /**
  23578. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23579. * in order to compute objects velocities when enableVelocity is set to "true"
  23580. * @hidden
  23581. */
  23582. _previousTransformationMatrices: {
  23583. [index: number]: ISavedTransformationMatrix;
  23584. };
  23585. /**
  23586. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23587. * in order to compute objects velocities when enableVelocity is set to "true"
  23588. * @hidden
  23589. */
  23590. _previousBonesTransformationMatrices: {
  23591. [index: number]: Float32Array;
  23592. };
  23593. /**
  23594. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23595. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23596. */
  23597. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23598. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23599. renderTransparentMeshes: boolean;
  23600. private _scene;
  23601. private _resizeObserver;
  23602. private _multiRenderTarget;
  23603. private _ratio;
  23604. private _enablePosition;
  23605. private _enableVelocity;
  23606. private _enableReflectivity;
  23607. private _positionIndex;
  23608. private _velocityIndex;
  23609. private _reflectivityIndex;
  23610. private _depthNormalIndex;
  23611. private _linkedWithPrePass;
  23612. private _prePassRenderer;
  23613. private _attachments;
  23614. protected _effect: Effect;
  23615. protected _cachedDefines: string;
  23616. /**
  23617. * @hidden
  23618. * Sets up internal structures to share outputs with PrePassRenderer
  23619. * This method should only be called by the PrePassRenderer itself
  23620. */
  23621. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23622. /**
  23623. * @hidden
  23624. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23625. * This method should only be called by the PrePassRenderer itself
  23626. */
  23627. _unlinkPrePassRenderer(): void;
  23628. /**
  23629. * @hidden
  23630. * Resets the geometry buffer layout
  23631. */
  23632. _resetLayout(): void;
  23633. /**
  23634. * @hidden
  23635. * Replaces a texture in the geometry buffer renderer
  23636. * Useful when linking textures of the prepass renderer
  23637. */
  23638. _forceTextureType(geometryBufferType: number, index: number): void;
  23639. /**
  23640. * @hidden
  23641. * Sets texture attachments
  23642. * Useful when linking textures of the prepass renderer
  23643. */
  23644. _setAttachments(attachments: number[]): void;
  23645. /**
  23646. * @hidden
  23647. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23648. * Useful when linking textures of the prepass renderer
  23649. */
  23650. _linkInternalTexture(internalTexture: InternalTexture): void;
  23651. /**
  23652. * Gets the render list (meshes to be rendered) used in the G buffer.
  23653. */
  23654. get renderList(): Nullable<AbstractMesh[]>;
  23655. /**
  23656. * Set the render list (meshes to be rendered) used in the G buffer.
  23657. */
  23658. set renderList(meshes: Nullable<AbstractMesh[]>);
  23659. /**
  23660. * Gets wether or not G buffer are supported by the running hardware.
  23661. * This requires draw buffer supports
  23662. */
  23663. get isSupported(): boolean;
  23664. /**
  23665. * Returns the index of the given texture type in the G-Buffer textures array
  23666. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23667. * @returns the index of the given texture type in the G-Buffer textures array
  23668. */
  23669. getTextureIndex(textureType: number): number;
  23670. /**
  23671. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23672. */
  23673. get enablePosition(): boolean;
  23674. /**
  23675. * Sets whether or not objects positions are enabled for the G buffer.
  23676. */
  23677. set enablePosition(enable: boolean);
  23678. /**
  23679. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23680. */
  23681. get enableVelocity(): boolean;
  23682. /**
  23683. * Sets wether or not objects velocities are enabled for the G buffer.
  23684. */
  23685. set enableVelocity(enable: boolean);
  23686. /**
  23687. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23688. */
  23689. get enableReflectivity(): boolean;
  23690. /**
  23691. * Sets wether or not objects roughness are enabled for the G buffer.
  23692. */
  23693. set enableReflectivity(enable: boolean);
  23694. /**
  23695. * Gets the scene associated with the buffer.
  23696. */
  23697. get scene(): Scene;
  23698. /**
  23699. * Gets the ratio used by the buffer during its creation.
  23700. * How big is the buffer related to the main canvas.
  23701. */
  23702. get ratio(): number;
  23703. /** @hidden */
  23704. static _SceneComponentInitialization: (scene: Scene) => void;
  23705. /**
  23706. * Creates a new G Buffer for the scene
  23707. * @param scene The scene the buffer belongs to
  23708. * @param ratio How big is the buffer related to the main canvas.
  23709. */
  23710. constructor(scene: Scene, ratio?: number);
  23711. /**
  23712. * Checks wether everything is ready to render a submesh to the G buffer.
  23713. * @param subMesh the submesh to check readiness for
  23714. * @param useInstances is the mesh drawn using instance or not
  23715. * @returns true if ready otherwise false
  23716. */
  23717. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23718. /**
  23719. * Gets the current underlying G Buffer.
  23720. * @returns the buffer
  23721. */
  23722. getGBuffer(): MultiRenderTarget;
  23723. /**
  23724. * Gets the number of samples used to render the buffer (anti aliasing).
  23725. */
  23726. get samples(): number;
  23727. /**
  23728. * Sets the number of samples used to render the buffer (anti aliasing).
  23729. */
  23730. set samples(value: number);
  23731. /**
  23732. * Disposes the renderer and frees up associated resources.
  23733. */
  23734. dispose(): void;
  23735. private _assignRenderTargetIndices;
  23736. protected _createRenderTargets(): void;
  23737. private _copyBonesTransformationMatrices;
  23738. }
  23739. }
  23740. declare module "babylonjs/Rendering/prePassRenderer" {
  23741. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23742. import { Scene } from "babylonjs/scene";
  23743. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23744. import { Effect } from "babylonjs/Materials/effect";
  23745. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23747. import { Material } from "babylonjs/Materials/material";
  23748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23749. /**
  23750. * Renders a pre pass of the scene
  23751. * This means every mesh in the scene will be rendered to a render target texture
  23752. * And then this texture will be composited to the rendering canvas with post processes
  23753. * It is necessary for effects like subsurface scattering or deferred shading
  23754. */
  23755. export class PrePassRenderer {
  23756. /** @hidden */
  23757. static _SceneComponentInitialization: (scene: Scene) => void;
  23758. private _textureFormats;
  23759. /**
  23760. * To save performance, we can excluded skinned meshes from the prepass
  23761. */
  23762. excludedSkinnedMesh: AbstractMesh[];
  23763. /**
  23764. * Force material to be excluded from the prepass
  23765. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23766. * and you don't want a material to show in the effect.
  23767. */
  23768. excludedMaterials: Material[];
  23769. private _textureIndices;
  23770. private _scene;
  23771. private _engine;
  23772. private _isDirty;
  23773. /**
  23774. * Number of textures in the multi render target texture where the scene is directly rendered
  23775. */
  23776. mrtCount: number;
  23777. /**
  23778. * The render target where the scene is directly rendered
  23779. */
  23780. prePassRT: MultiRenderTarget;
  23781. private _multiRenderAttachments;
  23782. private _defaultAttachments;
  23783. private _clearAttachments;
  23784. private _postProcesses;
  23785. private readonly _clearColor;
  23786. /**
  23787. * Image processing post process for composition
  23788. */
  23789. imageProcessingPostProcess: ImageProcessingPostProcess;
  23790. /**
  23791. * Configuration for prepass effects
  23792. */
  23793. private _effectConfigurations;
  23794. private _mrtFormats;
  23795. private _mrtLayout;
  23796. private _enabled;
  23797. /**
  23798. * Indicates if the prepass is enabled
  23799. */
  23800. get enabled(): boolean;
  23801. /**
  23802. * How many samples are used for MSAA of the scene render target
  23803. */
  23804. get samples(): number;
  23805. set samples(n: number);
  23806. private _geometryBuffer;
  23807. private _useGeometryBufferFallback;
  23808. /**
  23809. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23810. */
  23811. get useGeometryBufferFallback(): boolean;
  23812. set useGeometryBufferFallback(value: boolean);
  23813. /**
  23814. * Set to true to disable gamma transform in PrePass.
  23815. * Can be useful in case you already proceed to gamma transform on a material level
  23816. * and your post processes don't need to be in linear color space.
  23817. */
  23818. disableGammaTransform: boolean;
  23819. /**
  23820. * Instanciates a prepass renderer
  23821. * @param scene The scene
  23822. */
  23823. constructor(scene: Scene);
  23824. private _initializeAttachments;
  23825. private _createCompositionEffect;
  23826. /**
  23827. * Indicates if rendering a prepass is supported
  23828. */
  23829. get isSupported(): boolean;
  23830. /**
  23831. * Sets the proper output textures to draw in the engine.
  23832. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23833. * @param subMesh Submesh on which the effect is applied
  23834. */
  23835. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23836. /**
  23837. * Restores attachments for single texture draw.
  23838. */
  23839. restoreAttachments(): void;
  23840. /**
  23841. * @hidden
  23842. */
  23843. _beforeCameraDraw(): void;
  23844. /**
  23845. * @hidden
  23846. */
  23847. _afterCameraDraw(): void;
  23848. private _checkRTSize;
  23849. private _bindFrameBuffer;
  23850. /**
  23851. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23852. */
  23853. clear(): void;
  23854. private _setState;
  23855. private _updateGeometryBufferLayout;
  23856. /**
  23857. * Adds an effect configuration to the prepass.
  23858. * If an effect has already been added, it won't add it twice and will return the configuration
  23859. * already present.
  23860. * @param cfg the effect configuration
  23861. * @return the effect configuration now used by the prepass
  23862. */
  23863. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23864. /**
  23865. * Returns the index of a texture in the multi render target texture array.
  23866. * @param type Texture type
  23867. * @return The index
  23868. */
  23869. getIndex(type: number): number;
  23870. private _enable;
  23871. private _disable;
  23872. private _resetLayout;
  23873. private _resetPostProcessChain;
  23874. private _bindPostProcessChain;
  23875. /**
  23876. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23877. */
  23878. markAsDirty(): void;
  23879. /**
  23880. * Enables a texture on the MultiRenderTarget for prepass
  23881. */
  23882. private _enableTextures;
  23883. private _update;
  23884. private _markAllMaterialsAsPrePassDirty;
  23885. /**
  23886. * Disposes the prepass renderer.
  23887. */
  23888. dispose(): void;
  23889. }
  23890. }
  23891. declare module "babylonjs/PostProcesses/postProcess" {
  23892. import { Nullable } from "babylonjs/types";
  23893. import { SmartArray } from "babylonjs/Misc/smartArray";
  23894. import { Observable } from "babylonjs/Misc/observable";
  23895. import { Vector2 } from "babylonjs/Maths/math.vector";
  23896. import { Camera } from "babylonjs/Cameras/camera";
  23897. import { Effect } from "babylonjs/Materials/effect";
  23898. import "babylonjs/Shaders/postprocess.vertex";
  23899. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23900. import { Engine } from "babylonjs/Engines/engine";
  23901. import { Color4 } from "babylonjs/Maths/math.color";
  23902. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23903. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23904. import { Scene } from "babylonjs/scene";
  23905. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23906. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23907. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23908. /**
  23909. * Size options for a post process
  23910. */
  23911. export type PostProcessOptions = {
  23912. width: number;
  23913. height: number;
  23914. };
  23915. /**
  23916. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23917. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23918. */
  23919. export class PostProcess {
  23920. /**
  23921. * Gets or sets the unique id of the post process
  23922. */
  23923. uniqueId: number;
  23924. /** Name of the PostProcess. */
  23925. name: string;
  23926. /**
  23927. * Width of the texture to apply the post process on
  23928. */
  23929. width: number;
  23930. /**
  23931. * Height of the texture to apply the post process on
  23932. */
  23933. height: number;
  23934. /**
  23935. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23936. */
  23937. nodeMaterialSource: Nullable<NodeMaterial>;
  23938. /**
  23939. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23940. * @hidden
  23941. */
  23942. _outputTexture: Nullable<InternalTexture>;
  23943. /**
  23944. * Sampling mode used by the shader
  23945. * See https://doc.babylonjs.com/classes/3.1/texture
  23946. */
  23947. renderTargetSamplingMode: number;
  23948. /**
  23949. * Clear color to use when screen clearing
  23950. */
  23951. clearColor: Color4;
  23952. /**
  23953. * If the buffer needs to be cleared before applying the post process. (default: true)
  23954. * Should be set to false if shader will overwrite all previous pixels.
  23955. */
  23956. autoClear: boolean;
  23957. /**
  23958. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23959. */
  23960. alphaMode: number;
  23961. /**
  23962. * Sets the setAlphaBlendConstants of the babylon engine
  23963. */
  23964. alphaConstants: Color4;
  23965. /**
  23966. * Animations to be used for the post processing
  23967. */
  23968. animations: import("babylonjs/Animations/animation").Animation[];
  23969. /**
  23970. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23971. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23972. */
  23973. enablePixelPerfectMode: boolean;
  23974. /**
  23975. * Force the postprocess to be applied without taking in account viewport
  23976. */
  23977. forceFullscreenViewport: boolean;
  23978. /**
  23979. * List of inspectable custom properties (used by the Inspector)
  23980. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23981. */
  23982. inspectableCustomProperties: IInspectable[];
  23983. /**
  23984. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23985. *
  23986. * | Value | Type | Description |
  23987. * | ----- | ----------------------------------- | ----------- |
  23988. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23989. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23990. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23991. *
  23992. */
  23993. scaleMode: number;
  23994. /**
  23995. * Force textures to be a power of two (default: false)
  23996. */
  23997. alwaysForcePOT: boolean;
  23998. private _samples;
  23999. /**
  24000. * Number of sample textures (default: 1)
  24001. */
  24002. get samples(): number;
  24003. set samples(n: number);
  24004. /**
  24005. * Modify the scale of the post process to be the same as the viewport (default: false)
  24006. */
  24007. adaptScaleToCurrentViewport: boolean;
  24008. private _camera;
  24009. protected _scene: Scene;
  24010. private _engine;
  24011. private _options;
  24012. private _reusable;
  24013. private _textureType;
  24014. private _textureFormat;
  24015. /**
  24016. * Smart array of input and output textures for the post process.
  24017. * @hidden
  24018. */
  24019. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24020. /**
  24021. * The index in _textures that corresponds to the output texture.
  24022. * @hidden
  24023. */
  24024. _currentRenderTextureInd: number;
  24025. private _effect;
  24026. private _samplers;
  24027. private _fragmentUrl;
  24028. private _vertexUrl;
  24029. private _parameters;
  24030. private _scaleRatio;
  24031. protected _indexParameters: any;
  24032. private _shareOutputWithPostProcess;
  24033. private _texelSize;
  24034. private _forcedOutputTexture;
  24035. /**
  24036. * Prepass configuration in case this post process needs a texture from prepass
  24037. * @hidden
  24038. */
  24039. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24040. /**
  24041. * Returns the fragment url or shader name used in the post process.
  24042. * @returns the fragment url or name in the shader store.
  24043. */
  24044. getEffectName(): string;
  24045. /**
  24046. * An event triggered when the postprocess is activated.
  24047. */
  24048. onActivateObservable: Observable<Camera>;
  24049. private _onActivateObserver;
  24050. /**
  24051. * A function that is added to the onActivateObservable
  24052. */
  24053. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24054. /**
  24055. * An event triggered when the postprocess changes its size.
  24056. */
  24057. onSizeChangedObservable: Observable<PostProcess>;
  24058. private _onSizeChangedObserver;
  24059. /**
  24060. * A function that is added to the onSizeChangedObservable
  24061. */
  24062. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24063. /**
  24064. * An event triggered when the postprocess applies its effect.
  24065. */
  24066. onApplyObservable: Observable<Effect>;
  24067. private _onApplyObserver;
  24068. /**
  24069. * A function that is added to the onApplyObservable
  24070. */
  24071. set onApply(callback: (effect: Effect) => void);
  24072. /**
  24073. * An event triggered before rendering the postprocess
  24074. */
  24075. onBeforeRenderObservable: Observable<Effect>;
  24076. private _onBeforeRenderObserver;
  24077. /**
  24078. * A function that is added to the onBeforeRenderObservable
  24079. */
  24080. set onBeforeRender(callback: (effect: Effect) => void);
  24081. /**
  24082. * An event triggered after rendering the postprocess
  24083. */
  24084. onAfterRenderObservable: Observable<Effect>;
  24085. private _onAfterRenderObserver;
  24086. /**
  24087. * A function that is added to the onAfterRenderObservable
  24088. */
  24089. set onAfterRender(callback: (efect: Effect) => void);
  24090. /**
  24091. * 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
  24092. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24093. */
  24094. get inputTexture(): InternalTexture;
  24095. set inputTexture(value: InternalTexture);
  24096. /**
  24097. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24098. * the only way to unset it is to use this function to restore its internal state
  24099. */
  24100. restoreDefaultInputTexture(): void;
  24101. /**
  24102. * Gets the camera which post process is applied to.
  24103. * @returns The camera the post process is applied to.
  24104. */
  24105. getCamera(): Camera;
  24106. /**
  24107. * Gets the texel size of the postprocess.
  24108. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24109. */
  24110. get texelSize(): Vector2;
  24111. /**
  24112. * Creates a new instance PostProcess
  24113. * @param name The name of the PostProcess.
  24114. * @param fragmentUrl The url of the fragment shader to be used.
  24115. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24116. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24117. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24118. * @param camera The camera to apply the render pass to.
  24119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24120. * @param engine The engine which the post process will be applied. (default: current engine)
  24121. * @param reusable If the post process can be reused on the same frame. (default: false)
  24122. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24123. * @param textureType Type of textures used when performing the post process. (default: 0)
  24124. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24125. * @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
  24126. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24127. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24128. */
  24129. 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);
  24130. /**
  24131. * Gets a string identifying the name of the class
  24132. * @returns "PostProcess" string
  24133. */
  24134. getClassName(): string;
  24135. /**
  24136. * Gets the engine which this post process belongs to.
  24137. * @returns The engine the post process was enabled with.
  24138. */
  24139. getEngine(): Engine;
  24140. /**
  24141. * The effect that is created when initializing the post process.
  24142. * @returns The created effect corresponding the the postprocess.
  24143. */
  24144. getEffect(): Effect;
  24145. /**
  24146. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24147. * @param postProcess The post process to share the output with.
  24148. * @returns This post process.
  24149. */
  24150. shareOutputWith(postProcess: PostProcess): PostProcess;
  24151. /**
  24152. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24153. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24154. */
  24155. useOwnOutput(): void;
  24156. /**
  24157. * Updates the effect with the current post process compile time values and recompiles the shader.
  24158. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24159. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24160. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24161. * @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
  24162. * @param onCompiled Called when the shader has been compiled.
  24163. * @param onError Called if there is an error when compiling a shader.
  24164. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24165. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24166. */
  24167. 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;
  24168. /**
  24169. * The post process is reusable if it can be used multiple times within one frame.
  24170. * @returns If the post process is reusable
  24171. */
  24172. isReusable(): boolean;
  24173. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24174. markTextureDirty(): void;
  24175. /**
  24176. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24177. * 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.
  24178. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24179. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24180. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24181. * @returns The target texture that was bound to be written to.
  24182. */
  24183. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24184. /**
  24185. * If the post process is supported.
  24186. */
  24187. get isSupported(): boolean;
  24188. /**
  24189. * The aspect ratio of the output texture.
  24190. */
  24191. get aspectRatio(): number;
  24192. /**
  24193. * Get a value indicating if the post-process is ready to be used
  24194. * @returns true if the post-process is ready (shader is compiled)
  24195. */
  24196. isReady(): boolean;
  24197. /**
  24198. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24199. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24200. */
  24201. apply(): Nullable<Effect>;
  24202. private _disposeTextures;
  24203. /**
  24204. * Sets the required values to the prepass renderer.
  24205. * @param prePassRenderer defines the prepass renderer to setup.
  24206. * @returns true if the pre pass is needed.
  24207. */
  24208. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24209. /**
  24210. * Disposes the post process.
  24211. * @param camera The camera to dispose the post process on.
  24212. */
  24213. dispose(camera?: Camera): void;
  24214. /**
  24215. * Serializes the particle system to a JSON object
  24216. * @returns the JSON object
  24217. */
  24218. serialize(): any;
  24219. /**
  24220. * Creates a material from parsed material data
  24221. * @param parsedPostProcess defines parsed post process data
  24222. * @param scene defines the hosting scene
  24223. * @param rootUrl defines the root URL to use to load textures
  24224. * @returns a new post process
  24225. */
  24226. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24227. }
  24228. }
  24229. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24230. /** @hidden */
  24231. export var kernelBlurVaryingDeclaration: {
  24232. name: string;
  24233. shader: string;
  24234. };
  24235. }
  24236. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  24237. /** @hidden */
  24238. export var packingFunctions: {
  24239. name: string;
  24240. shader: string;
  24241. };
  24242. }
  24243. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24244. /** @hidden */
  24245. export var kernelBlurFragment: {
  24246. name: string;
  24247. shader: string;
  24248. };
  24249. }
  24250. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24251. /** @hidden */
  24252. export var kernelBlurFragment2: {
  24253. name: string;
  24254. shader: string;
  24255. };
  24256. }
  24257. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24258. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24259. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24260. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24261. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24262. /** @hidden */
  24263. export var kernelBlurPixelShader: {
  24264. name: string;
  24265. shader: string;
  24266. };
  24267. }
  24268. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24269. /** @hidden */
  24270. export var kernelBlurVertex: {
  24271. name: string;
  24272. shader: string;
  24273. };
  24274. }
  24275. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24276. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24277. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24278. /** @hidden */
  24279. export var kernelBlurVertexShader: {
  24280. name: string;
  24281. shader: string;
  24282. };
  24283. }
  24284. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24285. import { Vector2 } from "babylonjs/Maths/math.vector";
  24286. import { Nullable } from "babylonjs/types";
  24287. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24288. import { Camera } from "babylonjs/Cameras/camera";
  24289. import { Effect } from "babylonjs/Materials/effect";
  24290. import { Engine } from "babylonjs/Engines/engine";
  24291. import "babylonjs/Shaders/kernelBlur.fragment";
  24292. import "babylonjs/Shaders/kernelBlur.vertex";
  24293. import { Scene } from "babylonjs/scene";
  24294. /**
  24295. * The Blur Post Process which blurs an image based on a kernel and direction.
  24296. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24297. */
  24298. export class BlurPostProcess extends PostProcess {
  24299. private blockCompilation;
  24300. protected _kernel: number;
  24301. protected _idealKernel: number;
  24302. protected _packedFloat: boolean;
  24303. private _staticDefines;
  24304. /** The direction in which to blur the image. */
  24305. direction: Vector2;
  24306. /**
  24307. * Sets the length in pixels of the blur sample region
  24308. */
  24309. set kernel(v: number);
  24310. /**
  24311. * Gets the length in pixels of the blur sample region
  24312. */
  24313. get kernel(): number;
  24314. /**
  24315. * Sets wether or not the blur needs to unpack/repack floats
  24316. */
  24317. set packedFloat(v: boolean);
  24318. /**
  24319. * Gets wether or not the blur is unpacking/repacking floats
  24320. */
  24321. get packedFloat(): boolean;
  24322. /**
  24323. * Gets a string identifying the name of the class
  24324. * @returns "BlurPostProcess" string
  24325. */
  24326. getClassName(): string;
  24327. /**
  24328. * Creates a new instance BlurPostProcess
  24329. * @param name The name of the effect.
  24330. * @param direction The direction in which to blur the image.
  24331. * @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.
  24332. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24333. * @param camera The camera to apply the render pass to.
  24334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24335. * @param engine The engine which the post process will be applied. (default: current engine)
  24336. * @param reusable If the post process can be reused on the same frame. (default: false)
  24337. * @param textureType Type of textures used when performing the post process. (default: 0)
  24338. * @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)
  24339. */
  24340. 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);
  24341. /**
  24342. * Updates the effect with the current post process compile time values and recompiles the shader.
  24343. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24344. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24345. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24346. * @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
  24347. * @param onCompiled Called when the shader has been compiled.
  24348. * @param onError Called if there is an error when compiling a shader.
  24349. */
  24350. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24351. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24352. /**
  24353. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24354. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24355. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24356. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24357. * The gaps between physical kernels are compensated for in the weighting of the samples
  24358. * @param idealKernel Ideal blur kernel.
  24359. * @return Nearest best kernel.
  24360. */
  24361. protected _nearestBestKernel(idealKernel: number): number;
  24362. /**
  24363. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24364. * @param x The point on the Gaussian distribution to sample.
  24365. * @return the value of the Gaussian function at x.
  24366. */
  24367. protected _gaussianWeight(x: number): number;
  24368. /**
  24369. * Generates a string that can be used as a floating point number in GLSL.
  24370. * @param x Value to print.
  24371. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24372. * @return GLSL float string.
  24373. */
  24374. protected _glslFloat(x: number, decimalFigures?: number): string;
  24375. /** @hidden */
  24376. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24377. }
  24378. }
  24379. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24380. import { Scene } from "babylonjs/scene";
  24381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24382. import { Plane } from "babylonjs/Maths/math.plane";
  24383. /**
  24384. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24385. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24386. * You can then easily use it as a reflectionTexture on a flat surface.
  24387. * In case the surface is not a plane, please consider relying on reflection probes.
  24388. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24389. */
  24390. export class MirrorTexture extends RenderTargetTexture {
  24391. private scene;
  24392. /**
  24393. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24394. * 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.
  24395. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24396. */
  24397. mirrorPlane: Plane;
  24398. /**
  24399. * Define the blur ratio used to blur the reflection if needed.
  24400. */
  24401. set blurRatio(value: number);
  24402. get blurRatio(): number;
  24403. /**
  24404. * Define the adaptive blur kernel used to blur the reflection if needed.
  24405. * This will autocompute the closest best match for the `blurKernel`
  24406. */
  24407. set adaptiveBlurKernel(value: number);
  24408. /**
  24409. * Define the blur kernel used to blur the reflection if needed.
  24410. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24411. */
  24412. set blurKernel(value: number);
  24413. /**
  24414. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24415. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24416. */
  24417. set blurKernelX(value: number);
  24418. get blurKernelX(): number;
  24419. /**
  24420. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24421. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24422. */
  24423. set blurKernelY(value: number);
  24424. get blurKernelY(): number;
  24425. private _autoComputeBlurKernel;
  24426. protected _onRatioRescale(): void;
  24427. private _updateGammaSpace;
  24428. private _imageProcessingConfigChangeObserver;
  24429. private _transformMatrix;
  24430. private _mirrorMatrix;
  24431. private _savedViewMatrix;
  24432. private _blurX;
  24433. private _blurY;
  24434. private _adaptiveBlurKernel;
  24435. private _blurKernelX;
  24436. private _blurKernelY;
  24437. private _blurRatio;
  24438. /**
  24439. * Instantiates a Mirror Texture.
  24440. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24441. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24442. * You can then easily use it as a reflectionTexture on a flat surface.
  24443. * In case the surface is not a plane, please consider relying on reflection probes.
  24444. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24445. * @param name
  24446. * @param size
  24447. * @param scene
  24448. * @param generateMipMaps
  24449. * @param type
  24450. * @param samplingMode
  24451. * @param generateDepthBuffer
  24452. */
  24453. constructor(name: string, size: number | {
  24454. width: number;
  24455. height: number;
  24456. } | {
  24457. ratio: number;
  24458. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24459. private _preparePostProcesses;
  24460. /**
  24461. * Clone the mirror texture.
  24462. * @returns the cloned texture
  24463. */
  24464. clone(): MirrorTexture;
  24465. /**
  24466. * Serialize the texture to a JSON representation you could use in Parse later on
  24467. * @returns the serialized JSON representation
  24468. */
  24469. serialize(): any;
  24470. /**
  24471. * Dispose the texture and release its associated resources.
  24472. */
  24473. dispose(): void;
  24474. }
  24475. }
  24476. declare module "babylonjs/Materials/Textures/texture" {
  24477. import { Observable } from "babylonjs/Misc/observable";
  24478. import { Nullable } from "babylonjs/types";
  24479. import { Matrix } from "babylonjs/Maths/math.vector";
  24480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24481. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24482. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24483. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24484. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24485. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24486. import { Scene } from "babylonjs/scene";
  24487. /**
  24488. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24489. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24490. */
  24491. export class Texture extends BaseTexture {
  24492. /**
  24493. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24494. */
  24495. static SerializeBuffers: boolean;
  24496. /**
  24497. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24498. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24499. */
  24500. static ForceSerializeBuffers: boolean;
  24501. /** @hidden */
  24502. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24503. /** @hidden */
  24504. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24505. /** @hidden */
  24506. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24507. /** nearest is mag = nearest and min = nearest and mip = linear */
  24508. static readonly NEAREST_SAMPLINGMODE: number;
  24509. /** nearest is mag = nearest and min = nearest and mip = linear */
  24510. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24511. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24512. static readonly BILINEAR_SAMPLINGMODE: number;
  24513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24514. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24515. /** Trilinear is mag = linear and min = linear and mip = linear */
  24516. static readonly TRILINEAR_SAMPLINGMODE: number;
  24517. /** Trilinear is mag = linear and min = linear and mip = linear */
  24518. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24519. /** mag = nearest and min = nearest and mip = nearest */
  24520. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24521. /** mag = nearest and min = linear and mip = nearest */
  24522. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24523. /** mag = nearest and min = linear and mip = linear */
  24524. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24525. /** mag = nearest and min = linear and mip = none */
  24526. static readonly NEAREST_LINEAR: number;
  24527. /** mag = nearest and min = nearest and mip = none */
  24528. static readonly NEAREST_NEAREST: number;
  24529. /** mag = linear and min = nearest and mip = nearest */
  24530. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24531. /** mag = linear and min = nearest and mip = linear */
  24532. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24533. /** mag = linear and min = linear and mip = none */
  24534. static readonly LINEAR_LINEAR: number;
  24535. /** mag = linear and min = nearest and mip = none */
  24536. static readonly LINEAR_NEAREST: number;
  24537. /** Explicit coordinates mode */
  24538. static readonly EXPLICIT_MODE: number;
  24539. /** Spherical coordinates mode */
  24540. static readonly SPHERICAL_MODE: number;
  24541. /** Planar coordinates mode */
  24542. static readonly PLANAR_MODE: number;
  24543. /** Cubic coordinates mode */
  24544. static readonly CUBIC_MODE: number;
  24545. /** Projection coordinates mode */
  24546. static readonly PROJECTION_MODE: number;
  24547. /** Inverse Cubic coordinates mode */
  24548. static readonly SKYBOX_MODE: number;
  24549. /** Inverse Cubic coordinates mode */
  24550. static readonly INVCUBIC_MODE: number;
  24551. /** Equirectangular coordinates mode */
  24552. static readonly EQUIRECTANGULAR_MODE: number;
  24553. /** Equirectangular Fixed coordinates mode */
  24554. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24555. /** Equirectangular Fixed Mirrored coordinates mode */
  24556. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24557. /** Texture is not repeating outside of 0..1 UVs */
  24558. static readonly CLAMP_ADDRESSMODE: number;
  24559. /** Texture is repeating outside of 0..1 UVs */
  24560. static readonly WRAP_ADDRESSMODE: number;
  24561. /** Texture is repeating and mirrored */
  24562. static readonly MIRROR_ADDRESSMODE: number;
  24563. /**
  24564. * 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
  24565. */
  24566. static UseSerializedUrlIfAny: boolean;
  24567. /**
  24568. * Define the url of the texture.
  24569. */
  24570. url: Nullable<string>;
  24571. /**
  24572. * Define an offset on the texture to offset the u coordinates of the UVs
  24573. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24574. */
  24575. uOffset: number;
  24576. /**
  24577. * Define an offset on the texture to offset the v coordinates of the UVs
  24578. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24579. */
  24580. vOffset: number;
  24581. /**
  24582. * Define an offset on the texture to scale the u coordinates of the UVs
  24583. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24584. */
  24585. uScale: number;
  24586. /**
  24587. * Define an offset on the texture to scale the v coordinates of the UVs
  24588. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24589. */
  24590. vScale: number;
  24591. /**
  24592. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24593. * @see https://doc.babylonjs.com/how_to/more_materials
  24594. */
  24595. uAng: number;
  24596. /**
  24597. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24598. * @see https://doc.babylonjs.com/how_to/more_materials
  24599. */
  24600. vAng: number;
  24601. /**
  24602. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24603. * @see https://doc.babylonjs.com/how_to/more_materials
  24604. */
  24605. wAng: number;
  24606. /**
  24607. * Defines the center of rotation (U)
  24608. */
  24609. uRotationCenter: number;
  24610. /**
  24611. * Defines the center of rotation (V)
  24612. */
  24613. vRotationCenter: number;
  24614. /**
  24615. * Defines the center of rotation (W)
  24616. */
  24617. wRotationCenter: number;
  24618. /**
  24619. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24620. */
  24621. homogeneousRotationInUVTransform: boolean;
  24622. /**
  24623. * Are mip maps generated for this texture or not.
  24624. */
  24625. get noMipmap(): boolean;
  24626. /**
  24627. * List of inspectable custom properties (used by the Inspector)
  24628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24629. */
  24630. inspectableCustomProperties: Nullable<IInspectable[]>;
  24631. private _noMipmap;
  24632. /** @hidden */
  24633. _invertY: boolean;
  24634. private _rowGenerationMatrix;
  24635. private _cachedTextureMatrix;
  24636. private _projectionModeMatrix;
  24637. private _t0;
  24638. private _t1;
  24639. private _t2;
  24640. private _cachedUOffset;
  24641. private _cachedVOffset;
  24642. private _cachedUScale;
  24643. private _cachedVScale;
  24644. private _cachedUAng;
  24645. private _cachedVAng;
  24646. private _cachedWAng;
  24647. private _cachedProjectionMatrixId;
  24648. private _cachedURotationCenter;
  24649. private _cachedVRotationCenter;
  24650. private _cachedWRotationCenter;
  24651. private _cachedHomogeneousRotationInUVTransform;
  24652. private _cachedCoordinatesMode;
  24653. /** @hidden */
  24654. protected _initialSamplingMode: number;
  24655. /** @hidden */
  24656. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24657. private _deleteBuffer;
  24658. protected _format: Nullable<number>;
  24659. private _delayedOnLoad;
  24660. private _delayedOnError;
  24661. private _mimeType?;
  24662. private _loaderOptions?;
  24663. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24664. get mimeType(): string | undefined;
  24665. /**
  24666. * Observable triggered once the texture has been loaded.
  24667. */
  24668. onLoadObservable: Observable<Texture>;
  24669. protected _isBlocking: boolean;
  24670. /**
  24671. * Is the texture preventing material to render while loading.
  24672. * If false, a default texture will be used instead of the loading one during the preparation step.
  24673. */
  24674. set isBlocking(value: boolean);
  24675. get isBlocking(): boolean;
  24676. /**
  24677. * Get the current sampling mode associated with the texture.
  24678. */
  24679. get samplingMode(): number;
  24680. /**
  24681. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24682. */
  24683. get invertY(): boolean;
  24684. /**
  24685. * Instantiates a new texture.
  24686. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24687. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24688. * @param url defines the url of the picture to load as a texture
  24689. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24690. * @param noMipmap defines if the texture will require mip maps or not
  24691. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24692. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24693. * @param onLoad defines a callback triggered when the texture has been loaded
  24694. * @param onError defines a callback triggered when an error occurred during the loading session
  24695. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24696. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24697. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24698. * @param mimeType defines an optional mime type information
  24699. * @param loaderOptions options to be passed to the loader
  24700. */
  24701. 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);
  24702. /**
  24703. * Update the url (and optional buffer) of this texture if url was null during construction.
  24704. * @param url the url of the texture
  24705. * @param buffer the buffer of the texture (defaults to null)
  24706. * @param onLoad callback called when the texture is loaded (defaults to null)
  24707. */
  24708. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24709. /**
  24710. * Finish the loading sequence of a texture flagged as delayed load.
  24711. * @hidden
  24712. */
  24713. delayLoad(): void;
  24714. private _prepareRowForTextureGeneration;
  24715. /**
  24716. * Checks if the texture has the same transform matrix than another texture
  24717. * @param texture texture to check against
  24718. * @returns true if the transforms are the same, else false
  24719. */
  24720. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24721. /**
  24722. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24723. * @returns the transform matrix of the texture.
  24724. */
  24725. getTextureMatrix(uBase?: number): Matrix;
  24726. /**
  24727. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24728. * @returns The reflection texture transform
  24729. */
  24730. getReflectionTextureMatrix(): Matrix;
  24731. /**
  24732. * Clones the texture.
  24733. * @returns the cloned texture
  24734. */
  24735. clone(): Texture;
  24736. /**
  24737. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24738. * @returns The JSON representation of the texture
  24739. */
  24740. serialize(): any;
  24741. /**
  24742. * Get the current class name of the texture useful for serialization or dynamic coding.
  24743. * @returns "Texture"
  24744. */
  24745. getClassName(): string;
  24746. /**
  24747. * Dispose the texture and release its associated resources.
  24748. */
  24749. dispose(): void;
  24750. /**
  24751. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24752. * @param parsedTexture Define the JSON representation of the texture
  24753. * @param scene Define the scene the parsed texture should be instantiated in
  24754. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24755. * @returns The parsed texture if successful
  24756. */
  24757. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24758. /**
  24759. * Creates a texture from its base 64 representation.
  24760. * @param data Define the base64 payload without the data: prefix
  24761. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24762. * @param scene Define the scene the texture should belong to
  24763. * @param noMipmap Forces the texture to not create mip map information if true
  24764. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24765. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24766. * @param onLoad define a callback triggered when the texture has been loaded
  24767. * @param onError define a callback triggered when an error occurred during the loading session
  24768. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24769. * @returns the created texture
  24770. */
  24771. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24772. /**
  24773. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24774. * @param data Define the base64 payload without the data: prefix
  24775. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24776. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24777. * @param scene Define the scene the texture should belong to
  24778. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24779. * @param noMipmap Forces the texture to not create mip map information if true
  24780. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24781. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24782. * @param onLoad define a callback triggered when the texture has been loaded
  24783. * @param onError define a callback triggered when an error occurred during the loading session
  24784. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24785. * @returns the created texture
  24786. */
  24787. 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;
  24788. }
  24789. }
  24790. declare module "babylonjs/Sprites/thinSprite" {
  24791. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24792. import { Nullable } from "babylonjs/types";
  24793. /**
  24794. * ThinSprite Class used to represent a thin sprite
  24795. * This is the base class for sprites but can also directly be used with ThinEngine
  24796. * @see https://doc.babylonjs.com/babylon101/sprites
  24797. */
  24798. export class ThinSprite {
  24799. /** Gets or sets the cell index in the sprite sheet */
  24800. cellIndex: number;
  24801. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24802. cellRef: string;
  24803. /** Gets or sets the current world position */
  24804. position: IVector3Like;
  24805. /** Gets or sets the main color */
  24806. color: IColor4Like;
  24807. /** Gets or sets the width */
  24808. width: number;
  24809. /** Gets or sets the height */
  24810. height: number;
  24811. /** Gets or sets rotation angle */
  24812. angle: number;
  24813. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24814. invertU: boolean;
  24815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24816. invertV: boolean;
  24817. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24818. isVisible: boolean;
  24819. /**
  24820. * Returns a boolean indicating if the animation is started
  24821. */
  24822. get animationStarted(): boolean;
  24823. /** Gets the initial key for the animation (setting it will restart the animation) */
  24824. get fromIndex(): number;
  24825. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24826. get toIndex(): number;
  24827. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24828. get loopAnimation(): boolean;
  24829. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24830. get delay(): number;
  24831. /** @hidden */
  24832. _xOffset: number;
  24833. /** @hidden */
  24834. _yOffset: number;
  24835. /** @hidden */
  24836. _xSize: number;
  24837. /** @hidden */
  24838. _ySize: number;
  24839. private _animationStarted;
  24840. protected _loopAnimation: boolean;
  24841. protected _fromIndex: number;
  24842. protected _toIndex: number;
  24843. protected _delay: number;
  24844. private _direction;
  24845. private _time;
  24846. private _onBaseAnimationEnd;
  24847. /**
  24848. * Creates a new Thin Sprite
  24849. */
  24850. constructor();
  24851. /**
  24852. * Starts an animation
  24853. * @param from defines the initial key
  24854. * @param to defines the end key
  24855. * @param loop defines if the animation must loop
  24856. * @param delay defines the start delay (in ms)
  24857. * @param onAnimationEnd defines a callback for when the animation ends
  24858. */
  24859. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24860. /** Stops current animation (if any) */
  24861. stopAnimation(): void;
  24862. /** @hidden */
  24863. _animate(deltaTime: number): void;
  24864. }
  24865. }
  24866. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24867. /** @hidden */
  24868. export var imageProcessingCompatibility: {
  24869. name: string;
  24870. shader: string;
  24871. };
  24872. }
  24873. declare module "babylonjs/Shaders/sprites.fragment" {
  24874. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24875. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24876. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24877. /** @hidden */
  24878. export var spritesPixelShader: {
  24879. name: string;
  24880. shader: string;
  24881. };
  24882. }
  24883. declare module "babylonjs/Shaders/sprites.vertex" {
  24884. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24885. /** @hidden */
  24886. export var spritesVertexShader: {
  24887. name: string;
  24888. shader: string;
  24889. };
  24890. }
  24891. declare module "babylonjs/Sprites/spriteRenderer" {
  24892. import { Nullable } from "babylonjs/types";
  24893. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24894. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24895. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24896. import { ISize } from "babylonjs/Maths/math.size";
  24897. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24898. import { Scene } from "babylonjs/scene";
  24899. import "babylonjs/Engines/Extensions/engine.alpha";
  24900. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24901. import "babylonjs/Shaders/sprites.fragment";
  24902. import "babylonjs/Shaders/sprites.vertex";
  24903. /**
  24904. * Class used to render sprites.
  24905. *
  24906. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24907. */
  24908. export class SpriteRenderer {
  24909. /**
  24910. * Defines the texture of the spritesheet
  24911. */
  24912. texture: Nullable<ThinTexture>;
  24913. /**
  24914. * Defines the default width of a cell in the spritesheet
  24915. */
  24916. cellWidth: number;
  24917. /**
  24918. * Defines the default height of a cell in the spritesheet
  24919. */
  24920. cellHeight: number;
  24921. /**
  24922. * Blend mode use to render the particle, it can be any of
  24923. * the static Constants.ALPHA_x properties provided in this class.
  24924. * Default value is Constants.ALPHA_COMBINE
  24925. */
  24926. blendMode: number;
  24927. /**
  24928. * Gets or sets a boolean indicating if alpha mode is automatically
  24929. * reset.
  24930. */
  24931. autoResetAlpha: boolean;
  24932. /**
  24933. * Disables writing to the depth buffer when rendering the sprites.
  24934. * It can be handy to disable depth writing when using textures without alpha channel
  24935. * and setting some specific blend modes.
  24936. */
  24937. disableDepthWrite: boolean;
  24938. /**
  24939. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24940. */
  24941. fogEnabled: boolean;
  24942. /**
  24943. * Gets the capacity of the manager
  24944. */
  24945. get capacity(): number;
  24946. private readonly _engine;
  24947. private readonly _useVAO;
  24948. private readonly _useInstancing;
  24949. private readonly _scene;
  24950. private readonly _capacity;
  24951. private readonly _epsilon;
  24952. private _vertexBufferSize;
  24953. private _vertexData;
  24954. private _buffer;
  24955. private _vertexBuffers;
  24956. private _spriteBuffer;
  24957. private _indexBuffer;
  24958. private _effectBase;
  24959. private _effectFog;
  24960. private _vertexArrayObject;
  24961. /**
  24962. * Creates a new sprite Renderer
  24963. * @param engine defines the engine the renderer works with
  24964. * @param capacity defines the maximum allowed number of sprites
  24965. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24966. * @param scene defines the hosting scene
  24967. */
  24968. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24969. /**
  24970. * Render all child sprites
  24971. * @param sprites defines the list of sprites to render
  24972. * @param deltaTime defines the time since last frame
  24973. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24974. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24975. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24976. */
  24977. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24978. private _appendSpriteVertex;
  24979. /**
  24980. * Release associated resources
  24981. */
  24982. dispose(): void;
  24983. }
  24984. }
  24985. declare module "babylonjs/Sprites/spriteManager" {
  24986. import { IDisposable, Scene } from "babylonjs/scene";
  24987. import { Nullable } from "babylonjs/types";
  24988. import { Observable } from "babylonjs/Misc/observable";
  24989. import { Sprite } from "babylonjs/Sprites/sprite";
  24990. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24991. import { Camera } from "babylonjs/Cameras/camera";
  24992. import { Texture } from "babylonjs/Materials/Textures/texture";
  24993. import { Ray } from "babylonjs/Culling/ray";
  24994. /**
  24995. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24996. */
  24997. export interface ISpriteManager extends IDisposable {
  24998. /**
  24999. * Gets manager's name
  25000. */
  25001. name: string;
  25002. /**
  25003. * Restricts the camera to viewing objects with the same layerMask.
  25004. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  25005. */
  25006. layerMask: number;
  25007. /**
  25008. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25009. */
  25010. isPickable: boolean;
  25011. /**
  25012. * Gets the hosting scene
  25013. */
  25014. scene: Scene;
  25015. /**
  25016. * Specifies the rendering group id for this mesh (0 by default)
  25017. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25018. */
  25019. renderingGroupId: number;
  25020. /**
  25021. * Defines the list of sprites managed by the manager.
  25022. */
  25023. sprites: Array<Sprite>;
  25024. /**
  25025. * Gets or sets the spritesheet texture
  25026. */
  25027. texture: Texture;
  25028. /** Defines the default width of a cell in the spritesheet */
  25029. cellWidth: number;
  25030. /** Defines the default height of a cell in the spritesheet */
  25031. cellHeight: number;
  25032. /**
  25033. * Tests the intersection of a sprite with a specific ray.
  25034. * @param ray The ray we are sending to test the collision
  25035. * @param camera The camera space we are sending rays in
  25036. * @param predicate A predicate allowing excluding sprites from the list of object to test
  25037. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25038. * @returns picking info or null.
  25039. */
  25040. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25041. /**
  25042. * Intersects the sprites with a ray
  25043. * @param ray defines the ray to intersect with
  25044. * @param camera defines the current active camera
  25045. * @param predicate defines a predicate used to select candidate sprites
  25046. * @returns null if no hit or a PickingInfo array
  25047. */
  25048. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25049. /**
  25050. * Renders the list of sprites on screen.
  25051. */
  25052. render(): void;
  25053. }
  25054. /**
  25055. * Class used to manage multiple sprites on the same spritesheet
  25056. * @see https://doc.babylonjs.com/babylon101/sprites
  25057. */
  25058. export class SpriteManager implements ISpriteManager {
  25059. /** defines the manager's name */
  25060. name: string;
  25061. /** Define the Url to load snippets */
  25062. static SnippetUrl: string;
  25063. /** Snippet ID if the manager was created from the snippet server */
  25064. snippetId: string;
  25065. /** Gets the list of sprites */
  25066. sprites: Sprite[];
  25067. /** Gets or sets the rendering group id (0 by default) */
  25068. renderingGroupId: number;
  25069. /** Gets or sets camera layer mask */
  25070. layerMask: number;
  25071. /** Gets or sets a boolean indicating if the sprites are pickable */
  25072. isPickable: boolean;
  25073. /**
  25074. * An event triggered when the manager is disposed.
  25075. */
  25076. onDisposeObservable: Observable<SpriteManager>;
  25077. /**
  25078. * Callback called when the manager is disposed
  25079. */
  25080. set onDispose(callback: () => void);
  25081. /**
  25082. * Gets or sets the unique id of the sprite
  25083. */
  25084. uniqueId: number;
  25085. /**
  25086. * Gets the array of sprites
  25087. */
  25088. get children(): Sprite[];
  25089. /**
  25090. * Gets the hosting scene
  25091. */
  25092. get scene(): Scene;
  25093. /**
  25094. * Gets the capacity of the manager
  25095. */
  25096. get capacity(): number;
  25097. /**
  25098. * Gets or sets the spritesheet texture
  25099. */
  25100. get texture(): Texture;
  25101. set texture(value: Texture);
  25102. /** Defines the default width of a cell in the spritesheet */
  25103. get cellWidth(): number;
  25104. set cellWidth(value: number);
  25105. /** Defines the default height of a cell in the spritesheet */
  25106. get cellHeight(): number;
  25107. set cellHeight(value: number);
  25108. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  25109. get fogEnabled(): boolean;
  25110. set fogEnabled(value: boolean);
  25111. /**
  25112. * Blend mode use to render the particle, it can be any of
  25113. * the static Constants.ALPHA_x properties provided in this class.
  25114. * Default value is Constants.ALPHA_COMBINE
  25115. */
  25116. get blendMode(): number;
  25117. set blendMode(blendMode: number);
  25118. /** Disables writing to the depth buffer when rendering the sprites.
  25119. * It can be handy to disable depth writing when using textures without alpha channel
  25120. * and setting some specific blend modes.
  25121. */
  25122. disableDepthWrite: boolean;
  25123. private _spriteRenderer;
  25124. /** Associative array from JSON sprite data file */
  25125. private _cellData;
  25126. /** Array of sprite names from JSON sprite data file */
  25127. private _spriteMap;
  25128. /** True when packed cell data from JSON file is ready*/
  25129. private _packedAndReady;
  25130. private _textureContent;
  25131. private _onDisposeObserver;
  25132. private _fromPacked;
  25133. private _scene;
  25134. /**
  25135. * Creates a new sprite manager
  25136. * @param name defines the manager's name
  25137. * @param imgUrl defines the sprite sheet url
  25138. * @param capacity defines the maximum allowed number of sprites
  25139. * @param cellSize defines the size of a sprite cell
  25140. * @param scene defines the hosting scene
  25141. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25142. * @param samplingMode defines the smapling mode to use with spritesheet
  25143. * @param fromPacked set to false; do not alter
  25144. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  25145. */
  25146. constructor(
  25147. /** defines the manager's name */
  25148. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  25149. /**
  25150. * Returns the string "SpriteManager"
  25151. * @returns "SpriteManager"
  25152. */
  25153. getClassName(): string;
  25154. private _makePacked;
  25155. private _checkTextureAlpha;
  25156. /**
  25157. * Intersects the sprites with a ray
  25158. * @param ray defines the ray to intersect with
  25159. * @param camera defines the current active camera
  25160. * @param predicate defines a predicate used to select candidate sprites
  25161. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  25162. * @returns null if no hit or a PickingInfo
  25163. */
  25164. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25165. /**
  25166. * Intersects the sprites with a ray
  25167. * @param ray defines the ray to intersect with
  25168. * @param camera defines the current active camera
  25169. * @param predicate defines a predicate used to select candidate sprites
  25170. * @returns null if no hit or a PickingInfo array
  25171. */
  25172. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25173. /**
  25174. * Render all child sprites
  25175. */
  25176. render(): void;
  25177. private _customUpdate;
  25178. /**
  25179. * Release associated resources
  25180. */
  25181. dispose(): void;
  25182. /**
  25183. * Serializes the sprite manager to a JSON object
  25184. * @param serializeTexture defines if the texture must be serialized as well
  25185. * @returns the JSON object
  25186. */
  25187. serialize(serializeTexture?: boolean): any;
  25188. /**
  25189. * Parses a JSON object to create a new sprite manager.
  25190. * @param parsedManager The JSON object to parse
  25191. * @param scene The scene to create the sprite managerin
  25192. * @param rootUrl The root url to use to load external dependencies like texture
  25193. * @returns the new sprite manager
  25194. */
  25195. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  25196. /**
  25197. * Creates a sprite manager from a snippet saved in a remote file
  25198. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  25199. * @param url defines the url to load from
  25200. * @param scene defines the hosting scene
  25201. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25202. * @returns a promise that will resolve to the new sprite manager
  25203. */
  25204. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25205. /**
  25206. * Creates a sprite manager from a snippet saved by the sprite editor
  25207. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  25208. * @param scene defines the hosting scene
  25209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25210. * @returns a promise that will resolve to the new sprite manager
  25211. */
  25212. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25213. }
  25214. }
  25215. declare module "babylonjs/Sprites/sprite" {
  25216. import { Vector3 } from "babylonjs/Maths/math.vector";
  25217. import { Nullable } from "babylonjs/types";
  25218. import { ActionManager } from "babylonjs/Actions/actionManager";
  25219. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  25220. import { Color4 } from "babylonjs/Maths/math.color";
  25221. import { Observable } from "babylonjs/Misc/observable";
  25222. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25223. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25224. import { Animation } from "babylonjs/Animations/animation";
  25225. /**
  25226. * Class used to represent a sprite
  25227. * @see https://doc.babylonjs.com/babylon101/sprites
  25228. */
  25229. export class Sprite extends ThinSprite implements IAnimatable {
  25230. /** defines the name */
  25231. name: string;
  25232. /** Gets or sets the current world position */
  25233. position: Vector3;
  25234. /** Gets or sets the main color */
  25235. color: Color4;
  25236. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  25237. disposeWhenFinishedAnimating: boolean;
  25238. /** Gets the list of attached animations */
  25239. animations: Nullable<Array<Animation>>;
  25240. /** Gets or sets a boolean indicating if the sprite can be picked */
  25241. isPickable: boolean;
  25242. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  25243. useAlphaForPicking: boolean;
  25244. /**
  25245. * Gets or sets the associated action manager
  25246. */
  25247. actionManager: Nullable<ActionManager>;
  25248. /**
  25249. * An event triggered when the control has been disposed
  25250. */
  25251. onDisposeObservable: Observable<Sprite>;
  25252. private _manager;
  25253. private _onAnimationEnd;
  25254. /**
  25255. * Gets or sets the sprite size
  25256. */
  25257. get size(): number;
  25258. set size(value: number);
  25259. /**
  25260. * Gets or sets the unique id of the sprite
  25261. */
  25262. uniqueId: number;
  25263. /**
  25264. * Gets the manager of this sprite
  25265. */
  25266. get manager(): ISpriteManager;
  25267. /**
  25268. * Creates a new Sprite
  25269. * @param name defines the name
  25270. * @param manager defines the manager
  25271. */
  25272. constructor(
  25273. /** defines the name */
  25274. name: string, manager: ISpriteManager);
  25275. /**
  25276. * Returns the string "Sprite"
  25277. * @returns "Sprite"
  25278. */
  25279. getClassName(): string;
  25280. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  25281. get fromIndex(): number;
  25282. set fromIndex(value: number);
  25283. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  25284. get toIndex(): number;
  25285. set toIndex(value: number);
  25286. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  25287. get loopAnimation(): boolean;
  25288. set loopAnimation(value: boolean);
  25289. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  25290. get delay(): number;
  25291. set delay(value: number);
  25292. /**
  25293. * Starts an animation
  25294. * @param from defines the initial key
  25295. * @param to defines the end key
  25296. * @param loop defines if the animation must loop
  25297. * @param delay defines the start delay (in ms)
  25298. * @param onAnimationEnd defines a callback to call when animation ends
  25299. */
  25300. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  25301. private _endAnimation;
  25302. /** Release associated resources */
  25303. dispose(): void;
  25304. /**
  25305. * Serializes the sprite to a JSON object
  25306. * @returns the JSON object
  25307. */
  25308. serialize(): any;
  25309. /**
  25310. * Parses a JSON object to create a new sprite
  25311. * @param parsedSprite The JSON object to parse
  25312. * @param manager defines the hosting manager
  25313. * @returns the new sprite
  25314. */
  25315. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  25316. }
  25317. }
  25318. declare module "babylonjs/Collisions/pickingInfo" {
  25319. import { Nullable } from "babylonjs/types";
  25320. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25322. import { Sprite } from "babylonjs/Sprites/sprite";
  25323. import { Ray } from "babylonjs/Culling/ray";
  25324. /**
  25325. * Information about the result of picking within a scene
  25326. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  25327. */
  25328. export class PickingInfo {
  25329. /** @hidden */
  25330. _pickingUnavailable: boolean;
  25331. /**
  25332. * If the pick collided with an object
  25333. */
  25334. hit: boolean;
  25335. /**
  25336. * Distance away where the pick collided
  25337. */
  25338. distance: number;
  25339. /**
  25340. * The location of pick collision
  25341. */
  25342. pickedPoint: Nullable<Vector3>;
  25343. /**
  25344. * The mesh corresponding the the pick collision
  25345. */
  25346. pickedMesh: Nullable<AbstractMesh>;
  25347. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  25348. bu: number;
  25349. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  25350. bv: number;
  25351. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25352. faceId: number;
  25353. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25354. subMeshFaceId: number;
  25355. /** Id of the the submesh that was picked */
  25356. subMeshId: number;
  25357. /** If a sprite was picked, this will be the sprite the pick collided with */
  25358. pickedSprite: Nullable<Sprite>;
  25359. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  25360. thinInstanceIndex: number;
  25361. /**
  25362. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  25363. */
  25364. originMesh: Nullable<AbstractMesh>;
  25365. /**
  25366. * The ray that was used to perform the picking.
  25367. */
  25368. ray: Nullable<Ray>;
  25369. /**
  25370. * Gets the normal correspodning to the face the pick collided with
  25371. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25372. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25373. * @returns The normal correspodning to the face the pick collided with
  25374. */
  25375. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25376. /**
  25377. * Gets the texture coordinates of where the pick occured
  25378. * @returns the vector containing the coordnates of the texture
  25379. */
  25380. getTextureCoordinates(): Nullable<Vector2>;
  25381. }
  25382. }
  25383. declare module "babylonjs/Events/pointerEvents" {
  25384. import { Nullable } from "babylonjs/types";
  25385. import { Vector2 } from "babylonjs/Maths/math.vector";
  25386. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25387. import { Ray } from "babylonjs/Culling/ray";
  25388. /**
  25389. * Gather the list of pointer event types as constants.
  25390. */
  25391. export class PointerEventTypes {
  25392. /**
  25393. * 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.
  25394. */
  25395. static readonly POINTERDOWN: number;
  25396. /**
  25397. * The pointerup event is fired when a pointer is no longer active.
  25398. */
  25399. static readonly POINTERUP: number;
  25400. /**
  25401. * The pointermove event is fired when a pointer changes coordinates.
  25402. */
  25403. static readonly POINTERMOVE: number;
  25404. /**
  25405. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25406. */
  25407. static readonly POINTERWHEEL: number;
  25408. /**
  25409. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25410. */
  25411. static readonly POINTERPICK: number;
  25412. /**
  25413. * The pointertap event is fired when a the object has been touched and released without drag.
  25414. */
  25415. static readonly POINTERTAP: number;
  25416. /**
  25417. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25418. */
  25419. static readonly POINTERDOUBLETAP: number;
  25420. }
  25421. /**
  25422. * Base class of pointer info types.
  25423. */
  25424. export class PointerInfoBase {
  25425. /**
  25426. * Defines the type of event (PointerEventTypes)
  25427. */
  25428. type: number;
  25429. /**
  25430. * Defines the related dom event
  25431. */
  25432. event: PointerEvent | MouseWheelEvent;
  25433. /**
  25434. * Instantiates the base class of pointers info.
  25435. * @param type Defines the type of event (PointerEventTypes)
  25436. * @param event Defines the related dom event
  25437. */
  25438. constructor(
  25439. /**
  25440. * Defines the type of event (PointerEventTypes)
  25441. */
  25442. type: number,
  25443. /**
  25444. * Defines the related dom event
  25445. */
  25446. event: PointerEvent | MouseWheelEvent);
  25447. }
  25448. /**
  25449. * This class is used to store pointer related info for the onPrePointerObservable event.
  25450. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25451. */
  25452. export class PointerInfoPre extends PointerInfoBase {
  25453. /**
  25454. * Ray from a pointer if availible (eg. 6dof controller)
  25455. */
  25456. ray: Nullable<Ray>;
  25457. /**
  25458. * Defines the local position of the pointer on the canvas.
  25459. */
  25460. localPosition: Vector2;
  25461. /**
  25462. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25463. */
  25464. skipOnPointerObservable: boolean;
  25465. /**
  25466. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25467. * @param type Defines the type of event (PointerEventTypes)
  25468. * @param event Defines the related dom event
  25469. * @param localX Defines the local x coordinates of the pointer when the event occured
  25470. * @param localY Defines the local y coordinates of the pointer when the event occured
  25471. */
  25472. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  25473. }
  25474. /**
  25475. * This type contains all the data related to a pointer event in Babylon.js.
  25476. * 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.
  25477. */
  25478. export class PointerInfo extends PointerInfoBase {
  25479. /**
  25480. * Defines the picking info associated to the info (if any)\
  25481. */
  25482. pickInfo: Nullable<PickingInfo>;
  25483. /**
  25484. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25485. * @param type Defines the type of event (PointerEventTypes)
  25486. * @param event Defines the related dom event
  25487. * @param pickInfo Defines the picking info associated to the info (if any)\
  25488. */
  25489. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  25490. /**
  25491. * Defines the picking info associated to the info (if any)\
  25492. */
  25493. pickInfo: Nullable<PickingInfo>);
  25494. }
  25495. /**
  25496. * Data relating to a touch event on the screen.
  25497. */
  25498. export interface PointerTouch {
  25499. /**
  25500. * X coordinate of touch.
  25501. */
  25502. x: number;
  25503. /**
  25504. * Y coordinate of touch.
  25505. */
  25506. y: number;
  25507. /**
  25508. * Id of touch. Unique for each finger.
  25509. */
  25510. pointerId: number;
  25511. /**
  25512. * Event type passed from DOM.
  25513. */
  25514. type: any;
  25515. }
  25516. }
  25517. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  25518. import { Observable } from "babylonjs/Misc/observable";
  25519. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25520. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25521. /**
  25522. * Manage the mouse inputs to control the movement of a free camera.
  25523. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25524. */
  25525. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25526. /**
  25527. * Define if touch is enabled in the mouse input
  25528. */
  25529. touchEnabled: boolean;
  25530. /**
  25531. * Defines the camera the input is attached to.
  25532. */
  25533. camera: FreeCamera;
  25534. /**
  25535. * Defines the buttons associated with the input to handle camera move.
  25536. */
  25537. buttons: number[];
  25538. /**
  25539. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25540. */
  25541. angularSensibility: number;
  25542. private _pointerInput;
  25543. private _onMouseMove;
  25544. private _observer;
  25545. private previousPosition;
  25546. /**
  25547. * Observable for when a pointer move event occurs containing the move offset
  25548. */
  25549. onPointerMovedObservable: Observable<{
  25550. offsetX: number;
  25551. offsetY: number;
  25552. }>;
  25553. /**
  25554. * @hidden
  25555. * If the camera should be rotated automatically based on pointer movement
  25556. */
  25557. _allowCameraRotation: boolean;
  25558. /**
  25559. * Manage the mouse inputs to control the movement of a free camera.
  25560. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25561. * @param touchEnabled Defines if touch is enabled or not
  25562. */
  25563. constructor(
  25564. /**
  25565. * Define if touch is enabled in the mouse input
  25566. */
  25567. touchEnabled?: boolean);
  25568. /**
  25569. * Attach the input controls to a specific dom element to get the input from.
  25570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25571. */
  25572. attachControl(noPreventDefault?: boolean): void;
  25573. /**
  25574. * Called on JS contextmenu event.
  25575. * Override this method to provide functionality.
  25576. */
  25577. protected onContextMenu(evt: PointerEvent): void;
  25578. /**
  25579. * Detach the current controls from the specified dom element.
  25580. */
  25581. detachControl(): void;
  25582. /**
  25583. * Gets the class name of the current intput.
  25584. * @returns the class name
  25585. */
  25586. getClassName(): string;
  25587. /**
  25588. * Get the friendly name associated with the input class.
  25589. * @returns the input friendly name
  25590. */
  25591. getSimpleName(): string;
  25592. }
  25593. }
  25594. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  25595. import { Observable } from "babylonjs/Misc/observable";
  25596. import { Camera } from "babylonjs/Cameras/camera";
  25597. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25598. /**
  25599. * Base class for mouse wheel input..
  25600. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25601. * for example usage.
  25602. */
  25603. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25604. /**
  25605. * Defines the camera the input is attached to.
  25606. */
  25607. abstract camera: Camera;
  25608. /**
  25609. * How fast is the camera moves in relation to X axis mouseWheel events.
  25610. * Use negative value to reverse direction.
  25611. */
  25612. wheelPrecisionX: number;
  25613. /**
  25614. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25615. * Use negative value to reverse direction.
  25616. */
  25617. wheelPrecisionY: number;
  25618. /**
  25619. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25620. * Use negative value to reverse direction.
  25621. */
  25622. wheelPrecisionZ: number;
  25623. /**
  25624. * Observable for when a mouse wheel move event occurs.
  25625. */
  25626. onChangedObservable: Observable<{
  25627. wheelDeltaX: number;
  25628. wheelDeltaY: number;
  25629. wheelDeltaZ: number;
  25630. }>;
  25631. private _wheel;
  25632. private _observer;
  25633. /**
  25634. * Attach the input controls to a specific dom element to get the input from.
  25635. * @param noPreventDefault Defines whether event caught by the controls
  25636. * should call preventdefault().
  25637. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25638. */
  25639. attachControl(noPreventDefault?: boolean): void;
  25640. /**
  25641. * Detach the current controls from the specified dom element.
  25642. */
  25643. detachControl(): void;
  25644. /**
  25645. * Called for each rendered frame.
  25646. */
  25647. checkInputs(): void;
  25648. /**
  25649. * Gets the class name of the current intput.
  25650. * @returns the class name
  25651. */
  25652. getClassName(): string;
  25653. /**
  25654. * Get the friendly name associated with the input class.
  25655. * @returns the input friendly name
  25656. */
  25657. getSimpleName(): string;
  25658. /**
  25659. * Incremental value of multiple mouse wheel movements of the X axis.
  25660. * Should be zero-ed when read.
  25661. */
  25662. protected _wheelDeltaX: number;
  25663. /**
  25664. * Incremental value of multiple mouse wheel movements of the Y axis.
  25665. * Should be zero-ed when read.
  25666. */
  25667. protected _wheelDeltaY: number;
  25668. /**
  25669. * Incremental value of multiple mouse wheel movements of the Z axis.
  25670. * Should be zero-ed when read.
  25671. */
  25672. protected _wheelDeltaZ: number;
  25673. /**
  25674. * Firefox uses a different scheme to report scroll distances to other
  25675. * browsers. Rather than use complicated methods to calculate the exact
  25676. * multiple we need to apply, let's just cheat and use a constant.
  25677. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25678. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25679. */
  25680. private readonly _ffMultiplier;
  25681. /**
  25682. * Different event attributes for wheel data fall into a few set ranges.
  25683. * Some relevant but dated date here:
  25684. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25685. */
  25686. private readonly _normalize;
  25687. }
  25688. }
  25689. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  25690. import { Nullable } from "babylonjs/types";
  25691. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25692. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  25693. import { Coordinate } from "babylonjs/Maths/math.axis";
  25694. /**
  25695. * Manage the mouse wheel inputs to control a free camera.
  25696. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25697. */
  25698. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25699. /**
  25700. * Defines the camera the input is attached to.
  25701. */
  25702. camera: FreeCamera;
  25703. /**
  25704. * Gets the class name of the current input.
  25705. * @returns the class name
  25706. */
  25707. getClassName(): string;
  25708. /**
  25709. * Set which movement axis (relative to camera's orientation) the mouse
  25710. * wheel's X axis controls.
  25711. * @param axis The axis to be moved. Set null to clear.
  25712. */
  25713. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25714. /**
  25715. * Get the configured movement axis (relative to camera's orientation) the
  25716. * mouse wheel's X axis controls.
  25717. * @returns The configured axis or null if none.
  25718. */
  25719. get wheelXMoveRelative(): Nullable<Coordinate>;
  25720. /**
  25721. * Set which movement axis (relative to camera's orientation) the mouse
  25722. * wheel's Y axis controls.
  25723. * @param axis The axis to be moved. Set null to clear.
  25724. */
  25725. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25726. /**
  25727. * Get the configured movement axis (relative to camera's orientation) the
  25728. * mouse wheel's Y axis controls.
  25729. * @returns The configured axis or null if none.
  25730. */
  25731. get wheelYMoveRelative(): Nullable<Coordinate>;
  25732. /**
  25733. * Set which movement axis (relative to camera's orientation) the mouse
  25734. * wheel's Z axis controls.
  25735. * @param axis The axis to be moved. Set null to clear.
  25736. */
  25737. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25738. /**
  25739. * Get the configured movement axis (relative to camera's orientation) the
  25740. * mouse wheel's Z axis controls.
  25741. * @returns The configured axis or null if none.
  25742. */
  25743. get wheelZMoveRelative(): Nullable<Coordinate>;
  25744. /**
  25745. * Set which rotation axis (relative to camera's orientation) the mouse
  25746. * wheel's X axis controls.
  25747. * @param axis The axis to be moved. Set null to clear.
  25748. */
  25749. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25750. /**
  25751. * Get the configured rotation axis (relative to camera's orientation) the
  25752. * mouse wheel's X axis controls.
  25753. * @returns The configured axis or null if none.
  25754. */
  25755. get wheelXRotateRelative(): Nullable<Coordinate>;
  25756. /**
  25757. * Set which rotation axis (relative to camera's orientation) the mouse
  25758. * wheel's Y axis controls.
  25759. * @param axis The axis to be moved. Set null to clear.
  25760. */
  25761. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25762. /**
  25763. * Get the configured rotation axis (relative to camera's orientation) the
  25764. * mouse wheel's Y axis controls.
  25765. * @returns The configured axis or null if none.
  25766. */
  25767. get wheelYRotateRelative(): Nullable<Coordinate>;
  25768. /**
  25769. * Set which rotation axis (relative to camera's orientation) the mouse
  25770. * wheel's Z axis controls.
  25771. * @param axis The axis to be moved. Set null to clear.
  25772. */
  25773. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25774. /**
  25775. * Get the configured rotation axis (relative to camera's orientation) the
  25776. * mouse wheel's Z axis controls.
  25777. * @returns The configured axis or null if none.
  25778. */
  25779. get wheelZRotateRelative(): Nullable<Coordinate>;
  25780. /**
  25781. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25782. * controls.
  25783. * @param axis The axis to be moved. Set null to clear.
  25784. */
  25785. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25786. /**
  25787. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25788. * X axis controls.
  25789. * @returns The configured axis or null if none.
  25790. */
  25791. get wheelXMoveScene(): Nullable<Coordinate>;
  25792. /**
  25793. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25794. * controls.
  25795. * @param axis The axis to be moved. Set null to clear.
  25796. */
  25797. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25798. /**
  25799. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25800. * Y axis controls.
  25801. * @returns The configured axis or null if none.
  25802. */
  25803. get wheelYMoveScene(): Nullable<Coordinate>;
  25804. /**
  25805. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25806. * controls.
  25807. * @param axis The axis to be moved. Set null to clear.
  25808. */
  25809. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25810. /**
  25811. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25812. * Z axis controls.
  25813. * @returns The configured axis or null if none.
  25814. */
  25815. get wheelZMoveScene(): Nullable<Coordinate>;
  25816. /**
  25817. * Called for each rendered frame.
  25818. */
  25819. checkInputs(): void;
  25820. private _moveRelative;
  25821. private _rotateRelative;
  25822. private _moveScene;
  25823. /**
  25824. * These are set to the desired default behaviour.
  25825. */
  25826. private _wheelXAction;
  25827. private _wheelXActionCoordinate;
  25828. private _wheelYAction;
  25829. private _wheelYActionCoordinate;
  25830. private _wheelZAction;
  25831. private _wheelZActionCoordinate;
  25832. /**
  25833. * Update the camera according to any configured properties for the 3
  25834. * mouse-wheel axis.
  25835. */
  25836. private _updateCamera;
  25837. }
  25838. }
  25839. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25840. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25841. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25842. /**
  25843. * Manage the touch inputs to control the movement of a free camera.
  25844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25845. */
  25846. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25847. /**
  25848. * Define if mouse events can be treated as touch events
  25849. */
  25850. allowMouse: boolean;
  25851. /**
  25852. * Defines the camera the input is attached to.
  25853. */
  25854. camera: FreeCamera;
  25855. /**
  25856. * Defines the touch sensibility for rotation.
  25857. * The higher the faster.
  25858. */
  25859. touchAngularSensibility: number;
  25860. /**
  25861. * Defines the touch sensibility for move.
  25862. * The higher the faster.
  25863. */
  25864. touchMoveSensibility: number;
  25865. private _offsetX;
  25866. private _offsetY;
  25867. private _pointerPressed;
  25868. private _pointerInput?;
  25869. private _observer;
  25870. private _onLostFocus;
  25871. /**
  25872. * Manage the touch inputs to control the movement of a free camera.
  25873. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25874. * @param allowMouse Defines if mouse events can be treated as touch events
  25875. */
  25876. constructor(
  25877. /**
  25878. * Define if mouse events can be treated as touch events
  25879. */
  25880. allowMouse?: boolean);
  25881. /**
  25882. * Attach the input controls to a specific dom element to get the input from.
  25883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25884. */
  25885. attachControl(noPreventDefault?: boolean): void;
  25886. /**
  25887. * Detach the current controls from the specified dom element.
  25888. */
  25889. detachControl(): void;
  25890. /**
  25891. * Update the current camera state depending on the inputs that have been used this frame.
  25892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25893. */
  25894. checkInputs(): void;
  25895. /**
  25896. * Gets the class name of the current intput.
  25897. * @returns the class name
  25898. */
  25899. getClassName(): string;
  25900. /**
  25901. * Get the friendly name associated with the input class.
  25902. * @returns the input friendly name
  25903. */
  25904. getSimpleName(): string;
  25905. }
  25906. }
  25907. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25909. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25910. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25911. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25912. import { Nullable } from "babylonjs/types";
  25913. /**
  25914. * Default Inputs manager for the FreeCamera.
  25915. * It groups all the default supported inputs for ease of use.
  25916. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25917. */
  25918. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25919. /**
  25920. * @hidden
  25921. */
  25922. _mouseInput: Nullable<FreeCameraMouseInput>;
  25923. /**
  25924. * @hidden
  25925. */
  25926. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25927. /**
  25928. * Instantiates a new FreeCameraInputsManager.
  25929. * @param camera Defines the camera the inputs belong to
  25930. */
  25931. constructor(camera: FreeCamera);
  25932. /**
  25933. * Add keyboard input support to the input manager.
  25934. * @returns the current input manager
  25935. */
  25936. addKeyboard(): FreeCameraInputsManager;
  25937. /**
  25938. * Add mouse input support to the input manager.
  25939. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25940. * @returns the current input manager
  25941. */
  25942. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25943. /**
  25944. * Removes the mouse input support from the manager
  25945. * @returns the current input manager
  25946. */
  25947. removeMouse(): FreeCameraInputsManager;
  25948. /**
  25949. * Add mouse wheel input support to the input manager.
  25950. * @returns the current input manager
  25951. */
  25952. addMouseWheel(): FreeCameraInputsManager;
  25953. /**
  25954. * Removes the mouse wheel input support from the manager
  25955. * @returns the current input manager
  25956. */
  25957. removeMouseWheel(): FreeCameraInputsManager;
  25958. /**
  25959. * Add touch input support to the input manager.
  25960. * @returns the current input manager
  25961. */
  25962. addTouch(): FreeCameraInputsManager;
  25963. /**
  25964. * Remove all attached input methods from a camera
  25965. */
  25966. clear(): void;
  25967. }
  25968. }
  25969. declare module "babylonjs/Cameras/freeCamera" {
  25970. import { Vector3 } from "babylonjs/Maths/math.vector";
  25971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25972. import { Scene } from "babylonjs/scene";
  25973. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25974. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25975. /**
  25976. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25977. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25978. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25979. */
  25980. export class FreeCamera extends TargetCamera {
  25981. /**
  25982. * Define the collision ellipsoid of the camera.
  25983. * This is helpful to simulate a camera body like the player body around the camera
  25984. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25985. */
  25986. ellipsoid: Vector3;
  25987. /**
  25988. * Define an offset for the position of the ellipsoid around the camera.
  25989. * This can be helpful to determine the center of the body near the gravity center of the body
  25990. * instead of its head.
  25991. */
  25992. ellipsoidOffset: Vector3;
  25993. /**
  25994. * Enable or disable collisions of the camera with the rest of the scene objects.
  25995. */
  25996. checkCollisions: boolean;
  25997. /**
  25998. * Enable or disable gravity on the camera.
  25999. */
  26000. applyGravity: boolean;
  26001. /**
  26002. * Define the input manager associated to the camera.
  26003. */
  26004. inputs: FreeCameraInputsManager;
  26005. /**
  26006. * Gets the input sensibility for a mouse input. (default is 2000.0)
  26007. * Higher values reduce sensitivity.
  26008. */
  26009. get angularSensibility(): number;
  26010. /**
  26011. * Sets the input sensibility for a mouse input. (default is 2000.0)
  26012. * Higher values reduce sensitivity.
  26013. */
  26014. set angularSensibility(value: number);
  26015. /**
  26016. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  26017. */
  26018. get keysUp(): number[];
  26019. set keysUp(value: number[]);
  26020. /**
  26021. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  26022. */
  26023. get keysUpward(): number[];
  26024. set keysUpward(value: number[]);
  26025. /**
  26026. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  26027. */
  26028. get keysDown(): number[];
  26029. set keysDown(value: number[]);
  26030. /**
  26031. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  26032. */
  26033. get keysDownward(): number[];
  26034. set keysDownward(value: number[]);
  26035. /**
  26036. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  26037. */
  26038. get keysLeft(): number[];
  26039. set keysLeft(value: number[]);
  26040. /**
  26041. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  26042. */
  26043. get keysRight(): number[];
  26044. set keysRight(value: number[]);
  26045. /**
  26046. * Event raised when the camera collide with a mesh in the scene.
  26047. */
  26048. onCollide: (collidedMesh: AbstractMesh) => void;
  26049. private _collider;
  26050. private _needMoveForGravity;
  26051. private _oldPosition;
  26052. private _diffPosition;
  26053. private _newPosition;
  26054. /** @hidden */
  26055. _localDirection: Vector3;
  26056. /** @hidden */
  26057. _transformedDirection: Vector3;
  26058. /**
  26059. * Instantiates a Free Camera.
  26060. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26061. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  26062. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26063. * @param name Define the name of the camera in the scene
  26064. * @param position Define the start position of the camera in the scene
  26065. * @param scene Define the scene the camera belongs to
  26066. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  26067. */
  26068. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26069. /**
  26070. * Attach the input controls to a specific dom element to get the input from.
  26071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26072. */
  26073. attachControl(noPreventDefault?: boolean): void;
  26074. /**
  26075. * Attach the input controls to a specific dom element to get the input from.
  26076. * @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
  26077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26078. * BACK COMPAT SIGNATURE ONLY.
  26079. */
  26080. attachControl(ignored: any, noPreventDefault?: boolean): void;
  26081. /**
  26082. * Detach the current controls from the specified dom element.
  26083. */
  26084. detachControl(): void;
  26085. /**
  26086. * Detach the current controls from the specified dom element.
  26087. * @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
  26088. */
  26089. detachControl(ignored: any): void;
  26090. private _collisionMask;
  26091. /**
  26092. * Define a collision mask to limit the list of object the camera can collide with
  26093. */
  26094. get collisionMask(): number;
  26095. set collisionMask(mask: number);
  26096. /** @hidden */
  26097. _collideWithWorld(displacement: Vector3): void;
  26098. private _onCollisionPositionChange;
  26099. /** @hidden */
  26100. _checkInputs(): void;
  26101. /** @hidden */
  26102. _decideIfNeedsToMove(): boolean;
  26103. /** @hidden */
  26104. _updatePosition(): void;
  26105. /**
  26106. * Destroy the camera and release the current resources hold by it.
  26107. */
  26108. dispose(): void;
  26109. /**
  26110. * Gets the current object class name.
  26111. * @return the class name
  26112. */
  26113. getClassName(): string;
  26114. }
  26115. }
  26116. declare module "babylonjs/Gamepads/gamepad" {
  26117. import { Observable } from "babylonjs/Misc/observable";
  26118. /**
  26119. * Represents a gamepad control stick position
  26120. */
  26121. export class StickValues {
  26122. /**
  26123. * The x component of the control stick
  26124. */
  26125. x: number;
  26126. /**
  26127. * The y component of the control stick
  26128. */
  26129. y: number;
  26130. /**
  26131. * Initializes the gamepad x and y control stick values
  26132. * @param x The x component of the gamepad control stick value
  26133. * @param y The y component of the gamepad control stick value
  26134. */
  26135. constructor(
  26136. /**
  26137. * The x component of the control stick
  26138. */
  26139. x: number,
  26140. /**
  26141. * The y component of the control stick
  26142. */
  26143. y: number);
  26144. }
  26145. /**
  26146. * An interface which manages callbacks for gamepad button changes
  26147. */
  26148. export interface GamepadButtonChanges {
  26149. /**
  26150. * Called when a gamepad has been changed
  26151. */
  26152. changed: boolean;
  26153. /**
  26154. * Called when a gamepad press event has been triggered
  26155. */
  26156. pressChanged: boolean;
  26157. /**
  26158. * Called when a touch event has been triggered
  26159. */
  26160. touchChanged: boolean;
  26161. /**
  26162. * Called when a value has changed
  26163. */
  26164. valueChanged: boolean;
  26165. }
  26166. /**
  26167. * Represents a gamepad
  26168. */
  26169. export class Gamepad {
  26170. /**
  26171. * The id of the gamepad
  26172. */
  26173. id: string;
  26174. /**
  26175. * The index of the gamepad
  26176. */
  26177. index: number;
  26178. /**
  26179. * The browser gamepad
  26180. */
  26181. browserGamepad: any;
  26182. /**
  26183. * Specifies what type of gamepad this represents
  26184. */
  26185. type: number;
  26186. private _leftStick;
  26187. private _rightStick;
  26188. /** @hidden */
  26189. _isConnected: boolean;
  26190. private _leftStickAxisX;
  26191. private _leftStickAxisY;
  26192. private _rightStickAxisX;
  26193. private _rightStickAxisY;
  26194. /**
  26195. * Triggered when the left control stick has been changed
  26196. */
  26197. private _onleftstickchanged;
  26198. /**
  26199. * Triggered when the right control stick has been changed
  26200. */
  26201. private _onrightstickchanged;
  26202. /**
  26203. * Represents a gamepad controller
  26204. */
  26205. static GAMEPAD: number;
  26206. /**
  26207. * Represents a generic controller
  26208. */
  26209. static GENERIC: number;
  26210. /**
  26211. * Represents an XBox controller
  26212. */
  26213. static XBOX: number;
  26214. /**
  26215. * Represents a pose-enabled controller
  26216. */
  26217. static POSE_ENABLED: number;
  26218. /**
  26219. * Represents an Dual Shock controller
  26220. */
  26221. static DUALSHOCK: number;
  26222. /**
  26223. * Specifies whether the left control stick should be Y-inverted
  26224. */
  26225. protected _invertLeftStickY: boolean;
  26226. /**
  26227. * Specifies if the gamepad has been connected
  26228. */
  26229. get isConnected(): boolean;
  26230. /**
  26231. * Initializes the gamepad
  26232. * @param id The id of the gamepad
  26233. * @param index The index of the gamepad
  26234. * @param browserGamepad The browser gamepad
  26235. * @param leftStickX The x component of the left joystick
  26236. * @param leftStickY The y component of the left joystick
  26237. * @param rightStickX The x component of the right joystick
  26238. * @param rightStickY The y component of the right joystick
  26239. */
  26240. constructor(
  26241. /**
  26242. * The id of the gamepad
  26243. */
  26244. id: string,
  26245. /**
  26246. * The index of the gamepad
  26247. */
  26248. index: number,
  26249. /**
  26250. * The browser gamepad
  26251. */
  26252. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  26253. /**
  26254. * Callback triggered when the left joystick has changed
  26255. * @param callback
  26256. */
  26257. onleftstickchanged(callback: (values: StickValues) => void): void;
  26258. /**
  26259. * Callback triggered when the right joystick has changed
  26260. * @param callback
  26261. */
  26262. onrightstickchanged(callback: (values: StickValues) => void): void;
  26263. /**
  26264. * Gets the left joystick
  26265. */
  26266. get leftStick(): StickValues;
  26267. /**
  26268. * Sets the left joystick values
  26269. */
  26270. set leftStick(newValues: StickValues);
  26271. /**
  26272. * Gets the right joystick
  26273. */
  26274. get rightStick(): StickValues;
  26275. /**
  26276. * Sets the right joystick value
  26277. */
  26278. set rightStick(newValues: StickValues);
  26279. /**
  26280. * Updates the gamepad joystick positions
  26281. */
  26282. update(): void;
  26283. /**
  26284. * Disposes the gamepad
  26285. */
  26286. dispose(): void;
  26287. }
  26288. /**
  26289. * Represents a generic gamepad
  26290. */
  26291. export class GenericPad extends Gamepad {
  26292. private _buttons;
  26293. private _onbuttondown;
  26294. private _onbuttonup;
  26295. /**
  26296. * Observable triggered when a button has been pressed
  26297. */
  26298. onButtonDownObservable: Observable<number>;
  26299. /**
  26300. * Observable triggered when a button has been released
  26301. */
  26302. onButtonUpObservable: Observable<number>;
  26303. /**
  26304. * Callback triggered when a button has been pressed
  26305. * @param callback Called when a button has been pressed
  26306. */
  26307. onbuttondown(callback: (buttonPressed: number) => void): void;
  26308. /**
  26309. * Callback triggered when a button has been released
  26310. * @param callback Called when a button has been released
  26311. */
  26312. onbuttonup(callback: (buttonReleased: number) => void): void;
  26313. /**
  26314. * Initializes the generic gamepad
  26315. * @param id The id of the generic gamepad
  26316. * @param index The index of the generic gamepad
  26317. * @param browserGamepad The browser gamepad
  26318. */
  26319. constructor(id: string, index: number, browserGamepad: any);
  26320. private _setButtonValue;
  26321. /**
  26322. * Updates the generic gamepad
  26323. */
  26324. update(): void;
  26325. /**
  26326. * Disposes the generic gamepad
  26327. */
  26328. dispose(): void;
  26329. }
  26330. }
  26331. declare module "babylonjs/Animations/runtimeAnimation" {
  26332. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  26333. import { Animatable } from "babylonjs/Animations/animatable";
  26334. import { Scene } from "babylonjs/scene";
  26335. /**
  26336. * Defines a runtime animation
  26337. */
  26338. export class RuntimeAnimation {
  26339. private _events;
  26340. /**
  26341. * The current frame of the runtime animation
  26342. */
  26343. private _currentFrame;
  26344. /**
  26345. * The animation used by the runtime animation
  26346. */
  26347. private _animation;
  26348. /**
  26349. * The target of the runtime animation
  26350. */
  26351. private _target;
  26352. /**
  26353. * The initiating animatable
  26354. */
  26355. private _host;
  26356. /**
  26357. * The original value of the runtime animation
  26358. */
  26359. private _originalValue;
  26360. /**
  26361. * The original blend value of the runtime animation
  26362. */
  26363. private _originalBlendValue;
  26364. /**
  26365. * The offsets cache of the runtime animation
  26366. */
  26367. private _offsetsCache;
  26368. /**
  26369. * The high limits cache of the runtime animation
  26370. */
  26371. private _highLimitsCache;
  26372. /**
  26373. * Specifies if the runtime animation has been stopped
  26374. */
  26375. private _stopped;
  26376. /**
  26377. * The blending factor of the runtime animation
  26378. */
  26379. private _blendingFactor;
  26380. /**
  26381. * The BabylonJS scene
  26382. */
  26383. private _scene;
  26384. /**
  26385. * The current value of the runtime animation
  26386. */
  26387. private _currentValue;
  26388. /** @hidden */
  26389. _animationState: _IAnimationState;
  26390. /**
  26391. * The active target of the runtime animation
  26392. */
  26393. private _activeTargets;
  26394. private _currentActiveTarget;
  26395. private _directTarget;
  26396. /**
  26397. * The target path of the runtime animation
  26398. */
  26399. private _targetPath;
  26400. /**
  26401. * The weight of the runtime animation
  26402. */
  26403. private _weight;
  26404. /**
  26405. * The ratio offset of the runtime animation
  26406. */
  26407. private _ratioOffset;
  26408. /**
  26409. * The previous delay of the runtime animation
  26410. */
  26411. private _previousDelay;
  26412. /**
  26413. * The previous ratio of the runtime animation
  26414. */
  26415. private _previousRatio;
  26416. private _enableBlending;
  26417. private _keys;
  26418. private _minFrame;
  26419. private _maxFrame;
  26420. private _minValue;
  26421. private _maxValue;
  26422. private _targetIsArray;
  26423. /**
  26424. * Gets the current frame of the runtime animation
  26425. */
  26426. get currentFrame(): number;
  26427. /**
  26428. * Gets the weight of the runtime animation
  26429. */
  26430. get weight(): number;
  26431. /**
  26432. * Gets the current value of the runtime animation
  26433. */
  26434. get currentValue(): any;
  26435. /**
  26436. * Gets the target path of the runtime animation
  26437. */
  26438. get targetPath(): string;
  26439. /**
  26440. * Gets the actual target of the runtime animation
  26441. */
  26442. get target(): any;
  26443. /**
  26444. * Gets the additive state of the runtime animation
  26445. */
  26446. get isAdditive(): boolean;
  26447. /** @hidden */
  26448. _onLoop: () => void;
  26449. /**
  26450. * Create a new RuntimeAnimation object
  26451. * @param target defines the target of the animation
  26452. * @param animation defines the source animation object
  26453. * @param scene defines the hosting scene
  26454. * @param host defines the initiating Animatable
  26455. */
  26456. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26457. private _preparePath;
  26458. /**
  26459. * Gets the animation from the runtime animation
  26460. */
  26461. get animation(): Animation;
  26462. /**
  26463. * Resets the runtime animation to the beginning
  26464. * @param restoreOriginal defines whether to restore the target property to the original value
  26465. */
  26466. reset(restoreOriginal?: boolean): void;
  26467. /**
  26468. * Specifies if the runtime animation is stopped
  26469. * @returns Boolean specifying if the runtime animation is stopped
  26470. */
  26471. isStopped(): boolean;
  26472. /**
  26473. * Disposes of the runtime animation
  26474. */
  26475. dispose(): void;
  26476. /**
  26477. * Apply the interpolated value to the target
  26478. * @param currentValue defines the value computed by the animation
  26479. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26480. */
  26481. setValue(currentValue: any, weight: number): void;
  26482. private _getOriginalValues;
  26483. private _setValue;
  26484. /**
  26485. * Gets the loop pmode of the runtime animation
  26486. * @returns Loop Mode
  26487. */
  26488. private _getCorrectLoopMode;
  26489. /**
  26490. * Move the current animation to a given frame
  26491. * @param frame defines the frame to move to
  26492. */
  26493. goToFrame(frame: number): void;
  26494. /**
  26495. * @hidden Internal use only
  26496. */
  26497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26498. /**
  26499. * Execute the current animation
  26500. * @param delay defines the delay to add to the current frame
  26501. * @param from defines the lower bound of the animation range
  26502. * @param to defines the upper bound of the animation range
  26503. * @param loop defines if the current animation must loop
  26504. * @param speedRatio defines the current speed ratio
  26505. * @param weight defines the weight of the animation (default is -1 so no weight)
  26506. * @param onLoop optional callback called when animation loops
  26507. * @returns a boolean indicating if the animation is running
  26508. */
  26509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26510. }
  26511. }
  26512. declare module "babylonjs/Animations/animatable" {
  26513. import { Animation } from "babylonjs/Animations/animation";
  26514. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26515. import { Nullable } from "babylonjs/types";
  26516. import { Observable } from "babylonjs/Misc/observable";
  26517. import { Scene } from "babylonjs/scene";
  26518. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  26519. import { Node } from "babylonjs/node";
  26520. /**
  26521. * Class used to store an actual running animation
  26522. */
  26523. export class Animatable {
  26524. /** defines the target object */
  26525. target: any;
  26526. /** defines the starting frame number (default is 0) */
  26527. fromFrame: number;
  26528. /** defines the ending frame number (default is 100) */
  26529. toFrame: number;
  26530. /** defines if the animation must loop (default is false) */
  26531. loopAnimation: boolean;
  26532. /** defines a callback to call when animation ends if it is not looping */
  26533. onAnimationEnd?: (() => void) | null | undefined;
  26534. /** defines a callback to call when animation loops */
  26535. onAnimationLoop?: (() => void) | null | undefined;
  26536. /** defines whether the animation should be evaluated additively */
  26537. isAdditive: boolean;
  26538. private _localDelayOffset;
  26539. private _pausedDelay;
  26540. private _runtimeAnimations;
  26541. private _paused;
  26542. private _scene;
  26543. private _speedRatio;
  26544. private _weight;
  26545. private _syncRoot;
  26546. /**
  26547. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26548. * This will only apply for non looping animation (default is true)
  26549. */
  26550. disposeOnEnd: boolean;
  26551. /**
  26552. * Gets a boolean indicating if the animation has started
  26553. */
  26554. animationStarted: boolean;
  26555. /**
  26556. * Observer raised when the animation ends
  26557. */
  26558. onAnimationEndObservable: Observable<Animatable>;
  26559. /**
  26560. * Observer raised when the animation loops
  26561. */
  26562. onAnimationLoopObservable: Observable<Animatable>;
  26563. /**
  26564. * Gets the root Animatable used to synchronize and normalize animations
  26565. */
  26566. get syncRoot(): Nullable<Animatable>;
  26567. /**
  26568. * Gets the current frame of the first RuntimeAnimation
  26569. * Used to synchronize Animatables
  26570. */
  26571. get masterFrame(): number;
  26572. /**
  26573. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26574. */
  26575. get weight(): number;
  26576. set weight(value: number);
  26577. /**
  26578. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26579. */
  26580. get speedRatio(): number;
  26581. set speedRatio(value: number);
  26582. /**
  26583. * Creates a new Animatable
  26584. * @param scene defines the hosting scene
  26585. * @param target defines the target object
  26586. * @param fromFrame defines the starting frame number (default is 0)
  26587. * @param toFrame defines the ending frame number (default is 100)
  26588. * @param loopAnimation defines if the animation must loop (default is false)
  26589. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26590. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26591. * @param animations defines a group of animation to add to the new Animatable
  26592. * @param onAnimationLoop defines a callback to call when animation loops
  26593. * @param isAdditive defines whether the animation should be evaluated additively
  26594. */
  26595. constructor(scene: Scene,
  26596. /** defines the target object */
  26597. target: any,
  26598. /** defines the starting frame number (default is 0) */
  26599. fromFrame?: number,
  26600. /** defines the ending frame number (default is 100) */
  26601. toFrame?: number,
  26602. /** defines if the animation must loop (default is false) */
  26603. loopAnimation?: boolean, speedRatio?: number,
  26604. /** defines a callback to call when animation ends if it is not looping */
  26605. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26606. /** defines a callback to call when animation loops */
  26607. onAnimationLoop?: (() => void) | null | undefined,
  26608. /** defines whether the animation should be evaluated additively */
  26609. isAdditive?: boolean);
  26610. /**
  26611. * Synchronize and normalize current Animatable with a source Animatable
  26612. * This is useful when using animation weights and when animations are not of the same length
  26613. * @param root defines the root Animatable to synchronize with
  26614. * @returns the current Animatable
  26615. */
  26616. syncWith(root: Animatable): Animatable;
  26617. /**
  26618. * Gets the list of runtime animations
  26619. * @returns an array of RuntimeAnimation
  26620. */
  26621. getAnimations(): RuntimeAnimation[];
  26622. /**
  26623. * Adds more animations to the current animatable
  26624. * @param target defines the target of the animations
  26625. * @param animations defines the new animations to add
  26626. */
  26627. appendAnimations(target: any, animations: Animation[]): void;
  26628. /**
  26629. * Gets the source animation for a specific property
  26630. * @param property defines the propertyu to look for
  26631. * @returns null or the source animation for the given property
  26632. */
  26633. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26634. /**
  26635. * Gets the runtime animation for a specific property
  26636. * @param property defines the propertyu to look for
  26637. * @returns null or the runtime animation for the given property
  26638. */
  26639. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26640. /**
  26641. * Resets the animatable to its original state
  26642. */
  26643. reset(): void;
  26644. /**
  26645. * Allows the animatable to blend with current running animations
  26646. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26647. * @param blendingSpeed defines the blending speed to use
  26648. */
  26649. enableBlending(blendingSpeed: number): void;
  26650. /**
  26651. * Disable animation blending
  26652. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26653. */
  26654. disableBlending(): void;
  26655. /**
  26656. * Jump directly to a given frame
  26657. * @param frame defines the frame to jump to
  26658. */
  26659. goToFrame(frame: number): void;
  26660. /**
  26661. * Pause the animation
  26662. */
  26663. pause(): void;
  26664. /**
  26665. * Restart the animation
  26666. */
  26667. restart(): void;
  26668. private _raiseOnAnimationEnd;
  26669. /**
  26670. * Stop and delete the current animation
  26671. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26672. * @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)
  26673. */
  26674. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26675. /**
  26676. * Wait asynchronously for the animation to end
  26677. * @returns a promise which will be fullfilled when the animation ends
  26678. */
  26679. waitAsync(): Promise<Animatable>;
  26680. /** @hidden */
  26681. _animate(delay: number): boolean;
  26682. }
  26683. module "babylonjs/scene" {
  26684. interface Scene {
  26685. /** @hidden */
  26686. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26687. /** @hidden */
  26688. _processLateAnimationBindingsForMatrices(holder: {
  26689. totalWeight: number;
  26690. totalAdditiveWeight: number;
  26691. animations: RuntimeAnimation[];
  26692. additiveAnimations: RuntimeAnimation[];
  26693. originalValue: Matrix;
  26694. }): any;
  26695. /** @hidden */
  26696. _processLateAnimationBindingsForQuaternions(holder: {
  26697. totalWeight: number;
  26698. totalAdditiveWeight: number;
  26699. animations: RuntimeAnimation[];
  26700. additiveAnimations: RuntimeAnimation[];
  26701. originalValue: Quaternion;
  26702. }, refQuaternion: Quaternion): Quaternion;
  26703. /** @hidden */
  26704. _processLateAnimationBindings(): void;
  26705. /**
  26706. * Will start the animation sequence of a given target
  26707. * @param target defines the target
  26708. * @param from defines from which frame should animation start
  26709. * @param to defines until which frame should animation run.
  26710. * @param weight defines the weight to apply to the animation (1.0 by default)
  26711. * @param loop defines if the animation loops
  26712. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26713. * @param onAnimationEnd defines the function to be executed when the animation ends
  26714. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26715. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26716. * @param onAnimationLoop defines the callback to call when an animation loops
  26717. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26718. * @returns the animatable object created for this animation
  26719. */
  26720. 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;
  26721. /**
  26722. * Will start the animation sequence of a given target
  26723. * @param target defines the target
  26724. * @param from defines from which frame should animation start
  26725. * @param to defines until which frame should animation run.
  26726. * @param loop defines if the animation loops
  26727. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26728. * @param onAnimationEnd defines the function to be executed when the animation ends
  26729. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26730. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26731. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26732. * @param onAnimationLoop defines the callback to call when an animation loops
  26733. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26734. * @returns the animatable object created for this animation
  26735. */
  26736. 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;
  26737. /**
  26738. * Will start the animation sequence of a given target and its hierarchy
  26739. * @param target defines the target
  26740. * @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.
  26741. * @param from defines from which frame should animation start
  26742. * @param to defines until which frame should animation run.
  26743. * @param loop defines if the animation loops
  26744. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26745. * @param onAnimationEnd defines the function to be executed when the animation ends
  26746. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26747. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26748. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26749. * @param onAnimationLoop defines the callback to call when an animation loops
  26750. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26751. * @returns the list of created animatables
  26752. */
  26753. 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[];
  26754. /**
  26755. * Begin a new animation on a given node
  26756. * @param target defines the target where the animation will take place
  26757. * @param animations defines the list of animations to start
  26758. * @param from defines the initial value
  26759. * @param to defines the final value
  26760. * @param loop defines if you want animation to loop (off by default)
  26761. * @param speedRatio defines the speed ratio to apply to all animations
  26762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26763. * @param onAnimationLoop defines the callback to call when an animation loops
  26764. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26765. * @returns the list of created animatables
  26766. */
  26767. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26768. /**
  26769. * Begin a new animation on a given node and its hierarchy
  26770. * @param target defines the root node where the animation will take place
  26771. * @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.
  26772. * @param animations defines the list of animations to start
  26773. * @param from defines the initial value
  26774. * @param to defines the final value
  26775. * @param loop defines if you want animation to loop (off by default)
  26776. * @param speedRatio defines the speed ratio to apply to all animations
  26777. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26778. * @param onAnimationLoop defines the callback to call when an animation loops
  26779. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26780. * @returns the list of animatables created for all nodes
  26781. */
  26782. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26783. /**
  26784. * Gets the animatable associated with a specific target
  26785. * @param target defines the target of the animatable
  26786. * @returns the required animatable if found
  26787. */
  26788. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26789. /**
  26790. * Gets all animatables associated with a given target
  26791. * @param target defines the target to look animatables for
  26792. * @returns an array of Animatables
  26793. */
  26794. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26795. /**
  26796. * Stops and removes all animations that have been applied to the scene
  26797. */
  26798. stopAllAnimations(): void;
  26799. /**
  26800. * Gets the current delta time used by animation engine
  26801. */
  26802. deltaTime: number;
  26803. }
  26804. }
  26805. module "babylonjs/Bones/bone" {
  26806. interface Bone {
  26807. /**
  26808. * Copy an animation range from another bone
  26809. * @param source defines the source bone
  26810. * @param rangeName defines the range name to copy
  26811. * @param frameOffset defines the frame offset
  26812. * @param rescaleAsRequired defines if rescaling must be applied if required
  26813. * @param skelDimensionsRatio defines the scaling ratio
  26814. * @returns true if operation was successful
  26815. */
  26816. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26817. }
  26818. }
  26819. }
  26820. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26821. /**
  26822. * Class used to override all child animations of a given target
  26823. */
  26824. export class AnimationPropertiesOverride {
  26825. /**
  26826. * Gets or sets a value indicating if animation blending must be used
  26827. */
  26828. enableBlending: boolean;
  26829. /**
  26830. * Gets or sets the blending speed to use when enableBlending is true
  26831. */
  26832. blendingSpeed: number;
  26833. /**
  26834. * Gets or sets the default loop mode to use
  26835. */
  26836. loopMode: number;
  26837. }
  26838. }
  26839. declare module "babylonjs/Bones/skeleton" {
  26840. import { Bone } from "babylonjs/Bones/bone";
  26841. import { Observable } from "babylonjs/Misc/observable";
  26842. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26843. import { Scene } from "babylonjs/scene";
  26844. import { Nullable } from "babylonjs/types";
  26845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26846. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26847. import { Animatable } from "babylonjs/Animations/animatable";
  26848. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26849. import { Animation } from "babylonjs/Animations/animation";
  26850. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26851. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26852. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26853. /**
  26854. * Class used to handle skinning animations
  26855. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26856. */
  26857. export class Skeleton implements IAnimatable {
  26858. /** defines the skeleton name */
  26859. name: string;
  26860. /** defines the skeleton Id */
  26861. id: string;
  26862. /**
  26863. * Defines the list of child bones
  26864. */
  26865. bones: Bone[];
  26866. /**
  26867. * Defines an estimate of the dimension of the skeleton at rest
  26868. */
  26869. dimensionsAtRest: Vector3;
  26870. /**
  26871. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26872. */
  26873. needInitialSkinMatrix: boolean;
  26874. /**
  26875. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26876. */
  26877. overrideMesh: Nullable<AbstractMesh>;
  26878. /**
  26879. * Gets the list of animations attached to this skeleton
  26880. */
  26881. animations: Array<Animation>;
  26882. private _scene;
  26883. private _isDirty;
  26884. private _transformMatrices;
  26885. private _transformMatrixTexture;
  26886. private _meshesWithPoseMatrix;
  26887. private _animatables;
  26888. private _identity;
  26889. private _synchronizedWithMesh;
  26890. private _ranges;
  26891. private _lastAbsoluteTransformsUpdateId;
  26892. private _canUseTextureForBones;
  26893. private _uniqueId;
  26894. /** @hidden */
  26895. _numBonesWithLinkedTransformNode: number;
  26896. /** @hidden */
  26897. _hasWaitingData: Nullable<boolean>;
  26898. /** @hidden */
  26899. _waitingOverrideMeshId: Nullable<string>;
  26900. /**
  26901. * Specifies if the skeleton should be serialized
  26902. */
  26903. doNotSerialize: boolean;
  26904. private _useTextureToStoreBoneMatrices;
  26905. /**
  26906. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26907. * Please note that this option is not available if the hardware does not support it
  26908. */
  26909. get useTextureToStoreBoneMatrices(): boolean;
  26910. set useTextureToStoreBoneMatrices(value: boolean);
  26911. private _animationPropertiesOverride;
  26912. /**
  26913. * Gets or sets the animation properties override
  26914. */
  26915. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26916. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26917. /**
  26918. * List of inspectable custom properties (used by the Inspector)
  26919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26920. */
  26921. inspectableCustomProperties: IInspectable[];
  26922. /**
  26923. * An observable triggered before computing the skeleton's matrices
  26924. */
  26925. onBeforeComputeObservable: Observable<Skeleton>;
  26926. /**
  26927. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26928. */
  26929. get isUsingTextureForMatrices(): boolean;
  26930. /**
  26931. * Gets the unique ID of this skeleton
  26932. */
  26933. get uniqueId(): number;
  26934. /**
  26935. * Creates a new skeleton
  26936. * @param name defines the skeleton name
  26937. * @param id defines the skeleton Id
  26938. * @param scene defines the hosting scene
  26939. */
  26940. constructor(
  26941. /** defines the skeleton name */
  26942. name: string,
  26943. /** defines the skeleton Id */
  26944. id: string, scene: Scene);
  26945. /**
  26946. * Gets the current object class name.
  26947. * @return the class name
  26948. */
  26949. getClassName(): string;
  26950. /**
  26951. * Returns an array containing the root bones
  26952. * @returns an array containing the root bones
  26953. */
  26954. getChildren(): Array<Bone>;
  26955. /**
  26956. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26957. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26958. * @returns a Float32Array containing matrices data
  26959. */
  26960. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26961. /**
  26962. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26963. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26964. * @returns a raw texture containing the data
  26965. */
  26966. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26967. /**
  26968. * Gets the current hosting scene
  26969. * @returns a scene object
  26970. */
  26971. getScene(): Scene;
  26972. /**
  26973. * Gets a string representing the current skeleton data
  26974. * @param fullDetails defines a boolean indicating if we want a verbose version
  26975. * @returns a string representing the current skeleton data
  26976. */
  26977. toString(fullDetails?: boolean): string;
  26978. /**
  26979. * Get bone's index searching by name
  26980. * @param name defines bone's name to search for
  26981. * @return the indice of the bone. Returns -1 if not found
  26982. */
  26983. getBoneIndexByName(name: string): number;
  26984. /**
  26985. * Creater a new animation range
  26986. * @param name defines the name of the range
  26987. * @param from defines the start key
  26988. * @param to defines the end key
  26989. */
  26990. createAnimationRange(name: string, from: number, to: number): void;
  26991. /**
  26992. * Delete a specific animation range
  26993. * @param name defines the name of the range
  26994. * @param deleteFrames defines if frames must be removed as well
  26995. */
  26996. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26997. /**
  26998. * Gets a specific animation range
  26999. * @param name defines the name of the range to look for
  27000. * @returns the requested animation range or null if not found
  27001. */
  27002. getAnimationRange(name: string): Nullable<AnimationRange>;
  27003. /**
  27004. * Gets the list of all animation ranges defined on this skeleton
  27005. * @returns an array
  27006. */
  27007. getAnimationRanges(): Nullable<AnimationRange>[];
  27008. /**
  27009. * Copy animation range from a source skeleton.
  27010. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  27011. * @param source defines the source skeleton
  27012. * @param name defines the name of the range to copy
  27013. * @param rescaleAsRequired defines if rescaling must be applied if required
  27014. * @returns true if operation was successful
  27015. */
  27016. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  27017. /**
  27018. * Forces the skeleton to go to rest pose
  27019. */
  27020. returnToRest(): void;
  27021. private _getHighestAnimationFrame;
  27022. /**
  27023. * Begin a specific animation range
  27024. * @param name defines the name of the range to start
  27025. * @param loop defines if looping must be turned on (false by default)
  27026. * @param speedRatio defines the speed ratio to apply (1 by default)
  27027. * @param onAnimationEnd defines a callback which will be called when animation will end
  27028. * @returns a new animatable
  27029. */
  27030. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27031. /**
  27032. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  27033. * @param skeleton defines the Skeleton containing the animation range to convert
  27034. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  27035. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  27036. * @returns the original skeleton
  27037. */
  27038. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  27039. /** @hidden */
  27040. _markAsDirty(): void;
  27041. /** @hidden */
  27042. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27043. /** @hidden */
  27044. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27045. private _computeTransformMatrices;
  27046. /**
  27047. * Build all resources required to render a skeleton
  27048. */
  27049. prepare(): void;
  27050. /**
  27051. * Gets the list of animatables currently running for this skeleton
  27052. * @returns an array of animatables
  27053. */
  27054. getAnimatables(): IAnimatable[];
  27055. /**
  27056. * Clone the current skeleton
  27057. * @param name defines the name of the new skeleton
  27058. * @param id defines the id of the new skeleton
  27059. * @returns the new skeleton
  27060. */
  27061. clone(name: string, id?: string): Skeleton;
  27062. /**
  27063. * Enable animation blending for this skeleton
  27064. * @param blendingSpeed defines the blending speed to apply
  27065. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  27066. */
  27067. enableBlending(blendingSpeed?: number): void;
  27068. /**
  27069. * Releases all resources associated with the current skeleton
  27070. */
  27071. dispose(): void;
  27072. /**
  27073. * Serialize the skeleton in a JSON object
  27074. * @returns a JSON object
  27075. */
  27076. serialize(): any;
  27077. /**
  27078. * Creates a new skeleton from serialized data
  27079. * @param parsedSkeleton defines the serialized data
  27080. * @param scene defines the hosting scene
  27081. * @returns a new skeleton
  27082. */
  27083. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  27084. /**
  27085. * Compute all node absolute transforms
  27086. * @param forceUpdate defines if computation must be done even if cache is up to date
  27087. */
  27088. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  27089. /**
  27090. * Gets the root pose matrix
  27091. * @returns a matrix
  27092. */
  27093. getPoseMatrix(): Nullable<Matrix>;
  27094. /**
  27095. * Sorts bones per internal index
  27096. */
  27097. sortBones(): void;
  27098. private _sortBones;
  27099. /**
  27100. * Set the current local matrix as the restPose for all bones in the skeleton.
  27101. */
  27102. setCurrentPoseAsRest(): void;
  27103. }
  27104. }
  27105. declare module "babylonjs/Bones/bone" {
  27106. import { Skeleton } from "babylonjs/Bones/skeleton";
  27107. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  27108. import { Nullable } from "babylonjs/types";
  27109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27110. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27111. import { Node } from "babylonjs/node";
  27112. import { Space } from "babylonjs/Maths/math.axis";
  27113. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27114. /**
  27115. * Class used to store bone information
  27116. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27117. */
  27118. export class Bone extends Node {
  27119. /**
  27120. * defines the bone name
  27121. */
  27122. name: string;
  27123. private static _tmpVecs;
  27124. private static _tmpQuat;
  27125. private static _tmpMats;
  27126. /**
  27127. * Gets the list of child bones
  27128. */
  27129. children: Bone[];
  27130. /** Gets the animations associated with this bone */
  27131. animations: import("babylonjs/Animations/animation").Animation[];
  27132. /**
  27133. * Gets or sets bone length
  27134. */
  27135. length: number;
  27136. /**
  27137. * @hidden Internal only
  27138. * Set this value to map this bone to a different index in the transform matrices
  27139. * Set this value to -1 to exclude the bone from the transform matrices
  27140. */
  27141. _index: Nullable<number>;
  27142. private _skeleton;
  27143. private _localMatrix;
  27144. private _restPose;
  27145. private _bindPose;
  27146. private _baseMatrix;
  27147. private _absoluteTransform;
  27148. private _invertedAbsoluteTransform;
  27149. private _parent;
  27150. private _scalingDeterminant;
  27151. private _worldTransform;
  27152. private _localScaling;
  27153. private _localRotation;
  27154. private _localPosition;
  27155. private _needToDecompose;
  27156. private _needToCompose;
  27157. /** @hidden */
  27158. _linkedTransformNode: Nullable<TransformNode>;
  27159. /** @hidden */
  27160. _waitingTransformNodeId: Nullable<string>;
  27161. /** @hidden */
  27162. get _matrix(): Matrix;
  27163. /** @hidden */
  27164. set _matrix(value: Matrix);
  27165. /**
  27166. * Create a new bone
  27167. * @param name defines the bone name
  27168. * @param skeleton defines the parent skeleton
  27169. * @param parentBone defines the parent (can be null if the bone is the root)
  27170. * @param localMatrix defines the local matrix
  27171. * @param restPose defines the rest pose matrix
  27172. * @param baseMatrix defines the base matrix
  27173. * @param index defines index of the bone in the hiearchy
  27174. */
  27175. constructor(
  27176. /**
  27177. * defines the bone name
  27178. */
  27179. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  27180. /**
  27181. * Gets the current object class name.
  27182. * @return the class name
  27183. */
  27184. getClassName(): string;
  27185. /**
  27186. * Gets the parent skeleton
  27187. * @returns a skeleton
  27188. */
  27189. getSkeleton(): Skeleton;
  27190. /**
  27191. * Gets parent bone
  27192. * @returns a bone or null if the bone is the root of the bone hierarchy
  27193. */
  27194. getParent(): Nullable<Bone>;
  27195. /**
  27196. * Returns an array containing the root bones
  27197. * @returns an array containing the root bones
  27198. */
  27199. getChildren(): Array<Bone>;
  27200. /**
  27201. * Gets the node index in matrix array generated for rendering
  27202. * @returns the node index
  27203. */
  27204. getIndex(): number;
  27205. /**
  27206. * Sets the parent bone
  27207. * @param parent defines the parent (can be null if the bone is the root)
  27208. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27209. */
  27210. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  27211. /**
  27212. * Gets the local matrix
  27213. * @returns a matrix
  27214. */
  27215. getLocalMatrix(): Matrix;
  27216. /**
  27217. * Gets the base matrix (initial matrix which remains unchanged)
  27218. * @returns a matrix
  27219. */
  27220. getBaseMatrix(): Matrix;
  27221. /**
  27222. * Gets the rest pose matrix
  27223. * @returns a matrix
  27224. */
  27225. getRestPose(): Matrix;
  27226. /**
  27227. * Sets the rest pose matrix
  27228. * @param matrix the local-space rest pose to set for this bone
  27229. */
  27230. setRestPose(matrix: Matrix): void;
  27231. /**
  27232. * Gets the bind pose matrix
  27233. * @returns the bind pose matrix
  27234. */
  27235. getBindPose(): Matrix;
  27236. /**
  27237. * Sets the bind pose matrix
  27238. * @param matrix the local-space bind pose to set for this bone
  27239. */
  27240. setBindPose(matrix: Matrix): void;
  27241. /**
  27242. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  27243. */
  27244. getWorldMatrix(): Matrix;
  27245. /**
  27246. * Sets the local matrix to rest pose matrix
  27247. */
  27248. returnToRest(): void;
  27249. /**
  27250. * Gets the inverse of the absolute transform matrix.
  27251. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  27252. * @returns a matrix
  27253. */
  27254. getInvertedAbsoluteTransform(): Matrix;
  27255. /**
  27256. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  27257. * @returns a matrix
  27258. */
  27259. getAbsoluteTransform(): Matrix;
  27260. /**
  27261. * Links with the given transform node.
  27262. * The local matrix of this bone is copied from the transform node every frame.
  27263. * @param transformNode defines the transform node to link to
  27264. */
  27265. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  27266. /**
  27267. * Gets the node used to drive the bone's transformation
  27268. * @returns a transform node or null
  27269. */
  27270. getTransformNode(): Nullable<TransformNode>;
  27271. /** Gets or sets current position (in local space) */
  27272. get position(): Vector3;
  27273. set position(newPosition: Vector3);
  27274. /** Gets or sets current rotation (in local space) */
  27275. get rotation(): Vector3;
  27276. set rotation(newRotation: Vector3);
  27277. /** Gets or sets current rotation quaternion (in local space) */
  27278. get rotationQuaternion(): Quaternion;
  27279. set rotationQuaternion(newRotation: Quaternion);
  27280. /** Gets or sets current scaling (in local space) */
  27281. get scaling(): Vector3;
  27282. set scaling(newScaling: Vector3);
  27283. /**
  27284. * Gets the animation properties override
  27285. */
  27286. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27287. private _decompose;
  27288. private _compose;
  27289. /**
  27290. * Update the base and local matrices
  27291. * @param matrix defines the new base or local matrix
  27292. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27293. * @param updateLocalMatrix defines if the local matrix should be updated
  27294. */
  27295. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  27296. /** @hidden */
  27297. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  27298. /**
  27299. * Flag the bone as dirty (Forcing it to update everything)
  27300. */
  27301. markAsDirty(): void;
  27302. /** @hidden */
  27303. _markAsDirtyAndCompose(): void;
  27304. private _markAsDirtyAndDecompose;
  27305. /**
  27306. * Translate the bone in local or world space
  27307. * @param vec The amount to translate the bone
  27308. * @param space The space that the translation is in
  27309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27310. */
  27311. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27312. /**
  27313. * Set the postion of the bone in local or world space
  27314. * @param position The position to set the bone
  27315. * @param space The space that the position is in
  27316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27317. */
  27318. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27319. /**
  27320. * Set the absolute position of the bone (world space)
  27321. * @param position The position to set the bone
  27322. * @param mesh The mesh that this bone is attached to
  27323. */
  27324. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  27325. /**
  27326. * Scale the bone on the x, y and z axes (in local space)
  27327. * @param x The amount to scale the bone on the x axis
  27328. * @param y The amount to scale the bone on the y axis
  27329. * @param z The amount to scale the bone on the z axis
  27330. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  27331. */
  27332. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  27333. /**
  27334. * Set the bone scaling in local space
  27335. * @param scale defines the scaling vector
  27336. */
  27337. setScale(scale: Vector3): void;
  27338. /**
  27339. * Gets the current scaling in local space
  27340. * @returns the current scaling vector
  27341. */
  27342. getScale(): Vector3;
  27343. /**
  27344. * Gets the current scaling in local space and stores it in a target vector
  27345. * @param result defines the target vector
  27346. */
  27347. getScaleToRef(result: Vector3): void;
  27348. /**
  27349. * Set the yaw, pitch, and roll of the bone in local or world space
  27350. * @param yaw The rotation of the bone on the y axis
  27351. * @param pitch The rotation of the bone on the x axis
  27352. * @param roll The rotation of the bone on the z axis
  27353. * @param space The space that the axes of rotation are in
  27354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27355. */
  27356. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  27357. /**
  27358. * Add a rotation to the bone on an axis in local or world space
  27359. * @param axis The axis to rotate the bone on
  27360. * @param amount The amount to rotate the bone
  27361. * @param space The space that the axis is in
  27362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27363. */
  27364. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  27365. /**
  27366. * Set the rotation of the bone to a particular axis angle in local or world space
  27367. * @param axis The axis to rotate the bone on
  27368. * @param angle The angle that the bone should be rotated to
  27369. * @param space The space that the axis is in
  27370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27371. */
  27372. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  27373. /**
  27374. * Set the euler rotation of the bone in local or world space
  27375. * @param rotation The euler rotation that the bone should be set to
  27376. * @param space The space that the rotation is in
  27377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27378. */
  27379. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27380. /**
  27381. * Set the quaternion rotation of the bone in local or world space
  27382. * @param quat The quaternion rotation that the bone should be set to
  27383. * @param space The space that the rotation is in
  27384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27385. */
  27386. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  27387. /**
  27388. * Set the rotation matrix of the bone in local or world space
  27389. * @param rotMat The rotation matrix that the bone should be set to
  27390. * @param space The space that the rotation is in
  27391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27392. */
  27393. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  27394. private _rotateWithMatrix;
  27395. private _getNegativeRotationToRef;
  27396. /**
  27397. * Get the position of the bone in local or world space
  27398. * @param space The space that the returned position is in
  27399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27400. * @returns The position of the bone
  27401. */
  27402. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27403. /**
  27404. * Copy the position of the bone to a vector3 in local or world space
  27405. * @param space The space that the returned position is in
  27406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27407. * @param result The vector3 to copy the position to
  27408. */
  27409. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  27410. /**
  27411. * Get the absolute position of the bone (world space)
  27412. * @param mesh The mesh that this bone is attached to
  27413. * @returns The absolute position of the bone
  27414. */
  27415. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  27416. /**
  27417. * Copy the absolute position of the bone (world space) to the result param
  27418. * @param mesh The mesh that this bone is attached to
  27419. * @param result The vector3 to copy the absolute position to
  27420. */
  27421. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  27422. /**
  27423. * Compute the absolute transforms of this bone and its children
  27424. */
  27425. computeAbsoluteTransforms(): void;
  27426. /**
  27427. * Get the world direction from an axis that is in the local space of the bone
  27428. * @param localAxis The local direction that is used to compute the world direction
  27429. * @param mesh The mesh that this bone is attached to
  27430. * @returns The world direction
  27431. */
  27432. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27433. /**
  27434. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27435. * @param localAxis The local direction that is used to compute the world direction
  27436. * @param mesh The mesh that this bone is attached to
  27437. * @param result The vector3 that the world direction will be copied to
  27438. */
  27439. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27440. /**
  27441. * Get the euler rotation of the bone in local or world space
  27442. * @param space The space that the rotation should be in
  27443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27444. * @returns The euler rotation
  27445. */
  27446. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27447. /**
  27448. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27449. * @param space The space that the rotation should be in
  27450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27451. * @param result The vector3 that the rotation should be copied to
  27452. */
  27453. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27454. /**
  27455. * Get the quaternion rotation of the bone in either local or world space
  27456. * @param space The space that the rotation should be in
  27457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27458. * @returns The quaternion rotation
  27459. */
  27460. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27461. /**
  27462. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27463. * @param space The space that the rotation should be in
  27464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27465. * @param result The quaternion that the rotation should be copied to
  27466. */
  27467. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27468. /**
  27469. * Get the rotation matrix of the bone in local or world space
  27470. * @param space The space that the rotation should be in
  27471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27472. * @returns The rotation matrix
  27473. */
  27474. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27475. /**
  27476. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27477. * @param space The space that the rotation should be in
  27478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27479. * @param result The quaternion that the rotation should be copied to
  27480. */
  27481. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27482. /**
  27483. * Get the world position of a point that is in the local space of the bone
  27484. * @param position The local position
  27485. * @param mesh The mesh that this bone is attached to
  27486. * @returns The world position
  27487. */
  27488. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27489. /**
  27490. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27491. * @param position The local position
  27492. * @param mesh The mesh that this bone is attached to
  27493. * @param result The vector3 that the world position should be copied to
  27494. */
  27495. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27496. /**
  27497. * Get the local position of a point that is in world space
  27498. * @param position The world position
  27499. * @param mesh The mesh that this bone is attached to
  27500. * @returns The local position
  27501. */
  27502. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27503. /**
  27504. * Get the local position of a point that is in world space and copy it to the result param
  27505. * @param position The world position
  27506. * @param mesh The mesh that this bone is attached to
  27507. * @param result The vector3 that the local position should be copied to
  27508. */
  27509. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27510. /**
  27511. * Set the current local matrix as the restPose for this bone.
  27512. */
  27513. setCurrentPoseAsRest(): void;
  27514. }
  27515. }
  27516. declare module "babylonjs/Meshes/transformNode" {
  27517. import { DeepImmutable } from "babylonjs/types";
  27518. import { Observable } from "babylonjs/Misc/observable";
  27519. import { Nullable } from "babylonjs/types";
  27520. import { Camera } from "babylonjs/Cameras/camera";
  27521. import { Scene } from "babylonjs/scene";
  27522. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27523. import { Node } from "babylonjs/node";
  27524. import { Bone } from "babylonjs/Bones/bone";
  27525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27526. import { Space } from "babylonjs/Maths/math.axis";
  27527. /**
  27528. * 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.
  27529. * @see https://doc.babylonjs.com/how_to/transformnode
  27530. */
  27531. export class TransformNode extends Node {
  27532. /**
  27533. * Object will not rotate to face the camera
  27534. */
  27535. static BILLBOARDMODE_NONE: number;
  27536. /**
  27537. * Object will rotate to face the camera but only on the x axis
  27538. */
  27539. static BILLBOARDMODE_X: number;
  27540. /**
  27541. * Object will rotate to face the camera but only on the y axis
  27542. */
  27543. static BILLBOARDMODE_Y: number;
  27544. /**
  27545. * Object will rotate to face the camera but only on the z axis
  27546. */
  27547. static BILLBOARDMODE_Z: number;
  27548. /**
  27549. * Object will rotate to face the camera
  27550. */
  27551. static BILLBOARDMODE_ALL: number;
  27552. /**
  27553. * Object will rotate to face the camera's position instead of orientation
  27554. */
  27555. static BILLBOARDMODE_USE_POSITION: number;
  27556. private static _TmpRotation;
  27557. private static _TmpScaling;
  27558. private static _TmpTranslation;
  27559. private _forward;
  27560. private _forwardInverted;
  27561. private _up;
  27562. private _right;
  27563. private _rightInverted;
  27564. private _position;
  27565. private _rotation;
  27566. private _rotationQuaternion;
  27567. protected _scaling: Vector3;
  27568. protected _isDirty: boolean;
  27569. private _transformToBoneReferal;
  27570. private _isAbsoluteSynced;
  27571. private _billboardMode;
  27572. /**
  27573. * Gets or sets the billboard mode. Default is 0.
  27574. *
  27575. * | Value | Type | Description |
  27576. * | --- | --- | --- |
  27577. * | 0 | BILLBOARDMODE_NONE | |
  27578. * | 1 | BILLBOARDMODE_X | |
  27579. * | 2 | BILLBOARDMODE_Y | |
  27580. * | 4 | BILLBOARDMODE_Z | |
  27581. * | 7 | BILLBOARDMODE_ALL | |
  27582. *
  27583. */
  27584. get billboardMode(): number;
  27585. set billboardMode(value: number);
  27586. private _preserveParentRotationForBillboard;
  27587. /**
  27588. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27589. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27590. */
  27591. get preserveParentRotationForBillboard(): boolean;
  27592. set preserveParentRotationForBillboard(value: boolean);
  27593. /**
  27594. * 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
  27595. */
  27596. scalingDeterminant: number;
  27597. private _infiniteDistance;
  27598. /**
  27599. * Gets or sets the distance of the object to max, often used by skybox
  27600. */
  27601. get infiniteDistance(): boolean;
  27602. set infiniteDistance(value: boolean);
  27603. /**
  27604. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27605. * By default the system will update normals to compensate
  27606. */
  27607. ignoreNonUniformScaling: boolean;
  27608. /**
  27609. * 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
  27610. */
  27611. reIntegrateRotationIntoRotationQuaternion: boolean;
  27612. /** @hidden */
  27613. _poseMatrix: Nullable<Matrix>;
  27614. /** @hidden */
  27615. _localMatrix: Matrix;
  27616. private _usePivotMatrix;
  27617. private _absolutePosition;
  27618. private _absoluteScaling;
  27619. private _absoluteRotationQuaternion;
  27620. private _pivotMatrix;
  27621. private _pivotMatrixInverse;
  27622. /** @hidden */
  27623. _postMultiplyPivotMatrix: boolean;
  27624. protected _isWorldMatrixFrozen: boolean;
  27625. /** @hidden */
  27626. _indexInSceneTransformNodesArray: number;
  27627. /**
  27628. * An event triggered after the world matrix is updated
  27629. */
  27630. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27631. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27632. /**
  27633. * Gets a string identifying the name of the class
  27634. * @returns "TransformNode" string
  27635. */
  27636. getClassName(): string;
  27637. /**
  27638. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27639. */
  27640. get position(): Vector3;
  27641. set position(newPosition: Vector3);
  27642. /**
  27643. * 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)).
  27644. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27645. */
  27646. get rotation(): Vector3;
  27647. set rotation(newRotation: Vector3);
  27648. /**
  27649. * 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)).
  27650. */
  27651. get scaling(): Vector3;
  27652. set scaling(newScaling: Vector3);
  27653. /**
  27654. * 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).
  27655. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27656. */
  27657. get rotationQuaternion(): Nullable<Quaternion>;
  27658. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27659. /**
  27660. * The forward direction of that transform in world space.
  27661. */
  27662. get forward(): Vector3;
  27663. /**
  27664. * The up direction of that transform in world space.
  27665. */
  27666. get up(): Vector3;
  27667. /**
  27668. * The right direction of that transform in world space.
  27669. */
  27670. get right(): Vector3;
  27671. /**
  27672. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27673. * @param matrix the matrix to copy the pose from
  27674. * @returns this TransformNode.
  27675. */
  27676. updatePoseMatrix(matrix: Matrix): TransformNode;
  27677. /**
  27678. * Returns the mesh Pose matrix.
  27679. * @returns the pose matrix
  27680. */
  27681. getPoseMatrix(): Matrix;
  27682. /** @hidden */
  27683. _isSynchronized(): boolean;
  27684. /** @hidden */
  27685. _initCache(): void;
  27686. /**
  27687. * Flag the transform node as dirty (Forcing it to update everything)
  27688. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  27689. * @returns this transform node
  27690. */
  27691. markAsDirty(property: string): TransformNode;
  27692. /**
  27693. * Returns the current mesh absolute position.
  27694. * Returns a Vector3.
  27695. */
  27696. get absolutePosition(): Vector3;
  27697. /**
  27698. * Returns the current mesh absolute scaling.
  27699. * Returns a Vector3.
  27700. */
  27701. get absoluteScaling(): Vector3;
  27702. /**
  27703. * Returns the current mesh absolute rotation.
  27704. * Returns a Quaternion.
  27705. */
  27706. get absoluteRotationQuaternion(): Quaternion;
  27707. /**
  27708. * Sets a new matrix to apply before all other transformation
  27709. * @param matrix defines the transform matrix
  27710. * @returns the current TransformNode
  27711. */
  27712. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27713. /**
  27714. * Sets a new pivot matrix to the current node
  27715. * @param matrix defines the new pivot matrix to use
  27716. * @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
  27717. * @returns the current TransformNode
  27718. */
  27719. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27720. /**
  27721. * Returns the mesh pivot matrix.
  27722. * Default : Identity.
  27723. * @returns the matrix
  27724. */
  27725. getPivotMatrix(): Matrix;
  27726. /**
  27727. * Instantiate (when possible) or clone that node with its hierarchy
  27728. * @param newParent defines the new parent to use for the instance (or clone)
  27729. * @param options defines options to configure how copy is done
  27730. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27731. * @returns an instance (or a clone) of the current node with its hiearchy
  27732. */
  27733. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27734. doNotInstantiate: boolean;
  27735. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27736. /**
  27737. * Prevents the World matrix to be computed any longer
  27738. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27739. * @returns the TransformNode.
  27740. */
  27741. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27742. /**
  27743. * Allows back the World matrix computation.
  27744. * @returns the TransformNode.
  27745. */
  27746. unfreezeWorldMatrix(): this;
  27747. /**
  27748. * True if the World matrix has been frozen.
  27749. */
  27750. get isWorldMatrixFrozen(): boolean;
  27751. /**
  27752. * Retuns the mesh absolute position in the World.
  27753. * @returns a Vector3.
  27754. */
  27755. getAbsolutePosition(): Vector3;
  27756. /**
  27757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27758. * @param absolutePosition the absolute position to set
  27759. * @returns the TransformNode.
  27760. */
  27761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27762. /**
  27763. * Sets the mesh position in its local space.
  27764. * @param vector3 the position to set in localspace
  27765. * @returns the TransformNode.
  27766. */
  27767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27768. /**
  27769. * Returns the mesh position in the local space from the current World matrix values.
  27770. * @returns a new Vector3.
  27771. */
  27772. getPositionExpressedInLocalSpace(): Vector3;
  27773. /**
  27774. * Translates the mesh along the passed Vector3 in its local space.
  27775. * @param vector3 the distance to translate in localspace
  27776. * @returns the TransformNode.
  27777. */
  27778. locallyTranslate(vector3: Vector3): TransformNode;
  27779. private static _lookAtVectorCache;
  27780. /**
  27781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27782. * @param targetPoint the position (must be in same space as current mesh) to look at
  27783. * @param yawCor optional yaw (y-axis) correction in radians
  27784. * @param pitchCor optional pitch (x-axis) correction in radians
  27785. * @param rollCor optional roll (z-axis) correction in radians
  27786. * @param space the choosen space of the target
  27787. * @returns the TransformNode.
  27788. */
  27789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27790. /**
  27791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27792. * This Vector3 is expressed in the World space.
  27793. * @param localAxis axis to rotate
  27794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27795. */
  27796. getDirection(localAxis: Vector3): Vector3;
  27797. /**
  27798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27799. * localAxis is expressed in the mesh local space.
  27800. * result is computed in the Wordl space from the mesh World matrix.
  27801. * @param localAxis axis to rotate
  27802. * @param result the resulting transformnode
  27803. * @returns this TransformNode.
  27804. */
  27805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27806. /**
  27807. * Sets this transform node rotation to the given local axis.
  27808. * @param localAxis the axis in local space
  27809. * @param yawCor optional yaw (y-axis) correction in radians
  27810. * @param pitchCor optional pitch (x-axis) correction in radians
  27811. * @param rollCor optional roll (z-axis) correction in radians
  27812. * @returns this TransformNode
  27813. */
  27814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27815. /**
  27816. * Sets a new pivot point to the current node
  27817. * @param point defines the new pivot point to use
  27818. * @param space defines if the point is in world or local space (local by default)
  27819. * @returns the current TransformNode
  27820. */
  27821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27822. /**
  27823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27824. * @returns the pivot point
  27825. */
  27826. getPivotPoint(): Vector3;
  27827. /**
  27828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27829. * @param result the vector3 to store the result
  27830. * @returns this TransformNode.
  27831. */
  27832. getPivotPointToRef(result: Vector3): TransformNode;
  27833. /**
  27834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27836. */
  27837. getAbsolutePivotPoint(): Vector3;
  27838. /**
  27839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27840. * @param result vector3 to store the result
  27841. * @returns this TransformNode.
  27842. */
  27843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27844. /**
  27845. * Defines the passed node as the parent of the current node.
  27846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27847. * @see https://doc.babylonjs.com/how_to/parenting
  27848. * @param node the node ot set as the parent
  27849. * @returns this TransformNode.
  27850. */
  27851. setParent(node: Nullable<Node>): TransformNode;
  27852. private _nonUniformScaling;
  27853. /**
  27854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27855. */
  27856. get nonUniformScaling(): boolean;
  27857. /** @hidden */
  27858. _updateNonUniformScalingState(value: boolean): boolean;
  27859. /**
  27860. * Attach the current TransformNode to another TransformNode associated with a bone
  27861. * @param bone Bone affecting the TransformNode
  27862. * @param affectedTransformNode TransformNode associated with the bone
  27863. * @returns this object
  27864. */
  27865. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27866. /**
  27867. * Detach the transform node if its associated with a bone
  27868. * @returns this object
  27869. */
  27870. detachFromBone(): TransformNode;
  27871. private static _rotationAxisCache;
  27872. /**
  27873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27875. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27876. * The passed axis is also normalized.
  27877. * @param axis the axis to rotate around
  27878. * @param amount the amount to rotate in radians
  27879. * @param space Space to rotate in (Default: local)
  27880. * @returns the TransformNode.
  27881. */
  27882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27883. /**
  27884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27886. * The passed axis is also normalized. .
  27887. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27888. * @param point the point to rotate around
  27889. * @param axis the axis to rotate around
  27890. * @param amount the amount to rotate in radians
  27891. * @returns the TransformNode
  27892. */
  27893. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27894. /**
  27895. * Translates the mesh along the axis vector for the passed distance in the given space.
  27896. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27897. * @param axis the axis to translate in
  27898. * @param distance the distance to translate
  27899. * @param space Space to rotate in (Default: local)
  27900. * @returns the TransformNode.
  27901. */
  27902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27903. /**
  27904. * Adds a rotation step to the mesh current rotation.
  27905. * x, y, z are Euler angles expressed in radians.
  27906. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27907. * This means this rotation is made in the mesh local space only.
  27908. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27909. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27910. * ```javascript
  27911. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27912. * ```
  27913. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27914. * 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.
  27915. * @param x Rotation to add
  27916. * @param y Rotation to add
  27917. * @param z Rotation to add
  27918. * @returns the TransformNode.
  27919. */
  27920. addRotation(x: number, y: number, z: number): TransformNode;
  27921. /**
  27922. * @hidden
  27923. */
  27924. protected _getEffectiveParent(): Nullable<Node>;
  27925. /**
  27926. * Computes the world matrix of the node
  27927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27928. * @returns the world matrix
  27929. */
  27930. computeWorldMatrix(force?: boolean): Matrix;
  27931. /**
  27932. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27933. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27934. */
  27935. resetLocalMatrix(independentOfChildren?: boolean): void;
  27936. protected _afterComputeWorldMatrix(): void;
  27937. /**
  27938. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27939. * @param func callback function to add
  27940. *
  27941. * @returns the TransformNode.
  27942. */
  27943. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27944. /**
  27945. * Removes a registered callback function.
  27946. * @param func callback function to remove
  27947. * @returns the TransformNode.
  27948. */
  27949. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27950. /**
  27951. * Gets the position of the current mesh in camera space
  27952. * @param camera defines the camera to use
  27953. * @returns a position
  27954. */
  27955. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27956. /**
  27957. * Returns the distance from the mesh to the active camera
  27958. * @param camera defines the camera to use
  27959. * @returns the distance
  27960. */
  27961. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27962. /**
  27963. * Clone the current transform node
  27964. * @param name Name of the new clone
  27965. * @param newParent New parent for the clone
  27966. * @param doNotCloneChildren Do not clone children hierarchy
  27967. * @returns the new transform node
  27968. */
  27969. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27970. /**
  27971. * Serializes the objects information.
  27972. * @param currentSerializationObject defines the object to serialize in
  27973. * @returns the serialized object
  27974. */
  27975. serialize(currentSerializationObject?: any): any;
  27976. /**
  27977. * Returns a new TransformNode object parsed from the source provided.
  27978. * @param parsedTransformNode is the source.
  27979. * @param scene the scne the object belongs to
  27980. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27981. * @returns a new TransformNode object parsed from the source provided.
  27982. */
  27983. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27984. /**
  27985. * Get all child-transformNodes of this node
  27986. * @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
  27987. * @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
  27988. * @returns an array of TransformNode
  27989. */
  27990. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27991. /**
  27992. * Releases resources associated with this transform node.
  27993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27995. */
  27996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27997. /**
  27998. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27999. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28000. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28001. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28002. * @returns the current mesh
  28003. */
  28004. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  28005. private _syncAbsoluteScalingAndRotation;
  28006. }
  28007. }
  28008. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  28009. import { Observable } from "babylonjs/Misc/observable";
  28010. import { Nullable } from "babylonjs/types";
  28011. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28012. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28014. import { Ray } from "babylonjs/Culling/ray";
  28015. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  28016. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  28017. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  28018. /**
  28019. * Defines the types of pose enabled controllers that are supported
  28020. */
  28021. export enum PoseEnabledControllerType {
  28022. /**
  28023. * HTC Vive
  28024. */
  28025. VIVE = 0,
  28026. /**
  28027. * Oculus Rift
  28028. */
  28029. OCULUS = 1,
  28030. /**
  28031. * Windows mixed reality
  28032. */
  28033. WINDOWS = 2,
  28034. /**
  28035. * Samsung gear VR
  28036. */
  28037. GEAR_VR = 3,
  28038. /**
  28039. * Google Daydream
  28040. */
  28041. DAYDREAM = 4,
  28042. /**
  28043. * Generic
  28044. */
  28045. GENERIC = 5
  28046. }
  28047. /**
  28048. * Defines the MutableGamepadButton interface for the state of a gamepad button
  28049. */
  28050. export interface MutableGamepadButton {
  28051. /**
  28052. * Value of the button/trigger
  28053. */
  28054. value: number;
  28055. /**
  28056. * If the button/trigger is currently touched
  28057. */
  28058. touched: boolean;
  28059. /**
  28060. * If the button/trigger is currently pressed
  28061. */
  28062. pressed: boolean;
  28063. }
  28064. /**
  28065. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  28066. * @hidden
  28067. */
  28068. export interface ExtendedGamepadButton extends GamepadButton {
  28069. /**
  28070. * If the button/trigger is currently pressed
  28071. */
  28072. readonly pressed: boolean;
  28073. /**
  28074. * If the button/trigger is currently touched
  28075. */
  28076. readonly touched: boolean;
  28077. /**
  28078. * Value of the button/trigger
  28079. */
  28080. readonly value: number;
  28081. }
  28082. /** @hidden */
  28083. export interface _GamePadFactory {
  28084. /**
  28085. * Returns whether or not the current gamepad can be created for this type of controller.
  28086. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28087. * @returns true if it can be created, otherwise false
  28088. */
  28089. canCreate(gamepadInfo: any): boolean;
  28090. /**
  28091. * Creates a new instance of the Gamepad.
  28092. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28093. * @returns the new gamepad instance
  28094. */
  28095. create(gamepadInfo: any): Gamepad;
  28096. }
  28097. /**
  28098. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28099. */
  28100. export class PoseEnabledControllerHelper {
  28101. /** @hidden */
  28102. static _ControllerFactories: _GamePadFactory[];
  28103. /** @hidden */
  28104. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  28105. /**
  28106. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28107. * @param vrGamepad the gamepad to initialized
  28108. * @returns a vr controller of the type the gamepad identified as
  28109. */
  28110. static InitiateController(vrGamepad: any): Gamepad;
  28111. }
  28112. /**
  28113. * Defines the PoseEnabledController object that contains state of a vr capable controller
  28114. */
  28115. export class PoseEnabledController extends Gamepad implements PoseControlled {
  28116. /**
  28117. * If the controller is used in a webXR session
  28118. */
  28119. isXR: boolean;
  28120. private _deviceRoomPosition;
  28121. private _deviceRoomRotationQuaternion;
  28122. /**
  28123. * The device position in babylon space
  28124. */
  28125. devicePosition: Vector3;
  28126. /**
  28127. * The device rotation in babylon space
  28128. */
  28129. deviceRotationQuaternion: Quaternion;
  28130. /**
  28131. * The scale factor of the device in babylon space
  28132. */
  28133. deviceScaleFactor: number;
  28134. /**
  28135. * (Likely devicePosition should be used instead) The device position in its room space
  28136. */
  28137. position: Vector3;
  28138. /**
  28139. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  28140. */
  28141. rotationQuaternion: Quaternion;
  28142. /**
  28143. * The type of controller (Eg. Windows mixed reality)
  28144. */
  28145. controllerType: PoseEnabledControllerType;
  28146. protected _calculatedPosition: Vector3;
  28147. private _calculatedRotation;
  28148. /**
  28149. * The raw pose from the device
  28150. */
  28151. rawPose: DevicePose;
  28152. private _trackPosition;
  28153. private _maxRotationDistFromHeadset;
  28154. private _draggedRoomRotation;
  28155. /**
  28156. * @hidden
  28157. */
  28158. _disableTrackPosition(fixedPosition: Vector3): void;
  28159. /**
  28160. * Internal, the mesh attached to the controller
  28161. * @hidden
  28162. */
  28163. _mesh: Nullable<AbstractMesh>;
  28164. private _poseControlledCamera;
  28165. private _leftHandSystemQuaternion;
  28166. /**
  28167. * Internal, matrix used to convert room space to babylon space
  28168. * @hidden
  28169. */
  28170. _deviceToWorld: Matrix;
  28171. /**
  28172. * Node to be used when casting a ray from the controller
  28173. * @hidden
  28174. */
  28175. _pointingPoseNode: Nullable<TransformNode>;
  28176. /**
  28177. * Name of the child mesh that can be used to cast a ray from the controller
  28178. */
  28179. static readonly POINTING_POSE: string;
  28180. /**
  28181. * Creates a new PoseEnabledController from a gamepad
  28182. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  28183. */
  28184. constructor(browserGamepad: any);
  28185. private _workingMatrix;
  28186. /**
  28187. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  28188. */
  28189. update(): void;
  28190. /**
  28191. * Updates only the pose device and mesh without doing any button event checking
  28192. */
  28193. protected _updatePoseAndMesh(): void;
  28194. /**
  28195. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  28196. * @param poseData raw pose fromthe device
  28197. */
  28198. updateFromDevice(poseData: DevicePose): void;
  28199. /**
  28200. * @hidden
  28201. */
  28202. _meshAttachedObservable: Observable<AbstractMesh>;
  28203. /**
  28204. * Attaches a mesh to the controller
  28205. * @param mesh the mesh to be attached
  28206. */
  28207. attachToMesh(mesh: AbstractMesh): void;
  28208. /**
  28209. * Attaches the controllers mesh to a camera
  28210. * @param camera the camera the mesh should be attached to
  28211. */
  28212. attachToPoseControlledCamera(camera: TargetCamera): void;
  28213. /**
  28214. * Disposes of the controller
  28215. */
  28216. dispose(): void;
  28217. /**
  28218. * The mesh that is attached to the controller
  28219. */
  28220. get mesh(): Nullable<AbstractMesh>;
  28221. /**
  28222. * Gets the ray of the controller in the direction the controller is pointing
  28223. * @param length the length the resulting ray should be
  28224. * @returns a ray in the direction the controller is pointing
  28225. */
  28226. getForwardRay(length?: number): Ray;
  28227. }
  28228. }
  28229. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  28230. import { Observable } from "babylonjs/Misc/observable";
  28231. import { Scene } from "babylonjs/scene";
  28232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28233. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  28234. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  28235. import { Nullable } from "babylonjs/types";
  28236. /**
  28237. * Defines the WebVRController object that represents controllers tracked in 3D space
  28238. */
  28239. export abstract class WebVRController extends PoseEnabledController {
  28240. /**
  28241. * Internal, the default controller model for the controller
  28242. */
  28243. protected _defaultModel: Nullable<AbstractMesh>;
  28244. /**
  28245. * Fired when the trigger state has changed
  28246. */
  28247. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  28248. /**
  28249. * Fired when the main button state has changed
  28250. */
  28251. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28252. /**
  28253. * Fired when the secondary button state has changed
  28254. */
  28255. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28256. /**
  28257. * Fired when the pad state has changed
  28258. */
  28259. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  28260. /**
  28261. * Fired when controllers stick values have changed
  28262. */
  28263. onPadValuesChangedObservable: Observable<StickValues>;
  28264. /**
  28265. * Array of button availible on the controller
  28266. */
  28267. protected _buttons: Array<MutableGamepadButton>;
  28268. private _onButtonStateChange;
  28269. /**
  28270. * Fired when a controller button's state has changed
  28271. * @param callback the callback containing the button that was modified
  28272. */
  28273. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  28274. /**
  28275. * X and Y axis corresponding to the controllers joystick
  28276. */
  28277. pad: StickValues;
  28278. /**
  28279. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  28280. */
  28281. hand: string;
  28282. /**
  28283. * The default controller model for the controller
  28284. */
  28285. get defaultModel(): Nullable<AbstractMesh>;
  28286. /**
  28287. * Creates a new WebVRController from a gamepad
  28288. * @param vrGamepad the gamepad that the WebVRController should be created from
  28289. */
  28290. constructor(vrGamepad: any);
  28291. /**
  28292. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  28293. */
  28294. update(): void;
  28295. /**
  28296. * Function to be called when a button is modified
  28297. */
  28298. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28299. /**
  28300. * Loads a mesh and attaches it to the controller
  28301. * @param scene the scene the mesh should be added to
  28302. * @param meshLoaded callback for when the mesh has been loaded
  28303. */
  28304. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28305. private _setButtonValue;
  28306. private _changes;
  28307. private _checkChanges;
  28308. /**
  28309. * Disposes of th webVRCOntroller
  28310. */
  28311. dispose(): void;
  28312. }
  28313. }
  28314. declare module "babylonjs/Lights/hemisphericLight" {
  28315. import { Nullable } from "babylonjs/types";
  28316. import { Scene } from "babylonjs/scene";
  28317. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28318. import { Color3 } from "babylonjs/Maths/math.color";
  28319. import { Effect } from "babylonjs/Materials/effect";
  28320. import { Light } from "babylonjs/Lights/light";
  28321. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  28322. /**
  28323. * The HemisphericLight simulates the ambient environment light,
  28324. * so the passed direction is the light reflection direction, not the incoming direction.
  28325. */
  28326. export class HemisphericLight extends Light {
  28327. /**
  28328. * The groundColor is the light in the opposite direction to the one specified during creation.
  28329. * 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.
  28330. */
  28331. groundColor: Color3;
  28332. /**
  28333. * The light reflection direction, not the incoming direction.
  28334. */
  28335. direction: Vector3;
  28336. /**
  28337. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  28338. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  28339. * The HemisphericLight can't cast shadows.
  28340. * Documentation : https://doc.babylonjs.com/babylon101/lights
  28341. * @param name The friendly name of the light
  28342. * @param direction The direction of the light reflection
  28343. * @param scene The scene the light belongs to
  28344. */
  28345. constructor(name: string, direction: Vector3, scene: Scene);
  28346. protected _buildUniformLayout(): void;
  28347. /**
  28348. * Returns the string "HemisphericLight".
  28349. * @return The class name
  28350. */
  28351. getClassName(): string;
  28352. /**
  28353. * Sets the HemisphericLight direction towards the passed target (Vector3).
  28354. * Returns the updated direction.
  28355. * @param target The target the direction should point to
  28356. * @return The computed direction
  28357. */
  28358. setDirectionToTarget(target: Vector3): Vector3;
  28359. /**
  28360. * Returns the shadow generator associated to the light.
  28361. * @returns Always null for hemispheric lights because it does not support shadows.
  28362. */
  28363. getShadowGenerator(): Nullable<IShadowGenerator>;
  28364. /**
  28365. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  28366. * @param effect The effect to update
  28367. * @param lightIndex The index of the light in the effect to update
  28368. * @returns The hemispheric light
  28369. */
  28370. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  28371. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  28372. /**
  28373. * Computes the world matrix of the node
  28374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28375. * @param useWasUpdatedFlag defines a reserved property
  28376. * @returns the world matrix
  28377. */
  28378. computeWorldMatrix(): Matrix;
  28379. /**
  28380. * Returns the integer 3.
  28381. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  28382. */
  28383. getTypeID(): number;
  28384. /**
  28385. * Prepares the list of defines specific to the light type.
  28386. * @param defines the list of defines
  28387. * @param lightIndex defines the index of the light for the effect
  28388. */
  28389. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  28390. }
  28391. }
  28392. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  28393. /** @hidden */
  28394. export var vrMultiviewToSingleviewPixelShader: {
  28395. name: string;
  28396. shader: string;
  28397. };
  28398. }
  28399. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  28400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28401. import { Scene } from "babylonjs/scene";
  28402. /**
  28403. * Renders to multiple views with a single draw call
  28404. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  28405. */
  28406. export class MultiviewRenderTarget extends RenderTargetTexture {
  28407. /**
  28408. * Creates a multiview render target
  28409. * @param scene scene used with the render target
  28410. * @param size the size of the render target (used for each view)
  28411. */
  28412. constructor(scene: Scene, size?: number | {
  28413. width: number;
  28414. height: number;
  28415. } | {
  28416. ratio: number;
  28417. });
  28418. /**
  28419. * @hidden
  28420. * @param faceIndex the face index, if its a cube texture
  28421. */
  28422. _bindFrameBuffer(faceIndex?: number): void;
  28423. /**
  28424. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28425. * @returns the view count
  28426. */
  28427. getViewCount(): number;
  28428. }
  28429. }
  28430. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  28431. import { Camera } from "babylonjs/Cameras/camera";
  28432. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28433. import { Nullable } from "babylonjs/types";
  28434. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28435. import { Matrix } from "babylonjs/Maths/math.vector";
  28436. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28437. module "babylonjs/Engines/engine" {
  28438. interface Engine {
  28439. /**
  28440. * Creates a new multiview render target
  28441. * @param width defines the width of the texture
  28442. * @param height defines the height of the texture
  28443. * @returns the created multiview texture
  28444. */
  28445. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28446. /**
  28447. * Binds a multiview framebuffer to be drawn to
  28448. * @param multiviewTexture texture to bind
  28449. */
  28450. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28451. }
  28452. }
  28453. module "babylonjs/Cameras/camera" {
  28454. interface Camera {
  28455. /**
  28456. * @hidden
  28457. * 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)
  28458. */
  28459. _useMultiviewToSingleView: boolean;
  28460. /**
  28461. * @hidden
  28462. * 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)
  28463. */
  28464. _multiviewTexture: Nullable<RenderTargetTexture>;
  28465. /**
  28466. * @hidden
  28467. * ensures the multiview texture of the camera exists and has the specified width/height
  28468. * @param width height to set on the multiview texture
  28469. * @param height width to set on the multiview texture
  28470. */
  28471. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28472. }
  28473. }
  28474. module "babylonjs/scene" {
  28475. interface Scene {
  28476. /** @hidden */
  28477. _transformMatrixR: Matrix;
  28478. /** @hidden */
  28479. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28480. /** @hidden */
  28481. _createMultiviewUbo(): void;
  28482. /** @hidden */
  28483. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28484. /** @hidden */
  28485. _renderMultiviewToSingleView(camera: Camera): void;
  28486. }
  28487. }
  28488. }
  28489. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  28490. import { Camera } from "babylonjs/Cameras/camera";
  28491. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28492. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  28493. import "babylonjs/Engines/Extensions/engine.multiview";
  28494. /**
  28495. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28496. * This will not be used for webXR as it supports displaying texture arrays directly
  28497. */
  28498. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28499. /**
  28500. * Gets a string identifying the name of the class
  28501. * @returns "VRMultiviewToSingleviewPostProcess" string
  28502. */
  28503. getClassName(): string;
  28504. /**
  28505. * Initializes a VRMultiviewToSingleview
  28506. * @param name name of the post process
  28507. * @param camera camera to be applied to
  28508. * @param scaleFactor scaling factor to the size of the output texture
  28509. */
  28510. constructor(name: string, camera: Camera, scaleFactor: number);
  28511. }
  28512. }
  28513. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  28514. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  28515. import { Nullable } from "babylonjs/types";
  28516. import { Size } from "babylonjs/Maths/math.size";
  28517. import { Observable } from "babylonjs/Misc/observable";
  28518. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  28519. /**
  28520. * Interface used to define additional presentation attributes
  28521. */
  28522. export interface IVRPresentationAttributes {
  28523. /**
  28524. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28525. */
  28526. highRefreshRate: boolean;
  28527. /**
  28528. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28529. */
  28530. foveationLevel: number;
  28531. }
  28532. module "babylonjs/Engines/engine" {
  28533. interface Engine {
  28534. /** @hidden */
  28535. _vrDisplay: any;
  28536. /** @hidden */
  28537. _vrSupported: boolean;
  28538. /** @hidden */
  28539. _oldSize: Size;
  28540. /** @hidden */
  28541. _oldHardwareScaleFactor: number;
  28542. /** @hidden */
  28543. _vrExclusivePointerMode: boolean;
  28544. /** @hidden */
  28545. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28546. /** @hidden */
  28547. _onVRDisplayPointerRestricted: () => void;
  28548. /** @hidden */
  28549. _onVRDisplayPointerUnrestricted: () => void;
  28550. /** @hidden */
  28551. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28552. /** @hidden */
  28553. _onVrDisplayDisconnect: Nullable<() => void>;
  28554. /** @hidden */
  28555. _onVrDisplayPresentChange: Nullable<() => void>;
  28556. /**
  28557. * Observable signaled when VR display mode changes
  28558. */
  28559. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28560. /**
  28561. * Observable signaled when VR request present is complete
  28562. */
  28563. onVRRequestPresentComplete: Observable<boolean>;
  28564. /**
  28565. * Observable signaled when VR request present starts
  28566. */
  28567. onVRRequestPresentStart: Observable<Engine>;
  28568. /**
  28569. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28570. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28571. */
  28572. isInVRExclusivePointerMode: boolean;
  28573. /**
  28574. * Gets a boolean indicating if a webVR device was detected
  28575. * @returns true if a webVR device was detected
  28576. */
  28577. isVRDevicePresent(): boolean;
  28578. /**
  28579. * Gets the current webVR device
  28580. * @returns the current webVR device (or null)
  28581. */
  28582. getVRDevice(): any;
  28583. /**
  28584. * Initializes a webVR display and starts listening to display change events
  28585. * The onVRDisplayChangedObservable will be notified upon these changes
  28586. * @returns A promise containing a VRDisplay and if vr is supported
  28587. */
  28588. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28589. /** @hidden */
  28590. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28591. /**
  28592. * Gets or sets the presentation attributes used to configure VR rendering
  28593. */
  28594. vrPresentationAttributes?: IVRPresentationAttributes;
  28595. /**
  28596. * Call this function to switch to webVR mode
  28597. * Will do nothing if webVR is not supported or if there is no webVR device
  28598. * @param options the webvr options provided to the camera. mainly used for multiview
  28599. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28600. */
  28601. enableVR(options: WebVROptions): void;
  28602. /** @hidden */
  28603. _onVRFullScreenTriggered(): void;
  28604. }
  28605. }
  28606. }
  28607. declare module "babylonjs/Cameras/VR/webVRCamera" {
  28608. import { Nullable } from "babylonjs/types";
  28609. import { Observable } from "babylonjs/Misc/observable";
  28610. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  28611. import { Scene } from "babylonjs/scene";
  28612. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28613. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  28614. import { Node } from "babylonjs/node";
  28615. import { Ray } from "babylonjs/Culling/ray";
  28616. import "babylonjs/Cameras/RigModes/webVRRigMode";
  28617. import "babylonjs/Engines/Extensions/engine.webVR";
  28618. /**
  28619. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28620. * IMPORTANT!! The data is right-hand data.
  28621. * @export
  28622. * @interface DevicePose
  28623. */
  28624. export interface DevicePose {
  28625. /**
  28626. * The position of the device, values in array are [x,y,z].
  28627. */
  28628. readonly position: Nullable<Float32Array>;
  28629. /**
  28630. * The linearVelocity of the device, values in array are [x,y,z].
  28631. */
  28632. readonly linearVelocity: Nullable<Float32Array>;
  28633. /**
  28634. * The linearAcceleration of the device, values in array are [x,y,z].
  28635. */
  28636. readonly linearAcceleration: Nullable<Float32Array>;
  28637. /**
  28638. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28639. */
  28640. readonly orientation: Nullable<Float32Array>;
  28641. /**
  28642. * The angularVelocity of the device, values in array are [x,y,z].
  28643. */
  28644. readonly angularVelocity: Nullable<Float32Array>;
  28645. /**
  28646. * The angularAcceleration of the device, values in array are [x,y,z].
  28647. */
  28648. readonly angularAcceleration: Nullable<Float32Array>;
  28649. }
  28650. /**
  28651. * Interface representing a pose controlled object in Babylon.
  28652. * A pose controlled object has both regular pose values as well as pose values
  28653. * from an external device such as a VR head mounted display
  28654. */
  28655. export interface PoseControlled {
  28656. /**
  28657. * The position of the object in babylon space.
  28658. */
  28659. position: Vector3;
  28660. /**
  28661. * The rotation quaternion of the object in babylon space.
  28662. */
  28663. rotationQuaternion: Quaternion;
  28664. /**
  28665. * The position of the device in babylon space.
  28666. */
  28667. devicePosition?: Vector3;
  28668. /**
  28669. * The rotation quaternion of the device in babylon space.
  28670. */
  28671. deviceRotationQuaternion: Quaternion;
  28672. /**
  28673. * The raw pose coming from the device.
  28674. */
  28675. rawPose: Nullable<DevicePose>;
  28676. /**
  28677. * The scale of the device to be used when translating from device space to babylon space.
  28678. */
  28679. deviceScaleFactor: number;
  28680. /**
  28681. * Updates the poseControlled values based on the input device pose.
  28682. * @param poseData the pose data to update the object with
  28683. */
  28684. updateFromDevice(poseData: DevicePose): void;
  28685. }
  28686. /**
  28687. * Set of options to customize the webVRCamera
  28688. */
  28689. export interface WebVROptions {
  28690. /**
  28691. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28692. */
  28693. trackPosition?: boolean;
  28694. /**
  28695. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28696. */
  28697. positionScale?: number;
  28698. /**
  28699. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28700. */
  28701. displayName?: string;
  28702. /**
  28703. * Should the native controller meshes be initialized. (default: true)
  28704. */
  28705. controllerMeshes?: boolean;
  28706. /**
  28707. * Creating a default HemiLight only on controllers. (default: true)
  28708. */
  28709. defaultLightingOnControllers?: boolean;
  28710. /**
  28711. * If you don't want to use the default VR button of the helper. (default: false)
  28712. */
  28713. useCustomVRButton?: boolean;
  28714. /**
  28715. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28716. */
  28717. customVRButton?: HTMLButtonElement;
  28718. /**
  28719. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28720. */
  28721. rayLength?: number;
  28722. /**
  28723. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28724. */
  28725. defaultHeight?: number;
  28726. /**
  28727. * If multiview should be used if availible (default: false)
  28728. */
  28729. useMultiview?: boolean;
  28730. }
  28731. /**
  28732. * This represents a WebVR camera.
  28733. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28734. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28735. */
  28736. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28737. private webVROptions;
  28738. /**
  28739. * @hidden
  28740. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28741. */
  28742. _vrDevice: any;
  28743. /**
  28744. * The rawPose of the vrDevice.
  28745. */
  28746. rawPose: Nullable<DevicePose>;
  28747. private _onVREnabled;
  28748. private _specsVersion;
  28749. private _attached;
  28750. private _frameData;
  28751. protected _descendants: Array<Node>;
  28752. private _deviceRoomPosition;
  28753. /** @hidden */
  28754. _deviceRoomRotationQuaternion: Quaternion;
  28755. private _standingMatrix;
  28756. /**
  28757. * Represents device position in babylon space.
  28758. */
  28759. devicePosition: Vector3;
  28760. /**
  28761. * Represents device rotation in babylon space.
  28762. */
  28763. deviceRotationQuaternion: Quaternion;
  28764. /**
  28765. * The scale of the device to be used when translating from device space to babylon space.
  28766. */
  28767. deviceScaleFactor: number;
  28768. private _deviceToWorld;
  28769. private _worldToDevice;
  28770. /**
  28771. * References to the webVR controllers for the vrDevice.
  28772. */
  28773. controllers: Array<WebVRController>;
  28774. /**
  28775. * Emits an event when a controller is attached.
  28776. */
  28777. onControllersAttachedObservable: Observable<WebVRController[]>;
  28778. /**
  28779. * Emits an event when a controller's mesh has been loaded;
  28780. */
  28781. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28782. /**
  28783. * Emits an event when the HMD's pose has been updated.
  28784. */
  28785. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28786. private _poseSet;
  28787. /**
  28788. * If the rig cameras be used as parent instead of this camera.
  28789. */
  28790. rigParenting: boolean;
  28791. private _lightOnControllers;
  28792. private _defaultHeight?;
  28793. /**
  28794. * Instantiates a WebVRFreeCamera.
  28795. * @param name The name of the WebVRFreeCamera
  28796. * @param position The starting anchor position for the camera
  28797. * @param scene The scene the camera belongs to
  28798. * @param webVROptions a set of customizable options for the webVRCamera
  28799. */
  28800. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28801. /**
  28802. * Gets the device distance from the ground in meters.
  28803. * @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.
  28804. */
  28805. deviceDistanceToRoomGround(): number;
  28806. /**
  28807. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28808. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28809. */
  28810. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28811. /**
  28812. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28813. * @returns A promise with a boolean set to if the standing matrix is supported.
  28814. */
  28815. useStandingMatrixAsync(): Promise<boolean>;
  28816. /**
  28817. * Disposes the camera
  28818. */
  28819. dispose(): void;
  28820. /**
  28821. * Gets a vrController by name.
  28822. * @param name The name of the controller to retreive
  28823. * @returns the controller matching the name specified or null if not found
  28824. */
  28825. getControllerByName(name: string): Nullable<WebVRController>;
  28826. private _leftController;
  28827. /**
  28828. * The controller corresponding to the users left hand.
  28829. */
  28830. get leftController(): Nullable<WebVRController>;
  28831. private _rightController;
  28832. /**
  28833. * The controller corresponding to the users right hand.
  28834. */
  28835. get rightController(): Nullable<WebVRController>;
  28836. /**
  28837. * Casts a ray forward from the vrCamera's gaze.
  28838. * @param length Length of the ray (default: 100)
  28839. * @returns the ray corresponding to the gaze
  28840. */
  28841. getForwardRay(length?: number): Ray;
  28842. /**
  28843. * @hidden
  28844. * Updates the camera based on device's frame data
  28845. */
  28846. _checkInputs(): void;
  28847. /**
  28848. * Updates the poseControlled values based on the input device pose.
  28849. * @param poseData Pose coming from the device
  28850. */
  28851. updateFromDevice(poseData: DevicePose): void;
  28852. private _detachIfAttached;
  28853. /**
  28854. * WebVR's attach control will start broadcasting frames to the device.
  28855. * Note that in certain browsers (chrome for example) this function must be called
  28856. * within a user-interaction callback. Example:
  28857. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28858. *
  28859. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28860. */
  28861. attachControl(noPreventDefault?: boolean): void;
  28862. /**
  28863. * Detach the current controls from the specified dom element.
  28864. */
  28865. detachControl(): void;
  28866. /**
  28867. * @returns the name of this class
  28868. */
  28869. getClassName(): string;
  28870. /**
  28871. * Calls resetPose on the vrDisplay
  28872. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28873. */
  28874. resetToCurrentRotation(): void;
  28875. /**
  28876. * @hidden
  28877. * Updates the rig cameras (left and right eye)
  28878. */
  28879. _updateRigCameras(): void;
  28880. private _workingVector;
  28881. private _oneVector;
  28882. private _workingMatrix;
  28883. private updateCacheCalled;
  28884. private _correctPositionIfNotTrackPosition;
  28885. /**
  28886. * @hidden
  28887. * Updates the cached values of the camera
  28888. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28889. */
  28890. _updateCache(ignoreParentClass?: boolean): void;
  28891. /**
  28892. * @hidden
  28893. * Get current device position in babylon world
  28894. */
  28895. _computeDevicePosition(): void;
  28896. /**
  28897. * Updates the current device position and rotation in the babylon world
  28898. */
  28899. update(): void;
  28900. /**
  28901. * @hidden
  28902. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28903. * @returns an identity matrix
  28904. */
  28905. _getViewMatrix(): Matrix;
  28906. private _tmpMatrix;
  28907. /**
  28908. * This function is called by the two RIG cameras.
  28909. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28910. * @hidden
  28911. */
  28912. _getWebVRViewMatrix(): Matrix;
  28913. /** @hidden */
  28914. _getWebVRProjectionMatrix(): Matrix;
  28915. private _onGamepadConnectedObserver;
  28916. private _onGamepadDisconnectedObserver;
  28917. private _updateCacheWhenTrackingDisabledObserver;
  28918. /**
  28919. * Initializes the controllers and their meshes
  28920. */
  28921. initControllers(): void;
  28922. }
  28923. }
  28924. declare module "babylonjs/Materials/materialHelper" {
  28925. import { Nullable } from "babylonjs/types";
  28926. import { Scene } from "babylonjs/scene";
  28927. import { Engine } from "babylonjs/Engines/engine";
  28928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28929. import { Light } from "babylonjs/Lights/light";
  28930. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28932. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28934. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28935. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28936. import { Vector4 } from "babylonjs/Maths/math.vector";
  28937. /**
  28938. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28939. *
  28940. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28941. *
  28942. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28943. */
  28944. export class MaterialHelper {
  28945. /**
  28946. * Bind the current view position to an effect.
  28947. * @param effect The effect to be bound
  28948. * @param scene The scene the eyes position is used from
  28949. * @param variableName name of the shader variable that will hold the eye position
  28950. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28951. * @return the computed eye position
  28952. */
  28953. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28954. /**
  28955. * Helps preparing the defines values about the UVs in used in the effect.
  28956. * UVs are shared as much as we can accross channels in the shaders.
  28957. * @param texture The texture we are preparing the UVs for
  28958. * @param defines The defines to update
  28959. * @param key The channel key "diffuse", "specular"... used in the shader
  28960. */
  28961. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28962. /**
  28963. * Binds a texture matrix value to its corrsponding uniform
  28964. * @param texture The texture to bind the matrix for
  28965. * @param uniformBuffer The uniform buffer receivin the data
  28966. * @param key The channel key "diffuse", "specular"... used in the shader
  28967. */
  28968. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28969. /**
  28970. * Gets the current status of the fog (should it be enabled?)
  28971. * @param mesh defines the mesh to evaluate for fog support
  28972. * @param scene defines the hosting scene
  28973. * @returns true if fog must be enabled
  28974. */
  28975. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28976. /**
  28977. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28978. * @param mesh defines the current mesh
  28979. * @param scene defines the current scene
  28980. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28981. * @param pointsCloud defines if point cloud rendering has to be turned on
  28982. * @param fogEnabled defines if fog has to be turned on
  28983. * @param alphaTest defines if alpha testing has to be turned on
  28984. * @param defines defines the current list of defines
  28985. */
  28986. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28987. /**
  28988. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28989. * @param scene defines the current scene
  28990. * @param engine defines the current engine
  28991. * @param defines specifies the list of active defines
  28992. * @param useInstances defines if instances have to be turned on
  28993. * @param useClipPlane defines if clip plane have to be turned on
  28994. * @param useInstances defines if instances have to be turned on
  28995. * @param useThinInstances defines if thin instances have to be turned on
  28996. */
  28997. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28998. /**
  28999. * Prepares the defines for bones
  29000. * @param mesh The mesh containing the geometry data we will draw
  29001. * @param defines The defines to update
  29002. */
  29003. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  29004. /**
  29005. * Prepares the defines for morph targets
  29006. * @param mesh The mesh containing the geometry data we will draw
  29007. * @param defines The defines to update
  29008. */
  29009. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  29010. /**
  29011. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  29012. * @param mesh The mesh containing the geometry data we will draw
  29013. * @param defines The defines to update
  29014. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  29015. * @param useBones Precise whether bones should be used or not (override mesh info)
  29016. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  29017. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  29018. * @returns false if defines are considered not dirty and have not been checked
  29019. */
  29020. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  29021. /**
  29022. * Prepares the defines related to multiview
  29023. * @param scene The scene we are intending to draw
  29024. * @param defines The defines to update
  29025. */
  29026. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  29027. /**
  29028. * Prepares the defines related to the prepass
  29029. * @param scene The scene we are intending to draw
  29030. * @param defines The defines to update
  29031. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  29032. */
  29033. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  29034. /**
  29035. * Prepares the defines related to the light information passed in parameter
  29036. * @param scene The scene we are intending to draw
  29037. * @param mesh The mesh the effect is compiling for
  29038. * @param light The light the effect is compiling for
  29039. * @param lightIndex The index of the light
  29040. * @param defines The defines to update
  29041. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29042. * @param state Defines the current state regarding what is needed (normals, etc...)
  29043. */
  29044. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  29045. needNormals: boolean;
  29046. needRebuild: boolean;
  29047. shadowEnabled: boolean;
  29048. specularEnabled: boolean;
  29049. lightmapMode: boolean;
  29050. }): void;
  29051. /**
  29052. * Prepares the defines related to the light information passed in parameter
  29053. * @param scene The scene we are intending to draw
  29054. * @param mesh The mesh the effect is compiling for
  29055. * @param defines The defines to update
  29056. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29057. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  29058. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  29059. * @returns true if normals will be required for the rest of the effect
  29060. */
  29061. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  29062. /**
  29063. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  29064. * @param lightIndex defines the light index
  29065. * @param uniformsList The uniform list
  29066. * @param samplersList The sampler list
  29067. * @param projectedLightTexture defines if projected texture must be used
  29068. * @param uniformBuffersList defines an optional list of uniform buffers
  29069. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  29070. */
  29071. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  29072. /**
  29073. * Prepares the uniforms and samplers list to be used in the effect
  29074. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  29075. * @param samplersList The sampler list
  29076. * @param defines The defines helping in the list generation
  29077. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  29078. */
  29079. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  29080. /**
  29081. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  29082. * @param defines The defines to update while falling back
  29083. * @param fallbacks The authorized effect fallbacks
  29084. * @param maxSimultaneousLights The maximum number of lights allowed
  29085. * @param rank the current rank of the Effect
  29086. * @returns The newly affected rank
  29087. */
  29088. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  29089. private static _TmpMorphInfluencers;
  29090. /**
  29091. * Prepares the list of attributes required for morph targets according to the effect defines.
  29092. * @param attribs The current list of supported attribs
  29093. * @param mesh The mesh to prepare the morph targets attributes for
  29094. * @param influencers The number of influencers
  29095. */
  29096. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  29097. /**
  29098. * Prepares the list of attributes required for morph targets according to the effect defines.
  29099. * @param attribs The current list of supported attribs
  29100. * @param mesh The mesh to prepare the morph targets attributes for
  29101. * @param defines The current Defines of the effect
  29102. */
  29103. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  29104. /**
  29105. * Prepares the list of attributes required for bones according to the effect defines.
  29106. * @param attribs The current list of supported attribs
  29107. * @param mesh The mesh to prepare the bones attributes for
  29108. * @param defines The current Defines of the effect
  29109. * @param fallbacks The current efffect fallback strategy
  29110. */
  29111. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  29112. /**
  29113. * Check and prepare the list of attributes required for instances according to the effect defines.
  29114. * @param attribs The current list of supported attribs
  29115. * @param defines The current MaterialDefines of the effect
  29116. */
  29117. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  29118. /**
  29119. * Add the list of attributes required for instances to the attribs array.
  29120. * @param attribs The current list of supported attribs
  29121. */
  29122. static PushAttributesForInstances(attribs: string[]): void;
  29123. /**
  29124. * Binds the light information to the effect.
  29125. * @param light The light containing the generator
  29126. * @param effect The effect we are binding the data to
  29127. * @param lightIndex The light index in the effect used to render
  29128. */
  29129. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  29130. /**
  29131. * Binds the lights information from the scene to the effect for the given mesh.
  29132. * @param light Light to bind
  29133. * @param lightIndex Light index
  29134. * @param scene The scene where the light belongs to
  29135. * @param effect The effect we are binding the data to
  29136. * @param useSpecular Defines if specular is supported
  29137. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29138. */
  29139. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  29140. /**
  29141. * Binds the lights information from the scene to the effect for the given mesh.
  29142. * @param scene The scene the lights belongs to
  29143. * @param mesh The mesh we are binding the information to render
  29144. * @param effect The effect we are binding the data to
  29145. * @param defines The generated defines for the effect
  29146. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  29147. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29148. */
  29149. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  29150. private static _tempFogColor;
  29151. /**
  29152. * Binds the fog information from the scene to the effect for the given mesh.
  29153. * @param scene The scene the lights belongs to
  29154. * @param mesh The mesh we are binding the information to render
  29155. * @param effect The effect we are binding the data to
  29156. * @param linearSpace Defines if the fog effect is applied in linear space
  29157. */
  29158. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  29159. /**
  29160. * Binds the bones information from the mesh to the effect.
  29161. * @param mesh The mesh we are binding the information to render
  29162. * @param effect The effect we are binding the data to
  29163. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  29164. */
  29165. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  29166. private static _CopyBonesTransformationMatrices;
  29167. /**
  29168. * Binds the morph targets information from the mesh to the effect.
  29169. * @param abstractMesh The mesh we are binding the information to render
  29170. * @param effect The effect we are binding the data to
  29171. */
  29172. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  29173. /**
  29174. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  29175. * @param defines The generated defines used in the effect
  29176. * @param effect The effect we are binding the data to
  29177. * @param scene The scene we are willing to render with logarithmic scale for
  29178. */
  29179. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  29180. /**
  29181. * Binds the clip plane information from the scene to the effect.
  29182. * @param scene The scene the clip plane information are extracted from
  29183. * @param effect The effect we are binding the data to
  29184. */
  29185. static BindClipPlane(effect: Effect, scene: Scene): void;
  29186. }
  29187. }
  29188. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  29189. /** @hidden */
  29190. export var bayerDitherFunctions: {
  29191. name: string;
  29192. shader: string;
  29193. };
  29194. }
  29195. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  29196. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29197. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  29198. /** @hidden */
  29199. export var shadowMapFragmentDeclaration: {
  29200. name: string;
  29201. shader: string;
  29202. };
  29203. }
  29204. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  29205. /** @hidden */
  29206. export var shadowMapFragment: {
  29207. name: string;
  29208. shader: string;
  29209. };
  29210. }
  29211. declare module "babylonjs/Shaders/shadowMap.fragment" {
  29212. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  29213. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29214. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29215. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  29216. /** @hidden */
  29217. export var shadowMapPixelShader: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  29223. /** @hidden */
  29224. export var shadowMapVertexDeclaration: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  29230. /** @hidden */
  29231. export var shadowMapVertexNormalBias: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  29237. /** @hidden */
  29238. export var shadowMapVertexMetric: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module "babylonjs/Shaders/shadowMap.vertex" {
  29244. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29245. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  29246. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  29247. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29248. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  29249. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  29250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  29252. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29253. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29254. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  29255. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  29256. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29257. /** @hidden */
  29258. export var shadowMapVertexShader: {
  29259. name: string;
  29260. shader: string;
  29261. };
  29262. }
  29263. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  29264. /** @hidden */
  29265. export var depthBoxBlurPixelShader: {
  29266. name: string;
  29267. shader: string;
  29268. };
  29269. }
  29270. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  29271. /** @hidden */
  29272. export var shadowMapFragmentSoftTransparentShadow: {
  29273. name: string;
  29274. shader: string;
  29275. };
  29276. }
  29277. declare module "babylonjs/Meshes/instancedMesh" {
  29278. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29279. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29280. import { Camera } from "babylonjs/Cameras/camera";
  29281. import { Node } from "babylonjs/node";
  29282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29283. import { Mesh } from "babylonjs/Meshes/mesh";
  29284. import { Material } from "babylonjs/Materials/material";
  29285. import { Skeleton } from "babylonjs/Bones/skeleton";
  29286. import { Light } from "babylonjs/Lights/light";
  29287. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29288. /**
  29289. * Creates an instance based on a source mesh.
  29290. */
  29291. export class InstancedMesh extends AbstractMesh {
  29292. private _sourceMesh;
  29293. private _currentLOD;
  29294. /** @hidden */
  29295. _indexInSourceMeshInstanceArray: number;
  29296. constructor(name: string, source: Mesh);
  29297. /**
  29298. * Returns the string "InstancedMesh".
  29299. */
  29300. getClassName(): string;
  29301. /** Gets the list of lights affecting that mesh */
  29302. get lightSources(): Light[];
  29303. _resyncLightSources(): void;
  29304. _resyncLightSource(light: Light): void;
  29305. _removeLightSource(light: Light, dispose: boolean): void;
  29306. /**
  29307. * If the source mesh receives shadows
  29308. */
  29309. get receiveShadows(): boolean;
  29310. /**
  29311. * The material of the source mesh
  29312. */
  29313. get material(): Nullable<Material>;
  29314. /**
  29315. * Visibility of the source mesh
  29316. */
  29317. get visibility(): number;
  29318. /**
  29319. * Skeleton of the source mesh
  29320. */
  29321. get skeleton(): Nullable<Skeleton>;
  29322. /**
  29323. * Rendering ground id of the source mesh
  29324. */
  29325. get renderingGroupId(): number;
  29326. set renderingGroupId(value: number);
  29327. /**
  29328. * Returns the total number of vertices (integer).
  29329. */
  29330. getTotalVertices(): number;
  29331. /**
  29332. * Returns a positive integer : the total number of indices in this mesh geometry.
  29333. * @returns the numner of indices or zero if the mesh has no geometry.
  29334. */
  29335. getTotalIndices(): number;
  29336. /**
  29337. * The source mesh of the instance
  29338. */
  29339. get sourceMesh(): Mesh;
  29340. /**
  29341. * Creates a new InstancedMesh object from the mesh model.
  29342. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29343. * @param name defines the name of the new instance
  29344. * @returns a new InstancedMesh
  29345. */
  29346. createInstance(name: string): InstancedMesh;
  29347. /**
  29348. * Is this node ready to be used/rendered
  29349. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29350. * @return {boolean} is it ready
  29351. */
  29352. isReady(completeCheck?: boolean): boolean;
  29353. /**
  29354. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29355. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  29356. * @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.
  29357. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  29358. */
  29359. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  29360. /**
  29361. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29362. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29363. * The `data` are either a numeric array either a Float32Array.
  29364. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  29365. * 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).
  29366. * Note that a new underlying VertexBuffer object is created each call.
  29367. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29368. *
  29369. * Possible `kind` values :
  29370. * - VertexBuffer.PositionKind
  29371. * - VertexBuffer.UVKind
  29372. * - VertexBuffer.UV2Kind
  29373. * - VertexBuffer.UV3Kind
  29374. * - VertexBuffer.UV4Kind
  29375. * - VertexBuffer.UV5Kind
  29376. * - VertexBuffer.UV6Kind
  29377. * - VertexBuffer.ColorKind
  29378. * - VertexBuffer.MatricesIndicesKind
  29379. * - VertexBuffer.MatricesIndicesExtraKind
  29380. * - VertexBuffer.MatricesWeightsKind
  29381. * - VertexBuffer.MatricesWeightsExtraKind
  29382. *
  29383. * Returns the Mesh.
  29384. */
  29385. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29386. /**
  29387. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29388. * If the mesh has no geometry, it is simply returned as it is.
  29389. * The `data` are either a numeric array either a Float32Array.
  29390. * No new underlying VertexBuffer object is created.
  29391. * 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.
  29392. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  29393. *
  29394. * Possible `kind` values :
  29395. * - VertexBuffer.PositionKind
  29396. * - VertexBuffer.UVKind
  29397. * - VertexBuffer.UV2Kind
  29398. * - VertexBuffer.UV3Kind
  29399. * - VertexBuffer.UV4Kind
  29400. * - VertexBuffer.UV5Kind
  29401. * - VertexBuffer.UV6Kind
  29402. * - VertexBuffer.ColorKind
  29403. * - VertexBuffer.MatricesIndicesKind
  29404. * - VertexBuffer.MatricesIndicesExtraKind
  29405. * - VertexBuffer.MatricesWeightsKind
  29406. * - VertexBuffer.MatricesWeightsExtraKind
  29407. *
  29408. * Returns the Mesh.
  29409. */
  29410. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  29411. /**
  29412. * Sets the mesh indices.
  29413. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  29414. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29415. * This method creates a new index buffer each call.
  29416. * Returns the Mesh.
  29417. */
  29418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  29419. /**
  29420. * Boolean : True if the mesh owns the requested kind of data.
  29421. */
  29422. isVerticesDataPresent(kind: string): boolean;
  29423. /**
  29424. * Returns an array of indices (IndicesArray).
  29425. */
  29426. getIndices(): Nullable<IndicesArray>;
  29427. get _positions(): Nullable<Vector3[]>;
  29428. /**
  29429. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29430. * This means the mesh underlying bounding box and sphere are recomputed.
  29431. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29432. * @returns the current mesh
  29433. */
  29434. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  29435. /** @hidden */
  29436. _preActivate(): InstancedMesh;
  29437. /** @hidden */
  29438. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29439. /** @hidden */
  29440. _postActivate(): void;
  29441. getWorldMatrix(): Matrix;
  29442. get isAnInstance(): boolean;
  29443. /**
  29444. * Returns the current associated LOD AbstractMesh.
  29445. */
  29446. getLOD(camera: Camera): AbstractMesh;
  29447. /** @hidden */
  29448. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29449. /** @hidden */
  29450. _syncSubMeshes(): InstancedMesh;
  29451. /** @hidden */
  29452. _generatePointsArray(): boolean;
  29453. /** @hidden */
  29454. _updateBoundingInfo(): AbstractMesh;
  29455. /**
  29456. * Creates a new InstancedMesh from the current mesh.
  29457. * - name (string) : the cloned mesh name
  29458. * - newParent (optional Node) : the optional Node to parent the clone to.
  29459. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  29460. *
  29461. * Returns the clone.
  29462. */
  29463. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  29464. /**
  29465. * Disposes the InstancedMesh.
  29466. * Returns nothing.
  29467. */
  29468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29469. }
  29470. module "babylonjs/Meshes/mesh" {
  29471. interface Mesh {
  29472. /**
  29473. * Register a custom buffer that will be instanced
  29474. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29475. * @param kind defines the buffer kind
  29476. * @param stride defines the stride in floats
  29477. */
  29478. registerInstancedBuffer(kind: string, stride: number): void;
  29479. /**
  29480. * true to use the edge renderer for all instances of this mesh
  29481. */
  29482. edgesShareWithInstances: boolean;
  29483. /** @hidden */
  29484. _userInstancedBuffersStorage: {
  29485. data: {
  29486. [key: string]: Float32Array;
  29487. };
  29488. sizes: {
  29489. [key: string]: number;
  29490. };
  29491. vertexBuffers: {
  29492. [key: string]: Nullable<VertexBuffer>;
  29493. };
  29494. strides: {
  29495. [key: string]: number;
  29496. };
  29497. };
  29498. }
  29499. }
  29500. module "babylonjs/Meshes/abstractMesh" {
  29501. interface AbstractMesh {
  29502. /**
  29503. * Object used to store instanced buffers defined by user
  29504. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29505. */
  29506. instancedBuffers: {
  29507. [key: string]: any;
  29508. };
  29509. }
  29510. }
  29511. }
  29512. declare module "babylonjs/Materials/shaderMaterial" {
  29513. import { Nullable } from "babylonjs/types";
  29514. import { Scene } from "babylonjs/scene";
  29515. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29517. import { Mesh } from "babylonjs/Meshes/mesh";
  29518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29520. import { Effect } from "babylonjs/Materials/effect";
  29521. import { Material } from "babylonjs/Materials/material";
  29522. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29523. /**
  29524. * Defines the options associated with the creation of a shader material.
  29525. */
  29526. export interface IShaderMaterialOptions {
  29527. /**
  29528. * Does the material work in alpha blend mode
  29529. */
  29530. needAlphaBlending: boolean;
  29531. /**
  29532. * Does the material work in alpha test mode
  29533. */
  29534. needAlphaTesting: boolean;
  29535. /**
  29536. * The list of attribute names used in the shader
  29537. */
  29538. attributes: string[];
  29539. /**
  29540. * The list of unifrom names used in the shader
  29541. */
  29542. uniforms: string[];
  29543. /**
  29544. * The list of UBO names used in the shader
  29545. */
  29546. uniformBuffers: string[];
  29547. /**
  29548. * The list of sampler names used in the shader
  29549. */
  29550. samplers: string[];
  29551. /**
  29552. * The list of defines used in the shader
  29553. */
  29554. defines: string[];
  29555. }
  29556. /**
  29557. * 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.
  29558. *
  29559. * This returned material effects how the mesh will look based on the code in the shaders.
  29560. *
  29561. * @see https://doc.babylonjs.com/how_to/shader_material
  29562. */
  29563. export class ShaderMaterial extends Material {
  29564. private _shaderPath;
  29565. private _options;
  29566. private _textures;
  29567. private _textureArrays;
  29568. private _floats;
  29569. private _ints;
  29570. private _floatsArrays;
  29571. private _colors3;
  29572. private _colors3Arrays;
  29573. private _colors4;
  29574. private _colors4Arrays;
  29575. private _vectors2;
  29576. private _vectors3;
  29577. private _vectors4;
  29578. private _matrices;
  29579. private _matrixArrays;
  29580. private _matrices3x3;
  29581. private _matrices2x2;
  29582. private _vectors2Arrays;
  29583. private _vectors3Arrays;
  29584. private _vectors4Arrays;
  29585. private _cachedWorldViewMatrix;
  29586. private _cachedWorldViewProjectionMatrix;
  29587. private _renderId;
  29588. private _multiview;
  29589. private _cachedDefines;
  29590. /** Define the Url to load snippets */
  29591. static SnippetUrl: string;
  29592. /** Snippet ID if the material was created from the snippet server */
  29593. snippetId: string;
  29594. /**
  29595. * Instantiate a new shader material.
  29596. * 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.
  29597. * This returned material effects how the mesh will look based on the code in the shaders.
  29598. * @see https://doc.babylonjs.com/how_to/shader_material
  29599. * @param name Define the name of the material in the scene
  29600. * @param scene Define the scene the material belongs to
  29601. * @param shaderPath Defines the route to the shader code in one of three ways:
  29602. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29603. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29604. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29605. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29606. * @param options Define the options used to create the shader
  29607. */
  29608. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29609. /**
  29610. * Gets the shader path used to define the shader code
  29611. * It can be modified to trigger a new compilation
  29612. */
  29613. get shaderPath(): any;
  29614. /**
  29615. * Sets the shader path used to define the shader code
  29616. * It can be modified to trigger a new compilation
  29617. */
  29618. set shaderPath(shaderPath: any);
  29619. /**
  29620. * Gets the options used to compile the shader.
  29621. * They can be modified to trigger a new compilation
  29622. */
  29623. get options(): IShaderMaterialOptions;
  29624. /**
  29625. * Gets the current class name of the material e.g. "ShaderMaterial"
  29626. * Mainly use in serialization.
  29627. * @returns the class name
  29628. */
  29629. getClassName(): string;
  29630. /**
  29631. * Specifies if the material will require alpha blending
  29632. * @returns a boolean specifying if alpha blending is needed
  29633. */
  29634. needAlphaBlending(): boolean;
  29635. /**
  29636. * Specifies if this material should be rendered in alpha test mode
  29637. * @returns a boolean specifying if an alpha test is needed.
  29638. */
  29639. needAlphaTesting(): boolean;
  29640. private _checkUniform;
  29641. /**
  29642. * Set a texture in the shader.
  29643. * @param name Define the name of the uniform samplers as defined in the shader
  29644. * @param texture Define the texture to bind to this sampler
  29645. * @return the material itself allowing "fluent" like uniform updates
  29646. */
  29647. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29648. /**
  29649. * Set a texture array in the shader.
  29650. * @param name Define the name of the uniform sampler array as defined in the shader
  29651. * @param textures Define the list of textures to bind to this sampler
  29652. * @return the material itself allowing "fluent" like uniform updates
  29653. */
  29654. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29655. /**
  29656. * Set a float in the shader.
  29657. * @param name Define the name of the uniform as defined in the shader
  29658. * @param value Define the value to give to the uniform
  29659. * @return the material itself allowing "fluent" like uniform updates
  29660. */
  29661. setFloat(name: string, value: number): ShaderMaterial;
  29662. /**
  29663. * Set a int in the shader.
  29664. * @param name Define the name of the uniform as defined in the shader
  29665. * @param value Define the value to give to the uniform
  29666. * @return the material itself allowing "fluent" like uniform updates
  29667. */
  29668. setInt(name: string, value: number): ShaderMaterial;
  29669. /**
  29670. * Set an array of floats in the shader.
  29671. * @param name Define the name of the uniform as defined in the shader
  29672. * @param value Define the value to give to the uniform
  29673. * @return the material itself allowing "fluent" like uniform updates
  29674. */
  29675. setFloats(name: string, value: number[]): ShaderMaterial;
  29676. /**
  29677. * Set a vec3 in the shader from a Color3.
  29678. * @param name Define the name of the uniform as defined in the shader
  29679. * @param value Define the value to give to the uniform
  29680. * @return the material itself allowing "fluent" like uniform updates
  29681. */
  29682. setColor3(name: string, value: Color3): ShaderMaterial;
  29683. /**
  29684. * Set a vec3 array in the shader from a Color3 array.
  29685. * @param name Define the name of the uniform as defined in the shader
  29686. * @param value Define the value to give to the uniform
  29687. * @return the material itself allowing "fluent" like uniform updates
  29688. */
  29689. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  29690. /**
  29691. * Set a vec4 in the shader from a Color4.
  29692. * @param name Define the name of the uniform as defined in the shader
  29693. * @param value Define the value to give to the uniform
  29694. * @return the material itself allowing "fluent" like uniform updates
  29695. */
  29696. setColor4(name: string, value: Color4): ShaderMaterial;
  29697. /**
  29698. * Set a vec4 array in the shader from a Color4 array.
  29699. * @param name Define the name of the uniform as defined in the shader
  29700. * @param value Define the value to give to the uniform
  29701. * @return the material itself allowing "fluent" like uniform updates
  29702. */
  29703. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  29704. /**
  29705. * Set a vec2 in the shader from a Vector2.
  29706. * @param name Define the name of the uniform as defined in the shader
  29707. * @param value Define the value to give to the uniform
  29708. * @return the material itself allowing "fluent" like uniform updates
  29709. */
  29710. setVector2(name: string, value: Vector2): ShaderMaterial;
  29711. /**
  29712. * Set a vec3 in the shader from a Vector3.
  29713. * @param name Define the name of the uniform as defined in the shader
  29714. * @param value Define the value to give to the uniform
  29715. * @return the material itself allowing "fluent" like uniform updates
  29716. */
  29717. setVector3(name: string, value: Vector3): ShaderMaterial;
  29718. /**
  29719. * Set a vec4 in the shader from a Vector4.
  29720. * @param name Define the name of the uniform as defined in the shader
  29721. * @param value Define the value to give to the uniform
  29722. * @return the material itself allowing "fluent" like uniform updates
  29723. */
  29724. setVector4(name: string, value: Vector4): ShaderMaterial;
  29725. /**
  29726. * Set a mat4 in the shader from a Matrix.
  29727. * @param name Define the name of the uniform as defined in the shader
  29728. * @param value Define the value to give to the uniform
  29729. * @return the material itself allowing "fluent" like uniform updates
  29730. */
  29731. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29732. /**
  29733. * Set a float32Array in the shader from a matrix array.
  29734. * @param name Define the name of the uniform as defined in the shader
  29735. * @param value Define the value to give to the uniform
  29736. * @return the material itself allowing "fluent" like uniform updates
  29737. */
  29738. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29739. /**
  29740. * Set a mat3 in the shader from a Float32Array.
  29741. * @param name Define the name of the uniform as defined in the shader
  29742. * @param value Define the value to give to the uniform
  29743. * @return the material itself allowing "fluent" like uniform updates
  29744. */
  29745. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29746. /**
  29747. * Set a mat2 in the shader from a Float32Array.
  29748. * @param name Define the name of the uniform as defined in the shader
  29749. * @param value Define the value to give to the uniform
  29750. * @return the material itself allowing "fluent" like uniform updates
  29751. */
  29752. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29753. /**
  29754. * Set a vec2 array in the shader from a number array.
  29755. * @param name Define the name of the uniform as defined in the shader
  29756. * @param value Define the value to give to the uniform
  29757. * @return the material itself allowing "fluent" like uniform updates
  29758. */
  29759. setArray2(name: string, value: number[]): ShaderMaterial;
  29760. /**
  29761. * Set a vec3 array in the shader from a number array.
  29762. * @param name Define the name of the uniform as defined in the shader
  29763. * @param value Define the value to give to the uniform
  29764. * @return the material itself allowing "fluent" like uniform updates
  29765. */
  29766. setArray3(name: string, value: number[]): ShaderMaterial;
  29767. /**
  29768. * Set a vec4 array in the shader from a number array.
  29769. * @param name Define the name of the uniform as defined in the shader
  29770. * @param value Define the value to give to the uniform
  29771. * @return the material itself allowing "fluent" like uniform updates
  29772. */
  29773. setArray4(name: string, value: number[]): ShaderMaterial;
  29774. private _checkCache;
  29775. /**
  29776. * Specifies that the submesh is ready to be used
  29777. * @param mesh defines the mesh to check
  29778. * @param subMesh defines which submesh to check
  29779. * @param useInstances specifies that instances should be used
  29780. * @returns a boolean indicating that the submesh is ready or not
  29781. */
  29782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29783. /**
  29784. * Checks if the material is ready to render the requested mesh
  29785. * @param mesh Define the mesh to render
  29786. * @param useInstances Define whether or not the material is used with instances
  29787. * @returns true if ready, otherwise false
  29788. */
  29789. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29790. /**
  29791. * Binds the world matrix to the material
  29792. * @param world defines the world transformation matrix
  29793. * @param effectOverride - If provided, use this effect instead of internal effect
  29794. */
  29795. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29796. /**
  29797. * Binds the submesh to this material by preparing the effect and shader to draw
  29798. * @param world defines the world transformation matrix
  29799. * @param mesh defines the mesh containing the submesh
  29800. * @param subMesh defines the submesh to bind the material to
  29801. */
  29802. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29803. /**
  29804. * Binds the material to the mesh
  29805. * @param world defines the world transformation matrix
  29806. * @param mesh defines the mesh to bind the material to
  29807. * @param effectOverride - If provided, use this effect instead of internal effect
  29808. */
  29809. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29810. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29811. /**
  29812. * Gets the active textures from the material
  29813. * @returns an array of textures
  29814. */
  29815. getActiveTextures(): BaseTexture[];
  29816. /**
  29817. * Specifies if the material uses a texture
  29818. * @param texture defines the texture to check against the material
  29819. * @returns a boolean specifying if the material uses the texture
  29820. */
  29821. hasTexture(texture: BaseTexture): boolean;
  29822. /**
  29823. * Makes a duplicate of the material, and gives it a new name
  29824. * @param name defines the new name for the duplicated material
  29825. * @returns the cloned material
  29826. */
  29827. clone(name: string): ShaderMaterial;
  29828. /**
  29829. * Disposes the material
  29830. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29831. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29832. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29833. */
  29834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29835. /**
  29836. * Serializes this material in a JSON representation
  29837. * @returns the serialized material object
  29838. */
  29839. serialize(): any;
  29840. /**
  29841. * Creates a shader material from parsed shader material data
  29842. * @param source defines the JSON represnetation of the material
  29843. * @param scene defines the hosting scene
  29844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29845. * @returns a new material
  29846. */
  29847. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29848. /**
  29849. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29850. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29851. * @param url defines the url to load from
  29852. * @param scene defines the hosting scene
  29853. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29854. * @returns a promise that will resolve to the new ShaderMaterial
  29855. */
  29856. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29857. /**
  29858. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29859. * @param snippetId defines the snippet to load
  29860. * @param scene defines the hosting scene
  29861. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29862. * @returns a promise that will resolve to the new ShaderMaterial
  29863. */
  29864. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29865. }
  29866. }
  29867. declare module "babylonjs/Shaders/color.fragment" {
  29868. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29869. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29870. /** @hidden */
  29871. export var colorPixelShader: {
  29872. name: string;
  29873. shader: string;
  29874. };
  29875. }
  29876. declare module "babylonjs/Shaders/color.vertex" {
  29877. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29878. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29879. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29880. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29881. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29882. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29883. /** @hidden */
  29884. export var colorVertexShader: {
  29885. name: string;
  29886. shader: string;
  29887. };
  29888. }
  29889. declare module "babylonjs/Meshes/linesMesh" {
  29890. import { Nullable } from "babylonjs/types";
  29891. import { Scene } from "babylonjs/scene";
  29892. import { Color3 } from "babylonjs/Maths/math.color";
  29893. import { Node } from "babylonjs/node";
  29894. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29895. import { Mesh } from "babylonjs/Meshes/mesh";
  29896. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29897. import { Effect } from "babylonjs/Materials/effect";
  29898. import { Material } from "babylonjs/Materials/material";
  29899. import "babylonjs/Shaders/color.fragment";
  29900. import "babylonjs/Shaders/color.vertex";
  29901. /**
  29902. * Line mesh
  29903. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29904. */
  29905. export class LinesMesh extends Mesh {
  29906. /**
  29907. * If vertex color should be applied to the mesh
  29908. */
  29909. readonly useVertexColor?: boolean | undefined;
  29910. /**
  29911. * If vertex alpha should be applied to the mesh
  29912. */
  29913. readonly useVertexAlpha?: boolean | undefined;
  29914. /**
  29915. * Color of the line (Default: White)
  29916. */
  29917. color: Color3;
  29918. /**
  29919. * Alpha of the line (Default: 1)
  29920. */
  29921. alpha: number;
  29922. /**
  29923. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29924. * This margin is expressed in world space coordinates, so its value may vary.
  29925. * Default value is 0.1
  29926. */
  29927. intersectionThreshold: number;
  29928. private _colorShader;
  29929. private color4;
  29930. /**
  29931. * Creates a new LinesMesh
  29932. * @param name defines the name
  29933. * @param scene defines the hosting scene
  29934. * @param parent defines the parent mesh if any
  29935. * @param source defines the optional source LinesMesh used to clone data from
  29936. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29937. * When false, achieved by calling a clone(), also passing False.
  29938. * This will make creation of children, recursive.
  29939. * @param useVertexColor defines if this LinesMesh supports vertex color
  29940. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29941. */
  29942. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29943. /**
  29944. * If vertex color should be applied to the mesh
  29945. */
  29946. useVertexColor?: boolean | undefined,
  29947. /**
  29948. * If vertex alpha should be applied to the mesh
  29949. */
  29950. useVertexAlpha?: boolean | undefined);
  29951. private _addClipPlaneDefine;
  29952. private _removeClipPlaneDefine;
  29953. isReady(): boolean;
  29954. /**
  29955. * Returns the string "LineMesh"
  29956. */
  29957. getClassName(): string;
  29958. /**
  29959. * @hidden
  29960. */
  29961. get material(): Material;
  29962. /**
  29963. * @hidden
  29964. */
  29965. set material(value: Material);
  29966. /**
  29967. * @hidden
  29968. */
  29969. get checkCollisions(): boolean;
  29970. set checkCollisions(value: boolean);
  29971. /** @hidden */
  29972. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29973. /** @hidden */
  29974. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29975. /**
  29976. * Disposes of the line mesh
  29977. * @param doNotRecurse If children should be disposed
  29978. */
  29979. dispose(doNotRecurse?: boolean): void;
  29980. /**
  29981. * Returns a new LineMesh object cloned from the current one.
  29982. */
  29983. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29984. /**
  29985. * Creates a new InstancedLinesMesh object from the mesh model.
  29986. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29987. * @param name defines the name of the new instance
  29988. * @returns a new InstancedLinesMesh
  29989. */
  29990. createInstance(name: string): InstancedLinesMesh;
  29991. }
  29992. /**
  29993. * Creates an instance based on a source LinesMesh
  29994. */
  29995. export class InstancedLinesMesh extends InstancedMesh {
  29996. /**
  29997. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29998. * This margin is expressed in world space coordinates, so its value may vary.
  29999. * Initilized with the intersectionThreshold value of the source LinesMesh
  30000. */
  30001. intersectionThreshold: number;
  30002. constructor(name: string, source: LinesMesh);
  30003. /**
  30004. * Returns the string "InstancedLinesMesh".
  30005. */
  30006. getClassName(): string;
  30007. }
  30008. }
  30009. declare module "babylonjs/Shaders/line.fragment" {
  30010. /** @hidden */
  30011. export var linePixelShader: {
  30012. name: string;
  30013. shader: string;
  30014. };
  30015. }
  30016. declare module "babylonjs/Shaders/line.vertex" {
  30017. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30018. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30019. /** @hidden */
  30020. export var lineVertexShader: {
  30021. name: string;
  30022. shader: string;
  30023. };
  30024. }
  30025. declare module "babylonjs/Rendering/edgesRenderer" {
  30026. import { Immutable, Nullable } from "babylonjs/types";
  30027. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30029. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  30030. import { IDisposable } from "babylonjs/scene";
  30031. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  30032. import "babylonjs/Shaders/line.fragment";
  30033. import "babylonjs/Shaders/line.vertex";
  30034. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30035. import { SmartArray } from "babylonjs/Misc/smartArray";
  30036. module "babylonjs/scene" {
  30037. interface Scene {
  30038. /** @hidden */
  30039. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  30040. }
  30041. }
  30042. module "babylonjs/Meshes/abstractMesh" {
  30043. interface AbstractMesh {
  30044. /**
  30045. * Gets the edgesRenderer associated with the mesh
  30046. */
  30047. edgesRenderer: Nullable<EdgesRenderer>;
  30048. }
  30049. }
  30050. module "babylonjs/Meshes/linesMesh" {
  30051. interface LinesMesh {
  30052. /**
  30053. * Enables the edge rendering mode on the mesh.
  30054. * This mode makes the mesh edges visible
  30055. * @param epsilon defines the maximal distance between two angles to detect a face
  30056. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30057. * @returns the currentAbstractMesh
  30058. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30059. */
  30060. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30061. }
  30062. }
  30063. module "babylonjs/Meshes/linesMesh" {
  30064. interface InstancedLinesMesh {
  30065. /**
  30066. * Enables the edge rendering mode on the mesh.
  30067. * This mode makes the mesh edges visible
  30068. * @param epsilon defines the maximal distance between two angles to detect a face
  30069. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30070. * @returns the current InstancedLinesMesh
  30071. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30072. */
  30073. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  30074. }
  30075. }
  30076. /**
  30077. * Defines the minimum contract an Edges renderer should follow.
  30078. */
  30079. export interface IEdgesRenderer extends IDisposable {
  30080. /**
  30081. * Gets or sets a boolean indicating if the edgesRenderer is active
  30082. */
  30083. isEnabled: boolean;
  30084. /**
  30085. * Renders the edges of the attached mesh,
  30086. */
  30087. render(): void;
  30088. /**
  30089. * Checks wether or not the edges renderer is ready to render.
  30090. * @return true if ready, otherwise false.
  30091. */
  30092. isReady(): boolean;
  30093. /**
  30094. * List of instances to render in case the source mesh has instances
  30095. */
  30096. customInstances: SmartArray<Matrix>;
  30097. }
  30098. /**
  30099. * Defines the additional options of the edges renderer
  30100. */
  30101. export interface IEdgesRendererOptions {
  30102. /**
  30103. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  30104. * If not defined, the default value is true
  30105. */
  30106. useAlternateEdgeFinder?: boolean;
  30107. /**
  30108. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  30109. * If not defined, the default value is true.
  30110. * 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)
  30111. * This option is used only if useAlternateEdgeFinder = true
  30112. */
  30113. useFastVertexMerger?: boolean;
  30114. /**
  30115. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  30116. * The default value is 1e-6
  30117. * This option is used only if useAlternateEdgeFinder = true
  30118. */
  30119. epsilonVertexMerge?: number;
  30120. /**
  30121. * 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
  30122. * 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.
  30123. * This option is used only if useAlternateEdgeFinder = true
  30124. */
  30125. applyTessellation?: boolean;
  30126. /**
  30127. * 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
  30128. * The default value is 1e-6
  30129. * This option is used only if useAlternateEdgeFinder = true
  30130. */
  30131. epsilonVertexAligned?: number;
  30132. }
  30133. /**
  30134. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  30135. */
  30136. export class EdgesRenderer implements IEdgesRenderer {
  30137. /**
  30138. * Define the size of the edges with an orthographic camera
  30139. */
  30140. edgesWidthScalerForOrthographic: number;
  30141. /**
  30142. * Define the size of the edges with a perspective camera
  30143. */
  30144. edgesWidthScalerForPerspective: number;
  30145. protected _source: AbstractMesh;
  30146. protected _linesPositions: number[];
  30147. protected _linesNormals: number[];
  30148. protected _linesIndices: number[];
  30149. protected _epsilon: number;
  30150. protected _indicesCount: number;
  30151. protected _lineShader: ShaderMaterial;
  30152. protected _ib: DataBuffer;
  30153. protected _buffers: {
  30154. [key: string]: Nullable<VertexBuffer>;
  30155. };
  30156. protected _buffersForInstances: {
  30157. [key: string]: Nullable<VertexBuffer>;
  30158. };
  30159. protected _checkVerticesInsteadOfIndices: boolean;
  30160. protected _options: Nullable<IEdgesRendererOptions>;
  30161. private _meshRebuildObserver;
  30162. private _meshDisposeObserver;
  30163. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  30164. isEnabled: boolean;
  30165. /** Gets the vertices generated by the edge renderer */
  30166. get linesPositions(): Immutable<Array<number>>;
  30167. /** Gets the normals generated by the edge renderer */
  30168. get linesNormals(): Immutable<Array<number>>;
  30169. /** Gets the indices generated by the edge renderer */
  30170. get linesIndices(): Immutable<Array<number>>;
  30171. /**
  30172. * List of instances to render in case the source mesh has instances
  30173. */
  30174. customInstances: SmartArray<Matrix>;
  30175. private static GetShader;
  30176. /**
  30177. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  30178. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  30179. * @param source Mesh used to create edges
  30180. * @param epsilon sum of angles in adjacency to check for edge
  30181. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  30182. * @param generateEdgesLines - should generate Lines or only prepare resources.
  30183. * @param options The options to apply when generating the edges
  30184. */
  30185. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  30186. protected _prepareRessources(): void;
  30187. /** @hidden */
  30188. _rebuild(): void;
  30189. /**
  30190. * Releases the required resources for the edges renderer
  30191. */
  30192. dispose(): void;
  30193. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  30194. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  30195. /**
  30196. * Checks if the pair of p0 and p1 is en edge
  30197. * @param faceIndex
  30198. * @param edge
  30199. * @param faceNormals
  30200. * @param p0
  30201. * @param p1
  30202. * @private
  30203. */
  30204. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  30205. /**
  30206. * push line into the position, normal and index buffer
  30207. * @protected
  30208. */
  30209. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  30210. /**
  30211. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  30212. */
  30213. private _tessellateTriangle;
  30214. private _generateEdgesLinesAlternate;
  30215. /**
  30216. * Generates lines edges from adjacencjes
  30217. * @private
  30218. */
  30219. _generateEdgesLines(): void;
  30220. /**
  30221. * Checks wether or not the edges renderer is ready to render.
  30222. * @return true if ready, otherwise false.
  30223. */
  30224. isReady(): boolean;
  30225. /**
  30226. * Renders the edges of the attached mesh,
  30227. */
  30228. render(): void;
  30229. }
  30230. /**
  30231. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  30232. */
  30233. export class LineEdgesRenderer extends EdgesRenderer {
  30234. /**
  30235. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  30236. * @param source LineMesh used to generate edges
  30237. * @param epsilon not important (specified angle for edge detection)
  30238. * @param checkVerticesInsteadOfIndices not important for LineMesh
  30239. */
  30240. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  30241. /**
  30242. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  30243. */
  30244. _generateEdgesLines(): void;
  30245. }
  30246. }
  30247. declare module "babylonjs/Rendering/renderingGroup" {
  30248. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  30249. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30251. import { Nullable } from "babylonjs/types";
  30252. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30253. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  30254. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30255. import { Material } from "babylonjs/Materials/material";
  30256. import { Scene } from "babylonjs/scene";
  30257. /**
  30258. * This represents the object necessary to create a rendering group.
  30259. * This is exclusively used and created by the rendering manager.
  30260. * To modify the behavior, you use the available helpers in your scene or meshes.
  30261. * @hidden
  30262. */
  30263. export class RenderingGroup {
  30264. index: number;
  30265. private static _zeroVector;
  30266. private _scene;
  30267. private _opaqueSubMeshes;
  30268. private _transparentSubMeshes;
  30269. private _alphaTestSubMeshes;
  30270. private _depthOnlySubMeshes;
  30271. private _particleSystems;
  30272. private _spriteManagers;
  30273. private _opaqueSortCompareFn;
  30274. private _alphaTestSortCompareFn;
  30275. private _transparentSortCompareFn;
  30276. private _renderOpaque;
  30277. private _renderAlphaTest;
  30278. private _renderTransparent;
  30279. /** @hidden */
  30280. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  30281. onBeforeTransparentRendering: () => void;
  30282. /**
  30283. * Set the opaque sort comparison function.
  30284. * If null the sub meshes will be render in the order they were created
  30285. */
  30286. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30287. /**
  30288. * Set the alpha test sort comparison function.
  30289. * If null the sub meshes will be render in the order they were created
  30290. */
  30291. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30292. /**
  30293. * Set the transparent sort comparison function.
  30294. * If null the sub meshes will be render in the order they were created
  30295. */
  30296. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30297. /**
  30298. * Creates a new rendering group.
  30299. * @param index The rendering group index
  30300. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  30301. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  30302. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  30303. */
  30304. 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>);
  30305. /**
  30306. * Render all the sub meshes contained in the group.
  30307. * @param customRenderFunction Used to override the default render behaviour of the group.
  30308. * @returns true if rendered some submeshes.
  30309. */
  30310. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  30311. /**
  30312. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  30313. * @param subMeshes The submeshes to render
  30314. */
  30315. private renderOpaqueSorted;
  30316. /**
  30317. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  30318. * @param subMeshes The submeshes to render
  30319. */
  30320. private renderAlphaTestSorted;
  30321. /**
  30322. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  30323. * @param subMeshes The submeshes to render
  30324. */
  30325. private renderTransparentSorted;
  30326. /**
  30327. * Renders the submeshes in a specified order.
  30328. * @param subMeshes The submeshes to sort before render
  30329. * @param sortCompareFn The comparison function use to sort
  30330. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  30331. * @param transparent Specifies to activate blending if true
  30332. */
  30333. private static renderSorted;
  30334. /**
  30335. * Renders the submeshes in the order they were dispatched (no sort applied).
  30336. * @param subMeshes The submeshes to render
  30337. */
  30338. private static renderUnsorted;
  30339. /**
  30340. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30341. * are rendered back to front if in the same alpha index.
  30342. *
  30343. * @param a The first submesh
  30344. * @param b The second submesh
  30345. * @returns The result of the comparison
  30346. */
  30347. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  30348. /**
  30349. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30350. * are rendered back to front.
  30351. *
  30352. * @param a The first submesh
  30353. * @param b The second submesh
  30354. * @returns The result of the comparison
  30355. */
  30356. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  30357. /**
  30358. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30359. * are rendered front to back (prevent overdraw).
  30360. *
  30361. * @param a The first submesh
  30362. * @param b The second submesh
  30363. * @returns The result of the comparison
  30364. */
  30365. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  30366. /**
  30367. * Resets the different lists of submeshes to prepare a new frame.
  30368. */
  30369. prepare(): void;
  30370. dispose(): void;
  30371. /**
  30372. * Inserts the submesh in its correct queue depending on its material.
  30373. * @param subMesh The submesh to dispatch
  30374. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30375. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30376. */
  30377. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30378. dispatchSprites(spriteManager: ISpriteManager): void;
  30379. dispatchParticles(particleSystem: IParticleSystem): void;
  30380. private _renderParticles;
  30381. private _renderSprites;
  30382. }
  30383. }
  30384. declare module "babylonjs/Rendering/renderingManager" {
  30385. import { Nullable } from "babylonjs/types";
  30386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30387. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30388. import { SmartArray } from "babylonjs/Misc/smartArray";
  30389. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30390. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30391. import { Material } from "babylonjs/Materials/material";
  30392. import { Scene } from "babylonjs/scene";
  30393. import { Camera } from "babylonjs/Cameras/camera";
  30394. /**
  30395. * Interface describing the different options available in the rendering manager
  30396. * regarding Auto Clear between groups.
  30397. */
  30398. export interface IRenderingManagerAutoClearSetup {
  30399. /**
  30400. * Defines whether or not autoclear is enable.
  30401. */
  30402. autoClear: boolean;
  30403. /**
  30404. * Defines whether or not to autoclear the depth buffer.
  30405. */
  30406. depth: boolean;
  30407. /**
  30408. * Defines whether or not to autoclear the stencil buffer.
  30409. */
  30410. stencil: boolean;
  30411. }
  30412. /**
  30413. * This class is used by the onRenderingGroupObservable
  30414. */
  30415. export class RenderingGroupInfo {
  30416. /**
  30417. * The Scene that being rendered
  30418. */
  30419. scene: Scene;
  30420. /**
  30421. * The camera currently used for the rendering pass
  30422. */
  30423. camera: Nullable<Camera>;
  30424. /**
  30425. * The ID of the renderingGroup being processed
  30426. */
  30427. renderingGroupId: number;
  30428. }
  30429. /**
  30430. * This is the manager responsible of all the rendering for meshes sprites and particles.
  30431. * It is enable to manage the different groups as well as the different necessary sort functions.
  30432. * This should not be used directly aside of the few static configurations
  30433. */
  30434. export class RenderingManager {
  30435. /**
  30436. * The max id used for rendering groups (not included)
  30437. */
  30438. static MAX_RENDERINGGROUPS: number;
  30439. /**
  30440. * The min id used for rendering groups (included)
  30441. */
  30442. static MIN_RENDERINGGROUPS: number;
  30443. /**
  30444. * Used to globally prevent autoclearing scenes.
  30445. */
  30446. static AUTOCLEAR: boolean;
  30447. /**
  30448. * @hidden
  30449. */
  30450. _useSceneAutoClearSetup: boolean;
  30451. private _scene;
  30452. private _renderingGroups;
  30453. private _depthStencilBufferAlreadyCleaned;
  30454. private _autoClearDepthStencil;
  30455. private _customOpaqueSortCompareFn;
  30456. private _customAlphaTestSortCompareFn;
  30457. private _customTransparentSortCompareFn;
  30458. private _renderingGroupInfo;
  30459. /**
  30460. * Instantiates a new rendering group for a particular scene
  30461. * @param scene Defines the scene the groups belongs to
  30462. */
  30463. constructor(scene: Scene);
  30464. private _clearDepthStencilBuffer;
  30465. /**
  30466. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  30467. * @hidden
  30468. */
  30469. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  30470. /**
  30471. * Resets the different information of the group to prepare a new frame
  30472. * @hidden
  30473. */
  30474. reset(): void;
  30475. /**
  30476. * Dispose and release the group and its associated resources.
  30477. * @hidden
  30478. */
  30479. dispose(): void;
  30480. /**
  30481. * Clear the info related to rendering groups preventing retention points during dispose.
  30482. */
  30483. freeRenderingGroups(): void;
  30484. private _prepareRenderingGroup;
  30485. /**
  30486. * Add a sprite manager to the rendering manager in order to render it this frame.
  30487. * @param spriteManager Define the sprite manager to render
  30488. */
  30489. dispatchSprites(spriteManager: ISpriteManager): void;
  30490. /**
  30491. * Add a particle system to the rendering manager in order to render it this frame.
  30492. * @param particleSystem Define the particle system to render
  30493. */
  30494. dispatchParticles(particleSystem: IParticleSystem): void;
  30495. /**
  30496. * Add a submesh to the manager in order to render it this frame
  30497. * @param subMesh The submesh to dispatch
  30498. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30499. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30500. */
  30501. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30502. /**
  30503. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30504. * This allowed control for front to back rendering or reversly depending of the special needs.
  30505. *
  30506. * @param renderingGroupId The rendering group id corresponding to its index
  30507. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30508. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30509. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30510. */
  30511. 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;
  30512. /**
  30513. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30514. *
  30515. * @param renderingGroupId The rendering group id corresponding to its index
  30516. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30517. * @param depth Automatically clears depth between groups if true and autoClear is true.
  30518. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  30519. */
  30520. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  30521. /**
  30522. * Gets the current auto clear configuration for one rendering group of the rendering
  30523. * manager.
  30524. * @param index the rendering group index to get the information for
  30525. * @returns The auto clear setup for the requested rendering group
  30526. */
  30527. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  30528. }
  30529. }
  30530. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  30531. import { SmartArray } from "babylonjs/Misc/smartArray";
  30532. import { Nullable } from "babylonjs/types";
  30533. import { Scene } from "babylonjs/scene";
  30534. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30537. import { Mesh } from "babylonjs/Meshes/mesh";
  30538. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  30539. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30540. import { Effect } from "babylonjs/Materials/effect";
  30541. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30543. import "babylonjs/Shaders/shadowMap.fragment";
  30544. import "babylonjs/Shaders/shadowMap.vertex";
  30545. import "babylonjs/Shaders/depthBoxBlur.fragment";
  30546. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  30547. import { Observable } from "babylonjs/Misc/observable";
  30548. /**
  30549. * Defines the options associated with the creation of a custom shader for a shadow generator.
  30550. */
  30551. export interface ICustomShaderOptions {
  30552. /**
  30553. * Gets or sets the custom shader name to use
  30554. */
  30555. shaderName: string;
  30556. /**
  30557. * The list of attribute names used in the shader
  30558. */
  30559. attributes?: string[];
  30560. /**
  30561. * The list of unifrom names used in the shader
  30562. */
  30563. uniforms?: string[];
  30564. /**
  30565. * The list of sampler names used in the shader
  30566. */
  30567. samplers?: string[];
  30568. /**
  30569. * The list of defines used in the shader
  30570. */
  30571. defines?: string[];
  30572. }
  30573. /**
  30574. * Interface to implement to create a shadow generator compatible with BJS.
  30575. */
  30576. export interface IShadowGenerator {
  30577. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30578. id: string;
  30579. /**
  30580. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30581. * @returns The render target texture if present otherwise, null
  30582. */
  30583. getShadowMap(): Nullable<RenderTargetTexture>;
  30584. /**
  30585. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30586. * @param subMesh The submesh we want to render in the shadow map
  30587. * @param useInstances Defines wether will draw in the map using instances
  30588. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30589. * @returns true if ready otherwise, false
  30590. */
  30591. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30592. /**
  30593. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30594. * @param defines Defines of the material we want to update
  30595. * @param lightIndex Index of the light in the enabled light list of the material
  30596. */
  30597. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30598. /**
  30599. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30600. * defined in the generator but impacting the effect).
  30601. * It implies the unifroms available on the materials are the standard BJS ones.
  30602. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30603. * @param effect The effect we are binfing the information for
  30604. */
  30605. bindShadowLight(lightIndex: string, effect: Effect): void;
  30606. /**
  30607. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30608. * (eq to shadow prjection matrix * light transform matrix)
  30609. * @returns The transform matrix used to create the shadow map
  30610. */
  30611. getTransformMatrix(): Matrix;
  30612. /**
  30613. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30614. * Cube and 2D textures for instance.
  30615. */
  30616. recreateShadowMap(): void;
  30617. /**
  30618. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30619. * @param onCompiled Callback triggered at the and of the effects compilation
  30620. * @param options Sets of optional options forcing the compilation with different modes
  30621. */
  30622. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30623. useInstances: boolean;
  30624. }>): void;
  30625. /**
  30626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30627. * @param options Sets of optional options forcing the compilation with different modes
  30628. * @returns A promise that resolves when the compilation completes
  30629. */
  30630. forceCompilationAsync(options?: Partial<{
  30631. useInstances: boolean;
  30632. }>): Promise<void>;
  30633. /**
  30634. * Serializes the shadow generator setup to a json object.
  30635. * @returns The serialized JSON object
  30636. */
  30637. serialize(): any;
  30638. /**
  30639. * Disposes the Shadow map and related Textures and effects.
  30640. */
  30641. dispose(): void;
  30642. }
  30643. /**
  30644. * Default implementation IShadowGenerator.
  30645. * This is the main object responsible of generating shadows in the framework.
  30646. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30647. */
  30648. export class ShadowGenerator implements IShadowGenerator {
  30649. private static _Counter;
  30650. /**
  30651. * Name of the shadow generator class
  30652. */
  30653. static CLASSNAME: string;
  30654. /**
  30655. * Shadow generator mode None: no filtering applied.
  30656. */
  30657. static readonly FILTER_NONE: number;
  30658. /**
  30659. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30661. */
  30662. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30663. /**
  30664. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30665. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30666. */
  30667. static readonly FILTER_POISSONSAMPLING: number;
  30668. /**
  30669. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30670. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30671. */
  30672. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30673. /**
  30674. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30675. * edge artifacts on steep falloff.
  30676. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30677. */
  30678. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30679. /**
  30680. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30681. * edge artifacts on steep falloff.
  30682. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30683. */
  30684. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30685. /**
  30686. * Shadow generator mode PCF: Percentage Closer Filtering
  30687. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30688. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30689. */
  30690. static readonly FILTER_PCF: number;
  30691. /**
  30692. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30693. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30694. * Contact Hardening
  30695. */
  30696. static readonly FILTER_PCSS: number;
  30697. /**
  30698. * Reserved for PCF and PCSS
  30699. * Highest Quality.
  30700. *
  30701. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30702. *
  30703. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30704. */
  30705. static readonly QUALITY_HIGH: number;
  30706. /**
  30707. * Reserved for PCF and PCSS
  30708. * Good tradeoff for quality/perf cross devices
  30709. *
  30710. * Execute PCF on a 3*3 kernel.
  30711. *
  30712. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30713. */
  30714. static readonly QUALITY_MEDIUM: number;
  30715. /**
  30716. * Reserved for PCF and PCSS
  30717. * The lowest quality but the fastest.
  30718. *
  30719. * Execute PCF on a 1*1 kernel.
  30720. *
  30721. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30722. */
  30723. static readonly QUALITY_LOW: number;
  30724. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30725. id: string;
  30726. /** Gets or sets the custom shader name to use */
  30727. customShaderOptions: ICustomShaderOptions;
  30728. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30729. customAllowRendering: (subMesh: SubMesh) => boolean;
  30730. /**
  30731. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30732. */
  30733. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30734. /**
  30735. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30736. */
  30737. onAfterShadowMapRenderObservable: Observable<Effect>;
  30738. /**
  30739. * Observable triggered before a mesh is rendered in the shadow map.
  30740. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30741. */
  30742. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30743. /**
  30744. * Observable triggered after a mesh is rendered in the shadow map.
  30745. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30746. */
  30747. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30748. protected _bias: number;
  30749. /**
  30750. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30751. */
  30752. get bias(): number;
  30753. /**
  30754. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30755. */
  30756. set bias(bias: number);
  30757. protected _normalBias: number;
  30758. /**
  30759. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30760. */
  30761. get normalBias(): number;
  30762. /**
  30763. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30764. */
  30765. set normalBias(normalBias: number);
  30766. protected _blurBoxOffset: number;
  30767. /**
  30768. * Gets the blur box offset: offset applied during the blur pass.
  30769. * Only useful if useKernelBlur = false
  30770. */
  30771. get blurBoxOffset(): number;
  30772. /**
  30773. * Sets the blur box offset: offset applied during the blur pass.
  30774. * Only useful if useKernelBlur = false
  30775. */
  30776. set blurBoxOffset(value: number);
  30777. protected _blurScale: number;
  30778. /**
  30779. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30780. * 2 means half of the size.
  30781. */
  30782. get blurScale(): number;
  30783. /**
  30784. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30785. * 2 means half of the size.
  30786. */
  30787. set blurScale(value: number);
  30788. protected _blurKernel: number;
  30789. /**
  30790. * Gets the blur kernel: kernel size of the blur pass.
  30791. * Only useful if useKernelBlur = true
  30792. */
  30793. get blurKernel(): number;
  30794. /**
  30795. * Sets the blur kernel: kernel size of the blur pass.
  30796. * Only useful if useKernelBlur = true
  30797. */
  30798. set blurKernel(value: number);
  30799. protected _useKernelBlur: boolean;
  30800. /**
  30801. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30802. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30803. */
  30804. get useKernelBlur(): boolean;
  30805. /**
  30806. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30807. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30808. */
  30809. set useKernelBlur(value: boolean);
  30810. protected _depthScale: number;
  30811. /**
  30812. * Gets the depth scale used in ESM mode.
  30813. */
  30814. get depthScale(): number;
  30815. /**
  30816. * Sets the depth scale used in ESM mode.
  30817. * This can override the scale stored on the light.
  30818. */
  30819. set depthScale(value: number);
  30820. protected _validateFilter(filter: number): number;
  30821. protected _filter: number;
  30822. /**
  30823. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30824. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30825. */
  30826. get filter(): number;
  30827. /**
  30828. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30829. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30830. */
  30831. set filter(value: number);
  30832. /**
  30833. * Gets if the current filter is set to Poisson Sampling.
  30834. */
  30835. get usePoissonSampling(): boolean;
  30836. /**
  30837. * Sets the current filter to Poisson Sampling.
  30838. */
  30839. set usePoissonSampling(value: boolean);
  30840. /**
  30841. * Gets if the current filter is set to ESM.
  30842. */
  30843. get useExponentialShadowMap(): boolean;
  30844. /**
  30845. * Sets the current filter is to ESM.
  30846. */
  30847. set useExponentialShadowMap(value: boolean);
  30848. /**
  30849. * Gets if the current filter is set to filtered ESM.
  30850. */
  30851. get useBlurExponentialShadowMap(): boolean;
  30852. /**
  30853. * Gets if the current filter is set to filtered ESM.
  30854. */
  30855. set useBlurExponentialShadowMap(value: boolean);
  30856. /**
  30857. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30858. * exponential to prevent steep falloff artifacts).
  30859. */
  30860. get useCloseExponentialShadowMap(): boolean;
  30861. /**
  30862. * Sets the current filter to "close ESM" (using the inverse of the
  30863. * exponential to prevent steep falloff artifacts).
  30864. */
  30865. set useCloseExponentialShadowMap(value: boolean);
  30866. /**
  30867. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30868. * exponential to prevent steep falloff artifacts).
  30869. */
  30870. get useBlurCloseExponentialShadowMap(): boolean;
  30871. /**
  30872. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30873. * exponential to prevent steep falloff artifacts).
  30874. */
  30875. set useBlurCloseExponentialShadowMap(value: boolean);
  30876. /**
  30877. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30878. */
  30879. get usePercentageCloserFiltering(): boolean;
  30880. /**
  30881. * Sets the current filter to "PCF" (percentage closer filtering).
  30882. */
  30883. set usePercentageCloserFiltering(value: boolean);
  30884. protected _filteringQuality: number;
  30885. /**
  30886. * Gets the PCF or PCSS Quality.
  30887. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30888. */
  30889. get filteringQuality(): number;
  30890. /**
  30891. * Sets the PCF or PCSS Quality.
  30892. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30893. */
  30894. set filteringQuality(filteringQuality: number);
  30895. /**
  30896. * Gets if the current filter is set to "PCSS" (contact hardening).
  30897. */
  30898. get useContactHardeningShadow(): boolean;
  30899. /**
  30900. * Sets the current filter to "PCSS" (contact hardening).
  30901. */
  30902. set useContactHardeningShadow(value: boolean);
  30903. protected _contactHardeningLightSizeUVRatio: number;
  30904. /**
  30905. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30906. * Using a ratio helps keeping shape stability independently of the map size.
  30907. *
  30908. * It does not account for the light projection as it was having too much
  30909. * instability during the light setup or during light position changes.
  30910. *
  30911. * Only valid if useContactHardeningShadow is true.
  30912. */
  30913. get contactHardeningLightSizeUVRatio(): number;
  30914. /**
  30915. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30916. * Using a ratio helps keeping shape stability independently of the map size.
  30917. *
  30918. * It does not account for the light projection as it was having too much
  30919. * instability during the light setup or during light position changes.
  30920. *
  30921. * Only valid if useContactHardeningShadow is true.
  30922. */
  30923. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30924. protected _darkness: number;
  30925. /** Gets or sets the actual darkness of a shadow */
  30926. get darkness(): number;
  30927. set darkness(value: number);
  30928. /**
  30929. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30930. * 0 means strongest and 1 would means no shadow.
  30931. * @returns the darkness.
  30932. */
  30933. getDarkness(): number;
  30934. /**
  30935. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30936. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30937. * @returns the shadow generator allowing fluent coding.
  30938. */
  30939. setDarkness(darkness: number): ShadowGenerator;
  30940. protected _transparencyShadow: boolean;
  30941. /** Gets or sets the ability to have transparent shadow */
  30942. get transparencyShadow(): boolean;
  30943. set transparencyShadow(value: boolean);
  30944. /**
  30945. * Sets the ability to have transparent shadow (boolean).
  30946. * @param transparent True if transparent else False
  30947. * @returns the shadow generator allowing fluent coding
  30948. */
  30949. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30950. /**
  30951. * Enables or disables shadows with varying strength based on the transparency
  30952. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30953. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30954. * mesh.visibility * alphaTexture.a
  30955. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30956. */
  30957. enableSoftTransparentShadow: boolean;
  30958. protected _shadowMap: Nullable<RenderTargetTexture>;
  30959. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30960. /**
  30961. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30962. * @returns The render target texture if present otherwise, null
  30963. */
  30964. getShadowMap(): Nullable<RenderTargetTexture>;
  30965. /**
  30966. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30967. * @returns The render target texture if the shadow map is present otherwise, null
  30968. */
  30969. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30970. /**
  30971. * Gets the class name of that object
  30972. * @returns "ShadowGenerator"
  30973. */
  30974. getClassName(): string;
  30975. /**
  30976. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30977. * @param mesh Mesh to add
  30978. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30979. * @returns the Shadow Generator itself
  30980. */
  30981. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30982. /**
  30983. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30984. * @param mesh Mesh to remove
  30985. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30986. * @returns the Shadow Generator itself
  30987. */
  30988. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30989. /**
  30990. * Controls the extent to which the shadows fade out at the edge of the frustum
  30991. */
  30992. frustumEdgeFalloff: number;
  30993. protected _light: IShadowLight;
  30994. /**
  30995. * Returns the associated light object.
  30996. * @returns the light generating the shadow
  30997. */
  30998. getLight(): IShadowLight;
  30999. /**
  31000. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31001. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31002. * It might on the other hand introduce peter panning.
  31003. */
  31004. forceBackFacesOnly: boolean;
  31005. protected _scene: Scene;
  31006. protected _lightDirection: Vector3;
  31007. protected _viewMatrix: Matrix;
  31008. protected _projectionMatrix: Matrix;
  31009. protected _transformMatrix: Matrix;
  31010. protected _cachedPosition: Vector3;
  31011. protected _cachedDirection: Vector3;
  31012. protected _cachedDefines: string;
  31013. protected _currentRenderID: number;
  31014. protected _boxBlurPostprocess: Nullable<PostProcess>;
  31015. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  31016. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  31017. protected _blurPostProcesses: PostProcess[];
  31018. protected _mapSize: number;
  31019. protected _currentFaceIndex: number;
  31020. protected _currentFaceIndexCache: number;
  31021. protected _textureType: number;
  31022. protected _defaultTextureMatrix: Matrix;
  31023. protected _storedUniqueId: Nullable<number>;
  31024. protected _nameForCustomEffect: string;
  31025. /** @hidden */
  31026. static _SceneComponentInitialization: (scene: Scene) => void;
  31027. /**
  31028. * Gets or sets the size of the texture what stores the shadows
  31029. */
  31030. get mapSize(): number;
  31031. set mapSize(size: number);
  31032. /**
  31033. * Creates a ShadowGenerator object.
  31034. * A ShadowGenerator is the required tool to use the shadows.
  31035. * Each light casting shadows needs to use its own ShadowGenerator.
  31036. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  31037. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31038. * @param light The light object generating the shadows.
  31039. * @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.
  31040. */
  31041. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  31042. protected _initializeGenerator(): void;
  31043. protected _createTargetRenderTexture(): void;
  31044. protected _initializeShadowMap(): void;
  31045. protected _initializeBlurRTTAndPostProcesses(): void;
  31046. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  31047. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  31048. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  31049. protected _applyFilterValues(): void;
  31050. /**
  31051. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31052. * @param onCompiled Callback triggered at the and of the effects compilation
  31053. * @param options Sets of optional options forcing the compilation with different modes
  31054. */
  31055. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  31056. useInstances: boolean;
  31057. }>): void;
  31058. /**
  31059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31060. * @param options Sets of optional options forcing the compilation with different modes
  31061. * @returns A promise that resolves when the compilation completes
  31062. */
  31063. forceCompilationAsync(options?: Partial<{
  31064. useInstances: boolean;
  31065. }>): Promise<void>;
  31066. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  31067. private _prepareShadowDefines;
  31068. /**
  31069. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31070. * @param subMesh The submesh we want to render in the shadow map
  31071. * @param useInstances Defines wether will draw in the map using instances
  31072. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  31073. * @returns true if ready otherwise, false
  31074. */
  31075. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  31076. /**
  31077. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31078. * @param defines Defines of the material we want to update
  31079. * @param lightIndex Index of the light in the enabled light list of the material
  31080. */
  31081. prepareDefines(defines: any, lightIndex: number): void;
  31082. /**
  31083. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31084. * defined in the generator but impacting the effect).
  31085. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31086. * @param effect The effect we are binfing the information for
  31087. */
  31088. bindShadowLight(lightIndex: string, effect: Effect): void;
  31089. /**
  31090. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31091. * (eq to shadow prjection matrix * light transform matrix)
  31092. * @returns The transform matrix used to create the shadow map
  31093. */
  31094. getTransformMatrix(): Matrix;
  31095. /**
  31096. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31097. * Cube and 2D textures for instance.
  31098. */
  31099. recreateShadowMap(): void;
  31100. protected _disposeBlurPostProcesses(): void;
  31101. protected _disposeRTTandPostProcesses(): void;
  31102. /**
  31103. * Disposes the ShadowGenerator.
  31104. * Returns nothing.
  31105. */
  31106. dispose(): void;
  31107. /**
  31108. * Serializes the shadow generator setup to a json object.
  31109. * @returns The serialized JSON object
  31110. */
  31111. serialize(): any;
  31112. /**
  31113. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31114. * @param parsedShadowGenerator The JSON object to parse
  31115. * @param scene The scene to create the shadow map for
  31116. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  31117. * @returns The parsed shadow generator
  31118. */
  31119. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  31120. }
  31121. }
  31122. declare module "babylonjs/Materials/shadowDepthWrapper" {
  31123. import { Nullable } from "babylonjs/types";
  31124. import { Scene } from "babylonjs/scene";
  31125. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31126. import { Material } from "babylonjs/Materials/material";
  31127. import { Effect } from "babylonjs/Materials/effect";
  31128. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  31129. /**
  31130. * Options to be used when creating a shadow depth material
  31131. */
  31132. export interface IIOptionShadowDepthMaterial {
  31133. /** Variables in the vertex shader code that need to have their names remapped.
  31134. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  31135. * "var_name" should be either: worldPos or vNormalW
  31136. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  31137. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  31138. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  31139. */
  31140. remappedVariables?: string[];
  31141. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  31142. standalone?: boolean;
  31143. }
  31144. /**
  31145. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  31146. */
  31147. export class ShadowDepthWrapper {
  31148. private _scene;
  31149. private _options?;
  31150. private _baseMaterial;
  31151. private _onEffectCreatedObserver;
  31152. private _subMeshToEffect;
  31153. private _subMeshToDepthEffect;
  31154. private _meshes;
  31155. /** @hidden */
  31156. _matriceNames: any;
  31157. /** Gets the standalone status of the wrapper */
  31158. get standalone(): boolean;
  31159. /** Gets the base material the wrapper is built upon */
  31160. get baseMaterial(): Material;
  31161. /**
  31162. * Instantiate a new shadow depth wrapper.
  31163. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  31164. * generate the shadow depth map. For more information, please refer to the documentation:
  31165. * https://doc.babylonjs.com/babylon101/shadows
  31166. * @param baseMaterial Material to wrap
  31167. * @param scene Define the scene the material belongs to
  31168. * @param options Options used to create the wrapper
  31169. */
  31170. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  31171. /**
  31172. * Gets the effect to use to generate the depth map
  31173. * @param subMesh subMesh to get the effect for
  31174. * @param shadowGenerator shadow generator to get the effect for
  31175. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  31176. */
  31177. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  31178. /**
  31179. * Specifies that the submesh is ready to be used for depth rendering
  31180. * @param subMesh submesh to check
  31181. * @param defines the list of defines to take into account when checking the effect
  31182. * @param shadowGenerator combined with subMesh, it defines the effect to check
  31183. * @param useInstances specifies that instances should be used
  31184. * @returns a boolean indicating that the submesh is ready or not
  31185. */
  31186. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  31187. /**
  31188. * Disposes the resources
  31189. */
  31190. dispose(): void;
  31191. private _makeEffect;
  31192. }
  31193. }
  31194. declare module "babylonjs/Materials/material" {
  31195. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31196. import { SmartArray } from "babylonjs/Misc/smartArray";
  31197. import { Observable } from "babylonjs/Misc/observable";
  31198. import { Nullable } from "babylonjs/types";
  31199. import { Matrix } from "babylonjs/Maths/math.vector";
  31200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31202. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31203. import { Effect } from "babylonjs/Materials/effect";
  31204. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31205. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31206. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31207. import { IInspectable } from "babylonjs/Misc/iInspectable";
  31208. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  31209. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  31210. import { Mesh } from "babylonjs/Meshes/mesh";
  31211. import { Animation } from "babylonjs/Animations/animation";
  31212. import { Scene } from "babylonjs/scene";
  31213. /**
  31214. * Options for compiling materials.
  31215. */
  31216. export interface IMaterialCompilationOptions {
  31217. /**
  31218. * Defines whether clip planes are enabled.
  31219. */
  31220. clipPlane: boolean;
  31221. /**
  31222. * Defines whether instances are enabled.
  31223. */
  31224. useInstances: boolean;
  31225. }
  31226. /**
  31227. * Options passed when calling customShaderNameResolve
  31228. */
  31229. export interface ICustomShaderNameResolveOptions {
  31230. /**
  31231. * 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
  31232. */
  31233. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  31234. }
  31235. /**
  31236. * Base class for the main features of a material in Babylon.js
  31237. */
  31238. export class Material implements IAnimatable {
  31239. /**
  31240. * Returns the triangle fill mode
  31241. */
  31242. static readonly TriangleFillMode: number;
  31243. /**
  31244. * Returns the wireframe mode
  31245. */
  31246. static readonly WireFrameFillMode: number;
  31247. /**
  31248. * Returns the point fill mode
  31249. */
  31250. static readonly PointFillMode: number;
  31251. /**
  31252. * Returns the point list draw mode
  31253. */
  31254. static readonly PointListDrawMode: number;
  31255. /**
  31256. * Returns the line list draw mode
  31257. */
  31258. static readonly LineListDrawMode: number;
  31259. /**
  31260. * Returns the line loop draw mode
  31261. */
  31262. static readonly LineLoopDrawMode: number;
  31263. /**
  31264. * Returns the line strip draw mode
  31265. */
  31266. static readonly LineStripDrawMode: number;
  31267. /**
  31268. * Returns the triangle strip draw mode
  31269. */
  31270. static readonly TriangleStripDrawMode: number;
  31271. /**
  31272. * Returns the triangle fan draw mode
  31273. */
  31274. static readonly TriangleFanDrawMode: number;
  31275. /**
  31276. * Stores the clock-wise side orientation
  31277. */
  31278. static readonly ClockWiseSideOrientation: number;
  31279. /**
  31280. * Stores the counter clock-wise side orientation
  31281. */
  31282. static readonly CounterClockWiseSideOrientation: number;
  31283. /**
  31284. * The dirty texture flag value
  31285. */
  31286. static readonly TextureDirtyFlag: number;
  31287. /**
  31288. * The dirty light flag value
  31289. */
  31290. static readonly LightDirtyFlag: number;
  31291. /**
  31292. * The dirty fresnel flag value
  31293. */
  31294. static readonly FresnelDirtyFlag: number;
  31295. /**
  31296. * The dirty attribute flag value
  31297. */
  31298. static readonly AttributesDirtyFlag: number;
  31299. /**
  31300. * The dirty misc flag value
  31301. */
  31302. static readonly MiscDirtyFlag: number;
  31303. /**
  31304. * The dirty prepass flag value
  31305. */
  31306. static readonly PrePassDirtyFlag: number;
  31307. /**
  31308. * The all dirty flag value
  31309. */
  31310. static readonly AllDirtyFlag: number;
  31311. /**
  31312. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31313. */
  31314. static readonly MATERIAL_OPAQUE: number;
  31315. /**
  31316. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31317. */
  31318. static readonly MATERIAL_ALPHATEST: number;
  31319. /**
  31320. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31321. */
  31322. static readonly MATERIAL_ALPHABLEND: number;
  31323. /**
  31324. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31325. * They are also discarded below the alpha cutoff threshold to improve performances.
  31326. */
  31327. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  31328. /**
  31329. * The Whiteout method is used to blend normals.
  31330. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31331. */
  31332. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  31333. /**
  31334. * The Reoriented Normal Mapping method is used to blend normals.
  31335. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31336. */
  31337. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  31338. /**
  31339. * Custom callback helping to override the default shader used in the material.
  31340. */
  31341. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  31342. /**
  31343. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  31344. */
  31345. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  31346. /**
  31347. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  31348. * This means that the material can keep using a previous shader while a new one is being compiled.
  31349. * This is mostly used when shader parallel compilation is supported (true by default)
  31350. */
  31351. allowShaderHotSwapping: boolean;
  31352. /**
  31353. * The ID of the material
  31354. */
  31355. id: string;
  31356. /**
  31357. * Gets or sets the unique id of the material
  31358. */
  31359. uniqueId: number;
  31360. /**
  31361. * The name of the material
  31362. */
  31363. name: string;
  31364. /**
  31365. * Gets or sets user defined metadata
  31366. */
  31367. metadata: any;
  31368. /**
  31369. * For internal use only. Please do not use.
  31370. */
  31371. reservedDataStore: any;
  31372. /**
  31373. * Specifies if the ready state should be checked on each call
  31374. */
  31375. checkReadyOnEveryCall: boolean;
  31376. /**
  31377. * Specifies if the ready state should be checked once
  31378. */
  31379. checkReadyOnlyOnce: boolean;
  31380. /**
  31381. * The state of the material
  31382. */
  31383. state: string;
  31384. /**
  31385. * If the material can be rendered to several textures with MRT extension
  31386. */
  31387. get canRenderToMRT(): boolean;
  31388. /**
  31389. * The alpha value of the material
  31390. */
  31391. protected _alpha: number;
  31392. /**
  31393. * List of inspectable custom properties (used by the Inspector)
  31394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31395. */
  31396. inspectableCustomProperties: IInspectable[];
  31397. /**
  31398. * Sets the alpha value of the material
  31399. */
  31400. set alpha(value: number);
  31401. /**
  31402. * Gets the alpha value of the material
  31403. */
  31404. get alpha(): number;
  31405. /**
  31406. * Specifies if back face culling is enabled
  31407. */
  31408. protected _backFaceCulling: boolean;
  31409. /**
  31410. * Sets the back-face culling state
  31411. */
  31412. set backFaceCulling(value: boolean);
  31413. /**
  31414. * Gets the back-face culling state
  31415. */
  31416. get backFaceCulling(): boolean;
  31417. /**
  31418. * Stores the value for side orientation
  31419. */
  31420. sideOrientation: number;
  31421. /**
  31422. * Callback triggered when the material is compiled
  31423. */
  31424. onCompiled: Nullable<(effect: Effect) => void>;
  31425. /**
  31426. * Callback triggered when an error occurs
  31427. */
  31428. onError: Nullable<(effect: Effect, errors: string) => void>;
  31429. /**
  31430. * Callback triggered to get the render target textures
  31431. */
  31432. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  31433. /**
  31434. * Gets a boolean indicating that current material needs to register RTT
  31435. */
  31436. get hasRenderTargetTextures(): boolean;
  31437. /**
  31438. * Specifies if the material should be serialized
  31439. */
  31440. doNotSerialize: boolean;
  31441. /**
  31442. * @hidden
  31443. */
  31444. _storeEffectOnSubMeshes: boolean;
  31445. /**
  31446. * Stores the animations for the material
  31447. */
  31448. animations: Nullable<Array<Animation>>;
  31449. /**
  31450. * An event triggered when the material is disposed
  31451. */
  31452. onDisposeObservable: Observable<Material>;
  31453. /**
  31454. * An observer which watches for dispose events
  31455. */
  31456. private _onDisposeObserver;
  31457. private _onUnBindObservable;
  31458. /**
  31459. * Called during a dispose event
  31460. */
  31461. set onDispose(callback: () => void);
  31462. private _onBindObservable;
  31463. /**
  31464. * An event triggered when the material is bound
  31465. */
  31466. get onBindObservable(): Observable<AbstractMesh>;
  31467. /**
  31468. * An observer which watches for bind events
  31469. */
  31470. private _onBindObserver;
  31471. /**
  31472. * Called during a bind event
  31473. */
  31474. set onBind(callback: (Mesh: AbstractMesh) => void);
  31475. /**
  31476. * An event triggered when the material is unbound
  31477. */
  31478. get onUnBindObservable(): Observable<Material>;
  31479. protected _onEffectCreatedObservable: Nullable<Observable<{
  31480. effect: Effect;
  31481. subMesh: Nullable<SubMesh>;
  31482. }>>;
  31483. /**
  31484. * An event triggered when the effect is (re)created
  31485. */
  31486. get onEffectCreatedObservable(): Observable<{
  31487. effect: Effect;
  31488. subMesh: Nullable<SubMesh>;
  31489. }>;
  31490. /**
  31491. * Stores the value of the alpha mode
  31492. */
  31493. private _alphaMode;
  31494. /**
  31495. * Sets the value of the alpha mode.
  31496. *
  31497. * | Value | Type | Description |
  31498. * | --- | --- | --- |
  31499. * | 0 | ALPHA_DISABLE | |
  31500. * | 1 | ALPHA_ADD | |
  31501. * | 2 | ALPHA_COMBINE | |
  31502. * | 3 | ALPHA_SUBTRACT | |
  31503. * | 4 | ALPHA_MULTIPLY | |
  31504. * | 5 | ALPHA_MAXIMIZED | |
  31505. * | 6 | ALPHA_ONEONE | |
  31506. * | 7 | ALPHA_PREMULTIPLIED | |
  31507. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  31508. * | 9 | ALPHA_INTERPOLATE | |
  31509. * | 10 | ALPHA_SCREENMODE | |
  31510. *
  31511. */
  31512. set alphaMode(value: number);
  31513. /**
  31514. * Gets the value of the alpha mode
  31515. */
  31516. get alphaMode(): number;
  31517. /**
  31518. * Stores the state of the need depth pre-pass value
  31519. */
  31520. private _needDepthPrePass;
  31521. /**
  31522. * Sets the need depth pre-pass value
  31523. */
  31524. set needDepthPrePass(value: boolean);
  31525. /**
  31526. * Gets the depth pre-pass value
  31527. */
  31528. get needDepthPrePass(): boolean;
  31529. /**
  31530. * Specifies if depth writing should be disabled
  31531. */
  31532. disableDepthWrite: boolean;
  31533. /**
  31534. * Specifies if color writing should be disabled
  31535. */
  31536. disableColorWrite: boolean;
  31537. /**
  31538. * Specifies if depth writing should be forced
  31539. */
  31540. forceDepthWrite: boolean;
  31541. /**
  31542. * Specifies the depth function that should be used. 0 means the default engine function
  31543. */
  31544. depthFunction: number;
  31545. /**
  31546. * Specifies if there should be a separate pass for culling
  31547. */
  31548. separateCullingPass: boolean;
  31549. /**
  31550. * Stores the state specifing if fog should be enabled
  31551. */
  31552. private _fogEnabled;
  31553. /**
  31554. * Sets the state for enabling fog
  31555. */
  31556. set fogEnabled(value: boolean);
  31557. /**
  31558. * Gets the value of the fog enabled state
  31559. */
  31560. get fogEnabled(): boolean;
  31561. /**
  31562. * Stores the size of points
  31563. */
  31564. pointSize: number;
  31565. /**
  31566. * Stores the z offset value
  31567. */
  31568. zOffset: number;
  31569. get wireframe(): boolean;
  31570. /**
  31571. * Sets the state of wireframe mode
  31572. */
  31573. set wireframe(value: boolean);
  31574. /**
  31575. * Gets the value specifying if point clouds are enabled
  31576. */
  31577. get pointsCloud(): boolean;
  31578. /**
  31579. * Sets the state of point cloud mode
  31580. */
  31581. set pointsCloud(value: boolean);
  31582. /**
  31583. * Gets the material fill mode
  31584. */
  31585. get fillMode(): number;
  31586. /**
  31587. * Sets the material fill mode
  31588. */
  31589. set fillMode(value: number);
  31590. /**
  31591. * @hidden
  31592. * Stores the effects for the material
  31593. */
  31594. _effect: Nullable<Effect>;
  31595. /**
  31596. * Specifies if uniform buffers should be used
  31597. */
  31598. private _useUBO;
  31599. /**
  31600. * Stores a reference to the scene
  31601. */
  31602. private _scene;
  31603. private _needToBindSceneUbo;
  31604. /**
  31605. * Stores the fill mode state
  31606. */
  31607. private _fillMode;
  31608. /**
  31609. * Specifies if the depth write state should be cached
  31610. */
  31611. private _cachedDepthWriteState;
  31612. /**
  31613. * Specifies if the color write state should be cached
  31614. */
  31615. private _cachedColorWriteState;
  31616. /**
  31617. * Specifies if the depth function state should be cached
  31618. */
  31619. private _cachedDepthFunctionState;
  31620. /**
  31621. * Stores the uniform buffer
  31622. */
  31623. protected _uniformBuffer: UniformBuffer;
  31624. /** @hidden */
  31625. _indexInSceneMaterialArray: number;
  31626. /** @hidden */
  31627. meshMap: Nullable<{
  31628. [id: string]: AbstractMesh | undefined;
  31629. }>;
  31630. /**
  31631. * Creates a material instance
  31632. * @param name defines the name of the material
  31633. * @param scene defines the scene to reference
  31634. * @param doNotAdd specifies if the material should be added to the scene
  31635. */
  31636. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31637. /**
  31638. * Returns a string representation of the current material
  31639. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31640. * @returns a string with material information
  31641. */
  31642. toString(fullDetails?: boolean): string;
  31643. /**
  31644. * Gets the class name of the material
  31645. * @returns a string with the class name of the material
  31646. */
  31647. getClassName(): string;
  31648. /**
  31649. * Specifies if updates for the material been locked
  31650. */
  31651. get isFrozen(): boolean;
  31652. /**
  31653. * Locks updates for the material
  31654. */
  31655. freeze(): void;
  31656. /**
  31657. * Unlocks updates for the material
  31658. */
  31659. unfreeze(): void;
  31660. /**
  31661. * Specifies if the material is ready to be used
  31662. * @param mesh defines the mesh to check
  31663. * @param useInstances specifies if instances should be used
  31664. * @returns a boolean indicating if the material is ready to be used
  31665. */
  31666. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  31667. /**
  31668. * Specifies that the submesh is ready to be used
  31669. * @param mesh defines the mesh to check
  31670. * @param subMesh defines which submesh to check
  31671. * @param useInstances specifies that instances should be used
  31672. * @returns a boolean indicating that the submesh is ready or not
  31673. */
  31674. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31675. /**
  31676. * Returns the material effect
  31677. * @returns the effect associated with the material
  31678. */
  31679. getEffect(): Nullable<Effect>;
  31680. /**
  31681. * Returns the current scene
  31682. * @returns a Scene
  31683. */
  31684. getScene(): Scene;
  31685. /**
  31686. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31687. */
  31688. protected _forceAlphaTest: boolean;
  31689. /**
  31690. * The transparency mode of the material.
  31691. */
  31692. protected _transparencyMode: Nullable<number>;
  31693. /**
  31694. * Gets the current transparency mode.
  31695. */
  31696. get transparencyMode(): Nullable<number>;
  31697. /**
  31698. * Sets the transparency mode of the material.
  31699. *
  31700. * | Value | Type | Description |
  31701. * | ----- | ----------------------------------- | ----------- |
  31702. * | 0 | OPAQUE | |
  31703. * | 1 | ALPHATEST | |
  31704. * | 2 | ALPHABLEND | |
  31705. * | 3 | ALPHATESTANDBLEND | |
  31706. *
  31707. */
  31708. set transparencyMode(value: Nullable<number>);
  31709. /**
  31710. * Returns true if alpha blending should be disabled.
  31711. */
  31712. protected get _disableAlphaBlending(): boolean;
  31713. /**
  31714. * Specifies whether or not this material should be rendered in alpha blend mode.
  31715. * @returns a boolean specifying if alpha blending is needed
  31716. */
  31717. needAlphaBlending(): boolean;
  31718. /**
  31719. * Specifies if the mesh will require alpha blending
  31720. * @param mesh defines the mesh to check
  31721. * @returns a boolean specifying if alpha blending is needed for the mesh
  31722. */
  31723. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31724. /**
  31725. * Specifies whether or not this material should be rendered in alpha test mode.
  31726. * @returns a boolean specifying if an alpha test is needed.
  31727. */
  31728. needAlphaTesting(): boolean;
  31729. /**
  31730. * Specifies if material alpha testing should be turned on for the mesh
  31731. * @param mesh defines the mesh to check
  31732. */
  31733. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31734. /**
  31735. * Gets the texture used for the alpha test
  31736. * @returns the texture to use for alpha testing
  31737. */
  31738. getAlphaTestTexture(): Nullable<BaseTexture>;
  31739. /**
  31740. * Marks the material to indicate that it needs to be re-calculated
  31741. */
  31742. markDirty(): void;
  31743. /** @hidden */
  31744. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31745. /**
  31746. * Binds the material to the mesh
  31747. * @param world defines the world transformation matrix
  31748. * @param mesh defines the mesh to bind the material to
  31749. */
  31750. bind(world: Matrix, mesh?: Mesh): void;
  31751. /**
  31752. * Binds the submesh to the material
  31753. * @param world defines the world transformation matrix
  31754. * @param mesh defines the mesh containing the submesh
  31755. * @param subMesh defines the submesh to bind the material to
  31756. */
  31757. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31758. /**
  31759. * Binds the world matrix to the material
  31760. * @param world defines the world transformation matrix
  31761. */
  31762. bindOnlyWorldMatrix(world: Matrix): void;
  31763. /**
  31764. * Update the scene ubo before it can be used in rendering processing
  31765. * @param scene the scene to retrieve the ubo from
  31766. * @returns the scene UniformBuffer
  31767. */
  31768. finalizeSceneUbo(scene: Scene): UniformBuffer;
  31769. /**
  31770. * Binds the scene's uniform buffer to the effect.
  31771. * @param effect defines the effect to bind to the scene uniform buffer
  31772. * @param sceneUbo defines the uniform buffer storing scene data
  31773. */
  31774. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31775. /**
  31776. * Binds the view matrix to the effect
  31777. * @param effect defines the effect to bind the view matrix to
  31778. */
  31779. bindView(effect: Effect): void;
  31780. /**
  31781. * Binds the view projection and projection matrices to the effect
  31782. * @param effect defines the effect to bind the view projection and projection matrices to
  31783. */
  31784. bindViewProjection(effect: Effect): void;
  31785. /**
  31786. * Binds the view matrix to the effect
  31787. * @param effect defines the effect to bind the view matrix to
  31788. * @param variableName name of the shader variable that will hold the eye position
  31789. */
  31790. bindEyePosition(effect: Effect, variableName?: string): void;
  31791. /**
  31792. * Processes to execute after binding the material to a mesh
  31793. * @param mesh defines the rendered mesh
  31794. */
  31795. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  31796. /**
  31797. * Unbinds the material from the mesh
  31798. */
  31799. unbind(): void;
  31800. /**
  31801. * Gets the active textures from the material
  31802. * @returns an array of textures
  31803. */
  31804. getActiveTextures(): BaseTexture[];
  31805. /**
  31806. * Specifies if the material uses a texture
  31807. * @param texture defines the texture to check against the material
  31808. * @returns a boolean specifying if the material uses the texture
  31809. */
  31810. hasTexture(texture: BaseTexture): boolean;
  31811. /**
  31812. * Makes a duplicate of the material, and gives it a new name
  31813. * @param name defines the new name for the duplicated material
  31814. * @returns the cloned material
  31815. */
  31816. clone(name: string): Nullable<Material>;
  31817. /**
  31818. * Gets the meshes bound to the material
  31819. * @returns an array of meshes bound to the material
  31820. */
  31821. getBindedMeshes(): AbstractMesh[];
  31822. /**
  31823. * Force shader compilation
  31824. * @param mesh defines the mesh associated with this material
  31825. * @param onCompiled defines a function to execute once the material is compiled
  31826. * @param options defines the options to configure the compilation
  31827. * @param onError defines a function to execute if the material fails compiling
  31828. */
  31829. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31830. /**
  31831. * Force shader compilation
  31832. * @param mesh defines the mesh that will use this material
  31833. * @param options defines additional options for compiling the shaders
  31834. * @returns a promise that resolves when the compilation completes
  31835. */
  31836. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31837. private static readonly _AllDirtyCallBack;
  31838. private static readonly _ImageProcessingDirtyCallBack;
  31839. private static readonly _TextureDirtyCallBack;
  31840. private static readonly _FresnelDirtyCallBack;
  31841. private static readonly _MiscDirtyCallBack;
  31842. private static readonly _PrePassDirtyCallBack;
  31843. private static readonly _LightsDirtyCallBack;
  31844. private static readonly _AttributeDirtyCallBack;
  31845. private static _FresnelAndMiscDirtyCallBack;
  31846. private static _TextureAndMiscDirtyCallBack;
  31847. private static readonly _DirtyCallbackArray;
  31848. private static readonly _RunDirtyCallBacks;
  31849. /**
  31850. * Marks a define in the material to indicate that it needs to be re-computed
  31851. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31852. */
  31853. markAsDirty(flag: number): void;
  31854. /**
  31855. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31856. * @param func defines a function which checks material defines against the submeshes
  31857. */
  31858. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31859. /**
  31860. * Indicates that the scene should check if the rendering now needs a prepass
  31861. */
  31862. protected _markScenePrePassDirty(): void;
  31863. /**
  31864. * Indicates that we need to re-calculated for all submeshes
  31865. */
  31866. protected _markAllSubMeshesAsAllDirty(): void;
  31867. /**
  31868. * Indicates that image processing needs to be re-calculated for all submeshes
  31869. */
  31870. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31871. /**
  31872. * Indicates that textures need to be re-calculated for all submeshes
  31873. */
  31874. protected _markAllSubMeshesAsTexturesDirty(): void;
  31875. /**
  31876. * Indicates that fresnel needs to be re-calculated for all submeshes
  31877. */
  31878. protected _markAllSubMeshesAsFresnelDirty(): void;
  31879. /**
  31880. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31881. */
  31882. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31883. /**
  31884. * Indicates that lights need to be re-calculated for all submeshes
  31885. */
  31886. protected _markAllSubMeshesAsLightsDirty(): void;
  31887. /**
  31888. * Indicates that attributes need to be re-calculated for all submeshes
  31889. */
  31890. protected _markAllSubMeshesAsAttributesDirty(): void;
  31891. /**
  31892. * Indicates that misc needs to be re-calculated for all submeshes
  31893. */
  31894. protected _markAllSubMeshesAsMiscDirty(): void;
  31895. /**
  31896. * Indicates that prepass needs to be re-calculated for all submeshes
  31897. */
  31898. protected _markAllSubMeshesAsPrePassDirty(): void;
  31899. /**
  31900. * Indicates that textures and misc need to be re-calculated for all submeshes
  31901. */
  31902. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31903. /**
  31904. * Sets the required values to the prepass renderer.
  31905. * @param prePassRenderer defines the prepass renderer to setup.
  31906. * @returns true if the pre pass is needed.
  31907. */
  31908. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31909. /**
  31910. * Disposes the material
  31911. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31912. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31913. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31914. */
  31915. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31916. /** @hidden */
  31917. private releaseVertexArrayObject;
  31918. /**
  31919. * Serializes this material
  31920. * @returns the serialized material object
  31921. */
  31922. serialize(): any;
  31923. /**
  31924. * Creates a material from parsed material data
  31925. * @param parsedMaterial defines parsed material data
  31926. * @param scene defines the hosting scene
  31927. * @param rootUrl defines the root URL to use to load textures
  31928. * @returns a new material
  31929. */
  31930. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31931. }
  31932. }
  31933. declare module "babylonjs/Materials/multiMaterial" {
  31934. import { Nullable } from "babylonjs/types";
  31935. import { Scene } from "babylonjs/scene";
  31936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31939. import { Material } from "babylonjs/Materials/material";
  31940. /**
  31941. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31942. * separate meshes. This can be use to improve performances.
  31943. * @see https://doc.babylonjs.com/how_to/multi_materials
  31944. */
  31945. export class MultiMaterial extends Material {
  31946. private _subMaterials;
  31947. /**
  31948. * Gets or Sets the list of Materials used within the multi material.
  31949. * They need to be ordered according to the submeshes order in the associated mesh
  31950. */
  31951. get subMaterials(): Nullable<Material>[];
  31952. set subMaterials(value: Nullable<Material>[]);
  31953. /**
  31954. * Function used to align with Node.getChildren()
  31955. * @returns the list of Materials used within the multi material
  31956. */
  31957. getChildren(): Nullable<Material>[];
  31958. /**
  31959. * Instantiates a new Multi Material
  31960. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31961. * separate meshes. This can be use to improve performances.
  31962. * @see https://doc.babylonjs.com/how_to/multi_materials
  31963. * @param name Define the name in the scene
  31964. * @param scene Define the scene the material belongs to
  31965. */
  31966. constructor(name: string, scene: Scene);
  31967. private _hookArray;
  31968. /**
  31969. * Get one of the submaterial by its index in the submaterials array
  31970. * @param index The index to look the sub material at
  31971. * @returns The Material if the index has been defined
  31972. */
  31973. getSubMaterial(index: number): Nullable<Material>;
  31974. /**
  31975. * Get the list of active textures for the whole sub materials list.
  31976. * @returns All the textures that will be used during the rendering
  31977. */
  31978. getActiveTextures(): BaseTexture[];
  31979. /**
  31980. * Specifies if any sub-materials of this multi-material use a given texture.
  31981. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31982. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31983. */
  31984. hasTexture(texture: BaseTexture): boolean;
  31985. /**
  31986. * Gets the current class name of the material e.g. "MultiMaterial"
  31987. * Mainly use in serialization.
  31988. * @returns the class name
  31989. */
  31990. getClassName(): string;
  31991. /**
  31992. * Checks if the material is ready to render the requested sub mesh
  31993. * @param mesh Define the mesh the submesh belongs to
  31994. * @param subMesh Define the sub mesh to look readyness for
  31995. * @param useInstances Define whether or not the material is used with instances
  31996. * @returns true if ready, otherwise false
  31997. */
  31998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31999. /**
  32000. * Clones the current material and its related sub materials
  32001. * @param name Define the name of the newly cloned material
  32002. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  32003. * @returns the cloned material
  32004. */
  32005. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  32006. /**
  32007. * Serializes the materials into a JSON representation.
  32008. * @returns the JSON representation
  32009. */
  32010. serialize(): any;
  32011. /**
  32012. * Dispose the material and release its associated resources
  32013. * @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)
  32014. * @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)
  32015. * @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)
  32016. */
  32017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  32018. /**
  32019. * Creates a MultiMaterial from parsed MultiMaterial data.
  32020. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  32021. * @param scene defines the hosting scene
  32022. * @returns a new MultiMaterial
  32023. */
  32024. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  32025. }
  32026. }
  32027. declare module "babylonjs/Meshes/subMesh" {
  32028. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  32029. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32030. import { Engine } from "babylonjs/Engines/engine";
  32031. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  32032. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32033. import { Effect } from "babylonjs/Materials/effect";
  32034. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32035. import { Plane } from "babylonjs/Maths/math.plane";
  32036. import { Collider } from "babylonjs/Collisions/collider";
  32037. import { Material } from "babylonjs/Materials/material";
  32038. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  32039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32040. import { Mesh } from "babylonjs/Meshes/mesh";
  32041. import { Ray } from "babylonjs/Culling/ray";
  32042. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32043. /** @hidden */
  32044. export interface ICustomEffect {
  32045. effect: Effect;
  32046. defines: string;
  32047. }
  32048. /**
  32049. * Defines a subdivision inside a mesh
  32050. */
  32051. export class SubMesh implements ICullable {
  32052. /** the material index to use */
  32053. materialIndex: number;
  32054. /** vertex index start */
  32055. verticesStart: number;
  32056. /** vertices count */
  32057. verticesCount: number;
  32058. /** index start */
  32059. indexStart: number;
  32060. /** indices count */
  32061. indexCount: number;
  32062. /** @hidden */
  32063. _materialDefines: Nullable<MaterialDefines>;
  32064. /** @hidden */
  32065. _materialEffect: Nullable<Effect>;
  32066. /** @hidden */
  32067. _effectOverride: Nullable<Effect>;
  32068. private _customEffects;
  32069. /**
  32070. * Gets material defines used by the effect associated to the sub mesh
  32071. */
  32072. get materialDefines(): Nullable<MaterialDefines>;
  32073. /**
  32074. * Sets material defines used by the effect associated to the sub mesh
  32075. */
  32076. set materialDefines(defines: Nullable<MaterialDefines>);
  32077. /** @hidden */
  32078. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  32079. /** @hidden */
  32080. _removeCustomEffect(name: string): void;
  32081. /**
  32082. * Gets associated effect
  32083. */
  32084. get effect(): Nullable<Effect>;
  32085. /**
  32086. * Sets associated effect (effect used to render this submesh)
  32087. * @param effect defines the effect to associate with
  32088. * @param defines defines the set of defines used to compile this effect
  32089. */
  32090. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  32091. /** @hidden */
  32092. _linesIndexCount: number;
  32093. private _mesh;
  32094. private _renderingMesh;
  32095. private _boundingInfo;
  32096. private _linesIndexBuffer;
  32097. /** @hidden */
  32098. _lastColliderWorldVertices: Nullable<Vector3[]>;
  32099. /** @hidden */
  32100. _trianglePlanes: Plane[];
  32101. /** @hidden */
  32102. _lastColliderTransformMatrix: Nullable<Matrix>;
  32103. /** @hidden */
  32104. _renderId: number;
  32105. /** @hidden */
  32106. _alphaIndex: number;
  32107. /** @hidden */
  32108. _distanceToCamera: number;
  32109. /** @hidden */
  32110. _id: number;
  32111. private _currentMaterial;
  32112. /**
  32113. * Add a new submesh to a mesh
  32114. * @param materialIndex defines the material index to use
  32115. * @param verticesStart defines vertex index start
  32116. * @param verticesCount defines vertices count
  32117. * @param indexStart defines index start
  32118. * @param indexCount defines indices count
  32119. * @param mesh defines the parent mesh
  32120. * @param renderingMesh defines an optional rendering mesh
  32121. * @param createBoundingBox defines if bounding box should be created for this submesh
  32122. * @returns the new submesh
  32123. */
  32124. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  32125. /**
  32126. * Creates a new submesh
  32127. * @param materialIndex defines the material index to use
  32128. * @param verticesStart defines vertex index start
  32129. * @param verticesCount defines vertices count
  32130. * @param indexStart defines index start
  32131. * @param indexCount defines indices count
  32132. * @param mesh defines the parent mesh
  32133. * @param renderingMesh defines an optional rendering mesh
  32134. * @param createBoundingBox defines if bounding box should be created for this submesh
  32135. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  32136. */
  32137. constructor(
  32138. /** the material index to use */
  32139. materialIndex: number,
  32140. /** vertex index start */
  32141. verticesStart: number,
  32142. /** vertices count */
  32143. verticesCount: number,
  32144. /** index start */
  32145. indexStart: number,
  32146. /** indices count */
  32147. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  32148. /**
  32149. * Returns true if this submesh covers the entire parent mesh
  32150. * @ignorenaming
  32151. */
  32152. get IsGlobal(): boolean;
  32153. /**
  32154. * Returns the submesh BoudingInfo object
  32155. * @returns current bounding info (or mesh's one if the submesh is global)
  32156. */
  32157. getBoundingInfo(): BoundingInfo;
  32158. /**
  32159. * Sets the submesh BoundingInfo
  32160. * @param boundingInfo defines the new bounding info to use
  32161. * @returns the SubMesh
  32162. */
  32163. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  32164. /**
  32165. * Returns the mesh of the current submesh
  32166. * @return the parent mesh
  32167. */
  32168. getMesh(): AbstractMesh;
  32169. /**
  32170. * Returns the rendering mesh of the submesh
  32171. * @returns the rendering mesh (could be different from parent mesh)
  32172. */
  32173. getRenderingMesh(): Mesh;
  32174. /**
  32175. * Returns the replacement mesh of the submesh
  32176. * @returns the replacement mesh (could be different from parent mesh)
  32177. */
  32178. getReplacementMesh(): Nullable<AbstractMesh>;
  32179. /**
  32180. * Returns the effective mesh of the submesh
  32181. * @returns the effective mesh (could be different from parent mesh)
  32182. */
  32183. getEffectiveMesh(): AbstractMesh;
  32184. /**
  32185. * Returns the submesh material
  32186. * @returns null or the current material
  32187. */
  32188. getMaterial(): Nullable<Material>;
  32189. private _IsMultiMaterial;
  32190. /**
  32191. * Sets a new updated BoundingInfo object to the submesh
  32192. * @param data defines an optional position array to use to determine the bounding info
  32193. * @returns the SubMesh
  32194. */
  32195. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  32196. /** @hidden */
  32197. _checkCollision(collider: Collider): boolean;
  32198. /**
  32199. * Updates the submesh BoundingInfo
  32200. * @param world defines the world matrix to use to update the bounding info
  32201. * @returns the submesh
  32202. */
  32203. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  32204. /**
  32205. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  32206. * @param frustumPlanes defines the frustum planes
  32207. * @returns true if the submesh is intersecting with the frustum
  32208. */
  32209. isInFrustum(frustumPlanes: Plane[]): boolean;
  32210. /**
  32211. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  32212. * @param frustumPlanes defines the frustum planes
  32213. * @returns true if the submesh is inside the frustum
  32214. */
  32215. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32216. /**
  32217. * Renders the submesh
  32218. * @param enableAlphaMode defines if alpha needs to be used
  32219. * @returns the submesh
  32220. */
  32221. render(enableAlphaMode: boolean): SubMesh;
  32222. /**
  32223. * @hidden
  32224. */
  32225. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  32226. /**
  32227. * Checks if the submesh intersects with a ray
  32228. * @param ray defines the ray to test
  32229. * @returns true is the passed ray intersects the submesh bounding box
  32230. */
  32231. canIntersects(ray: Ray): boolean;
  32232. /**
  32233. * Intersects current submesh with a ray
  32234. * @param ray defines the ray to test
  32235. * @param positions defines mesh's positions array
  32236. * @param indices defines mesh's indices array
  32237. * @param fastCheck defines if the first intersection will be used (and not the closest)
  32238. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32239. * @returns intersection info or null if no intersection
  32240. */
  32241. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  32242. /** @hidden */
  32243. private _intersectLines;
  32244. /** @hidden */
  32245. private _intersectUnIndexedLines;
  32246. /** @hidden */
  32247. private _intersectTriangles;
  32248. /** @hidden */
  32249. private _intersectUnIndexedTriangles;
  32250. /** @hidden */
  32251. _rebuild(): void;
  32252. /**
  32253. * Creates a new submesh from the passed mesh
  32254. * @param newMesh defines the new hosting mesh
  32255. * @param newRenderingMesh defines an optional rendering mesh
  32256. * @returns the new submesh
  32257. */
  32258. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  32259. /**
  32260. * Release associated resources
  32261. */
  32262. dispose(): void;
  32263. /**
  32264. * Gets the class name
  32265. * @returns the string "SubMesh".
  32266. */
  32267. getClassName(): string;
  32268. /**
  32269. * Creates a new submesh from indices data
  32270. * @param materialIndex the index of the main mesh material
  32271. * @param startIndex the index where to start the copy in the mesh indices array
  32272. * @param indexCount the number of indices to copy then from the startIndex
  32273. * @param mesh the main mesh to create the submesh from
  32274. * @param renderingMesh the optional rendering mesh
  32275. * @returns a new submesh
  32276. */
  32277. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  32278. }
  32279. }
  32280. declare module "babylonjs/Loading/sceneLoaderFlags" {
  32281. /**
  32282. * Class used to represent data loading progression
  32283. */
  32284. export class SceneLoaderFlags {
  32285. private static _ForceFullSceneLoadingForIncremental;
  32286. private static _ShowLoadingScreen;
  32287. private static _CleanBoneMatrixWeights;
  32288. private static _loggingLevel;
  32289. /**
  32290. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  32291. */
  32292. static get ForceFullSceneLoadingForIncremental(): boolean;
  32293. static set ForceFullSceneLoadingForIncremental(value: boolean);
  32294. /**
  32295. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  32296. */
  32297. static get ShowLoadingScreen(): boolean;
  32298. static set ShowLoadingScreen(value: boolean);
  32299. /**
  32300. * Defines the current logging level (while loading the scene)
  32301. * @ignorenaming
  32302. */
  32303. static get loggingLevel(): number;
  32304. static set loggingLevel(value: number);
  32305. /**
  32306. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  32307. */
  32308. static get CleanBoneMatrixWeights(): boolean;
  32309. static set CleanBoneMatrixWeights(value: boolean);
  32310. }
  32311. }
  32312. declare module "babylonjs/Meshes/geometry" {
  32313. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  32314. import { Scene } from "babylonjs/scene";
  32315. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32316. import { Engine } from "babylonjs/Engines/engine";
  32317. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  32318. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32319. import { Effect } from "babylonjs/Materials/effect";
  32320. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32321. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32322. import { Mesh } from "babylonjs/Meshes/mesh";
  32323. /**
  32324. * Class used to store geometry data (vertex buffers + index buffer)
  32325. */
  32326. export class Geometry implements IGetSetVerticesData {
  32327. /**
  32328. * Gets or sets the ID of the geometry
  32329. */
  32330. id: string;
  32331. /**
  32332. * Gets or sets the unique ID of the geometry
  32333. */
  32334. uniqueId: number;
  32335. /**
  32336. * Gets the delay loading state of the geometry (none by default which means not delayed)
  32337. */
  32338. delayLoadState: number;
  32339. /**
  32340. * Gets the file containing the data to load when running in delay load state
  32341. */
  32342. delayLoadingFile: Nullable<string>;
  32343. /**
  32344. * Callback called when the geometry is updated
  32345. */
  32346. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  32347. private _scene;
  32348. private _engine;
  32349. private _meshes;
  32350. private _totalVertices;
  32351. /** @hidden */
  32352. _indices: IndicesArray;
  32353. /** @hidden */
  32354. _vertexBuffers: {
  32355. [key: string]: VertexBuffer;
  32356. };
  32357. private _isDisposed;
  32358. private _extend;
  32359. private _boundingBias;
  32360. /** @hidden */
  32361. _delayInfo: Array<string>;
  32362. private _indexBuffer;
  32363. private _indexBufferIsUpdatable;
  32364. /** @hidden */
  32365. _boundingInfo: Nullable<BoundingInfo>;
  32366. /** @hidden */
  32367. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  32368. /** @hidden */
  32369. _softwareSkinningFrameId: number;
  32370. private _vertexArrayObjects;
  32371. private _updatable;
  32372. /** @hidden */
  32373. _positions: Nullable<Vector3[]>;
  32374. private _positionsCache;
  32375. /**
  32376. * 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
  32377. */
  32378. get boundingBias(): Vector2;
  32379. /**
  32380. * 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
  32381. */
  32382. set boundingBias(value: Vector2);
  32383. /**
  32384. * Static function used to attach a new empty geometry to a mesh
  32385. * @param mesh defines the mesh to attach the geometry to
  32386. * @returns the new Geometry
  32387. */
  32388. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  32389. /** Get the list of meshes using this geometry */
  32390. get meshes(): Mesh[];
  32391. /**
  32392. * 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
  32393. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  32394. */
  32395. useBoundingInfoFromGeometry: boolean;
  32396. /**
  32397. * Creates a new geometry
  32398. * @param id defines the unique ID
  32399. * @param scene defines the hosting scene
  32400. * @param vertexData defines the VertexData used to get geometry data
  32401. * @param updatable defines if geometry must be updatable (false by default)
  32402. * @param mesh defines the mesh that will be associated with the geometry
  32403. */
  32404. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  32405. /**
  32406. * Gets the current extend of the geometry
  32407. */
  32408. get extend(): {
  32409. minimum: Vector3;
  32410. maximum: Vector3;
  32411. };
  32412. /**
  32413. * Gets the hosting scene
  32414. * @returns the hosting Scene
  32415. */
  32416. getScene(): Scene;
  32417. /**
  32418. * Gets the hosting engine
  32419. * @returns the hosting Engine
  32420. */
  32421. getEngine(): Engine;
  32422. /**
  32423. * Defines if the geometry is ready to use
  32424. * @returns true if the geometry is ready to be used
  32425. */
  32426. isReady(): boolean;
  32427. /**
  32428. * Gets a value indicating that the geometry should not be serialized
  32429. */
  32430. get doNotSerialize(): boolean;
  32431. /** @hidden */
  32432. _rebuild(): void;
  32433. /**
  32434. * Affects all geometry data in one call
  32435. * @param vertexData defines the geometry data
  32436. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  32437. */
  32438. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  32439. /**
  32440. * Set specific vertex data
  32441. * @param kind defines the data kind (Position, normal, etc...)
  32442. * @param data defines the vertex data to use
  32443. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  32444. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  32445. */
  32446. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  32447. /**
  32448. * Removes a specific vertex data
  32449. * @param kind defines the data kind (Position, normal, etc...)
  32450. */
  32451. removeVerticesData(kind: string): void;
  32452. /**
  32453. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  32454. * @param buffer defines the vertex buffer to use
  32455. * @param totalVertices defines the total number of vertices for position kind (could be null)
  32456. */
  32457. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  32458. /**
  32459. * Update a specific vertex buffer
  32460. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  32461. * It will do nothing if the buffer is not updatable
  32462. * @param kind defines the data kind (Position, normal, etc...)
  32463. * @param data defines the data to use
  32464. * @param offset defines the offset in the target buffer where to store the data
  32465. * @param useBytes set to true if the offset is in bytes
  32466. */
  32467. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  32468. /**
  32469. * Update a specific vertex buffer
  32470. * This function will create a new buffer if the current one is not updatable
  32471. * @param kind defines the data kind (Position, normal, etc...)
  32472. * @param data defines the data to use
  32473. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  32474. */
  32475. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  32476. private _updateBoundingInfo;
  32477. /** @hidden */
  32478. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  32479. /**
  32480. * Gets total number of vertices
  32481. * @returns the total number of vertices
  32482. */
  32483. getTotalVertices(): number;
  32484. /**
  32485. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  32486. * @param kind defines the data kind (Position, normal, etc...)
  32487. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32488. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32489. * @returns a float array containing vertex data
  32490. */
  32491. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32492. /**
  32493. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  32494. * @param kind defines the data kind (Position, normal, etc...)
  32495. * @returns true if the vertex buffer with the specified kind is updatable
  32496. */
  32497. isVertexBufferUpdatable(kind: string): boolean;
  32498. /**
  32499. * Gets a specific vertex buffer
  32500. * @param kind defines the data kind (Position, normal, etc...)
  32501. * @returns a VertexBuffer
  32502. */
  32503. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32504. /**
  32505. * Returns all vertex buffers
  32506. * @return an object holding all vertex buffers indexed by kind
  32507. */
  32508. getVertexBuffers(): Nullable<{
  32509. [key: string]: VertexBuffer;
  32510. }>;
  32511. /**
  32512. * Gets a boolean indicating if specific vertex buffer is present
  32513. * @param kind defines the data kind (Position, normal, etc...)
  32514. * @returns true if data is present
  32515. */
  32516. isVerticesDataPresent(kind: string): boolean;
  32517. /**
  32518. * Gets a list of all attached data kinds (Position, normal, etc...)
  32519. * @returns a list of string containing all kinds
  32520. */
  32521. getVerticesDataKinds(): string[];
  32522. /**
  32523. * Update index buffer
  32524. * @param indices defines the indices to store in the index buffer
  32525. * @param offset defines the offset in the target buffer where to store the data
  32526. * @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)
  32527. */
  32528. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  32529. /**
  32530. * Creates a new index buffer
  32531. * @param indices defines the indices to store in the index buffer
  32532. * @param totalVertices defines the total number of vertices (could be null)
  32533. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  32534. */
  32535. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  32536. /**
  32537. * Return the total number of indices
  32538. * @returns the total number of indices
  32539. */
  32540. getTotalIndices(): number;
  32541. /**
  32542. * Gets the index buffer array
  32543. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32544. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32545. * @returns the index buffer array
  32546. */
  32547. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32548. /**
  32549. * Gets the index buffer
  32550. * @return the index buffer
  32551. */
  32552. getIndexBuffer(): Nullable<DataBuffer>;
  32553. /** @hidden */
  32554. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  32555. /**
  32556. * Release the associated resources for a specific mesh
  32557. * @param mesh defines the source mesh
  32558. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  32559. */
  32560. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  32561. /**
  32562. * Apply current geometry to a given mesh
  32563. * @param mesh defines the mesh to apply geometry to
  32564. */
  32565. applyToMesh(mesh: Mesh): void;
  32566. private _updateExtend;
  32567. private _applyToMesh;
  32568. private notifyUpdate;
  32569. /**
  32570. * Load the geometry if it was flagged as delay loaded
  32571. * @param scene defines the hosting scene
  32572. * @param onLoaded defines a callback called when the geometry is loaded
  32573. */
  32574. load(scene: Scene, onLoaded?: () => void): void;
  32575. private _queueLoad;
  32576. /**
  32577. * Invert the geometry to move from a right handed system to a left handed one.
  32578. */
  32579. toLeftHanded(): void;
  32580. /** @hidden */
  32581. _resetPointsArrayCache(): void;
  32582. /** @hidden */
  32583. _generatePointsArray(): boolean;
  32584. /**
  32585. * Gets a value indicating if the geometry is disposed
  32586. * @returns true if the geometry was disposed
  32587. */
  32588. isDisposed(): boolean;
  32589. private _disposeVertexArrayObjects;
  32590. /**
  32591. * Free all associated resources
  32592. */
  32593. dispose(): void;
  32594. /**
  32595. * Clone the current geometry into a new geometry
  32596. * @param id defines the unique ID of the new geometry
  32597. * @returns a new geometry object
  32598. */
  32599. copy(id: string): Geometry;
  32600. /**
  32601. * Serialize the current geometry info (and not the vertices data) into a JSON object
  32602. * @return a JSON representation of the current geometry data (without the vertices data)
  32603. */
  32604. serialize(): any;
  32605. private toNumberArray;
  32606. /**
  32607. * Serialize all vertices data into a JSON oject
  32608. * @returns a JSON representation of the current geometry data
  32609. */
  32610. serializeVerticeData(): any;
  32611. /**
  32612. * Extracts a clone of a mesh geometry
  32613. * @param mesh defines the source mesh
  32614. * @param id defines the unique ID of the new geometry object
  32615. * @returns the new geometry object
  32616. */
  32617. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  32618. /**
  32619. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  32620. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32621. * Be aware Math.random() could cause collisions, but:
  32622. * "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"
  32623. * @returns a string containing a new GUID
  32624. */
  32625. static RandomId(): string;
  32626. /** @hidden */
  32627. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  32628. private static _CleanMatricesWeights;
  32629. /**
  32630. * Create a new geometry from persisted data (Using .babylon file format)
  32631. * @param parsedVertexData defines the persisted data
  32632. * @param scene defines the hosting scene
  32633. * @param rootUrl defines the root url to use to load assets (like delayed data)
  32634. * @returns the new geometry object
  32635. */
  32636. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  32637. }
  32638. }
  32639. declare module "babylonjs/Morph/morphTarget" {
  32640. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32641. import { Observable } from "babylonjs/Misc/observable";
  32642. import { Nullable, FloatArray } from "babylonjs/types";
  32643. import { Scene } from "babylonjs/scene";
  32644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32645. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32646. /**
  32647. * Defines a target to use with MorphTargetManager
  32648. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32649. */
  32650. export class MorphTarget implements IAnimatable {
  32651. /** defines the name of the target */
  32652. name: string;
  32653. /**
  32654. * Gets or sets the list of animations
  32655. */
  32656. animations: import("babylonjs/Animations/animation").Animation[];
  32657. private _scene;
  32658. private _positions;
  32659. private _normals;
  32660. private _tangents;
  32661. private _uvs;
  32662. private _influence;
  32663. private _uniqueId;
  32664. /**
  32665. * Observable raised when the influence changes
  32666. */
  32667. onInfluenceChanged: Observable<boolean>;
  32668. /** @hidden */
  32669. _onDataLayoutChanged: Observable<void>;
  32670. /**
  32671. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32672. */
  32673. get influence(): number;
  32674. set influence(influence: number);
  32675. /**
  32676. * Gets or sets the id of the morph Target
  32677. */
  32678. id: string;
  32679. private _animationPropertiesOverride;
  32680. /**
  32681. * Gets or sets the animation properties override
  32682. */
  32683. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32684. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32685. /**
  32686. * Creates a new MorphTarget
  32687. * @param name defines the name of the target
  32688. * @param influence defines the influence to use
  32689. * @param scene defines the scene the morphtarget belongs to
  32690. */
  32691. constructor(
  32692. /** defines the name of the target */
  32693. name: string, influence?: number, scene?: Nullable<Scene>);
  32694. /**
  32695. * Gets the unique ID of this manager
  32696. */
  32697. get uniqueId(): number;
  32698. /**
  32699. * Gets a boolean defining if the target contains position data
  32700. */
  32701. get hasPositions(): boolean;
  32702. /**
  32703. * Gets a boolean defining if the target contains normal data
  32704. */
  32705. get hasNormals(): boolean;
  32706. /**
  32707. * Gets a boolean defining if the target contains tangent data
  32708. */
  32709. get hasTangents(): boolean;
  32710. /**
  32711. * Gets a boolean defining if the target contains texture coordinates data
  32712. */
  32713. get hasUVs(): boolean;
  32714. /**
  32715. * Affects position data to this target
  32716. * @param data defines the position data to use
  32717. */
  32718. setPositions(data: Nullable<FloatArray>): void;
  32719. /**
  32720. * Gets the position data stored in this target
  32721. * @returns a FloatArray containing the position data (or null if not present)
  32722. */
  32723. getPositions(): Nullable<FloatArray>;
  32724. /**
  32725. * Affects normal data to this target
  32726. * @param data defines the normal data to use
  32727. */
  32728. setNormals(data: Nullable<FloatArray>): void;
  32729. /**
  32730. * Gets the normal data stored in this target
  32731. * @returns a FloatArray containing the normal data (or null if not present)
  32732. */
  32733. getNormals(): Nullable<FloatArray>;
  32734. /**
  32735. * Affects tangent data to this target
  32736. * @param data defines the tangent data to use
  32737. */
  32738. setTangents(data: Nullable<FloatArray>): void;
  32739. /**
  32740. * Gets the tangent data stored in this target
  32741. * @returns a FloatArray containing the tangent data (or null if not present)
  32742. */
  32743. getTangents(): Nullable<FloatArray>;
  32744. /**
  32745. * Affects texture coordinates data to this target
  32746. * @param data defines the texture coordinates data to use
  32747. */
  32748. setUVs(data: Nullable<FloatArray>): void;
  32749. /**
  32750. * Gets the texture coordinates data stored in this target
  32751. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32752. */
  32753. getUVs(): Nullable<FloatArray>;
  32754. /**
  32755. * Clone the current target
  32756. * @returns a new MorphTarget
  32757. */
  32758. clone(): MorphTarget;
  32759. /**
  32760. * Serializes the current target into a Serialization object
  32761. * @returns the serialized object
  32762. */
  32763. serialize(): any;
  32764. /**
  32765. * Returns the string "MorphTarget"
  32766. * @returns "MorphTarget"
  32767. */
  32768. getClassName(): string;
  32769. /**
  32770. * Creates a new target from serialized data
  32771. * @param serializationObject defines the serialized data to use
  32772. * @returns a new MorphTarget
  32773. */
  32774. static Parse(serializationObject: any): MorphTarget;
  32775. /**
  32776. * Creates a MorphTarget from mesh data
  32777. * @param mesh defines the source mesh
  32778. * @param name defines the name to use for the new target
  32779. * @param influence defines the influence to attach to the target
  32780. * @returns a new MorphTarget
  32781. */
  32782. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32783. }
  32784. }
  32785. declare module "babylonjs/Morph/morphTargetManager" {
  32786. import { Nullable } from "babylonjs/types";
  32787. import { Scene } from "babylonjs/scene";
  32788. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32789. /**
  32790. * This class is used to deform meshes using morphing between different targets
  32791. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32792. */
  32793. export class MorphTargetManager {
  32794. private _targets;
  32795. private _targetInfluenceChangedObservers;
  32796. private _targetDataLayoutChangedObservers;
  32797. private _activeTargets;
  32798. private _scene;
  32799. private _influences;
  32800. private _supportsNormals;
  32801. private _supportsTangents;
  32802. private _supportsUVs;
  32803. private _vertexCount;
  32804. private _uniqueId;
  32805. private _tempInfluences;
  32806. /**
  32807. * Gets or sets a boolean indicating if normals must be morphed
  32808. */
  32809. enableNormalMorphing: boolean;
  32810. /**
  32811. * Gets or sets a boolean indicating if tangents must be morphed
  32812. */
  32813. enableTangentMorphing: boolean;
  32814. /**
  32815. * Gets or sets a boolean indicating if UV must be morphed
  32816. */
  32817. enableUVMorphing: boolean;
  32818. /**
  32819. * Creates a new MorphTargetManager
  32820. * @param scene defines the current scene
  32821. */
  32822. constructor(scene?: Nullable<Scene>);
  32823. /**
  32824. * Gets the unique ID of this manager
  32825. */
  32826. get uniqueId(): number;
  32827. /**
  32828. * Gets the number of vertices handled by this manager
  32829. */
  32830. get vertexCount(): number;
  32831. /**
  32832. * Gets a boolean indicating if this manager supports morphing of normals
  32833. */
  32834. get supportsNormals(): boolean;
  32835. /**
  32836. * Gets a boolean indicating if this manager supports morphing of tangents
  32837. */
  32838. get supportsTangents(): boolean;
  32839. /**
  32840. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32841. */
  32842. get supportsUVs(): boolean;
  32843. /**
  32844. * Gets the number of targets stored in this manager
  32845. */
  32846. get numTargets(): number;
  32847. /**
  32848. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32849. */
  32850. get numInfluencers(): number;
  32851. /**
  32852. * Gets the list of influences (one per target)
  32853. */
  32854. get influences(): Float32Array;
  32855. /**
  32856. * Gets the active target at specified index. An active target is a target with an influence > 0
  32857. * @param index defines the index to check
  32858. * @returns the requested target
  32859. */
  32860. getActiveTarget(index: number): MorphTarget;
  32861. /**
  32862. * Gets the target at specified index
  32863. * @param index defines the index to check
  32864. * @returns the requested target
  32865. */
  32866. getTarget(index: number): MorphTarget;
  32867. /**
  32868. * Add a new target to this manager
  32869. * @param target defines the target to add
  32870. */
  32871. addTarget(target: MorphTarget): void;
  32872. /**
  32873. * Removes a target from the manager
  32874. * @param target defines the target to remove
  32875. */
  32876. removeTarget(target: MorphTarget): void;
  32877. /**
  32878. * Clone the current manager
  32879. * @returns a new MorphTargetManager
  32880. */
  32881. clone(): MorphTargetManager;
  32882. /**
  32883. * Serializes the current manager into a Serialization object
  32884. * @returns the serialized object
  32885. */
  32886. serialize(): any;
  32887. private _syncActiveTargets;
  32888. /**
  32889. * Syncrhonize the targets with all the meshes using this morph target manager
  32890. */
  32891. synchronize(): void;
  32892. /**
  32893. * Creates a new MorphTargetManager from serialized data
  32894. * @param serializationObject defines the serialized data
  32895. * @param scene defines the hosting scene
  32896. * @returns the new MorphTargetManager
  32897. */
  32898. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32899. }
  32900. }
  32901. declare module "babylonjs/Meshes/meshLODLevel" {
  32902. import { Mesh } from "babylonjs/Meshes/mesh";
  32903. import { Nullable } from "babylonjs/types";
  32904. /**
  32905. * Class used to represent a specific level of detail of a mesh
  32906. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32907. */
  32908. export class MeshLODLevel {
  32909. /** Defines the distance where this level should start being displayed */
  32910. distance: number;
  32911. /** Defines the mesh to use to render this level */
  32912. mesh: Nullable<Mesh>;
  32913. /**
  32914. * Creates a new LOD level
  32915. * @param distance defines the distance where this level should star being displayed
  32916. * @param mesh defines the mesh to use to render this level
  32917. */
  32918. constructor(
  32919. /** Defines the distance where this level should start being displayed */
  32920. distance: number,
  32921. /** Defines the mesh to use to render this level */
  32922. mesh: Nullable<Mesh>);
  32923. }
  32924. }
  32925. declare module "babylonjs/Misc/canvasGenerator" {
  32926. /**
  32927. * Helper class used to generate a canvas to manipulate images
  32928. */
  32929. export class CanvasGenerator {
  32930. /**
  32931. * Create a new canvas (or offscreen canvas depending on the context)
  32932. * @param width defines the expected width
  32933. * @param height defines the expected height
  32934. * @return a new canvas or offscreen canvas
  32935. */
  32936. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32937. }
  32938. }
  32939. declare module "babylonjs/Meshes/groundMesh" {
  32940. import { Scene } from "babylonjs/scene";
  32941. import { Vector3 } from "babylonjs/Maths/math.vector";
  32942. import { Mesh } from "babylonjs/Meshes/mesh";
  32943. /**
  32944. * Mesh representing the gorund
  32945. */
  32946. export class GroundMesh extends Mesh {
  32947. /** If octree should be generated */
  32948. generateOctree: boolean;
  32949. private _heightQuads;
  32950. /** @hidden */
  32951. _subdivisionsX: number;
  32952. /** @hidden */
  32953. _subdivisionsY: number;
  32954. /** @hidden */
  32955. _width: number;
  32956. /** @hidden */
  32957. _height: number;
  32958. /** @hidden */
  32959. _minX: number;
  32960. /** @hidden */
  32961. _maxX: number;
  32962. /** @hidden */
  32963. _minZ: number;
  32964. /** @hidden */
  32965. _maxZ: number;
  32966. constructor(name: string, scene: Scene);
  32967. /**
  32968. * "GroundMesh"
  32969. * @returns "GroundMesh"
  32970. */
  32971. getClassName(): string;
  32972. /**
  32973. * The minimum of x and y subdivisions
  32974. */
  32975. get subdivisions(): number;
  32976. /**
  32977. * X subdivisions
  32978. */
  32979. get subdivisionsX(): number;
  32980. /**
  32981. * Y subdivisions
  32982. */
  32983. get subdivisionsY(): number;
  32984. /**
  32985. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32986. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32987. * @param chunksCount the number of subdivisions for x and y
  32988. * @param octreeBlocksSize (Default: 32)
  32989. */
  32990. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32991. /**
  32992. * Returns a height (y) value in the Worl system :
  32993. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32994. * @param x x coordinate
  32995. * @param z z coordinate
  32996. * @returns the ground y position if (x, z) are outside the ground surface.
  32997. */
  32998. getHeightAtCoordinates(x: number, z: number): number;
  32999. /**
  33000. * Returns a normalized vector (Vector3) orthogonal to the ground
  33001. * at the ground coordinates (x, z) expressed in the World system.
  33002. * @param x x coordinate
  33003. * @param z z coordinate
  33004. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  33005. */
  33006. getNormalAtCoordinates(x: number, z: number): Vector3;
  33007. /**
  33008. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  33009. * at the ground coordinates (x, z) expressed in the World system.
  33010. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  33011. * @param x x coordinate
  33012. * @param z z coordinate
  33013. * @param ref vector to store the result
  33014. * @returns the GroundMesh.
  33015. */
  33016. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  33017. /**
  33018. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  33019. * if the ground has been updated.
  33020. * This can be used in the render loop.
  33021. * @returns the GroundMesh.
  33022. */
  33023. updateCoordinateHeights(): GroundMesh;
  33024. private _getFacetAt;
  33025. private _initHeightQuads;
  33026. private _computeHeightQuads;
  33027. /**
  33028. * Serializes this ground mesh
  33029. * @param serializationObject object to write serialization to
  33030. */
  33031. serialize(serializationObject: any): void;
  33032. /**
  33033. * Parses a serialized ground mesh
  33034. * @param parsedMesh the serialized mesh
  33035. * @param scene the scene to create the ground mesh in
  33036. * @returns the created ground mesh
  33037. */
  33038. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  33039. }
  33040. }
  33041. declare module "babylonjs/Physics/physicsJoint" {
  33042. import { Vector3 } from "babylonjs/Maths/math.vector";
  33043. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  33044. /**
  33045. * Interface for Physics-Joint data
  33046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33047. */
  33048. export interface PhysicsJointData {
  33049. /**
  33050. * The main pivot of the joint
  33051. */
  33052. mainPivot?: Vector3;
  33053. /**
  33054. * The connected pivot of the joint
  33055. */
  33056. connectedPivot?: Vector3;
  33057. /**
  33058. * The main axis of the joint
  33059. */
  33060. mainAxis?: Vector3;
  33061. /**
  33062. * The connected axis of the joint
  33063. */
  33064. connectedAxis?: Vector3;
  33065. /**
  33066. * The collision of the joint
  33067. */
  33068. collision?: boolean;
  33069. /**
  33070. * Native Oimo/Cannon/Energy data
  33071. */
  33072. nativeParams?: any;
  33073. }
  33074. /**
  33075. * This is a holder class for the physics joint created by the physics plugin
  33076. * It holds a set of functions to control the underlying joint
  33077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33078. */
  33079. export class PhysicsJoint {
  33080. /**
  33081. * The type of the physics joint
  33082. */
  33083. type: number;
  33084. /**
  33085. * The data for the physics joint
  33086. */
  33087. jointData: PhysicsJointData;
  33088. private _physicsJoint;
  33089. protected _physicsPlugin: IPhysicsEnginePlugin;
  33090. /**
  33091. * Initializes the physics joint
  33092. * @param type The type of the physics joint
  33093. * @param jointData The data for the physics joint
  33094. */
  33095. constructor(
  33096. /**
  33097. * The type of the physics joint
  33098. */
  33099. type: number,
  33100. /**
  33101. * The data for the physics joint
  33102. */
  33103. jointData: PhysicsJointData);
  33104. /**
  33105. * Gets the physics joint
  33106. */
  33107. get physicsJoint(): any;
  33108. /**
  33109. * Sets the physics joint
  33110. */
  33111. set physicsJoint(newJoint: any);
  33112. /**
  33113. * Sets the physics plugin
  33114. */
  33115. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  33116. /**
  33117. * Execute a function that is physics-plugin specific.
  33118. * @param {Function} func the function that will be executed.
  33119. * It accepts two parameters: the physics world and the physics joint
  33120. */
  33121. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33122. /**
  33123. * Distance-Joint type
  33124. */
  33125. static DistanceJoint: number;
  33126. /**
  33127. * Hinge-Joint type
  33128. */
  33129. static HingeJoint: number;
  33130. /**
  33131. * Ball-and-Socket joint type
  33132. */
  33133. static BallAndSocketJoint: number;
  33134. /**
  33135. * Wheel-Joint type
  33136. */
  33137. static WheelJoint: number;
  33138. /**
  33139. * Slider-Joint type
  33140. */
  33141. static SliderJoint: number;
  33142. /**
  33143. * Prismatic-Joint type
  33144. */
  33145. static PrismaticJoint: number;
  33146. /**
  33147. * Universal-Joint type
  33148. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33149. */
  33150. static UniversalJoint: number;
  33151. /**
  33152. * Hinge-Joint 2 type
  33153. */
  33154. static Hinge2Joint: number;
  33155. /**
  33156. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33157. */
  33158. static PointToPointJoint: number;
  33159. /**
  33160. * Spring-Joint type
  33161. */
  33162. static SpringJoint: number;
  33163. /**
  33164. * Lock-Joint type
  33165. */
  33166. static LockJoint: number;
  33167. }
  33168. /**
  33169. * A class representing a physics distance joint
  33170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33171. */
  33172. export class DistanceJoint extends PhysicsJoint {
  33173. /**
  33174. *
  33175. * @param jointData The data for the Distance-Joint
  33176. */
  33177. constructor(jointData: DistanceJointData);
  33178. /**
  33179. * Update the predefined distance.
  33180. * @param maxDistance The maximum preferred distance
  33181. * @param minDistance The minimum preferred distance
  33182. */
  33183. updateDistance(maxDistance: number, minDistance?: number): void;
  33184. }
  33185. /**
  33186. * Represents a Motor-Enabled Joint
  33187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33188. */
  33189. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33190. /**
  33191. * Initializes the Motor-Enabled Joint
  33192. * @param type The type of the joint
  33193. * @param jointData The physica joint data for the joint
  33194. */
  33195. constructor(type: number, jointData: PhysicsJointData);
  33196. /**
  33197. * Set the motor values.
  33198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33199. * @param force the force to apply
  33200. * @param maxForce max force for this motor.
  33201. */
  33202. setMotor(force?: number, maxForce?: number): void;
  33203. /**
  33204. * Set the motor's limits.
  33205. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33206. * @param upperLimit The upper limit of the motor
  33207. * @param lowerLimit The lower limit of the motor
  33208. */
  33209. setLimit(upperLimit: number, lowerLimit?: number): void;
  33210. }
  33211. /**
  33212. * This class represents a single physics Hinge-Joint
  33213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33214. */
  33215. export class HingeJoint extends MotorEnabledJoint {
  33216. /**
  33217. * Initializes the Hinge-Joint
  33218. * @param jointData The joint data for the Hinge-Joint
  33219. */
  33220. constructor(jointData: PhysicsJointData);
  33221. /**
  33222. * Set the motor values.
  33223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33224. * @param {number} force the force to apply
  33225. * @param {number} maxForce max force for this motor.
  33226. */
  33227. setMotor(force?: number, maxForce?: number): void;
  33228. /**
  33229. * Set the motor's limits.
  33230. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33231. * @param upperLimit The upper limit of the motor
  33232. * @param lowerLimit The lower limit of the motor
  33233. */
  33234. setLimit(upperLimit: number, lowerLimit?: number): void;
  33235. }
  33236. /**
  33237. * This class represents a dual hinge physics joint (same as wheel joint)
  33238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33239. */
  33240. export class Hinge2Joint extends MotorEnabledJoint {
  33241. /**
  33242. * Initializes the Hinge2-Joint
  33243. * @param jointData The joint data for the Hinge2-Joint
  33244. */
  33245. constructor(jointData: PhysicsJointData);
  33246. /**
  33247. * Set the motor values.
  33248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33249. * @param {number} targetSpeed the speed the motor is to reach
  33250. * @param {number} maxForce max force for this motor.
  33251. * @param {motorIndex} the motor's index, 0 or 1.
  33252. */
  33253. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  33254. /**
  33255. * Set the motor limits.
  33256. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33257. * @param {number} upperLimit the upper limit
  33258. * @param {number} lowerLimit lower limit
  33259. * @param {motorIndex} the motor's index, 0 or 1.
  33260. */
  33261. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33262. }
  33263. /**
  33264. * Interface for a motor enabled joint
  33265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33266. */
  33267. export interface IMotorEnabledJoint {
  33268. /**
  33269. * Physics joint
  33270. */
  33271. physicsJoint: any;
  33272. /**
  33273. * Sets the motor of the motor-enabled joint
  33274. * @param force The force of the motor
  33275. * @param maxForce The maximum force of the motor
  33276. * @param motorIndex The index of the motor
  33277. */
  33278. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33279. /**
  33280. * Sets the limit of the motor
  33281. * @param upperLimit The upper limit of the motor
  33282. * @param lowerLimit The lower limit of the motor
  33283. * @param motorIndex The index of the motor
  33284. */
  33285. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33286. }
  33287. /**
  33288. * Joint data for a Distance-Joint
  33289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33290. */
  33291. export interface DistanceJointData extends PhysicsJointData {
  33292. /**
  33293. * Max distance the 2 joint objects can be apart
  33294. */
  33295. maxDistance: number;
  33296. }
  33297. /**
  33298. * Joint data from a spring joint
  33299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33300. */
  33301. export interface SpringJointData extends PhysicsJointData {
  33302. /**
  33303. * Length of the spring
  33304. */
  33305. length: number;
  33306. /**
  33307. * Stiffness of the spring
  33308. */
  33309. stiffness: number;
  33310. /**
  33311. * Damping of the spring
  33312. */
  33313. damping: number;
  33314. /** this callback will be called when applying the force to the impostors. */
  33315. forceApplicationCallback: () => void;
  33316. }
  33317. }
  33318. declare module "babylonjs/Physics/physicsRaycastResult" {
  33319. import { Vector3 } from "babylonjs/Maths/math.vector";
  33320. /**
  33321. * Holds the data for the raycast result
  33322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33323. */
  33324. export class PhysicsRaycastResult {
  33325. private _hasHit;
  33326. private _hitDistance;
  33327. private _hitNormalWorld;
  33328. private _hitPointWorld;
  33329. private _rayFromWorld;
  33330. private _rayToWorld;
  33331. /**
  33332. * Gets if there was a hit
  33333. */
  33334. get hasHit(): boolean;
  33335. /**
  33336. * Gets the distance from the hit
  33337. */
  33338. get hitDistance(): number;
  33339. /**
  33340. * Gets the hit normal/direction in the world
  33341. */
  33342. get hitNormalWorld(): Vector3;
  33343. /**
  33344. * Gets the hit point in the world
  33345. */
  33346. get hitPointWorld(): Vector3;
  33347. /**
  33348. * Gets the ray "start point" of the ray in the world
  33349. */
  33350. get rayFromWorld(): Vector3;
  33351. /**
  33352. * Gets the ray "end point" of the ray in the world
  33353. */
  33354. get rayToWorld(): Vector3;
  33355. /**
  33356. * Sets the hit data (normal & point in world space)
  33357. * @param hitNormalWorld defines the normal in world space
  33358. * @param hitPointWorld defines the point in world space
  33359. */
  33360. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33361. /**
  33362. * Sets the distance from the start point to the hit point
  33363. * @param distance
  33364. */
  33365. setHitDistance(distance: number): void;
  33366. /**
  33367. * Calculates the distance manually
  33368. */
  33369. calculateHitDistance(): void;
  33370. /**
  33371. * Resets all the values to default
  33372. * @param from The from point on world space
  33373. * @param to The to point on world space
  33374. */
  33375. reset(from?: Vector3, to?: Vector3): void;
  33376. }
  33377. /**
  33378. * Interface for the size containing width and height
  33379. */
  33380. interface IXYZ {
  33381. /**
  33382. * X
  33383. */
  33384. x: number;
  33385. /**
  33386. * Y
  33387. */
  33388. y: number;
  33389. /**
  33390. * Z
  33391. */
  33392. z: number;
  33393. }
  33394. }
  33395. declare module "babylonjs/Physics/IPhysicsEngine" {
  33396. import { Nullable } from "babylonjs/types";
  33397. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33399. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33400. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33401. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33402. /**
  33403. * Interface used to describe a physics joint
  33404. */
  33405. export interface PhysicsImpostorJoint {
  33406. /** Defines the main impostor to which the joint is linked */
  33407. mainImpostor: PhysicsImpostor;
  33408. /** Defines the impostor that is connected to the main impostor using this joint */
  33409. connectedImpostor: PhysicsImpostor;
  33410. /** Defines the joint itself */
  33411. joint: PhysicsJoint;
  33412. }
  33413. /** @hidden */
  33414. export interface IPhysicsEnginePlugin {
  33415. world: any;
  33416. name: string;
  33417. setGravity(gravity: Vector3): void;
  33418. setTimeStep(timeStep: number): void;
  33419. getTimeStep(): number;
  33420. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33422. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33423. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33424. removePhysicsBody(impostor: PhysicsImpostor): void;
  33425. generateJoint(joint: PhysicsImpostorJoint): void;
  33426. removeJoint(joint: PhysicsImpostorJoint): void;
  33427. isSupported(): boolean;
  33428. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33429. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33430. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33431. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33432. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33433. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33434. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33435. getBodyMass(impostor: PhysicsImpostor): number;
  33436. getBodyFriction(impostor: PhysicsImpostor): number;
  33437. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33438. getBodyRestitution(impostor: PhysicsImpostor): number;
  33439. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33440. getBodyPressure?(impostor: PhysicsImpostor): number;
  33441. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33442. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33443. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33444. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33445. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33446. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33447. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33448. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33449. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33450. sleepBody(impostor: PhysicsImpostor): void;
  33451. wakeUpBody(impostor: PhysicsImpostor): void;
  33452. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33453. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33454. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33455. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33456. getRadius(impostor: PhysicsImpostor): number;
  33457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33458. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33459. dispose(): void;
  33460. }
  33461. /**
  33462. * Interface used to define a physics engine
  33463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33464. */
  33465. export interface IPhysicsEngine {
  33466. /**
  33467. * Gets the gravity vector used by the simulation
  33468. */
  33469. gravity: Vector3;
  33470. /**
  33471. * Sets the gravity vector used by the simulation
  33472. * @param gravity defines the gravity vector to use
  33473. */
  33474. setGravity(gravity: Vector3): void;
  33475. /**
  33476. * Set the time step of the physics engine.
  33477. * Default is 1/60.
  33478. * To slow it down, enter 1/600 for example.
  33479. * To speed it up, 1/30
  33480. * @param newTimeStep the new timestep to apply to this world.
  33481. */
  33482. setTimeStep(newTimeStep: number): void;
  33483. /**
  33484. * Get the time step of the physics engine.
  33485. * @returns the current time step
  33486. */
  33487. getTimeStep(): number;
  33488. /**
  33489. * Set the sub time step of the physics engine.
  33490. * Default is 0 meaning there is no sub steps
  33491. * To increase physics resolution precision, set a small value (like 1 ms)
  33492. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33493. */
  33494. setSubTimeStep(subTimeStep: number): void;
  33495. /**
  33496. * Get the sub time step of the physics engine.
  33497. * @returns the current sub time step
  33498. */
  33499. getSubTimeStep(): number;
  33500. /**
  33501. * Release all resources
  33502. */
  33503. dispose(): void;
  33504. /**
  33505. * Gets the name of the current physics plugin
  33506. * @returns the name of the plugin
  33507. */
  33508. getPhysicsPluginName(): string;
  33509. /**
  33510. * Adding a new impostor for the impostor tracking.
  33511. * This will be done by the impostor itself.
  33512. * @param impostor the impostor to add
  33513. */
  33514. addImpostor(impostor: PhysicsImpostor): void;
  33515. /**
  33516. * Remove an impostor from the engine.
  33517. * This impostor and its mesh will not longer be updated by the physics engine.
  33518. * @param impostor the impostor to remove
  33519. */
  33520. removeImpostor(impostor: PhysicsImpostor): void;
  33521. /**
  33522. * Add a joint to the physics engine
  33523. * @param mainImpostor defines the main impostor to which the joint is added.
  33524. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33525. * @param joint defines the joint that will connect both impostors.
  33526. */
  33527. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33528. /**
  33529. * Removes a joint from the simulation
  33530. * @param mainImpostor defines the impostor used with the joint
  33531. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33532. * @param joint defines the joint to remove
  33533. */
  33534. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33535. /**
  33536. * Gets the current plugin used to run the simulation
  33537. * @returns current plugin
  33538. */
  33539. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33540. /**
  33541. * Gets the list of physic impostors
  33542. * @returns an array of PhysicsImpostor
  33543. */
  33544. getImpostors(): Array<PhysicsImpostor>;
  33545. /**
  33546. * Gets the impostor for a physics enabled object
  33547. * @param object defines the object impersonated by the impostor
  33548. * @returns the PhysicsImpostor or null if not found
  33549. */
  33550. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33551. /**
  33552. * Gets the impostor for a physics body object
  33553. * @param body defines physics body used by the impostor
  33554. * @returns the PhysicsImpostor or null if not found
  33555. */
  33556. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33557. /**
  33558. * Does a raycast in the physics world
  33559. * @param from when should the ray start?
  33560. * @param to when should the ray end?
  33561. * @returns PhysicsRaycastResult
  33562. */
  33563. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33564. /**
  33565. * Called by the scene. No need to call it.
  33566. * @param delta defines the timespam between frames
  33567. */
  33568. _step(delta: number): void;
  33569. }
  33570. }
  33571. declare module "babylonjs/Physics/physicsImpostor" {
  33572. import { Nullable, IndicesArray } from "babylonjs/types";
  33573. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33576. import { Scene } from "babylonjs/scene";
  33577. import { Bone } from "babylonjs/Bones/bone";
  33578. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33579. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33580. import { Space } from "babylonjs/Maths/math.axis";
  33581. /**
  33582. * The interface for the physics imposter parameters
  33583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33584. */
  33585. export interface PhysicsImpostorParameters {
  33586. /**
  33587. * The mass of the physics imposter
  33588. */
  33589. mass: number;
  33590. /**
  33591. * The friction of the physics imposter
  33592. */
  33593. friction?: number;
  33594. /**
  33595. * The coefficient of restitution of the physics imposter
  33596. */
  33597. restitution?: number;
  33598. /**
  33599. * The native options of the physics imposter
  33600. */
  33601. nativeOptions?: any;
  33602. /**
  33603. * Specifies if the parent should be ignored
  33604. */
  33605. ignoreParent?: boolean;
  33606. /**
  33607. * Specifies if bi-directional transformations should be disabled
  33608. */
  33609. disableBidirectionalTransformation?: boolean;
  33610. /**
  33611. * The pressure inside the physics imposter, soft object only
  33612. */
  33613. pressure?: number;
  33614. /**
  33615. * The stiffness the physics imposter, soft object only
  33616. */
  33617. stiffness?: number;
  33618. /**
  33619. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33620. */
  33621. velocityIterations?: number;
  33622. /**
  33623. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33624. */
  33625. positionIterations?: number;
  33626. /**
  33627. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33628. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33629. * Add to fix multiple points
  33630. */
  33631. fixedPoints?: number;
  33632. /**
  33633. * The collision margin around a soft object
  33634. */
  33635. margin?: number;
  33636. /**
  33637. * The collision margin around a soft object
  33638. */
  33639. damping?: number;
  33640. /**
  33641. * The path for a rope based on an extrusion
  33642. */
  33643. path?: any;
  33644. /**
  33645. * The shape of an extrusion used for a rope based on an extrusion
  33646. */
  33647. shape?: any;
  33648. }
  33649. /**
  33650. * Interface for a physics-enabled object
  33651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33652. */
  33653. export interface IPhysicsEnabledObject {
  33654. /**
  33655. * The position of the physics-enabled object
  33656. */
  33657. position: Vector3;
  33658. /**
  33659. * The rotation of the physics-enabled object
  33660. */
  33661. rotationQuaternion: Nullable<Quaternion>;
  33662. /**
  33663. * The scale of the physics-enabled object
  33664. */
  33665. scaling: Vector3;
  33666. /**
  33667. * The rotation of the physics-enabled object
  33668. */
  33669. rotation?: Vector3;
  33670. /**
  33671. * The parent of the physics-enabled object
  33672. */
  33673. parent?: any;
  33674. /**
  33675. * The bounding info of the physics-enabled object
  33676. * @returns The bounding info of the physics-enabled object
  33677. */
  33678. getBoundingInfo(): BoundingInfo;
  33679. /**
  33680. * Computes the world matrix
  33681. * @param force Specifies if the world matrix should be computed by force
  33682. * @returns A world matrix
  33683. */
  33684. computeWorldMatrix(force: boolean): Matrix;
  33685. /**
  33686. * Gets the world matrix
  33687. * @returns A world matrix
  33688. */
  33689. getWorldMatrix?(): Matrix;
  33690. /**
  33691. * Gets the child meshes
  33692. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33693. * @returns An array of abstract meshes
  33694. */
  33695. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33696. /**
  33697. * Gets the vertex data
  33698. * @param kind The type of vertex data
  33699. * @returns A nullable array of numbers, or a float32 array
  33700. */
  33701. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33702. /**
  33703. * Gets the indices from the mesh
  33704. * @returns A nullable array of index arrays
  33705. */
  33706. getIndices?(): Nullable<IndicesArray>;
  33707. /**
  33708. * Gets the scene from the mesh
  33709. * @returns the indices array or null
  33710. */
  33711. getScene?(): Scene;
  33712. /**
  33713. * Gets the absolute position from the mesh
  33714. * @returns the absolute position
  33715. */
  33716. getAbsolutePosition(): Vector3;
  33717. /**
  33718. * Gets the absolute pivot point from the mesh
  33719. * @returns the absolute pivot point
  33720. */
  33721. getAbsolutePivotPoint(): Vector3;
  33722. /**
  33723. * Rotates the mesh
  33724. * @param axis The axis of rotation
  33725. * @param amount The amount of rotation
  33726. * @param space The space of the rotation
  33727. * @returns The rotation transform node
  33728. */
  33729. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33730. /**
  33731. * Translates the mesh
  33732. * @param axis The axis of translation
  33733. * @param distance The distance of translation
  33734. * @param space The space of the translation
  33735. * @returns The transform node
  33736. */
  33737. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33738. /**
  33739. * Sets the absolute position of the mesh
  33740. * @param absolutePosition The absolute position of the mesh
  33741. * @returns The transform node
  33742. */
  33743. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33744. /**
  33745. * Gets the class name of the mesh
  33746. * @returns The class name
  33747. */
  33748. getClassName(): string;
  33749. }
  33750. /**
  33751. * Represents a physics imposter
  33752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33753. */
  33754. export class PhysicsImpostor {
  33755. /**
  33756. * The physics-enabled object used as the physics imposter
  33757. */
  33758. object: IPhysicsEnabledObject;
  33759. /**
  33760. * The type of the physics imposter
  33761. */
  33762. type: number;
  33763. private _options;
  33764. private _scene?;
  33765. /**
  33766. * The default object size of the imposter
  33767. */
  33768. static DEFAULT_OBJECT_SIZE: Vector3;
  33769. /**
  33770. * The identity quaternion of the imposter
  33771. */
  33772. static IDENTITY_QUATERNION: Quaternion;
  33773. /** @hidden */
  33774. _pluginData: any;
  33775. private _physicsEngine;
  33776. private _physicsBody;
  33777. private _bodyUpdateRequired;
  33778. private _onBeforePhysicsStepCallbacks;
  33779. private _onAfterPhysicsStepCallbacks;
  33780. /** @hidden */
  33781. _onPhysicsCollideCallbacks: Array<{
  33782. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33783. otherImpostors: Array<PhysicsImpostor>;
  33784. }>;
  33785. private _deltaPosition;
  33786. private _deltaRotation;
  33787. private _deltaRotationConjugated;
  33788. /** @hidden */
  33789. _isFromLine: boolean;
  33790. private _parent;
  33791. private _isDisposed;
  33792. private static _tmpVecs;
  33793. private static _tmpQuat;
  33794. /**
  33795. * Specifies if the physics imposter is disposed
  33796. */
  33797. get isDisposed(): boolean;
  33798. /**
  33799. * Gets the mass of the physics imposter
  33800. */
  33801. get mass(): number;
  33802. set mass(value: number);
  33803. /**
  33804. * Gets the coefficient of friction
  33805. */
  33806. get friction(): number;
  33807. /**
  33808. * Sets the coefficient of friction
  33809. */
  33810. set friction(value: number);
  33811. /**
  33812. * Gets the coefficient of restitution
  33813. */
  33814. get restitution(): number;
  33815. /**
  33816. * Sets the coefficient of restitution
  33817. */
  33818. set restitution(value: number);
  33819. /**
  33820. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33821. */
  33822. get pressure(): number;
  33823. /**
  33824. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33825. */
  33826. set pressure(value: number);
  33827. /**
  33828. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33829. */
  33830. get stiffness(): number;
  33831. /**
  33832. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33833. */
  33834. set stiffness(value: number);
  33835. /**
  33836. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33837. */
  33838. get velocityIterations(): number;
  33839. /**
  33840. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33841. */
  33842. set velocityIterations(value: number);
  33843. /**
  33844. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33845. */
  33846. get positionIterations(): number;
  33847. /**
  33848. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33849. */
  33850. set positionIterations(value: number);
  33851. /**
  33852. * The unique id of the physics imposter
  33853. * set by the physics engine when adding this impostor to the array
  33854. */
  33855. uniqueId: number;
  33856. /**
  33857. * @hidden
  33858. */
  33859. soft: boolean;
  33860. /**
  33861. * @hidden
  33862. */
  33863. segments: number;
  33864. private _joints;
  33865. /**
  33866. * Initializes the physics imposter
  33867. * @param object The physics-enabled object used as the physics imposter
  33868. * @param type The type of the physics imposter
  33869. * @param _options The options for the physics imposter
  33870. * @param _scene The Babylon scene
  33871. */
  33872. constructor(
  33873. /**
  33874. * The physics-enabled object used as the physics imposter
  33875. */
  33876. object: IPhysicsEnabledObject,
  33877. /**
  33878. * The type of the physics imposter
  33879. */
  33880. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33881. /**
  33882. * This function will completly initialize this impostor.
  33883. * It will create a new body - but only if this mesh has no parent.
  33884. * If it has, this impostor will not be used other than to define the impostor
  33885. * of the child mesh.
  33886. * @hidden
  33887. */
  33888. _init(): void;
  33889. private _getPhysicsParent;
  33890. /**
  33891. * Should a new body be generated.
  33892. * @returns boolean specifying if body initialization is required
  33893. */
  33894. isBodyInitRequired(): boolean;
  33895. /**
  33896. * Sets the updated scaling
  33897. * @param updated Specifies if the scaling is updated
  33898. */
  33899. setScalingUpdated(): void;
  33900. /**
  33901. * Force a regeneration of this or the parent's impostor's body.
  33902. * Use under cautious - This will remove all joints already implemented.
  33903. */
  33904. forceUpdate(): void;
  33905. /**
  33906. * Gets the body that holds this impostor. Either its own, or its parent.
  33907. */
  33908. get physicsBody(): any;
  33909. /**
  33910. * Get the parent of the physics imposter
  33911. * @returns Physics imposter or null
  33912. */
  33913. get parent(): Nullable<PhysicsImpostor>;
  33914. /**
  33915. * Sets the parent of the physics imposter
  33916. */
  33917. set parent(value: Nullable<PhysicsImpostor>);
  33918. /**
  33919. * Set the physics body. Used mainly by the physics engine/plugin
  33920. */
  33921. set physicsBody(physicsBody: any);
  33922. /**
  33923. * Resets the update flags
  33924. */
  33925. resetUpdateFlags(): void;
  33926. /**
  33927. * Gets the object extend size
  33928. * @returns the object extend size
  33929. */
  33930. getObjectExtendSize(): Vector3;
  33931. /**
  33932. * Gets the object center
  33933. * @returns The object center
  33934. */
  33935. getObjectCenter(): Vector3;
  33936. /**
  33937. * Get a specific parameter from the options parameters
  33938. * @param paramName The object parameter name
  33939. * @returns The object parameter
  33940. */
  33941. getParam(paramName: string): any;
  33942. /**
  33943. * Sets a specific parameter in the options given to the physics plugin
  33944. * @param paramName The parameter name
  33945. * @param value The value of the parameter
  33946. */
  33947. setParam(paramName: string, value: number): void;
  33948. /**
  33949. * Specifically change the body's mass option. Won't recreate the physics body object
  33950. * @param mass The mass of the physics imposter
  33951. */
  33952. setMass(mass: number): void;
  33953. /**
  33954. * Gets the linear velocity
  33955. * @returns linear velocity or null
  33956. */
  33957. getLinearVelocity(): Nullable<Vector3>;
  33958. /**
  33959. * Sets the linear velocity
  33960. * @param velocity linear velocity or null
  33961. */
  33962. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33963. /**
  33964. * Gets the angular velocity
  33965. * @returns angular velocity or null
  33966. */
  33967. getAngularVelocity(): Nullable<Vector3>;
  33968. /**
  33969. * Sets the angular velocity
  33970. * @param velocity The velocity or null
  33971. */
  33972. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33973. /**
  33974. * Execute a function with the physics plugin native code
  33975. * Provide a function the will have two variables - the world object and the physics body object
  33976. * @param func The function to execute with the physics plugin native code
  33977. */
  33978. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33979. /**
  33980. * Register a function that will be executed before the physics world is stepping forward
  33981. * @param func The function to execute before the physics world is stepped forward
  33982. */
  33983. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33984. /**
  33985. * Unregister a function that will be executed before the physics world is stepping forward
  33986. * @param func The function to execute before the physics world is stepped forward
  33987. */
  33988. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33989. /**
  33990. * Register a function that will be executed after the physics step
  33991. * @param func The function to execute after physics step
  33992. */
  33993. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33994. /**
  33995. * Unregisters a function that will be executed after the physics step
  33996. * @param func The function to execute after physics step
  33997. */
  33998. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33999. /**
  34000. * register a function that will be executed when this impostor collides against a different body
  34001. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34002. * @param func Callback that is executed on collision
  34003. */
  34004. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34005. /**
  34006. * Unregisters the physics imposter on contact
  34007. * @param collideAgainst The physics object to collide against
  34008. * @param func Callback to execute on collision
  34009. */
  34010. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34011. private _tmpQuat;
  34012. private _tmpQuat2;
  34013. /**
  34014. * Get the parent rotation
  34015. * @returns The parent rotation
  34016. */
  34017. getParentsRotation(): Quaternion;
  34018. /**
  34019. * this function is executed by the physics engine.
  34020. */
  34021. beforeStep: () => void;
  34022. /**
  34023. * this function is executed by the physics engine
  34024. */
  34025. afterStep: () => void;
  34026. /**
  34027. * Legacy collision detection event support
  34028. */
  34029. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34030. /**
  34031. * event and body object due to cannon's event-based architecture.
  34032. */
  34033. onCollide: (e: {
  34034. body: any;
  34035. point: Nullable<Vector3>;
  34036. }) => void;
  34037. /**
  34038. * Apply a force
  34039. * @param force The force to apply
  34040. * @param contactPoint The contact point for the force
  34041. * @returns The physics imposter
  34042. */
  34043. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34044. /**
  34045. * Apply an impulse
  34046. * @param force The impulse force
  34047. * @param contactPoint The contact point for the impulse force
  34048. * @returns The physics imposter
  34049. */
  34050. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34051. /**
  34052. * A help function to create a joint
  34053. * @param otherImpostor A physics imposter used to create a joint
  34054. * @param jointType The type of joint
  34055. * @param jointData The data for the joint
  34056. * @returns The physics imposter
  34057. */
  34058. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34059. /**
  34060. * Add a joint to this impostor with a different impostor
  34061. * @param otherImpostor A physics imposter used to add a joint
  34062. * @param joint The joint to add
  34063. * @returns The physics imposter
  34064. */
  34065. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34066. /**
  34067. * Add an anchor to a cloth impostor
  34068. * @param otherImpostor rigid impostor to anchor to
  34069. * @param width ratio across width from 0 to 1
  34070. * @param height ratio up height from 0 to 1
  34071. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  34072. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  34073. * @returns impostor the soft imposter
  34074. */
  34075. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34076. /**
  34077. * Add a hook to a rope impostor
  34078. * @param otherImpostor rigid impostor to anchor to
  34079. * @param length ratio across rope from 0 to 1
  34080. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  34081. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  34082. * @returns impostor the rope imposter
  34083. */
  34084. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34085. /**
  34086. * Will keep this body still, in a sleep mode.
  34087. * @returns the physics imposter
  34088. */
  34089. sleep(): PhysicsImpostor;
  34090. /**
  34091. * Wake the body up.
  34092. * @returns The physics imposter
  34093. */
  34094. wakeUp(): PhysicsImpostor;
  34095. /**
  34096. * Clones the physics imposter
  34097. * @param newObject The physics imposter clones to this physics-enabled object
  34098. * @returns A nullable physics imposter
  34099. */
  34100. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34101. /**
  34102. * Disposes the physics imposter
  34103. */
  34104. dispose(): void;
  34105. /**
  34106. * Sets the delta position
  34107. * @param position The delta position amount
  34108. */
  34109. setDeltaPosition(position: Vector3): void;
  34110. /**
  34111. * Sets the delta rotation
  34112. * @param rotation The delta rotation amount
  34113. */
  34114. setDeltaRotation(rotation: Quaternion): void;
  34115. /**
  34116. * Gets the box size of the physics imposter and stores the result in the input parameter
  34117. * @param result Stores the box size
  34118. * @returns The physics imposter
  34119. */
  34120. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34121. /**
  34122. * Gets the radius of the physics imposter
  34123. * @returns Radius of the physics imposter
  34124. */
  34125. getRadius(): number;
  34126. /**
  34127. * Sync a bone with this impostor
  34128. * @param bone The bone to sync to the impostor.
  34129. * @param boneMesh The mesh that the bone is influencing.
  34130. * @param jointPivot The pivot of the joint / bone in local space.
  34131. * @param distToJoint Optional distance from the impostor to the joint.
  34132. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34133. */
  34134. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34135. /**
  34136. * Sync impostor to a bone
  34137. * @param bone The bone that the impostor will be synced to.
  34138. * @param boneMesh The mesh that the bone is influencing.
  34139. * @param jointPivot The pivot of the joint / bone in local space.
  34140. * @param distToJoint Optional distance from the impostor to the joint.
  34141. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34142. * @param boneAxis Optional vector3 axis the bone is aligned with
  34143. */
  34144. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34145. /**
  34146. * No-Imposter type
  34147. */
  34148. static NoImpostor: number;
  34149. /**
  34150. * Sphere-Imposter type
  34151. */
  34152. static SphereImpostor: number;
  34153. /**
  34154. * Box-Imposter type
  34155. */
  34156. static BoxImpostor: number;
  34157. /**
  34158. * Plane-Imposter type
  34159. */
  34160. static PlaneImpostor: number;
  34161. /**
  34162. * Mesh-imposter type
  34163. */
  34164. static MeshImpostor: number;
  34165. /**
  34166. * Capsule-Impostor type (Ammo.js plugin only)
  34167. */
  34168. static CapsuleImpostor: number;
  34169. /**
  34170. * Cylinder-Imposter type
  34171. */
  34172. static CylinderImpostor: number;
  34173. /**
  34174. * Particle-Imposter type
  34175. */
  34176. static ParticleImpostor: number;
  34177. /**
  34178. * Heightmap-Imposter type
  34179. */
  34180. static HeightmapImpostor: number;
  34181. /**
  34182. * ConvexHull-Impostor type (Ammo.js plugin only)
  34183. */
  34184. static ConvexHullImpostor: number;
  34185. /**
  34186. * Custom-Imposter type (Ammo.js plugin only)
  34187. */
  34188. static CustomImpostor: number;
  34189. /**
  34190. * Rope-Imposter type
  34191. */
  34192. static RopeImpostor: number;
  34193. /**
  34194. * Cloth-Imposter type
  34195. */
  34196. static ClothImpostor: number;
  34197. /**
  34198. * Softbody-Imposter type
  34199. */
  34200. static SoftbodyImpostor: number;
  34201. }
  34202. }
  34203. declare module "babylonjs/Meshes/mesh" {
  34204. import { Observable } from "babylonjs/Misc/observable";
  34205. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34206. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34207. import { Camera } from "babylonjs/Cameras/camera";
  34208. import { Scene } from "babylonjs/scene";
  34209. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34210. import { Color4 } from "babylonjs/Maths/math.color";
  34211. import { Engine } from "babylonjs/Engines/engine";
  34212. import { Node } from "babylonjs/node";
  34213. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  34214. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  34215. import { Buffer } from "babylonjs/Meshes/buffer";
  34216. import { Geometry } from "babylonjs/Meshes/geometry";
  34217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34218. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34219. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  34220. import { Effect } from "babylonjs/Materials/effect";
  34221. import { Material } from "babylonjs/Materials/material";
  34222. import { Skeleton } from "babylonjs/Bones/skeleton";
  34223. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34224. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  34225. import { Path3D } from "babylonjs/Maths/math.path";
  34226. import { Plane } from "babylonjs/Maths/math.plane";
  34227. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34228. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34229. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  34230. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  34231. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  34232. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  34233. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  34234. /**
  34235. * @hidden
  34236. **/
  34237. export class _CreationDataStorage {
  34238. closePath?: boolean;
  34239. closeArray?: boolean;
  34240. idx: number[];
  34241. dashSize: number;
  34242. gapSize: number;
  34243. path3D: Path3D;
  34244. pathArray: Vector3[][];
  34245. arc: number;
  34246. radius: number;
  34247. cap: number;
  34248. tessellation: number;
  34249. }
  34250. /**
  34251. * @hidden
  34252. **/
  34253. class _InstanceDataStorage {
  34254. visibleInstances: any;
  34255. batchCache: _InstancesBatch;
  34256. instancesBufferSize: number;
  34257. instancesBuffer: Nullable<Buffer>;
  34258. instancesData: Float32Array;
  34259. overridenInstanceCount: number;
  34260. isFrozen: boolean;
  34261. previousBatch: Nullable<_InstancesBatch>;
  34262. hardwareInstancedRendering: boolean;
  34263. sideOrientation: number;
  34264. manualUpdate: boolean;
  34265. previousRenderId: number;
  34266. }
  34267. /**
  34268. * @hidden
  34269. **/
  34270. export class _InstancesBatch {
  34271. mustReturn: boolean;
  34272. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34273. renderSelf: boolean[];
  34274. hardwareInstancedRendering: boolean[];
  34275. }
  34276. /**
  34277. * @hidden
  34278. **/
  34279. class _ThinInstanceDataStorage {
  34280. instancesCount: number;
  34281. matrixBuffer: Nullable<Buffer>;
  34282. matrixBufferSize: number;
  34283. matrixData: Nullable<Float32Array>;
  34284. boundingVectors: Array<Vector3>;
  34285. worldMatrices: Nullable<Matrix[]>;
  34286. }
  34287. /**
  34288. * Class used to represent renderable models
  34289. */
  34290. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34291. /**
  34292. * Mesh side orientation : usually the external or front surface
  34293. */
  34294. static readonly FRONTSIDE: number;
  34295. /**
  34296. * Mesh side orientation : usually the internal or back surface
  34297. */
  34298. static readonly BACKSIDE: number;
  34299. /**
  34300. * Mesh side orientation : both internal and external or front and back surfaces
  34301. */
  34302. static readonly DOUBLESIDE: number;
  34303. /**
  34304. * Mesh side orientation : by default, `FRONTSIDE`
  34305. */
  34306. static readonly DEFAULTSIDE: number;
  34307. /**
  34308. * Mesh cap setting : no cap
  34309. */
  34310. static readonly NO_CAP: number;
  34311. /**
  34312. * Mesh cap setting : one cap at the beginning of the mesh
  34313. */
  34314. static readonly CAP_START: number;
  34315. /**
  34316. * Mesh cap setting : one cap at the end of the mesh
  34317. */
  34318. static readonly CAP_END: number;
  34319. /**
  34320. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34321. */
  34322. static readonly CAP_ALL: number;
  34323. /**
  34324. * Mesh pattern setting : no flip or rotate
  34325. */
  34326. static readonly NO_FLIP: number;
  34327. /**
  34328. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34329. */
  34330. static readonly FLIP_TILE: number;
  34331. /**
  34332. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34333. */
  34334. static readonly ROTATE_TILE: number;
  34335. /**
  34336. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34337. */
  34338. static readonly FLIP_ROW: number;
  34339. /**
  34340. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34341. */
  34342. static readonly ROTATE_ROW: number;
  34343. /**
  34344. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34345. */
  34346. static readonly FLIP_N_ROTATE_TILE: number;
  34347. /**
  34348. * Mesh pattern setting : rotate pattern and rotate
  34349. */
  34350. static readonly FLIP_N_ROTATE_ROW: number;
  34351. /**
  34352. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34353. */
  34354. static readonly CENTER: number;
  34355. /**
  34356. * Mesh tile positioning : part tiles on left
  34357. */
  34358. static readonly LEFT: number;
  34359. /**
  34360. * Mesh tile positioning : part tiles on right
  34361. */
  34362. static readonly RIGHT: number;
  34363. /**
  34364. * Mesh tile positioning : part tiles on top
  34365. */
  34366. static readonly TOP: number;
  34367. /**
  34368. * Mesh tile positioning : part tiles on bottom
  34369. */
  34370. static readonly BOTTOM: number;
  34371. /**
  34372. * Gets the default side orientation.
  34373. * @param orientation the orientation to value to attempt to get
  34374. * @returns the default orientation
  34375. * @hidden
  34376. */
  34377. static _GetDefaultSideOrientation(orientation?: number): number;
  34378. private _internalMeshDataInfo;
  34379. get computeBonesUsingShaders(): boolean;
  34380. set computeBonesUsingShaders(value: boolean);
  34381. /**
  34382. * An event triggered before rendering the mesh
  34383. */
  34384. get onBeforeRenderObservable(): Observable<Mesh>;
  34385. /**
  34386. * An event triggered before binding the mesh
  34387. */
  34388. get onBeforeBindObservable(): Observable<Mesh>;
  34389. /**
  34390. * An event triggered after rendering the mesh
  34391. */
  34392. get onAfterRenderObservable(): Observable<Mesh>;
  34393. /**
  34394. * An event triggered before drawing the mesh
  34395. */
  34396. get onBeforeDrawObservable(): Observable<Mesh>;
  34397. private _onBeforeDrawObserver;
  34398. /**
  34399. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34400. */
  34401. set onBeforeDraw(callback: () => void);
  34402. get hasInstances(): boolean;
  34403. get hasThinInstances(): boolean;
  34404. /**
  34405. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34406. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34407. */
  34408. delayLoadState: number;
  34409. /**
  34410. * Gets the list of instances created from this mesh
  34411. * it is not supposed to be modified manually.
  34412. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34413. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34414. */
  34415. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34416. /**
  34417. * Gets the file containing delay loading data for this mesh
  34418. */
  34419. delayLoadingFile: string;
  34420. /** @hidden */
  34421. _binaryInfo: any;
  34422. /**
  34423. * User defined function used to change how LOD level selection is done
  34424. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34425. */
  34426. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34427. /**
  34428. * Gets or sets the morph target manager
  34429. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34430. */
  34431. get morphTargetManager(): Nullable<MorphTargetManager>;
  34432. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34433. /** @hidden */
  34434. _creationDataStorage: Nullable<_CreationDataStorage>;
  34435. /** @hidden */
  34436. _geometry: Nullable<Geometry>;
  34437. /** @hidden */
  34438. _delayInfo: Array<string>;
  34439. /** @hidden */
  34440. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34441. /** @hidden */
  34442. _instanceDataStorage: _InstanceDataStorage;
  34443. /** @hidden */
  34444. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34445. private _effectiveMaterial;
  34446. /** @hidden */
  34447. _shouldGenerateFlatShading: boolean;
  34448. /** @hidden */
  34449. _originalBuilderSideOrientation: number;
  34450. /**
  34451. * Use this property to change the original side orientation defined at construction time
  34452. */
  34453. overrideMaterialSideOrientation: Nullable<number>;
  34454. /**
  34455. * Gets the source mesh (the one used to clone this one from)
  34456. */
  34457. get source(): Nullable<Mesh>;
  34458. /**
  34459. * Gets the list of clones of this mesh
  34460. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34461. * Note that useClonedMeshMap=true is the default setting
  34462. */
  34463. get cloneMeshMap(): Nullable<{
  34464. [id: string]: Mesh | undefined;
  34465. }>;
  34466. /**
  34467. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34468. */
  34469. get isUnIndexed(): boolean;
  34470. set isUnIndexed(value: boolean);
  34471. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34472. get worldMatrixInstancedBuffer(): Float32Array;
  34473. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34474. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34475. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34476. /**
  34477. * @constructor
  34478. * @param name The value used by scene.getMeshByName() to do a lookup.
  34479. * @param scene The scene to add this mesh to.
  34480. * @param parent The parent of this mesh, if it has one
  34481. * @param source An optional Mesh from which geometry is shared, cloned.
  34482. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34483. * When false, achieved by calling a clone(), also passing False.
  34484. * This will make creation of children, recursive.
  34485. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34486. */
  34487. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34488. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34489. doNotInstantiate: boolean;
  34490. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34491. /**
  34492. * Gets the class name
  34493. * @returns the string "Mesh".
  34494. */
  34495. getClassName(): string;
  34496. /** @hidden */
  34497. get _isMesh(): boolean;
  34498. /**
  34499. * Returns a description of this mesh
  34500. * @param fullDetails define if full details about this mesh must be used
  34501. * @returns a descriptive string representing this mesh
  34502. */
  34503. toString(fullDetails?: boolean): string;
  34504. /** @hidden */
  34505. _unBindEffect(): void;
  34506. /**
  34507. * Gets a boolean indicating if this mesh has LOD
  34508. */
  34509. get hasLODLevels(): boolean;
  34510. /**
  34511. * Gets the list of MeshLODLevel associated with the current mesh
  34512. * @returns an array of MeshLODLevel
  34513. */
  34514. getLODLevels(): MeshLODLevel[];
  34515. private _sortLODLevels;
  34516. /**
  34517. * Add a mesh as LOD level triggered at the given distance.
  34518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34519. * @param distance The distance from the center of the object to show this level
  34520. * @param mesh The mesh to be added as LOD level (can be null)
  34521. * @return This mesh (for chaining)
  34522. */
  34523. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34524. /**
  34525. * Returns the LOD level mesh at the passed distance or null if not found.
  34526. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34527. * @param distance The distance from the center of the object to show this level
  34528. * @returns a Mesh or `null`
  34529. */
  34530. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34531. /**
  34532. * Remove a mesh from the LOD array
  34533. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34534. * @param mesh defines the mesh to be removed
  34535. * @return This mesh (for chaining)
  34536. */
  34537. removeLODLevel(mesh: Mesh): Mesh;
  34538. /**
  34539. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34541. * @param camera defines the camera to use to compute distance
  34542. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34543. * @return This mesh (for chaining)
  34544. */
  34545. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34546. /**
  34547. * Gets the mesh internal Geometry object
  34548. */
  34549. get geometry(): Nullable<Geometry>;
  34550. /**
  34551. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34552. * @returns the total number of vertices
  34553. */
  34554. getTotalVertices(): number;
  34555. /**
  34556. * Returns the content of an associated vertex buffer
  34557. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34558. * - VertexBuffer.PositionKind
  34559. * - VertexBuffer.UVKind
  34560. * - VertexBuffer.UV2Kind
  34561. * - VertexBuffer.UV3Kind
  34562. * - VertexBuffer.UV4Kind
  34563. * - VertexBuffer.UV5Kind
  34564. * - VertexBuffer.UV6Kind
  34565. * - VertexBuffer.ColorKind
  34566. * - VertexBuffer.MatricesIndicesKind
  34567. * - VertexBuffer.MatricesIndicesExtraKind
  34568. * - VertexBuffer.MatricesWeightsKind
  34569. * - VertexBuffer.MatricesWeightsExtraKind
  34570. * @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
  34571. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34572. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34573. */
  34574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34575. /**
  34576. * Returns the mesh VertexBuffer object from the requested `kind`
  34577. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34578. * - VertexBuffer.PositionKind
  34579. * - VertexBuffer.NormalKind
  34580. * - VertexBuffer.UVKind
  34581. * - VertexBuffer.UV2Kind
  34582. * - VertexBuffer.UV3Kind
  34583. * - VertexBuffer.UV4Kind
  34584. * - VertexBuffer.UV5Kind
  34585. * - VertexBuffer.UV6Kind
  34586. * - VertexBuffer.ColorKind
  34587. * - VertexBuffer.MatricesIndicesKind
  34588. * - VertexBuffer.MatricesIndicesExtraKind
  34589. * - VertexBuffer.MatricesWeightsKind
  34590. * - VertexBuffer.MatricesWeightsExtraKind
  34591. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34592. */
  34593. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34594. /**
  34595. * Tests if a specific vertex buffer is associated with this mesh
  34596. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34597. * - VertexBuffer.PositionKind
  34598. * - VertexBuffer.NormalKind
  34599. * - VertexBuffer.UVKind
  34600. * - VertexBuffer.UV2Kind
  34601. * - VertexBuffer.UV3Kind
  34602. * - VertexBuffer.UV4Kind
  34603. * - VertexBuffer.UV5Kind
  34604. * - VertexBuffer.UV6Kind
  34605. * - VertexBuffer.ColorKind
  34606. * - VertexBuffer.MatricesIndicesKind
  34607. * - VertexBuffer.MatricesIndicesExtraKind
  34608. * - VertexBuffer.MatricesWeightsKind
  34609. * - VertexBuffer.MatricesWeightsExtraKind
  34610. * @returns a boolean
  34611. */
  34612. isVerticesDataPresent(kind: string): boolean;
  34613. /**
  34614. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34615. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34616. * - VertexBuffer.PositionKind
  34617. * - VertexBuffer.UVKind
  34618. * - VertexBuffer.UV2Kind
  34619. * - VertexBuffer.UV3Kind
  34620. * - VertexBuffer.UV4Kind
  34621. * - VertexBuffer.UV5Kind
  34622. * - VertexBuffer.UV6Kind
  34623. * - VertexBuffer.ColorKind
  34624. * - VertexBuffer.MatricesIndicesKind
  34625. * - VertexBuffer.MatricesIndicesExtraKind
  34626. * - VertexBuffer.MatricesWeightsKind
  34627. * - VertexBuffer.MatricesWeightsExtraKind
  34628. * @returns a boolean
  34629. */
  34630. isVertexBufferUpdatable(kind: string): boolean;
  34631. /**
  34632. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34633. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34634. * - VertexBuffer.PositionKind
  34635. * - VertexBuffer.NormalKind
  34636. * - VertexBuffer.UVKind
  34637. * - VertexBuffer.UV2Kind
  34638. * - VertexBuffer.UV3Kind
  34639. * - VertexBuffer.UV4Kind
  34640. * - VertexBuffer.UV5Kind
  34641. * - VertexBuffer.UV6Kind
  34642. * - VertexBuffer.ColorKind
  34643. * - VertexBuffer.MatricesIndicesKind
  34644. * - VertexBuffer.MatricesIndicesExtraKind
  34645. * - VertexBuffer.MatricesWeightsKind
  34646. * - VertexBuffer.MatricesWeightsExtraKind
  34647. * @returns an array of strings
  34648. */
  34649. getVerticesDataKinds(): string[];
  34650. /**
  34651. * Returns a positive integer : the total number of indices in this mesh geometry.
  34652. * @returns the numner of indices or zero if the mesh has no geometry.
  34653. */
  34654. getTotalIndices(): number;
  34655. /**
  34656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34657. * @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.
  34658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34659. * @returns the indices array or an empty array if the mesh has no geometry
  34660. */
  34661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34662. get isBlocked(): boolean;
  34663. /**
  34664. * Determine if the current mesh is ready to be rendered
  34665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34667. * @returns true if all associated assets are ready (material, textures, shaders)
  34668. */
  34669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34670. /**
  34671. * 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.
  34672. */
  34673. get areNormalsFrozen(): boolean;
  34674. /**
  34675. * 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.
  34676. * @returns the current mesh
  34677. */
  34678. freezeNormals(): Mesh;
  34679. /**
  34680. * 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
  34681. * @returns the current mesh
  34682. */
  34683. unfreezeNormals(): Mesh;
  34684. /**
  34685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34686. */
  34687. set overridenInstanceCount(count: number);
  34688. /** @hidden */
  34689. _preActivate(): Mesh;
  34690. /** @hidden */
  34691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34692. /** @hidden */
  34693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34694. protected _afterComputeWorldMatrix(): void;
  34695. /** @hidden */
  34696. _postActivate(): void;
  34697. /**
  34698. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34699. * This means the mesh underlying bounding box and sphere are recomputed.
  34700. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34701. * @returns the current mesh
  34702. */
  34703. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34704. /** @hidden */
  34705. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34706. /**
  34707. * This function will subdivide the mesh into multiple submeshes
  34708. * @param count defines the expected number of submeshes
  34709. */
  34710. subdivide(count: number): void;
  34711. /**
  34712. * Copy a FloatArray into a specific associated vertex buffer
  34713. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34714. * - VertexBuffer.PositionKind
  34715. * - VertexBuffer.UVKind
  34716. * - VertexBuffer.UV2Kind
  34717. * - VertexBuffer.UV3Kind
  34718. * - VertexBuffer.UV4Kind
  34719. * - VertexBuffer.UV5Kind
  34720. * - VertexBuffer.UV6Kind
  34721. * - VertexBuffer.ColorKind
  34722. * - VertexBuffer.MatricesIndicesKind
  34723. * - VertexBuffer.MatricesIndicesExtraKind
  34724. * - VertexBuffer.MatricesWeightsKind
  34725. * - VertexBuffer.MatricesWeightsExtraKind
  34726. * @param data defines the data source
  34727. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34728. * @param stride defines the data stride size (can be null)
  34729. * @returns the current mesh
  34730. */
  34731. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34732. /**
  34733. * Delete a vertex buffer associated with this mesh
  34734. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34735. * - VertexBuffer.PositionKind
  34736. * - VertexBuffer.UVKind
  34737. * - VertexBuffer.UV2Kind
  34738. * - VertexBuffer.UV3Kind
  34739. * - VertexBuffer.UV4Kind
  34740. * - VertexBuffer.UV5Kind
  34741. * - VertexBuffer.UV6Kind
  34742. * - VertexBuffer.ColorKind
  34743. * - VertexBuffer.MatricesIndicesKind
  34744. * - VertexBuffer.MatricesIndicesExtraKind
  34745. * - VertexBuffer.MatricesWeightsKind
  34746. * - VertexBuffer.MatricesWeightsExtraKind
  34747. */
  34748. removeVerticesData(kind: string): void;
  34749. /**
  34750. * Flags an associated vertex buffer as updatable
  34751. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34752. * - VertexBuffer.PositionKind
  34753. * - VertexBuffer.UVKind
  34754. * - VertexBuffer.UV2Kind
  34755. * - VertexBuffer.UV3Kind
  34756. * - VertexBuffer.UV4Kind
  34757. * - VertexBuffer.UV5Kind
  34758. * - VertexBuffer.UV6Kind
  34759. * - VertexBuffer.ColorKind
  34760. * - VertexBuffer.MatricesIndicesKind
  34761. * - VertexBuffer.MatricesIndicesExtraKind
  34762. * - VertexBuffer.MatricesWeightsKind
  34763. * - VertexBuffer.MatricesWeightsExtraKind
  34764. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34765. */
  34766. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34767. /**
  34768. * Sets the mesh global Vertex Buffer
  34769. * @param buffer defines the buffer to use
  34770. * @returns the current mesh
  34771. */
  34772. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34773. /**
  34774. * Update a specific associated vertex buffer
  34775. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34776. * - VertexBuffer.PositionKind
  34777. * - VertexBuffer.UVKind
  34778. * - VertexBuffer.UV2Kind
  34779. * - VertexBuffer.UV3Kind
  34780. * - VertexBuffer.UV4Kind
  34781. * - VertexBuffer.UV5Kind
  34782. * - VertexBuffer.UV6Kind
  34783. * - VertexBuffer.ColorKind
  34784. * - VertexBuffer.MatricesIndicesKind
  34785. * - VertexBuffer.MatricesIndicesExtraKind
  34786. * - VertexBuffer.MatricesWeightsKind
  34787. * - VertexBuffer.MatricesWeightsExtraKind
  34788. * @param data defines the data source
  34789. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34790. * @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)
  34791. * @returns the current mesh
  34792. */
  34793. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34794. /**
  34795. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34796. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34797. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34798. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34799. * @returns the current mesh
  34800. */
  34801. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34802. /**
  34803. * Creates a un-shared specific occurence of the geometry for the mesh.
  34804. * @returns the current mesh
  34805. */
  34806. makeGeometryUnique(): Mesh;
  34807. /**
  34808. * Set the index buffer of this mesh
  34809. * @param indices defines the source data
  34810. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34811. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34812. * @returns the current mesh
  34813. */
  34814. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34815. /**
  34816. * Update the current index buffer
  34817. * @param indices defines the source data
  34818. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34819. * @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)
  34820. * @returns the current mesh
  34821. */
  34822. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34823. /**
  34824. * Invert the geometry to move from a right handed system to a left handed one.
  34825. * @returns the current mesh
  34826. */
  34827. toLeftHanded(): Mesh;
  34828. /** @hidden */
  34829. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34830. /** @hidden */
  34831. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34832. /**
  34833. * Registers for this mesh a javascript function called just before the rendering process
  34834. * @param func defines the function to call before rendering this mesh
  34835. * @returns the current mesh
  34836. */
  34837. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34838. /**
  34839. * Disposes a previously registered javascript function called before the rendering
  34840. * @param func defines the function to remove
  34841. * @returns the current mesh
  34842. */
  34843. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34844. /**
  34845. * Registers for this mesh a javascript function called just after the rendering is complete
  34846. * @param func defines the function to call after rendering this mesh
  34847. * @returns the current mesh
  34848. */
  34849. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34850. /**
  34851. * Disposes a previously registered javascript function called after the rendering.
  34852. * @param func defines the function to remove
  34853. * @returns the current mesh
  34854. */
  34855. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34856. /** @hidden */
  34857. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34858. /** @hidden */
  34859. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34860. /** @hidden */
  34861. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34862. /** @hidden */
  34863. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34864. /** @hidden */
  34865. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34866. /** @hidden */
  34867. _rebuild(): void;
  34868. /** @hidden */
  34869. _freeze(): void;
  34870. /** @hidden */
  34871. _unFreeze(): void;
  34872. /**
  34873. * 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
  34874. * @param subMesh defines the subMesh to render
  34875. * @param enableAlphaMode defines if alpha mode can be changed
  34876. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34877. * @returns the current mesh
  34878. */
  34879. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34880. private _onBeforeDraw;
  34881. /**
  34882. * Renormalize the mesh and patch it up if there are no weights
  34883. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34884. * However in the case of zero weights then we set just a single influence to 1.
  34885. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34886. */
  34887. cleanMatrixWeights(): void;
  34888. private normalizeSkinFourWeights;
  34889. private normalizeSkinWeightsAndExtra;
  34890. /**
  34891. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34892. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34893. * the user know there was an issue with importing the mesh
  34894. * @returns a validation object with skinned, valid and report string
  34895. */
  34896. validateSkinning(): {
  34897. skinned: boolean;
  34898. valid: boolean;
  34899. report: string;
  34900. };
  34901. /** @hidden */
  34902. _checkDelayState(): Mesh;
  34903. private _queueLoad;
  34904. /**
  34905. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34906. * A mesh is in the frustum if its bounding box intersects the frustum
  34907. * @param frustumPlanes defines the frustum to test
  34908. * @returns true if the mesh is in the frustum planes
  34909. */
  34910. isInFrustum(frustumPlanes: Plane[]): boolean;
  34911. /**
  34912. * Sets the mesh material by the material or multiMaterial `id` property
  34913. * @param id is a string identifying the material or the multiMaterial
  34914. * @returns the current mesh
  34915. */
  34916. setMaterialByID(id: string): Mesh;
  34917. /**
  34918. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34919. * @returns an array of IAnimatable
  34920. */
  34921. getAnimatables(): IAnimatable[];
  34922. /**
  34923. * Modifies the mesh geometry according to the passed transformation matrix.
  34924. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34925. * The mesh normals are modified using the same transformation.
  34926. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34927. * @param transform defines the transform matrix to use
  34928. * @see https://doc.babylonjs.com/resources/baking_transformations
  34929. * @returns the current mesh
  34930. */
  34931. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34932. /**
  34933. * Modifies the mesh geometry according to its own current World Matrix.
  34934. * The mesh World Matrix is then reset.
  34935. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34936. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34937. * @see https://doc.babylonjs.com/resources/baking_transformations
  34938. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34939. * @returns the current mesh
  34940. */
  34941. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34942. /** @hidden */
  34943. get _positions(): Nullable<Vector3[]>;
  34944. /** @hidden */
  34945. _resetPointsArrayCache(): Mesh;
  34946. /** @hidden */
  34947. _generatePointsArray(): boolean;
  34948. /**
  34949. * Returns a new Mesh object generated from the current mesh properties.
  34950. * This method must not get confused with createInstance()
  34951. * @param name is a string, the name given to the new mesh
  34952. * @param newParent can be any Node object (default `null`)
  34953. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34954. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34955. * @returns a new mesh
  34956. */
  34957. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34958. /**
  34959. * Releases resources associated with this mesh.
  34960. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34961. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34962. */
  34963. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34964. /** @hidden */
  34965. _disposeInstanceSpecificData(): void;
  34966. /** @hidden */
  34967. _disposeThinInstanceSpecificData(): void;
  34968. /**
  34969. * Modifies the mesh geometry according to a displacement map.
  34970. * 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.
  34971. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34972. * @param url is a string, the URL from the image file is to be downloaded.
  34973. * @param minHeight is the lower limit of the displacement.
  34974. * @param maxHeight is the upper limit of the displacement.
  34975. * @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.
  34976. * @param uvOffset is an optional vector2 used to offset UV.
  34977. * @param uvScale is an optional vector2 used to scale UV.
  34978. * @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.
  34979. * @returns the Mesh.
  34980. */
  34981. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34982. /**
  34983. * Modifies the mesh geometry according to a displacementMap buffer.
  34984. * 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.
  34985. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34986. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34987. * @param heightMapWidth is the width of the buffer image.
  34988. * @param heightMapHeight is the height of the buffer image.
  34989. * @param minHeight is the lower limit of the displacement.
  34990. * @param maxHeight is the upper limit of the displacement.
  34991. * @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.
  34992. * @param uvOffset is an optional vector2 used to offset UV.
  34993. * @param uvScale is an optional vector2 used to scale UV.
  34994. * @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.
  34995. * @returns the Mesh.
  34996. */
  34997. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34998. /**
  34999. * Modify the mesh to get a flat shading rendering.
  35000. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  35001. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  35002. * @returns current mesh
  35003. */
  35004. convertToFlatShadedMesh(): Mesh;
  35005. /**
  35006. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  35007. * In other words, more vertices, no more indices and a single bigger VBO.
  35008. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  35009. * @returns current mesh
  35010. */
  35011. convertToUnIndexedMesh(): Mesh;
  35012. /**
  35013. * Inverses facet orientations.
  35014. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35015. * @param flipNormals will also inverts the normals
  35016. * @returns current mesh
  35017. */
  35018. flipFaces(flipNormals?: boolean): Mesh;
  35019. /**
  35020. * Increase the number of facets and hence vertices in a mesh
  35021. * Vertex normals are interpolated from existing vertex normals
  35022. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35023. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  35024. */
  35025. increaseVertices(numberPerEdge: number): void;
  35026. /**
  35027. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  35028. * This will undo any application of covertToFlatShadedMesh
  35029. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35030. */
  35031. forceSharedVertices(): void;
  35032. /** @hidden */
  35033. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  35034. /** @hidden */
  35035. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  35036. /**
  35037. * Creates a new InstancedMesh object from the mesh model.
  35038. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  35039. * @param name defines the name of the new instance
  35040. * @returns a new InstancedMesh
  35041. */
  35042. createInstance(name: string): InstancedMesh;
  35043. /**
  35044. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  35045. * After this call, all the mesh instances have the same submeshes than the current mesh.
  35046. * @returns the current mesh
  35047. */
  35048. synchronizeInstances(): Mesh;
  35049. /**
  35050. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  35051. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  35052. * This should be used together with the simplification to avoid disappearing triangles.
  35053. * @param successCallback an optional success callback to be called after the optimization finished.
  35054. * @returns the current mesh
  35055. */
  35056. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  35057. /**
  35058. * Serialize current mesh
  35059. * @param serializationObject defines the object which will receive the serialization data
  35060. */
  35061. serialize(serializationObject: any): void;
  35062. /** @hidden */
  35063. _syncGeometryWithMorphTargetManager(): void;
  35064. /** @hidden */
  35065. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  35066. /**
  35067. * Returns a new Mesh object parsed from the source provided.
  35068. * @param parsedMesh is the source
  35069. * @param scene defines the hosting scene
  35070. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  35071. * @returns a new Mesh
  35072. */
  35073. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  35074. /**
  35075. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  35076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35077. * @param name defines the name of the mesh to create
  35078. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  35079. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  35080. * @param closePath creates a seam between the first and the last points of each path of the path array
  35081. * @param offset is taken in account only if the `pathArray` is containing a single path
  35082. * @param scene defines the hosting scene
  35083. * @param updatable defines if the mesh must be flagged as updatable
  35084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35085. * @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)
  35086. * @returns a new Mesh
  35087. */
  35088. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35089. /**
  35090. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  35091. * @param name defines the name of the mesh to create
  35092. * @param radius sets the radius size (float) of the polygon (default 0.5)
  35093. * @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
  35094. * @param scene defines the hosting scene
  35095. * @param updatable defines if the mesh must be flagged as updatable
  35096. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35097. * @returns a new Mesh
  35098. */
  35099. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35100. /**
  35101. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  35102. * @param name defines the name of the mesh to create
  35103. * @param size sets the size (float) of each box side (default 1)
  35104. * @param scene defines the hosting scene
  35105. * @param updatable defines if the mesh must be flagged as updatable
  35106. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35107. * @returns a new Mesh
  35108. */
  35109. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35110. /**
  35111. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  35112. * @param name defines the name of the mesh to create
  35113. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35114. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35115. * @param scene defines the hosting scene
  35116. * @param updatable defines if the mesh must be flagged as updatable
  35117. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35118. * @returns a new Mesh
  35119. */
  35120. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35121. /**
  35122. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  35123. * @param name defines the name of the mesh to create
  35124. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35125. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35126. * @param scene defines the hosting scene
  35127. * @returns a new Mesh
  35128. */
  35129. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  35130. /**
  35131. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  35132. * @param name defines the name of the mesh to create
  35133. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  35134. * @param diameterTop set the top cap diameter (floats, default 1)
  35135. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  35136. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  35137. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  35138. * @param scene defines the hosting scene
  35139. * @param updatable defines if the mesh must be flagged as updatable
  35140. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35141. * @returns a new Mesh
  35142. */
  35143. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  35144. /**
  35145. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  35146. * @param name defines the name of the mesh to create
  35147. * @param diameter sets the diameter size (float) of the torus (default 1)
  35148. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  35149. * @param tessellation sets the number of torus sides (postive integer, default 16)
  35150. * @param scene defines the hosting scene
  35151. * @param updatable defines if the mesh must be flagged as updatable
  35152. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35153. * @returns a new Mesh
  35154. */
  35155. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35156. /**
  35157. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  35158. * @param name defines the name of the mesh to create
  35159. * @param radius sets the global radius size (float) of the torus knot (default 2)
  35160. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  35161. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  35162. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  35163. * @param p the number of windings on X axis (positive integers, default 2)
  35164. * @param q the number of windings on Y axis (positive integers, default 3)
  35165. * @param scene defines the hosting scene
  35166. * @param updatable defines if the mesh must be flagged as updatable
  35167. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35168. * @returns a new Mesh
  35169. */
  35170. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35171. /**
  35172. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  35173. * @param name defines the name of the mesh to create
  35174. * @param points is an array successive Vector3
  35175. * @param scene defines the hosting scene
  35176. * @param updatable defines if the mesh must be flagged as updatable
  35177. * @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).
  35178. * @returns a new Mesh
  35179. */
  35180. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  35181. /**
  35182. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  35183. * @param name defines the name of the mesh to create
  35184. * @param points is an array successive Vector3
  35185. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  35186. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  35187. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  35188. * @param scene defines the hosting scene
  35189. * @param updatable defines if the mesh must be flagged as updatable
  35190. * @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)
  35191. * @returns a new Mesh
  35192. */
  35193. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  35194. /**
  35195. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  35196. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  35197. * 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.
  35198. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35199. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  35200. * Remember you can only change the shape positions, not their number when updating a polygon.
  35201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  35202. * @param name defines the name of the mesh to create
  35203. * @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
  35204. * @param scene defines the hosting scene
  35205. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35206. * @param updatable defines if the mesh must be flagged as updatable
  35207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35208. * @param earcutInjection can be used to inject your own earcut reference
  35209. * @returns a new Mesh
  35210. */
  35211. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35212. /**
  35213. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  35214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  35215. * @param name defines the name of the mesh to create
  35216. * @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
  35217. * @param depth defines the height of extrusion
  35218. * @param scene defines the hosting scene
  35219. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35220. * @param updatable defines if the mesh must be flagged as updatable
  35221. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35222. * @param earcutInjection can be used to inject your own earcut reference
  35223. * @returns a new Mesh
  35224. */
  35225. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35226. /**
  35227. * Creates an extruded shape mesh.
  35228. * 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
  35229. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35231. * @param name defines the name of the mesh to create
  35232. * @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
  35233. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35234. * @param scale is the value to scale the shape
  35235. * @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
  35236. * @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
  35237. * @param scene defines the hosting scene
  35238. * @param updatable defines if the mesh must be flagged as updatable
  35239. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35240. * @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)
  35241. * @returns a new Mesh
  35242. */
  35243. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35244. /**
  35245. * Creates an custom extruded shape mesh.
  35246. * The custom extrusion is a parametric shape.
  35247. * It has no predefined shape. Its final shape will depend on the input parameters.
  35248. * Please consider using the same method from the MeshBuilder class instead
  35249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35250. * @param name defines the name of the mesh to create
  35251. * @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
  35252. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35253. * @param scaleFunction is a custom Javascript function called on each path point
  35254. * @param rotationFunction is a custom Javascript function called on each path point
  35255. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  35256. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  35257. * @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
  35258. * @param scene defines the hosting scene
  35259. * @param updatable defines if the mesh must be flagged as updatable
  35260. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35261. * @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)
  35262. * @returns a new Mesh
  35263. */
  35264. 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;
  35265. /**
  35266. * Creates lathe mesh.
  35267. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  35268. * Please consider using the same method from the MeshBuilder class instead
  35269. * @param name defines the name of the mesh to create
  35270. * @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
  35271. * @param radius is the radius value of the lathe
  35272. * @param tessellation is the side number of the lathe.
  35273. * @param scene defines the hosting scene
  35274. * @param updatable defines if the mesh must be flagged as updatable
  35275. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35276. * @returns a new Mesh
  35277. */
  35278. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35279. /**
  35280. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35281. * @param name defines the name of the mesh to create
  35282. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35283. * @param scene defines the hosting scene
  35284. * @param updatable defines if the mesh must be flagged as updatable
  35285. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35286. * @returns a new Mesh
  35287. */
  35288. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35289. /**
  35290. * Creates a ground mesh.
  35291. * Please consider using the same method from the MeshBuilder class instead
  35292. * @param name defines the name of the mesh to create
  35293. * @param width set the width of the ground
  35294. * @param height set the height of the ground
  35295. * @param subdivisions sets the number of subdivisions per side
  35296. * @param scene defines the hosting scene
  35297. * @param updatable defines if the mesh must be flagged as updatable
  35298. * @returns a new Mesh
  35299. */
  35300. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35301. /**
  35302. * Creates a tiled ground mesh.
  35303. * Please consider using the same method from the MeshBuilder class instead
  35304. * @param name defines the name of the mesh to create
  35305. * @param xmin set the ground minimum X coordinate
  35306. * @param zmin set the ground minimum Y coordinate
  35307. * @param xmax set the ground maximum X coordinate
  35308. * @param zmax set the ground maximum Z coordinate
  35309. * @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
  35310. * @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
  35311. * @param scene defines the hosting scene
  35312. * @param updatable defines if the mesh must be flagged as updatable
  35313. * @returns a new Mesh
  35314. */
  35315. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35316. w: number;
  35317. h: number;
  35318. }, precision: {
  35319. w: number;
  35320. h: number;
  35321. }, scene: Scene, updatable?: boolean): Mesh;
  35322. /**
  35323. * Creates a ground mesh from a height map.
  35324. * Please consider using the same method from the MeshBuilder class instead
  35325. * @see https://doc.babylonjs.com/babylon101/height_map
  35326. * @param name defines the name of the mesh to create
  35327. * @param url sets the URL of the height map image resource
  35328. * @param width set the ground width size
  35329. * @param height set the ground height size
  35330. * @param subdivisions sets the number of subdivision per side
  35331. * @param minHeight is the minimum altitude on the ground
  35332. * @param maxHeight is the maximum altitude on the ground
  35333. * @param scene defines the hosting scene
  35334. * @param updatable defines if the mesh must be flagged as updatable
  35335. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35336. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35337. * @returns a new Mesh
  35338. */
  35339. 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;
  35340. /**
  35341. * Creates a tube mesh.
  35342. * The tube is a parametric shape.
  35343. * It has no predefined shape. Its final shape will depend on the input parameters.
  35344. * Please consider using the same method from the MeshBuilder class instead
  35345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35346. * @param name defines the name of the mesh to create
  35347. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35348. * @param radius sets the tube radius size
  35349. * @param tessellation is the number of sides on the tubular surface
  35350. * @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
  35351. * @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
  35352. * @param scene defines the hosting scene
  35353. * @param updatable defines if the mesh must be flagged as updatable
  35354. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35355. * @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)
  35356. * @returns a new Mesh
  35357. */
  35358. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35359. (i: number, distance: number): number;
  35360. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35361. /**
  35362. * Creates a polyhedron mesh.
  35363. * Please consider using the same method from the MeshBuilder class instead.
  35364. * * 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
  35365. * * The parameter `size` (positive float, default 1) sets the polygon size
  35366. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35367. * * 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`
  35368. * * 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
  35369. * * 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)`)
  35370. * * 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
  35371. * * 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
  35372. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35373. * * 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
  35374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35375. * @param name defines the name of the mesh to create
  35376. * @param options defines the options used to create the mesh
  35377. * @param scene defines the hosting scene
  35378. * @returns a new Mesh
  35379. */
  35380. static CreatePolyhedron(name: string, options: {
  35381. type?: number;
  35382. size?: number;
  35383. sizeX?: number;
  35384. sizeY?: number;
  35385. sizeZ?: number;
  35386. custom?: any;
  35387. faceUV?: Vector4[];
  35388. faceColors?: Color4[];
  35389. updatable?: boolean;
  35390. sideOrientation?: number;
  35391. }, scene: Scene): Mesh;
  35392. /**
  35393. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35394. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35395. * * 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`)
  35396. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35397. * * 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
  35398. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35399. * * 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
  35400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35401. * @param name defines the name of the mesh
  35402. * @param options defines the options used to create the mesh
  35403. * @param scene defines the hosting scene
  35404. * @returns a new Mesh
  35405. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35406. */
  35407. static CreateIcoSphere(name: string, options: {
  35408. radius?: number;
  35409. flat?: boolean;
  35410. subdivisions?: number;
  35411. sideOrientation?: number;
  35412. updatable?: boolean;
  35413. }, scene: Scene): Mesh;
  35414. /**
  35415. * Creates a decal mesh.
  35416. * Please consider using the same method from the MeshBuilder class instead.
  35417. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35418. * @param name defines the name of the mesh
  35419. * @param sourceMesh defines the mesh receiving the decal
  35420. * @param position sets the position of the decal in world coordinates
  35421. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35422. * @param size sets the decal scaling
  35423. * @param angle sets the angle to rotate the decal
  35424. * @returns a new Mesh
  35425. */
  35426. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35427. /** Creates a Capsule Mesh
  35428. * @param name defines the name of the mesh.
  35429. * @param options the constructors options used to shape the mesh.
  35430. * @param scene defines the scene the mesh is scoped to.
  35431. * @returns the capsule mesh
  35432. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35433. */
  35434. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35435. /**
  35436. * Prepare internal position array for software CPU skinning
  35437. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35438. */
  35439. setPositionsForCPUSkinning(): Float32Array;
  35440. /**
  35441. * Prepare internal normal array for software CPU skinning
  35442. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35443. */
  35444. setNormalsForCPUSkinning(): Float32Array;
  35445. /**
  35446. * Updates the vertex buffer by applying transformation from the bones
  35447. * @param skeleton defines the skeleton to apply to current mesh
  35448. * @returns the current mesh
  35449. */
  35450. applySkeleton(skeleton: Skeleton): Mesh;
  35451. /**
  35452. * 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
  35453. * @param meshes defines the list of meshes to scan
  35454. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35455. */
  35456. static MinMax(meshes: AbstractMesh[]): {
  35457. min: Vector3;
  35458. max: Vector3;
  35459. };
  35460. /**
  35461. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35462. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35463. * @returns a vector3
  35464. */
  35465. static Center(meshesOrMinMaxVector: {
  35466. min: Vector3;
  35467. max: Vector3;
  35468. } | AbstractMesh[]): Vector3;
  35469. /**
  35470. * Merge the array of meshes into a single mesh for performance reasons.
  35471. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35472. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35473. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35474. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35475. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35476. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35477. * @returns a new mesh
  35478. */
  35479. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35480. /** @hidden */
  35481. addInstance(instance: InstancedMesh): void;
  35482. /** @hidden */
  35483. removeInstance(instance: InstancedMesh): void;
  35484. }
  35485. }
  35486. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  35487. import { Vector3 } from "babylonjs/Maths/math.vector";
  35488. import { Mesh } from "babylonjs/Meshes/mesh";
  35489. /**
  35490. * The options Interface for creating a Capsule Mesh
  35491. */
  35492. export interface ICreateCapsuleOptions {
  35493. /** The Orientation of the capsule. Default : Vector3.Up() */
  35494. orientation?: Vector3;
  35495. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  35496. subdivisions: number;
  35497. /** Number of cylindrical segments on the capsule. */
  35498. tessellation: number;
  35499. /** Height or Length of the capsule. */
  35500. height: number;
  35501. /** Radius of the capsule. */
  35502. radius: number;
  35503. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  35504. capSubdivisions: number;
  35505. /** Overwrite for the top radius. */
  35506. radiusTop?: number;
  35507. /** Overwrite for the bottom radius. */
  35508. radiusBottom?: number;
  35509. /** Overwrite for the top capSubdivisions. */
  35510. topCapSubdivisions?: number;
  35511. /** Overwrite for the bottom capSubdivisions. */
  35512. bottomCapSubdivisions?: number;
  35513. }
  35514. /**
  35515. * Class containing static functions to help procedurally build meshes
  35516. */
  35517. export class CapsuleBuilder {
  35518. /**
  35519. * Creates a capsule or a pill mesh
  35520. * @param name defines the name of the mesh
  35521. * @param options The constructors options.
  35522. * @param scene The scene the mesh is scoped to.
  35523. * @returns Capsule Mesh
  35524. */
  35525. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  35526. }
  35527. }
  35528. declare module "babylonjs/Meshes/mesh.vertexData" {
  35529. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  35530. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  35531. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35532. import { Geometry } from "babylonjs/Meshes/geometry";
  35533. import { Mesh } from "babylonjs/Meshes/mesh";
  35534. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  35535. /**
  35536. * Define an interface for all classes that will get and set the data on vertices
  35537. */
  35538. export interface IGetSetVerticesData {
  35539. /**
  35540. * Gets a boolean indicating if specific vertex data is present
  35541. * @param kind defines the vertex data kind to use
  35542. * @returns true is data kind is present
  35543. */
  35544. isVerticesDataPresent(kind: string): boolean;
  35545. /**
  35546. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  35547. * @param kind defines the data kind (Position, normal, etc...)
  35548. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  35549. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35550. * @returns a float array containing vertex data
  35551. */
  35552. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  35553. /**
  35554. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  35555. * @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.
  35556. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35557. * @returns the indices array or an empty array if the mesh has no geometry
  35558. */
  35559. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35560. /**
  35561. * Set specific vertex data
  35562. * @param kind defines the data kind (Position, normal, etc...)
  35563. * @param data defines the vertex data to use
  35564. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  35565. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  35566. */
  35567. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  35568. /**
  35569. * Update a specific associated vertex buffer
  35570. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35571. * - VertexBuffer.PositionKind
  35572. * - VertexBuffer.UVKind
  35573. * - VertexBuffer.UV2Kind
  35574. * - VertexBuffer.UV3Kind
  35575. * - VertexBuffer.UV4Kind
  35576. * - VertexBuffer.UV5Kind
  35577. * - VertexBuffer.UV6Kind
  35578. * - VertexBuffer.ColorKind
  35579. * - VertexBuffer.MatricesIndicesKind
  35580. * - VertexBuffer.MatricesIndicesExtraKind
  35581. * - VertexBuffer.MatricesWeightsKind
  35582. * - VertexBuffer.MatricesWeightsExtraKind
  35583. * @param data defines the data source
  35584. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  35585. * @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)
  35586. */
  35587. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  35588. /**
  35589. * Creates a new index buffer
  35590. * @param indices defines the indices to store in the index buffer
  35591. * @param totalVertices defines the total number of vertices (could be null)
  35592. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  35593. */
  35594. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  35595. }
  35596. /**
  35597. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  35598. */
  35599. export class VertexData {
  35600. /**
  35601. * Mesh side orientation : usually the external or front surface
  35602. */
  35603. static readonly FRONTSIDE: number;
  35604. /**
  35605. * Mesh side orientation : usually the internal or back surface
  35606. */
  35607. static readonly BACKSIDE: number;
  35608. /**
  35609. * Mesh side orientation : both internal and external or front and back surfaces
  35610. */
  35611. static readonly DOUBLESIDE: number;
  35612. /**
  35613. * Mesh side orientation : by default, `FRONTSIDE`
  35614. */
  35615. static readonly DEFAULTSIDE: number;
  35616. /**
  35617. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  35618. */
  35619. positions: Nullable<FloatArray>;
  35620. /**
  35621. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  35622. */
  35623. normals: Nullable<FloatArray>;
  35624. /**
  35625. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  35626. */
  35627. tangents: Nullable<FloatArray>;
  35628. /**
  35629. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35630. */
  35631. uvs: Nullable<FloatArray>;
  35632. /**
  35633. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35634. */
  35635. uvs2: Nullable<FloatArray>;
  35636. /**
  35637. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35638. */
  35639. uvs3: Nullable<FloatArray>;
  35640. /**
  35641. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35642. */
  35643. uvs4: Nullable<FloatArray>;
  35644. /**
  35645. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35646. */
  35647. uvs5: Nullable<FloatArray>;
  35648. /**
  35649. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35650. */
  35651. uvs6: Nullable<FloatArray>;
  35652. /**
  35653. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35654. */
  35655. colors: Nullable<FloatArray>;
  35656. /**
  35657. * 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).
  35658. */
  35659. matricesIndices: Nullable<FloatArray>;
  35660. /**
  35661. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35662. */
  35663. matricesWeights: Nullable<FloatArray>;
  35664. /**
  35665. * An array extending the number of possible indices
  35666. */
  35667. matricesIndicesExtra: Nullable<FloatArray>;
  35668. /**
  35669. * An array extending the number of possible weights when the number of indices is extended
  35670. */
  35671. matricesWeightsExtra: Nullable<FloatArray>;
  35672. /**
  35673. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35674. */
  35675. indices: Nullable<IndicesArray>;
  35676. /**
  35677. * Uses the passed data array to set the set the values for the specified kind of data
  35678. * @param data a linear array of floating numbers
  35679. * @param kind the type of data that is being set, eg positions, colors etc
  35680. */
  35681. set(data: FloatArray, kind: string): void;
  35682. /**
  35683. * Associates the vertexData to the passed Mesh.
  35684. * Sets it as updatable or not (default `false`)
  35685. * @param mesh the mesh the vertexData is applied to
  35686. * @param updatable when used and having the value true allows new data to update the vertexData
  35687. * @returns the VertexData
  35688. */
  35689. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35690. /**
  35691. * Associates the vertexData to the passed Geometry.
  35692. * Sets it as updatable or not (default `false`)
  35693. * @param geometry the geometry the vertexData is applied to
  35694. * @param updatable when used and having the value true allows new data to update the vertexData
  35695. * @returns VertexData
  35696. */
  35697. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35698. /**
  35699. * Updates the associated mesh
  35700. * @param mesh the mesh to be updated
  35701. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35702. * @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
  35703. * @returns VertexData
  35704. */
  35705. updateMesh(mesh: Mesh): VertexData;
  35706. /**
  35707. * Updates the associated geometry
  35708. * @param geometry the geometry to be updated
  35709. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35710. * @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
  35711. * @returns VertexData.
  35712. */
  35713. updateGeometry(geometry: Geometry): VertexData;
  35714. private _applyTo;
  35715. private _update;
  35716. /**
  35717. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35718. * @param matrix the transforming matrix
  35719. * @returns the VertexData
  35720. */
  35721. transform(matrix: Matrix): VertexData;
  35722. /**
  35723. * Merges the passed VertexData into the current one
  35724. * @param other the VertexData to be merged into the current one
  35725. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35726. * @returns the modified VertexData
  35727. */
  35728. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35729. private _mergeElement;
  35730. private _validate;
  35731. /**
  35732. * Serializes the VertexData
  35733. * @returns a serialized object
  35734. */
  35735. serialize(): any;
  35736. /**
  35737. * Extracts the vertexData from a mesh
  35738. * @param mesh the mesh from which to extract the VertexData
  35739. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35740. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35741. * @returns the object VertexData associated to the passed mesh
  35742. */
  35743. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35744. /**
  35745. * Extracts the vertexData from the geometry
  35746. * @param geometry the geometry from which to extract the VertexData
  35747. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  35748. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35749. * @returns the object VertexData associated to the passed mesh
  35750. */
  35751. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35752. private static _ExtractFrom;
  35753. /**
  35754. * Creates the VertexData for a Ribbon
  35755. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35756. * * pathArray array of paths, each of which an array of successive Vector3
  35757. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35758. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35759. * * 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
  35760. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35761. * * 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)
  35762. * * 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)
  35763. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35764. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35765. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35766. * @returns the VertexData of the ribbon
  35767. */
  35768. static CreateRibbon(options: {
  35769. pathArray: Vector3[][];
  35770. closeArray?: boolean;
  35771. closePath?: boolean;
  35772. offset?: number;
  35773. sideOrientation?: number;
  35774. frontUVs?: Vector4;
  35775. backUVs?: Vector4;
  35776. invertUV?: boolean;
  35777. uvs?: Vector2[];
  35778. colors?: Color4[];
  35779. }): VertexData;
  35780. /**
  35781. * Creates the VertexData for a box
  35782. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35783. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35784. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35785. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35786. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35787. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35788. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35790. * * 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)
  35791. * * 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)
  35792. * @returns the VertexData of the box
  35793. */
  35794. static CreateBox(options: {
  35795. size?: number;
  35796. width?: number;
  35797. height?: number;
  35798. depth?: number;
  35799. faceUV?: Vector4[];
  35800. faceColors?: Color4[];
  35801. sideOrientation?: number;
  35802. frontUVs?: Vector4;
  35803. backUVs?: Vector4;
  35804. }): VertexData;
  35805. /**
  35806. * Creates the VertexData for a tiled box
  35807. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35808. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35809. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35810. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35811. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35812. * @returns the VertexData of the box
  35813. */
  35814. static CreateTiledBox(options: {
  35815. pattern?: number;
  35816. width?: number;
  35817. height?: number;
  35818. depth?: number;
  35819. tileSize?: number;
  35820. tileWidth?: number;
  35821. tileHeight?: number;
  35822. alignHorizontal?: number;
  35823. alignVertical?: number;
  35824. faceUV?: Vector4[];
  35825. faceColors?: Color4[];
  35826. sideOrientation?: number;
  35827. }): VertexData;
  35828. /**
  35829. * Creates the VertexData for a tiled plane
  35830. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35831. * * pattern a limited pattern arrangement depending on the number
  35832. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35833. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35834. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35836. * * 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)
  35837. * * 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)
  35838. * @returns the VertexData of the tiled plane
  35839. */
  35840. static CreateTiledPlane(options: {
  35841. pattern?: number;
  35842. tileSize?: number;
  35843. tileWidth?: number;
  35844. tileHeight?: number;
  35845. size?: number;
  35846. width?: number;
  35847. height?: number;
  35848. alignHorizontal?: number;
  35849. alignVertical?: number;
  35850. sideOrientation?: number;
  35851. frontUVs?: Vector4;
  35852. backUVs?: Vector4;
  35853. }): VertexData;
  35854. /**
  35855. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35857. * * segments sets the number of horizontal strips optional, default 32
  35858. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35859. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35860. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35861. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35862. * * 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
  35863. * * 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
  35864. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35865. * * 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)
  35866. * * 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)
  35867. * @returns the VertexData of the ellipsoid
  35868. */
  35869. static CreateSphere(options: {
  35870. segments?: number;
  35871. diameter?: number;
  35872. diameterX?: number;
  35873. diameterY?: number;
  35874. diameterZ?: number;
  35875. arc?: number;
  35876. slice?: number;
  35877. sideOrientation?: number;
  35878. frontUVs?: Vector4;
  35879. backUVs?: Vector4;
  35880. }): VertexData;
  35881. /**
  35882. * Creates the VertexData for a cylinder, cone or prism
  35883. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35884. * * height sets the height (y direction) of the cylinder, optional, default 2
  35885. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35886. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35887. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35888. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35889. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35890. * * 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
  35891. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35892. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35893. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35894. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35895. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35896. * * 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)
  35897. * * 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)
  35898. * @returns the VertexData of the cylinder, cone or prism
  35899. */
  35900. static CreateCylinder(options: {
  35901. height?: number;
  35902. diameterTop?: number;
  35903. diameterBottom?: number;
  35904. diameter?: number;
  35905. tessellation?: number;
  35906. subdivisions?: number;
  35907. arc?: number;
  35908. faceColors?: Color4[];
  35909. faceUV?: Vector4[];
  35910. hasRings?: boolean;
  35911. enclose?: boolean;
  35912. sideOrientation?: number;
  35913. frontUVs?: Vector4;
  35914. backUVs?: Vector4;
  35915. }): VertexData;
  35916. /**
  35917. * Creates the VertexData for a torus
  35918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35919. * * diameter the diameter of the torus, optional default 1
  35920. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35921. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35923. * * 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)
  35924. * * 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)
  35925. * @returns the VertexData of the torus
  35926. */
  35927. static CreateTorus(options: {
  35928. diameter?: number;
  35929. thickness?: number;
  35930. tessellation?: number;
  35931. sideOrientation?: number;
  35932. frontUVs?: Vector4;
  35933. backUVs?: Vector4;
  35934. }): VertexData;
  35935. /**
  35936. * Creates the VertexData of the LineSystem
  35937. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35938. * - lines an array of lines, each line being an array of successive Vector3
  35939. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35940. * @returns the VertexData of the LineSystem
  35941. */
  35942. static CreateLineSystem(options: {
  35943. lines: Vector3[][];
  35944. colors?: Nullable<Color4[][]>;
  35945. }): VertexData;
  35946. /**
  35947. * Create the VertexData for a DashedLines
  35948. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35949. * - points an array successive Vector3
  35950. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35951. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35952. * - dashNb the intended total number of dashes, optional, default 200
  35953. * @returns the VertexData for the DashedLines
  35954. */
  35955. static CreateDashedLines(options: {
  35956. points: Vector3[];
  35957. dashSize?: number;
  35958. gapSize?: number;
  35959. dashNb?: number;
  35960. }): VertexData;
  35961. /**
  35962. * Creates the VertexData for a Ground
  35963. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35964. * - width the width (x direction) of the ground, optional, default 1
  35965. * - height the height (z direction) of the ground, optional, default 1
  35966. * - subdivisions the number of subdivisions per side, optional, default 1
  35967. * @returns the VertexData of the Ground
  35968. */
  35969. static CreateGround(options: {
  35970. width?: number;
  35971. height?: number;
  35972. subdivisions?: number;
  35973. subdivisionsX?: number;
  35974. subdivisionsY?: number;
  35975. }): VertexData;
  35976. /**
  35977. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35978. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35979. * * xmin the ground minimum X coordinate, optional, default -1
  35980. * * zmin the ground minimum Z coordinate, optional, default -1
  35981. * * xmax the ground maximum X coordinate, optional, default 1
  35982. * * zmax the ground maximum Z coordinate, optional, default 1
  35983. * * 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}
  35984. * * 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}
  35985. * @returns the VertexData of the TiledGround
  35986. */
  35987. static CreateTiledGround(options: {
  35988. xmin: number;
  35989. zmin: number;
  35990. xmax: number;
  35991. zmax: number;
  35992. subdivisions?: {
  35993. w: number;
  35994. h: number;
  35995. };
  35996. precision?: {
  35997. w: number;
  35998. h: number;
  35999. };
  36000. }): VertexData;
  36001. /**
  36002. * Creates the VertexData of the Ground designed from a heightmap
  36003. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  36004. * * width the width (x direction) of the ground
  36005. * * height the height (z direction) of the ground
  36006. * * subdivisions the number of subdivisions per side
  36007. * * minHeight the minimum altitude on the ground, optional, default 0
  36008. * * maxHeight the maximum altitude on the ground, optional default 1
  36009. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  36010. * * buffer the array holding the image color data
  36011. * * bufferWidth the width of image
  36012. * * bufferHeight the height of image
  36013. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  36014. * @returns the VertexData of the Ground designed from a heightmap
  36015. */
  36016. static CreateGroundFromHeightMap(options: {
  36017. width: number;
  36018. height: number;
  36019. subdivisions: number;
  36020. minHeight: number;
  36021. maxHeight: number;
  36022. colorFilter: Color3;
  36023. buffer: Uint8Array;
  36024. bufferWidth: number;
  36025. bufferHeight: number;
  36026. alphaFilter: number;
  36027. }): VertexData;
  36028. /**
  36029. * Creates the VertexData for a Plane
  36030. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  36031. * * size sets the width and height of the plane to the value of size, optional default 1
  36032. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  36033. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  36034. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36035. * * 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)
  36036. * * 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)
  36037. * @returns the VertexData of the box
  36038. */
  36039. static CreatePlane(options: {
  36040. size?: number;
  36041. width?: number;
  36042. height?: number;
  36043. sideOrientation?: number;
  36044. frontUVs?: Vector4;
  36045. backUVs?: Vector4;
  36046. }): VertexData;
  36047. /**
  36048. * Creates the VertexData of the Disc or regular Polygon
  36049. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  36050. * * radius the radius of the disc, optional default 0.5
  36051. * * tessellation the number of polygon sides, optional, default 64
  36052. * * 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
  36053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36054. * * 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)
  36055. * * 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)
  36056. * @returns the VertexData of the box
  36057. */
  36058. static CreateDisc(options: {
  36059. radius?: number;
  36060. tessellation?: number;
  36061. arc?: number;
  36062. sideOrientation?: number;
  36063. frontUVs?: Vector4;
  36064. backUVs?: Vector4;
  36065. }): VertexData;
  36066. /**
  36067. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  36068. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  36069. * @param polygon a mesh built from polygonTriangulation.build()
  36070. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36071. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36072. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36073. * @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)
  36074. * @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)
  36075. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  36076. * @returns the VertexData of the Polygon
  36077. */
  36078. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  36079. /**
  36080. * Creates the VertexData of the IcoSphere
  36081. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  36082. * * radius the radius of the IcoSphere, optional default 1
  36083. * * radiusX allows stretching in the x direction, optional, default radius
  36084. * * radiusY allows stretching in the y direction, optional, default radius
  36085. * * radiusZ allows stretching in the z direction, optional, default radius
  36086. * * flat when true creates a flat shaded mesh, optional, default true
  36087. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36089. * * 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)
  36090. * * 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)
  36091. * @returns the VertexData of the IcoSphere
  36092. */
  36093. static CreateIcoSphere(options: {
  36094. radius?: number;
  36095. radiusX?: number;
  36096. radiusY?: number;
  36097. radiusZ?: number;
  36098. flat?: boolean;
  36099. subdivisions?: number;
  36100. sideOrientation?: number;
  36101. frontUVs?: Vector4;
  36102. backUVs?: Vector4;
  36103. }): VertexData;
  36104. /**
  36105. * Creates the VertexData for a Polyhedron
  36106. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  36107. * * type provided types are:
  36108. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  36109. * * 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)
  36110. * * size the size of the IcoSphere, optional default 1
  36111. * * sizeX allows stretching in the x direction, optional, default size
  36112. * * sizeY allows stretching in the y direction, optional, default size
  36113. * * sizeZ allows stretching in the z direction, optional, default size
  36114. * * 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
  36115. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36116. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36117. * * flat when true creates a flat shaded mesh, optional, default true
  36118. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36120. * * 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)
  36121. * * 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)
  36122. * @returns the VertexData of the Polyhedron
  36123. */
  36124. static CreatePolyhedron(options: {
  36125. type?: number;
  36126. size?: number;
  36127. sizeX?: number;
  36128. sizeY?: number;
  36129. sizeZ?: number;
  36130. custom?: any;
  36131. faceUV?: Vector4[];
  36132. faceColors?: Color4[];
  36133. flat?: boolean;
  36134. sideOrientation?: number;
  36135. frontUVs?: Vector4;
  36136. backUVs?: Vector4;
  36137. }): VertexData;
  36138. /**
  36139. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  36140. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  36141. * @returns the VertexData of the Capsule
  36142. */
  36143. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  36144. /**
  36145. * Creates the VertexData for a TorusKnot
  36146. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  36147. * * radius the radius of the torus knot, optional, default 2
  36148. * * tube the thickness of the tube, optional, default 0.5
  36149. * * radialSegments the number of sides on each tube segments, optional, default 32
  36150. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  36151. * * p the number of windings around the z axis, optional, default 2
  36152. * * q the number of windings around the x axis, optional, default 3
  36153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36154. * * 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)
  36155. * * 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)
  36156. * @returns the VertexData of the Torus Knot
  36157. */
  36158. static CreateTorusKnot(options: {
  36159. radius?: number;
  36160. tube?: number;
  36161. radialSegments?: number;
  36162. tubularSegments?: number;
  36163. p?: number;
  36164. q?: number;
  36165. sideOrientation?: number;
  36166. frontUVs?: Vector4;
  36167. backUVs?: Vector4;
  36168. }): VertexData;
  36169. /**
  36170. * Compute normals for given positions and indices
  36171. * @param positions an array of vertex positions, [...., x, y, z, ......]
  36172. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  36173. * @param normals an array of vertex normals, [...., x, y, z, ......]
  36174. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  36175. * * facetNormals : optional array of facet normals (vector3)
  36176. * * facetPositions : optional array of facet positions (vector3)
  36177. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  36178. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  36179. * * bInfo : optional bounding info, required for facetPartitioning computation
  36180. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  36181. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  36182. * * useRightHandedSystem: optional boolean to for right handed system computation
  36183. * * depthSort : optional boolean to enable the facet depth sort computation
  36184. * * distanceTo : optional Vector3 to compute the facet depth from this location
  36185. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  36186. */
  36187. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  36188. facetNormals?: any;
  36189. facetPositions?: any;
  36190. facetPartitioning?: any;
  36191. ratio?: number;
  36192. bInfo?: any;
  36193. bbSize?: Vector3;
  36194. subDiv?: any;
  36195. useRightHandedSystem?: boolean;
  36196. depthSort?: boolean;
  36197. distanceTo?: Vector3;
  36198. depthSortedFacets?: any;
  36199. }): void;
  36200. /** @hidden */
  36201. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  36202. /**
  36203. * Applies VertexData created from the imported parameters to the geometry
  36204. * @param parsedVertexData the parsed data from an imported file
  36205. * @param geometry the geometry to apply the VertexData to
  36206. */
  36207. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  36208. }
  36209. }
  36210. declare module "babylonjs/Meshes/Builders/discBuilder" {
  36211. import { Nullable } from "babylonjs/types";
  36212. import { Scene } from "babylonjs/scene";
  36213. import { Vector4 } from "babylonjs/Maths/math.vector";
  36214. import { Mesh } from "babylonjs/Meshes/mesh";
  36215. /**
  36216. * Class containing static functions to help procedurally build meshes
  36217. */
  36218. export class DiscBuilder {
  36219. /**
  36220. * Creates a plane polygonal mesh. By default, this is a disc
  36221. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  36222. * * 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
  36223. * * 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
  36224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36225. * * 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
  36226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36227. * @param name defines the name of the mesh
  36228. * @param options defines the options used to create the mesh
  36229. * @param scene defines the hosting scene
  36230. * @returns the plane polygonal mesh
  36231. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  36232. */
  36233. static CreateDisc(name: string, options: {
  36234. radius?: number;
  36235. tessellation?: number;
  36236. arc?: number;
  36237. updatable?: boolean;
  36238. sideOrientation?: number;
  36239. frontUVs?: Vector4;
  36240. backUVs?: Vector4;
  36241. }, scene?: Nullable<Scene>): Mesh;
  36242. }
  36243. }
  36244. declare module "babylonjs/Particles/solidParticleSystem" {
  36245. import { Nullable } from "babylonjs/types";
  36246. import { Mesh } from "babylonjs/Meshes/mesh";
  36247. import { Scene, IDisposable } from "babylonjs/scene";
  36248. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  36249. import { Material } from "babylonjs/Materials/material";
  36250. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36251. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36252. /**
  36253. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  36254. *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.
  36255. * The SPS is also a particle system. It provides some methods to manage the particles.
  36256. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  36257. *
  36258. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  36259. */
  36260. export class SolidParticleSystem implements IDisposable {
  36261. /**
  36262. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  36263. * Example : var p = SPS.particles[i];
  36264. */
  36265. particles: SolidParticle[];
  36266. /**
  36267. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  36268. */
  36269. nbParticles: number;
  36270. /**
  36271. * If the particles must ever face the camera (default false). Useful for planar particles.
  36272. */
  36273. billboard: boolean;
  36274. /**
  36275. * Recompute normals when adding a shape
  36276. */
  36277. recomputeNormals: boolean;
  36278. /**
  36279. * This a counter ofr your own usage. It's not set by any SPS functions.
  36280. */
  36281. counter: number;
  36282. /**
  36283. * The SPS name. This name is also given to the underlying mesh.
  36284. */
  36285. name: string;
  36286. /**
  36287. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  36288. */
  36289. mesh: Mesh;
  36290. /**
  36291. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  36292. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  36293. */
  36294. vars: any;
  36295. /**
  36296. * This array is populated when the SPS is set as 'pickable'.
  36297. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  36298. * Each element of this array is an object `{idx: int, faceId: int}`.
  36299. * `idx` is the picked particle index in the `SPS.particles` array
  36300. * `faceId` is the picked face index counted within this particle.
  36301. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  36302. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  36303. * Use the method SPS.pickedParticle(pickingInfo) instead.
  36304. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36305. */
  36306. pickedParticles: {
  36307. idx: number;
  36308. faceId: number;
  36309. }[];
  36310. /**
  36311. * This array is populated when the SPS is set as 'pickable'
  36312. * Each key of this array is a submesh index.
  36313. * Each element of this array is a second array defined like this :
  36314. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  36315. * Each element of this second array is an object `{idx: int, faceId: int}`.
  36316. * `idx` is the picked particle index in the `SPS.particles` array
  36317. * `faceId` is the picked face index counted within this particle.
  36318. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  36319. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36320. */
  36321. pickedBySubMesh: {
  36322. idx: number;
  36323. faceId: number;
  36324. }[][];
  36325. /**
  36326. * This array is populated when `enableDepthSort` is set to true.
  36327. * Each element of this array is an instance of the class DepthSortedParticle.
  36328. */
  36329. depthSortedParticles: DepthSortedParticle[];
  36330. /**
  36331. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  36332. * @hidden
  36333. */
  36334. _bSphereOnly: boolean;
  36335. /**
  36336. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  36337. * @hidden
  36338. */
  36339. _bSphereRadiusFactor: number;
  36340. private _scene;
  36341. private _positions;
  36342. private _indices;
  36343. private _normals;
  36344. private _colors;
  36345. private _uvs;
  36346. private _indices32;
  36347. private _positions32;
  36348. private _normals32;
  36349. private _fixedNormal32;
  36350. private _colors32;
  36351. private _uvs32;
  36352. private _index;
  36353. private _updatable;
  36354. private _pickable;
  36355. private _isVisibilityBoxLocked;
  36356. private _alwaysVisible;
  36357. private _depthSort;
  36358. private _expandable;
  36359. private _shapeCounter;
  36360. private _copy;
  36361. private _color;
  36362. private _computeParticleColor;
  36363. private _computeParticleTexture;
  36364. private _computeParticleRotation;
  36365. private _computeParticleVertex;
  36366. private _computeBoundingBox;
  36367. private _depthSortParticles;
  36368. private _camera;
  36369. private _mustUnrotateFixedNormals;
  36370. private _particlesIntersect;
  36371. private _needs32Bits;
  36372. private _isNotBuilt;
  36373. private _lastParticleId;
  36374. private _idxOfId;
  36375. private _multimaterialEnabled;
  36376. private _useModelMaterial;
  36377. private _indicesByMaterial;
  36378. private _materialIndexes;
  36379. private _depthSortFunction;
  36380. private _materialSortFunction;
  36381. private _materials;
  36382. private _multimaterial;
  36383. private _materialIndexesById;
  36384. private _defaultMaterial;
  36385. private _autoUpdateSubMeshes;
  36386. private _tmpVertex;
  36387. /**
  36388. * Creates a SPS (Solid Particle System) object.
  36389. * @param name (String) is the SPS name, this will be the underlying mesh name.
  36390. * @param scene (Scene) is the scene in which the SPS is added.
  36391. * @param options defines the options of the sps e.g.
  36392. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  36393. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  36394. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  36395. * * 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.
  36396. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  36397. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  36398. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  36399. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  36400. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  36401. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  36402. */
  36403. constructor(name: string, scene: Scene, options?: {
  36404. updatable?: boolean;
  36405. isPickable?: boolean;
  36406. enableDepthSort?: boolean;
  36407. particleIntersection?: boolean;
  36408. boundingSphereOnly?: boolean;
  36409. bSphereRadiusFactor?: number;
  36410. expandable?: boolean;
  36411. useModelMaterial?: boolean;
  36412. enableMultiMaterial?: boolean;
  36413. });
  36414. /**
  36415. * Builds the SPS underlying mesh. Returns a standard Mesh.
  36416. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  36417. * @returns the created mesh
  36418. */
  36419. buildMesh(): Mesh;
  36420. /**
  36421. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  36422. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  36423. * Thus the particles generated from `digest()` have their property `position` set yet.
  36424. * @param mesh ( Mesh ) is the mesh to be digested
  36425. * @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
  36426. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  36427. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  36428. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36429. * @returns the current SPS
  36430. */
  36431. digest(mesh: Mesh, options?: {
  36432. facetNb?: number;
  36433. number?: number;
  36434. delta?: number;
  36435. storage?: [];
  36436. }): SolidParticleSystem;
  36437. /**
  36438. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  36439. * @hidden
  36440. */
  36441. private _unrotateFixedNormals;
  36442. /**
  36443. * Resets the temporary working copy particle
  36444. * @hidden
  36445. */
  36446. private _resetCopy;
  36447. /**
  36448. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36449. * @param p the current index in the positions array to be updated
  36450. * @param ind the current index in the indices array
  36451. * @param shape a Vector3 array, the shape geometry
  36452. * @param positions the positions array to be updated
  36453. * @param meshInd the shape indices array
  36454. * @param indices the indices array to be updated
  36455. * @param meshUV the shape uv array
  36456. * @param uvs the uv array to be updated
  36457. * @param meshCol the shape color array
  36458. * @param colors the color array to be updated
  36459. * @param meshNor the shape normals array
  36460. * @param normals the normals array to be updated
  36461. * @param idx the particle index
  36462. * @param idxInShape the particle index in its shape
  36463. * @param options the addShape() method passed options
  36464. * @model the particle model
  36465. * @hidden
  36466. */
  36467. private _meshBuilder;
  36468. /**
  36469. * Returns a shape Vector3 array from positions float array
  36470. * @param positions float array
  36471. * @returns a vector3 array
  36472. * @hidden
  36473. */
  36474. private _posToShape;
  36475. /**
  36476. * Returns a shapeUV array from a float uvs (array deep copy)
  36477. * @param uvs as a float array
  36478. * @returns a shapeUV array
  36479. * @hidden
  36480. */
  36481. private _uvsToShapeUV;
  36482. /**
  36483. * Adds a new particle object in the particles array
  36484. * @param idx particle index in particles array
  36485. * @param id particle id
  36486. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36487. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36488. * @param model particle ModelShape object
  36489. * @param shapeId model shape identifier
  36490. * @param idxInShape index of the particle in the current model
  36491. * @param bInfo model bounding info object
  36492. * @param storage target storage array, if any
  36493. * @hidden
  36494. */
  36495. private _addParticle;
  36496. /**
  36497. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36498. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36499. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36500. * @param nb (positive integer) the number of particles to be created from this model
  36501. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36502. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36503. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36504. * @returns the number of shapes in the system
  36505. */
  36506. addShape(mesh: Mesh, nb: number, options?: {
  36507. positionFunction?: any;
  36508. vertexFunction?: any;
  36509. storage?: [];
  36510. }): number;
  36511. /**
  36512. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36513. * @hidden
  36514. */
  36515. private _rebuildParticle;
  36516. /**
  36517. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36518. * @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.
  36519. * @returns the SPS.
  36520. */
  36521. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36522. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36523. * Returns an array with the removed particles.
  36524. * 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.
  36525. * The SPS can't be empty so at least one particle needs to remain in place.
  36526. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36527. * @param start index of the first particle to remove
  36528. * @param end index of the last particle to remove (included)
  36529. * @returns an array populated with the removed particles
  36530. */
  36531. removeParticles(start: number, end: number): SolidParticle[];
  36532. /**
  36533. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36534. * @param solidParticleArray an array populated with Solid Particles objects
  36535. * @returns the SPS
  36536. */
  36537. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36538. /**
  36539. * Creates a new particle and modifies the SPS mesh geometry :
  36540. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36541. * - calls _addParticle() to populate the particle array
  36542. * factorized code from addShape() and insertParticlesFromArray()
  36543. * @param idx particle index in the particles array
  36544. * @param i particle index in its shape
  36545. * @param modelShape particle ModelShape object
  36546. * @param shape shape vertex array
  36547. * @param meshInd shape indices array
  36548. * @param meshUV shape uv array
  36549. * @param meshCol shape color array
  36550. * @param meshNor shape normals array
  36551. * @param bbInfo shape bounding info
  36552. * @param storage target particle storage
  36553. * @options addShape() passed options
  36554. * @hidden
  36555. */
  36556. private _insertNewParticle;
  36557. /**
  36558. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36559. * This method calls `updateParticle()` for each particle of the SPS.
  36560. * For an animated SPS, it is usually called within the render loop.
  36561. * 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.
  36562. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36563. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36564. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36565. * @returns the SPS.
  36566. */
  36567. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36568. /**
  36569. * Disposes the SPS.
  36570. */
  36571. dispose(): void;
  36572. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36573. * idx is the particle index in the SPS
  36574. * faceId is the picked face index counted within this particle.
  36575. * Returns null if the pickInfo can't identify a picked particle.
  36576. * @param pickingInfo (PickingInfo object)
  36577. * @returns {idx: number, faceId: number} or null
  36578. */
  36579. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36580. idx: number;
  36581. faceId: number;
  36582. }>;
  36583. /**
  36584. * Returns a SolidParticle object from its identifier : particle.id
  36585. * @param id (integer) the particle Id
  36586. * @returns the searched particle or null if not found in the SPS.
  36587. */
  36588. getParticleById(id: number): Nullable<SolidParticle>;
  36589. /**
  36590. * Returns a new array populated with the particles having the passed shapeId.
  36591. * @param shapeId (integer) the shape identifier
  36592. * @returns a new solid particle array
  36593. */
  36594. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36595. /**
  36596. * Populates the passed array "ref" with the particles having the passed shapeId.
  36597. * @param shapeId the shape identifier
  36598. * @returns the SPS
  36599. * @param ref
  36600. */
  36601. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36602. /**
  36603. * Computes the required SubMeshes according the materials assigned to the particles.
  36604. * @returns the solid particle system.
  36605. * Does nothing if called before the SPS mesh is built.
  36606. */
  36607. computeSubMeshes(): SolidParticleSystem;
  36608. /**
  36609. * Sorts the solid particles by material when MultiMaterial is enabled.
  36610. * Updates the indices32 array.
  36611. * Updates the indicesByMaterial array.
  36612. * Updates the mesh indices array.
  36613. * @returns the SPS
  36614. * @hidden
  36615. */
  36616. private _sortParticlesByMaterial;
  36617. /**
  36618. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36619. * @hidden
  36620. */
  36621. private _setMaterialIndexesById;
  36622. /**
  36623. * Returns an array with unique values of Materials from the passed array
  36624. * @param array the material array to be checked and filtered
  36625. * @hidden
  36626. */
  36627. private _filterUniqueMaterialId;
  36628. /**
  36629. * Sets a new Standard Material as _defaultMaterial if not already set.
  36630. * @hidden
  36631. */
  36632. private _setDefaultMaterial;
  36633. /**
  36634. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36635. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36636. * @returns the SPS.
  36637. */
  36638. refreshVisibleSize(): SolidParticleSystem;
  36639. /**
  36640. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36641. * @param size the size (float) of the visibility box
  36642. * note : this doesn't lock the SPS mesh bounding box.
  36643. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36644. */
  36645. setVisibilityBox(size: number): void;
  36646. /**
  36647. * Gets whether the SPS as always visible or not
  36648. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36649. */
  36650. get isAlwaysVisible(): boolean;
  36651. /**
  36652. * Sets the SPS as always visible or not
  36653. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36654. */
  36655. set isAlwaysVisible(val: boolean);
  36656. /**
  36657. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36658. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36659. */
  36660. set isVisibilityBoxLocked(val: boolean);
  36661. /**
  36662. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36663. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36664. */
  36665. get isVisibilityBoxLocked(): boolean;
  36666. /**
  36667. * Tells to `setParticles()` to compute the particle rotations or not.
  36668. * Default value : true. The SPS is faster when it's set to false.
  36669. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36670. */
  36671. set computeParticleRotation(val: boolean);
  36672. /**
  36673. * Tells to `setParticles()` to compute the particle colors or not.
  36674. * Default value : true. The SPS is faster when it's set to false.
  36675. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36676. */
  36677. set computeParticleColor(val: boolean);
  36678. set computeParticleTexture(val: boolean);
  36679. /**
  36680. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36681. * Default value : false. The SPS is faster when it's set to false.
  36682. * Note : the particle custom vertex positions aren't stored values.
  36683. */
  36684. set computeParticleVertex(val: boolean);
  36685. /**
  36686. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36687. */
  36688. set computeBoundingBox(val: boolean);
  36689. /**
  36690. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36691. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36692. * Default : `true`
  36693. */
  36694. set depthSortParticles(val: boolean);
  36695. /**
  36696. * Gets if `setParticles()` computes the particle rotations or not.
  36697. * Default value : true. The SPS is faster when it's set to false.
  36698. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36699. */
  36700. get computeParticleRotation(): boolean;
  36701. /**
  36702. * Gets if `setParticles()` computes the particle colors or not.
  36703. * Default value : true. The SPS is faster when it's set to false.
  36704. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36705. */
  36706. get computeParticleColor(): boolean;
  36707. /**
  36708. * Gets if `setParticles()` computes the particle textures or not.
  36709. * Default value : true. The SPS is faster when it's set to false.
  36710. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36711. */
  36712. get computeParticleTexture(): boolean;
  36713. /**
  36714. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36715. * Default value : false. The SPS is faster when it's set to false.
  36716. * Note : the particle custom vertex positions aren't stored values.
  36717. */
  36718. get computeParticleVertex(): boolean;
  36719. /**
  36720. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36721. */
  36722. get computeBoundingBox(): boolean;
  36723. /**
  36724. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36725. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36726. * Default : `true`
  36727. */
  36728. get depthSortParticles(): boolean;
  36729. /**
  36730. * Gets if the SPS is created as expandable at construction time.
  36731. * Default : `false`
  36732. */
  36733. get expandable(): boolean;
  36734. /**
  36735. * Gets if the SPS supports the Multi Materials
  36736. */
  36737. get multimaterialEnabled(): boolean;
  36738. /**
  36739. * Gets if the SPS uses the model materials for its own multimaterial.
  36740. */
  36741. get useModelMaterial(): boolean;
  36742. /**
  36743. * The SPS used material array.
  36744. */
  36745. get materials(): Material[];
  36746. /**
  36747. * Sets the SPS MultiMaterial from the passed materials.
  36748. * Note : the passed array is internally copied and not used then by reference.
  36749. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36750. */
  36751. setMultiMaterial(materials: Material[]): void;
  36752. /**
  36753. * The SPS computed multimaterial object
  36754. */
  36755. get multimaterial(): MultiMaterial;
  36756. set multimaterial(mm: MultiMaterial);
  36757. /**
  36758. * If the subMeshes must be updated on the next call to setParticles()
  36759. */
  36760. get autoUpdateSubMeshes(): boolean;
  36761. set autoUpdateSubMeshes(val: boolean);
  36762. /**
  36763. * This function does nothing. It may be overwritten to set all the particle first values.
  36764. * The SPS doesn't call this function, you may have to call it by your own.
  36765. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36766. */
  36767. initParticles(): void;
  36768. /**
  36769. * This function does nothing. It may be overwritten to recycle a particle.
  36770. * The SPS doesn't call this function, you may have to call it by your own.
  36771. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36772. * @param particle The particle to recycle
  36773. * @returns the recycled particle
  36774. */
  36775. recycleParticle(particle: SolidParticle): SolidParticle;
  36776. /**
  36777. * Updates a particle : this function should be overwritten by the user.
  36778. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36779. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36780. * @example : just set a particle position or velocity and recycle conditions
  36781. * @param particle The particle to update
  36782. * @returns the updated particle
  36783. */
  36784. updateParticle(particle: SolidParticle): SolidParticle;
  36785. /**
  36786. * Updates a vertex of a particle : it can be overwritten by the user.
  36787. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36788. * @param particle the current particle
  36789. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36790. * @param pt the index of the current vertex in the particle shape
  36791. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36792. * @example : just set a vertex particle position or color
  36793. * @returns the sps
  36794. */
  36795. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36796. /**
  36797. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36798. * This does nothing and may be overwritten by the user.
  36799. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36800. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36801. * @param update the boolean update value actually passed to setParticles()
  36802. */
  36803. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36804. /**
  36805. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36806. * This will be passed three parameters.
  36807. * This does nothing and may be overwritten by the user.
  36808. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36809. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36810. * @param update the boolean update value actually passed to setParticles()
  36811. */
  36812. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36813. }
  36814. }
  36815. declare module "babylonjs/Particles/solidParticle" {
  36816. import { Nullable } from "babylonjs/types";
  36817. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36818. import { Color4 } from "babylonjs/Maths/math.color";
  36819. import { Mesh } from "babylonjs/Meshes/mesh";
  36820. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36821. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36822. import { Plane } from "babylonjs/Maths/math.plane";
  36823. import { Material } from "babylonjs/Materials/material";
  36824. /**
  36825. * Represents one particle of a solid particle system.
  36826. */
  36827. export class SolidParticle {
  36828. /**
  36829. * particle global index
  36830. */
  36831. idx: number;
  36832. /**
  36833. * particle identifier
  36834. */
  36835. id: number;
  36836. /**
  36837. * The color of the particle
  36838. */
  36839. color: Nullable<Color4>;
  36840. /**
  36841. * The world space position of the particle.
  36842. */
  36843. position: Vector3;
  36844. /**
  36845. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36846. */
  36847. rotation: Vector3;
  36848. /**
  36849. * The world space rotation quaternion of the particle.
  36850. */
  36851. rotationQuaternion: Nullable<Quaternion>;
  36852. /**
  36853. * The scaling of the particle.
  36854. */
  36855. scaling: Vector3;
  36856. /**
  36857. * The uvs of the particle.
  36858. */
  36859. uvs: Vector4;
  36860. /**
  36861. * The current speed of the particle.
  36862. */
  36863. velocity: Vector3;
  36864. /**
  36865. * The pivot point in the particle local space.
  36866. */
  36867. pivot: Vector3;
  36868. /**
  36869. * Must the particle be translated from its pivot point in its local space ?
  36870. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36871. * Default : false
  36872. */
  36873. translateFromPivot: boolean;
  36874. /**
  36875. * Is the particle active or not ?
  36876. */
  36877. alive: boolean;
  36878. /**
  36879. * Is the particle visible or not ?
  36880. */
  36881. isVisible: boolean;
  36882. /**
  36883. * Index of this particle in the global "positions" array (Internal use)
  36884. * @hidden
  36885. */
  36886. _pos: number;
  36887. /**
  36888. * @hidden Index of this particle in the global "indices" array (Internal use)
  36889. */
  36890. _ind: number;
  36891. /**
  36892. * @hidden ModelShape of this particle (Internal use)
  36893. */
  36894. _model: ModelShape;
  36895. /**
  36896. * ModelShape id of this particle
  36897. */
  36898. shapeId: number;
  36899. /**
  36900. * Index of the particle in its shape id
  36901. */
  36902. idxInShape: number;
  36903. /**
  36904. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36905. */
  36906. _modelBoundingInfo: BoundingInfo;
  36907. /**
  36908. * @hidden Particle BoundingInfo object (Internal use)
  36909. */
  36910. _boundingInfo: BoundingInfo;
  36911. /**
  36912. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36913. */
  36914. _sps: SolidParticleSystem;
  36915. /**
  36916. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36917. */
  36918. _stillInvisible: boolean;
  36919. /**
  36920. * @hidden Last computed particle rotation matrix
  36921. */
  36922. _rotationMatrix: number[];
  36923. /**
  36924. * Parent particle Id, if any.
  36925. * Default null.
  36926. */
  36927. parentId: Nullable<number>;
  36928. /**
  36929. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36930. */
  36931. materialIndex: Nullable<number>;
  36932. /**
  36933. * Custom object or properties.
  36934. */
  36935. props: Nullable<any>;
  36936. /**
  36937. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36938. * The possible values are :
  36939. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36940. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36941. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36942. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36943. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36944. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36945. * */
  36946. cullingStrategy: number;
  36947. /**
  36948. * @hidden Internal global position in the SPS.
  36949. */
  36950. _globalPosition: Vector3;
  36951. /**
  36952. * Creates a Solid Particle object.
  36953. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36954. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36955. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36956. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36957. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36958. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36959. * @param shapeId (integer) is the model shape identifier in the SPS.
  36960. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36961. * @param sps defines the sps it is associated to
  36962. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36963. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36964. */
  36965. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36966. /**
  36967. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36968. * @param target the particle target
  36969. * @returns the current particle
  36970. */
  36971. copyToRef(target: SolidParticle): SolidParticle;
  36972. /**
  36973. * Legacy support, changed scale to scaling
  36974. */
  36975. get scale(): Vector3;
  36976. /**
  36977. * Legacy support, changed scale to scaling
  36978. */
  36979. set scale(scale: Vector3);
  36980. /**
  36981. * Legacy support, changed quaternion to rotationQuaternion
  36982. */
  36983. get quaternion(): Nullable<Quaternion>;
  36984. /**
  36985. * Legacy support, changed quaternion to rotationQuaternion
  36986. */
  36987. set quaternion(q: Nullable<Quaternion>);
  36988. /**
  36989. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36990. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36991. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36992. * @returns true if it intersects
  36993. */
  36994. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36995. /**
  36996. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36997. * A particle is in the frustum if its bounding box intersects the frustum
  36998. * @param frustumPlanes defines the frustum to test
  36999. * @returns true if the particle is in the frustum planes
  37000. */
  37001. isInFrustum(frustumPlanes: Plane[]): boolean;
  37002. /**
  37003. * get the rotation matrix of the particle
  37004. * @hidden
  37005. */
  37006. getRotationMatrix(m: Matrix): void;
  37007. }
  37008. /**
  37009. * Represents the shape of the model used by one particle of a solid particle system.
  37010. * SPS internal tool, don't use it manually.
  37011. */
  37012. export class ModelShape {
  37013. /**
  37014. * The shape id
  37015. * @hidden
  37016. */
  37017. shapeID: number;
  37018. /**
  37019. * flat array of model positions (internal use)
  37020. * @hidden
  37021. */
  37022. _shape: Vector3[];
  37023. /**
  37024. * flat array of model UVs (internal use)
  37025. * @hidden
  37026. */
  37027. _shapeUV: number[];
  37028. /**
  37029. * color array of the model
  37030. * @hidden
  37031. */
  37032. _shapeColors: number[];
  37033. /**
  37034. * indices array of the model
  37035. * @hidden
  37036. */
  37037. _indices: number[];
  37038. /**
  37039. * normals array of the model
  37040. * @hidden
  37041. */
  37042. _normals: number[];
  37043. /**
  37044. * length of the shape in the model indices array (internal use)
  37045. * @hidden
  37046. */
  37047. _indicesLength: number;
  37048. /**
  37049. * Custom position function (internal use)
  37050. * @hidden
  37051. */
  37052. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  37053. /**
  37054. * Custom vertex function (internal use)
  37055. * @hidden
  37056. */
  37057. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  37058. /**
  37059. * Model material (internal use)
  37060. * @hidden
  37061. */
  37062. _material: Nullable<Material>;
  37063. /**
  37064. * 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.
  37065. * SPS internal tool, don't use it manually.
  37066. * @hidden
  37067. */
  37068. 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>);
  37069. }
  37070. /**
  37071. * Represents a Depth Sorted Particle in the solid particle system.
  37072. * @hidden
  37073. */
  37074. export class DepthSortedParticle {
  37075. /**
  37076. * Particle index
  37077. */
  37078. idx: number;
  37079. /**
  37080. * Index of the particle in the "indices" array
  37081. */
  37082. ind: number;
  37083. /**
  37084. * Length of the particle shape in the "indices" array
  37085. */
  37086. indicesLength: number;
  37087. /**
  37088. * Squared distance from the particle to the camera
  37089. */
  37090. sqDistance: number;
  37091. /**
  37092. * Material index when used with MultiMaterials
  37093. */
  37094. materialIndex: number;
  37095. /**
  37096. * Creates a new sorted particle
  37097. * @param materialIndex
  37098. */
  37099. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  37100. }
  37101. /**
  37102. * Represents a solid particle vertex
  37103. */
  37104. export class SolidParticleVertex {
  37105. /**
  37106. * Vertex position
  37107. */
  37108. position: Vector3;
  37109. /**
  37110. * Vertex color
  37111. */
  37112. color: Color4;
  37113. /**
  37114. * Vertex UV
  37115. */
  37116. uv: Vector2;
  37117. /**
  37118. * Creates a new solid particle vertex
  37119. */
  37120. constructor();
  37121. /** Vertex x coordinate */
  37122. get x(): number;
  37123. set x(val: number);
  37124. /** Vertex y coordinate */
  37125. get y(): number;
  37126. set y(val: number);
  37127. /** Vertex z coordinate */
  37128. get z(): number;
  37129. set z(val: number);
  37130. }
  37131. }
  37132. declare module "babylonjs/Collisions/meshCollisionData" {
  37133. import { Collider } from "babylonjs/Collisions/collider";
  37134. import { Vector3 } from "babylonjs/Maths/math.vector";
  37135. import { Nullable } from "babylonjs/types";
  37136. import { Observer } from "babylonjs/Misc/observable";
  37137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37138. /**
  37139. * @hidden
  37140. */
  37141. export class _MeshCollisionData {
  37142. _checkCollisions: boolean;
  37143. _collisionMask: number;
  37144. _collisionGroup: number;
  37145. _surroundingMeshes: Nullable<AbstractMesh[]>;
  37146. _collider: Nullable<Collider>;
  37147. _oldPositionForCollisions: Vector3;
  37148. _diffPositionForCollisions: Vector3;
  37149. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  37150. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  37151. _collisionResponse: boolean;
  37152. }
  37153. }
  37154. declare module "babylonjs/Meshes/abstractMesh" {
  37155. import { Observable } from "babylonjs/Misc/observable";
  37156. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  37157. import { Camera } from "babylonjs/Cameras/camera";
  37158. import { Scene, IDisposable } from "babylonjs/scene";
  37159. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37160. import { Node } from "babylonjs/node";
  37161. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  37162. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  37164. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  37165. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  37166. import { Material } from "babylonjs/Materials/material";
  37167. import { Light } from "babylonjs/Lights/light";
  37168. import { Skeleton } from "babylonjs/Bones/skeleton";
  37169. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  37170. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  37171. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37172. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  37173. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  37174. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37175. import { Plane } from "babylonjs/Maths/math.plane";
  37176. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37177. import { Ray } from "babylonjs/Culling/ray";
  37178. import { Collider } from "babylonjs/Collisions/collider";
  37179. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  37180. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  37181. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  37182. /** @hidden */
  37183. class _FacetDataStorage {
  37184. facetPositions: Vector3[];
  37185. facetNormals: Vector3[];
  37186. facetPartitioning: number[][];
  37187. facetNb: number;
  37188. partitioningSubdivisions: number;
  37189. partitioningBBoxRatio: number;
  37190. facetDataEnabled: boolean;
  37191. facetParameters: any;
  37192. bbSize: Vector3;
  37193. subDiv: {
  37194. max: number;
  37195. X: number;
  37196. Y: number;
  37197. Z: number;
  37198. };
  37199. facetDepthSort: boolean;
  37200. facetDepthSortEnabled: boolean;
  37201. depthSortedIndices: IndicesArray;
  37202. depthSortedFacets: {
  37203. ind: number;
  37204. sqDistance: number;
  37205. }[];
  37206. facetDepthSortFunction: (f1: {
  37207. ind: number;
  37208. sqDistance: number;
  37209. }, f2: {
  37210. ind: number;
  37211. sqDistance: number;
  37212. }) => number;
  37213. facetDepthSortFrom: Vector3;
  37214. facetDepthSortOrigin: Vector3;
  37215. invertedMatrix: Matrix;
  37216. }
  37217. /**
  37218. * @hidden
  37219. **/
  37220. class _InternalAbstractMeshDataInfo {
  37221. _hasVertexAlpha: boolean;
  37222. _useVertexColors: boolean;
  37223. _numBoneInfluencers: number;
  37224. _applyFog: boolean;
  37225. _receiveShadows: boolean;
  37226. _facetData: _FacetDataStorage;
  37227. _visibility: number;
  37228. _skeleton: Nullable<Skeleton>;
  37229. _layerMask: number;
  37230. _computeBonesUsingShaders: boolean;
  37231. _isActive: boolean;
  37232. _onlyForInstances: boolean;
  37233. _isActiveIntermediate: boolean;
  37234. _onlyForInstancesIntermediate: boolean;
  37235. _actAsRegularMesh: boolean;
  37236. _currentLOD: Nullable<AbstractMesh>;
  37237. _currentLODIsUpToDate: boolean;
  37238. }
  37239. /**
  37240. * Class used to store all common mesh properties
  37241. */
  37242. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  37243. /** No occlusion */
  37244. static OCCLUSION_TYPE_NONE: number;
  37245. /** Occlusion set to optimisitic */
  37246. static OCCLUSION_TYPE_OPTIMISTIC: number;
  37247. /** Occlusion set to strict */
  37248. static OCCLUSION_TYPE_STRICT: number;
  37249. /** Use an accurante occlusion algorithm */
  37250. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  37251. /** Use a conservative occlusion algorithm */
  37252. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  37253. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  37254. * Test order :
  37255. * Is the bounding sphere outside the frustum ?
  37256. * If not, are the bounding box vertices outside the frustum ?
  37257. * It not, then the cullable object is in the frustum.
  37258. */
  37259. static readonly CULLINGSTRATEGY_STANDARD: number;
  37260. /** Culling strategy : Bounding Sphere Only.
  37261. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  37262. * It's also less accurate than the standard because some not visible objects can still be selected.
  37263. * Test : is the bounding sphere outside the frustum ?
  37264. * If not, then the cullable object is in the frustum.
  37265. */
  37266. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  37267. /** Culling strategy : Optimistic Inclusion.
  37268. * This in an inclusion test first, then the standard exclusion test.
  37269. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  37270. * 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.
  37271. * Anyway, it's as accurate as the standard strategy.
  37272. * Test :
  37273. * Is the cullable object bounding sphere center in the frustum ?
  37274. * If not, apply the default culling strategy.
  37275. */
  37276. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  37277. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  37278. * This in an inclusion test first, then the bounding sphere only exclusion test.
  37279. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  37280. * 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.
  37281. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  37282. * Test :
  37283. * Is the cullable object bounding sphere center in the frustum ?
  37284. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  37285. */
  37286. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  37287. /**
  37288. * No billboard
  37289. */
  37290. static get BILLBOARDMODE_NONE(): number;
  37291. /** Billboard on X axis */
  37292. static get BILLBOARDMODE_X(): number;
  37293. /** Billboard on Y axis */
  37294. static get BILLBOARDMODE_Y(): number;
  37295. /** Billboard on Z axis */
  37296. static get BILLBOARDMODE_Z(): number;
  37297. /** Billboard on all axes */
  37298. static get BILLBOARDMODE_ALL(): number;
  37299. /** Billboard on using position instead of orientation */
  37300. static get BILLBOARDMODE_USE_POSITION(): number;
  37301. /** @hidden */
  37302. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  37303. /**
  37304. * The culling strategy to use to check whether the mesh must be rendered or not.
  37305. * This value can be changed at any time and will be used on the next render mesh selection.
  37306. * The possible values are :
  37307. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37308. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37311. * Please read each static variable documentation to get details about the culling process.
  37312. * */
  37313. cullingStrategy: number;
  37314. /**
  37315. * Gets the number of facets in the mesh
  37316. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37317. */
  37318. get facetNb(): number;
  37319. /**
  37320. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  37321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37322. */
  37323. get partitioningSubdivisions(): number;
  37324. set partitioningSubdivisions(nb: number);
  37325. /**
  37326. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  37327. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  37328. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37329. */
  37330. get partitioningBBoxRatio(): number;
  37331. set partitioningBBoxRatio(ratio: number);
  37332. /**
  37333. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  37334. * Works only for updatable meshes.
  37335. * Doesn't work with multi-materials
  37336. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37337. */
  37338. get mustDepthSortFacets(): boolean;
  37339. set mustDepthSortFacets(sort: boolean);
  37340. /**
  37341. * The location (Vector3) where the facet depth sort must be computed from.
  37342. * By default, the active camera position.
  37343. * Used only when facet depth sort is enabled
  37344. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37345. */
  37346. get facetDepthSortFrom(): Vector3;
  37347. set facetDepthSortFrom(location: Vector3);
  37348. /**
  37349. * gets a boolean indicating if facetData is enabled
  37350. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37351. */
  37352. get isFacetDataEnabled(): boolean;
  37353. /** @hidden */
  37354. _updateNonUniformScalingState(value: boolean): boolean;
  37355. /**
  37356. * An event triggered when this mesh collides with another one
  37357. */
  37358. onCollideObservable: Observable<AbstractMesh>;
  37359. /** Set a function to call when this mesh collides with another one */
  37360. set onCollide(callback: () => void);
  37361. /**
  37362. * An event triggered when the collision's position changes
  37363. */
  37364. onCollisionPositionChangeObservable: Observable<Vector3>;
  37365. /** Set a function to call when the collision's position changes */
  37366. set onCollisionPositionChange(callback: () => void);
  37367. /**
  37368. * An event triggered when material is changed
  37369. */
  37370. onMaterialChangedObservable: Observable<AbstractMesh>;
  37371. /**
  37372. * Gets or sets the orientation for POV movement & rotation
  37373. */
  37374. definedFacingForward: boolean;
  37375. /** @hidden */
  37376. _occlusionQuery: Nullable<WebGLQuery>;
  37377. /** @hidden */
  37378. _renderingGroup: Nullable<RenderingGroup>;
  37379. /**
  37380. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37381. */
  37382. get visibility(): number;
  37383. /**
  37384. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37385. */
  37386. set visibility(value: number);
  37387. /** Gets or sets the alpha index used to sort transparent meshes
  37388. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  37389. */
  37390. alphaIndex: number;
  37391. /**
  37392. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  37393. */
  37394. isVisible: boolean;
  37395. /**
  37396. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37397. */
  37398. isPickable: boolean;
  37399. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  37400. showSubMeshesBoundingBox: boolean;
  37401. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  37402. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  37403. */
  37404. isBlocker: boolean;
  37405. /**
  37406. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  37407. */
  37408. enablePointerMoveEvents: boolean;
  37409. private _renderingGroupId;
  37410. /**
  37411. * Specifies the rendering group id for this mesh (0 by default)
  37412. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37413. */
  37414. get renderingGroupId(): number;
  37415. set renderingGroupId(value: number);
  37416. private _material;
  37417. /** Gets or sets current material */
  37418. get material(): Nullable<Material>;
  37419. set material(value: Nullable<Material>);
  37420. /**
  37421. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  37422. * @see https://doc.babylonjs.com/babylon101/shadows
  37423. */
  37424. get receiveShadows(): boolean;
  37425. set receiveShadows(value: boolean);
  37426. /** Defines color to use when rendering outline */
  37427. outlineColor: Color3;
  37428. /** Define width to use when rendering outline */
  37429. outlineWidth: number;
  37430. /** Defines color to use when rendering overlay */
  37431. overlayColor: Color3;
  37432. /** Defines alpha to use when rendering overlay */
  37433. overlayAlpha: number;
  37434. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  37435. get hasVertexAlpha(): boolean;
  37436. set hasVertexAlpha(value: boolean);
  37437. /** 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) */
  37438. get useVertexColors(): boolean;
  37439. set useVertexColors(value: boolean);
  37440. /**
  37441. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  37442. */
  37443. get computeBonesUsingShaders(): boolean;
  37444. set computeBonesUsingShaders(value: boolean);
  37445. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  37446. get numBoneInfluencers(): number;
  37447. set numBoneInfluencers(value: number);
  37448. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  37449. get applyFog(): boolean;
  37450. set applyFog(value: boolean);
  37451. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37452. useOctreeForRenderingSelection: boolean;
  37453. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37454. useOctreeForPicking: boolean;
  37455. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37456. useOctreeForCollisions: boolean;
  37457. /**
  37458. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37459. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37460. */
  37461. get layerMask(): number;
  37462. set layerMask(value: number);
  37463. /**
  37464. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37465. */
  37466. alwaysSelectAsActiveMesh: boolean;
  37467. /**
  37468. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37469. */
  37470. doNotSyncBoundingInfo: boolean;
  37471. /**
  37472. * Gets or sets the current action manager
  37473. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37474. */
  37475. actionManager: Nullable<AbstractActionManager>;
  37476. private _meshCollisionData;
  37477. /**
  37478. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37479. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37480. */
  37481. ellipsoid: Vector3;
  37482. /**
  37483. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37484. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37485. */
  37486. ellipsoidOffset: Vector3;
  37487. /**
  37488. * Gets or sets a collision mask used to mask collisions (default is -1).
  37489. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37490. */
  37491. get collisionMask(): number;
  37492. set collisionMask(mask: number);
  37493. /**
  37494. * Gets or sets a collision response flag (default is true).
  37495. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37496. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37497. * to respond to the collision.
  37498. */
  37499. get collisionResponse(): boolean;
  37500. set collisionResponse(response: boolean);
  37501. /**
  37502. * Gets or sets the current collision group mask (-1 by default).
  37503. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37504. */
  37505. get collisionGroup(): number;
  37506. set collisionGroup(mask: number);
  37507. /**
  37508. * Gets or sets current surrounding meshes (null by default).
  37509. *
  37510. * By default collision detection is tested against every mesh in the scene.
  37511. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37512. * meshes will be tested for the collision.
  37513. *
  37514. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37515. */
  37516. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37517. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37518. /**
  37519. * Defines edge width used when edgesRenderer is enabled
  37520. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37521. */
  37522. edgesWidth: number;
  37523. /**
  37524. * Defines edge color used when edgesRenderer is enabled
  37525. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37526. */
  37527. edgesColor: Color4;
  37528. /** @hidden */
  37529. _edgesRenderer: Nullable<IEdgesRenderer>;
  37530. /** @hidden */
  37531. _masterMesh: Nullable<AbstractMesh>;
  37532. /** @hidden */
  37533. _boundingInfo: Nullable<BoundingInfo>;
  37534. /** @hidden */
  37535. _renderId: number;
  37536. /**
  37537. * Gets or sets the list of subMeshes
  37538. * @see https://doc.babylonjs.com/how_to/multi_materials
  37539. */
  37540. subMeshes: SubMesh[];
  37541. /** @hidden */
  37542. _intersectionsInProgress: AbstractMesh[];
  37543. /** @hidden */
  37544. _unIndexed: boolean;
  37545. /** @hidden */
  37546. _lightSources: Light[];
  37547. /** Gets the list of lights affecting that mesh */
  37548. get lightSources(): Light[];
  37549. /** @hidden */
  37550. get _positions(): Nullable<Vector3[]>;
  37551. /** @hidden */
  37552. _waitingData: {
  37553. lods: Nullable<any>;
  37554. actions: Nullable<any>;
  37555. freezeWorldMatrix: Nullable<boolean>;
  37556. };
  37557. /** @hidden */
  37558. _bonesTransformMatrices: Nullable<Float32Array>;
  37559. /** @hidden */
  37560. _transformMatrixTexture: Nullable<RawTexture>;
  37561. /**
  37562. * Gets or sets a skeleton to apply skining transformations
  37563. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37564. */
  37565. set skeleton(value: Nullable<Skeleton>);
  37566. get skeleton(): Nullable<Skeleton>;
  37567. /**
  37568. * An event triggered when the mesh is rebuilt.
  37569. */
  37570. onRebuildObservable: Observable<AbstractMesh>;
  37571. /**
  37572. * The current mesh unifom buffer.
  37573. * @hidden Internal use only.
  37574. */
  37575. _uniformBuffer: UniformBuffer;
  37576. /**
  37577. * Creates a new AbstractMesh
  37578. * @param name defines the name of the mesh
  37579. * @param scene defines the hosting scene
  37580. */
  37581. constructor(name: string, scene?: Nullable<Scene>);
  37582. protected _buildUniformLayout(): void;
  37583. /**
  37584. * Transfer the mesh values to its UBO.
  37585. * @param world The world matrix associated with the mesh
  37586. */
  37587. transferToEffect(world: Matrix): void;
  37588. /**
  37589. * Gets the mesh uniform buffer.
  37590. * @return the uniform buffer of the mesh.
  37591. */
  37592. getMeshUniformBuffer(): UniformBuffer;
  37593. /**
  37594. * Returns the string "AbstractMesh"
  37595. * @returns "AbstractMesh"
  37596. */
  37597. getClassName(): string;
  37598. /**
  37599. * Gets a string representation of the current mesh
  37600. * @param fullDetails defines a boolean indicating if full details must be included
  37601. * @returns a string representation of the current mesh
  37602. */
  37603. toString(fullDetails?: boolean): string;
  37604. /**
  37605. * @hidden
  37606. */
  37607. protected _getEffectiveParent(): Nullable<Node>;
  37608. /** @hidden */
  37609. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37610. /** @hidden */
  37611. _rebuild(): void;
  37612. /** @hidden */
  37613. _resyncLightSources(): void;
  37614. /** @hidden */
  37615. _resyncLightSource(light: Light): void;
  37616. /** @hidden */
  37617. _unBindEffect(): void;
  37618. /** @hidden */
  37619. _removeLightSource(light: Light, dispose: boolean): void;
  37620. private _markSubMeshesAsDirty;
  37621. /** @hidden */
  37622. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37623. /** @hidden */
  37624. _markSubMeshesAsAttributesDirty(): void;
  37625. /** @hidden */
  37626. _markSubMeshesAsMiscDirty(): void;
  37627. /**
  37628. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37629. */
  37630. get scaling(): Vector3;
  37631. set scaling(newScaling: Vector3);
  37632. /**
  37633. * Returns true if the mesh is blocked. Implemented by child classes
  37634. */
  37635. get isBlocked(): boolean;
  37636. /**
  37637. * Returns the mesh itself by default. Implemented by child classes
  37638. * @param camera defines the camera to use to pick the right LOD level
  37639. * @returns the currentAbstractMesh
  37640. */
  37641. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37642. /**
  37643. * Returns 0 by default. Implemented by child classes
  37644. * @returns an integer
  37645. */
  37646. getTotalVertices(): number;
  37647. /**
  37648. * Returns a positive integer : the total number of indices in this mesh geometry.
  37649. * @returns the numner of indices or zero if the mesh has no geometry.
  37650. */
  37651. getTotalIndices(): number;
  37652. /**
  37653. * Returns null by default. Implemented by child classes
  37654. * @returns null
  37655. */
  37656. getIndices(): Nullable<IndicesArray>;
  37657. /**
  37658. * Returns the array of the requested vertex data kind. Implemented by child classes
  37659. * @param kind defines the vertex data kind to use
  37660. * @returns null
  37661. */
  37662. getVerticesData(kind: string): Nullable<FloatArray>;
  37663. /**
  37664. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37665. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37666. * Note that a new underlying VertexBuffer object is created each call.
  37667. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37668. * @param kind defines vertex data kind:
  37669. * * VertexBuffer.PositionKind
  37670. * * VertexBuffer.UVKind
  37671. * * VertexBuffer.UV2Kind
  37672. * * VertexBuffer.UV3Kind
  37673. * * VertexBuffer.UV4Kind
  37674. * * VertexBuffer.UV5Kind
  37675. * * VertexBuffer.UV6Kind
  37676. * * VertexBuffer.ColorKind
  37677. * * VertexBuffer.MatricesIndicesKind
  37678. * * VertexBuffer.MatricesIndicesExtraKind
  37679. * * VertexBuffer.MatricesWeightsKind
  37680. * * VertexBuffer.MatricesWeightsExtraKind
  37681. * @param data defines the data source
  37682. * @param updatable defines if the data must be flagged as updatable (or static)
  37683. * @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
  37684. * @returns the current mesh
  37685. */
  37686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37687. /**
  37688. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37689. * If the mesh has no geometry, it is simply returned as it is.
  37690. * @param kind defines vertex data kind:
  37691. * * VertexBuffer.PositionKind
  37692. * * VertexBuffer.UVKind
  37693. * * VertexBuffer.UV2Kind
  37694. * * VertexBuffer.UV3Kind
  37695. * * VertexBuffer.UV4Kind
  37696. * * VertexBuffer.UV5Kind
  37697. * * VertexBuffer.UV6Kind
  37698. * * VertexBuffer.ColorKind
  37699. * * VertexBuffer.MatricesIndicesKind
  37700. * * VertexBuffer.MatricesIndicesExtraKind
  37701. * * VertexBuffer.MatricesWeightsKind
  37702. * * VertexBuffer.MatricesWeightsExtraKind
  37703. * @param data defines the data source
  37704. * @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
  37705. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37706. * @returns the current mesh
  37707. */
  37708. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37709. /**
  37710. * Sets the mesh indices,
  37711. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37712. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37713. * @param totalVertices Defines the total number of vertices
  37714. * @returns the current mesh
  37715. */
  37716. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37717. /**
  37718. * Gets a boolean indicating if specific vertex data is present
  37719. * @param kind defines the vertex data kind to use
  37720. * @returns true is data kind is present
  37721. */
  37722. isVerticesDataPresent(kind: string): boolean;
  37723. /**
  37724. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37725. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37726. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37727. * @returns a BoundingInfo
  37728. */
  37729. getBoundingInfo(): BoundingInfo;
  37730. /**
  37731. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37732. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37733. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37734. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37735. * @returns the current mesh
  37736. */
  37737. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37738. /**
  37739. * Overwrite the current bounding info
  37740. * @param boundingInfo defines the new bounding info
  37741. * @returns the current mesh
  37742. */
  37743. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37744. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37745. get useBones(): boolean;
  37746. /** @hidden */
  37747. _preActivate(): void;
  37748. /** @hidden */
  37749. _preActivateForIntermediateRendering(renderId: number): void;
  37750. /** @hidden */
  37751. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37752. /** @hidden */
  37753. _postActivate(): void;
  37754. /** @hidden */
  37755. _freeze(): void;
  37756. /** @hidden */
  37757. _unFreeze(): void;
  37758. /**
  37759. * Gets the current world matrix
  37760. * @returns a Matrix
  37761. */
  37762. getWorldMatrix(): Matrix;
  37763. /** @hidden */
  37764. _getWorldMatrixDeterminant(): number;
  37765. /**
  37766. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37767. */
  37768. get isAnInstance(): boolean;
  37769. /**
  37770. * Gets a boolean indicating if this mesh has instances
  37771. */
  37772. get hasInstances(): boolean;
  37773. /**
  37774. * Gets a boolean indicating if this mesh has thin instances
  37775. */
  37776. get hasThinInstances(): boolean;
  37777. /**
  37778. * Perform relative position change from the point of view of behind the front of the mesh.
  37779. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37780. * Supports definition of mesh facing forward or backward
  37781. * @param amountRight defines the distance on the right axis
  37782. * @param amountUp defines the distance on the up axis
  37783. * @param amountForward defines the distance on the forward axis
  37784. * @returns the current mesh
  37785. */
  37786. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37787. /**
  37788. * Calculate relative position change from the point of view of behind the front of the mesh.
  37789. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37790. * Supports definition of mesh facing forward or backward
  37791. * @param amountRight defines the distance on the right axis
  37792. * @param amountUp defines the distance on the up axis
  37793. * @param amountForward defines the distance on the forward axis
  37794. * @returns the new displacement vector
  37795. */
  37796. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37797. /**
  37798. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37799. * Supports definition of mesh facing forward or backward
  37800. * @param flipBack defines the flip
  37801. * @param twirlClockwise defines the twirl
  37802. * @param tiltRight defines the tilt
  37803. * @returns the current mesh
  37804. */
  37805. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37806. /**
  37807. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37808. * Supports definition of mesh facing forward or backward.
  37809. * @param flipBack defines the flip
  37810. * @param twirlClockwise defines the twirl
  37811. * @param tiltRight defines the tilt
  37812. * @returns the new rotation vector
  37813. */
  37814. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37815. /**
  37816. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37817. * This means the mesh underlying bounding box and sphere are recomputed.
  37818. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37819. * @returns the current mesh
  37820. */
  37821. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37822. /** @hidden */
  37823. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37824. /** @hidden */
  37825. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37826. /** @hidden */
  37827. _updateBoundingInfo(): AbstractMesh;
  37828. /** @hidden */
  37829. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37830. /** @hidden */
  37831. protected _afterComputeWorldMatrix(): void;
  37832. /** @hidden */
  37833. get _effectiveMesh(): AbstractMesh;
  37834. /**
  37835. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37836. * A mesh is in the frustum if its bounding box intersects the frustum
  37837. * @param frustumPlanes defines the frustum to test
  37838. * @returns true if the mesh is in the frustum planes
  37839. */
  37840. isInFrustum(frustumPlanes: Plane[]): boolean;
  37841. /**
  37842. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37843. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37844. * @param frustumPlanes defines the frustum to test
  37845. * @returns true if the mesh is completely in the frustum planes
  37846. */
  37847. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37848. /**
  37849. * True if the mesh intersects another mesh or a SolidParticle object
  37850. * @param mesh defines a target mesh or SolidParticle to test
  37851. * @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)
  37852. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37853. * @returns true if there is an intersection
  37854. */
  37855. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37856. /**
  37857. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37858. * @param point defines the point to test
  37859. * @returns true if there is an intersection
  37860. */
  37861. intersectsPoint(point: Vector3): boolean;
  37862. /**
  37863. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37864. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37865. */
  37866. get checkCollisions(): boolean;
  37867. set checkCollisions(collisionEnabled: boolean);
  37868. /**
  37869. * Gets Collider object used to compute collisions (not physics)
  37870. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37871. */
  37872. get collider(): Nullable<Collider>;
  37873. /**
  37874. * Move the mesh using collision engine
  37875. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37876. * @param displacement defines the requested displacement vector
  37877. * @returns the current mesh
  37878. */
  37879. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37880. private _onCollisionPositionChange;
  37881. /** @hidden */
  37882. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37883. /** @hidden */
  37884. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37885. /** @hidden */
  37886. _checkCollision(collider: Collider): AbstractMesh;
  37887. /** @hidden */
  37888. _generatePointsArray(): boolean;
  37889. /**
  37890. * Checks if the passed Ray intersects with the mesh
  37891. * @param ray defines the ray to use
  37892. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37893. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37894. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37895. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37896. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37897. * @returns the picking info
  37898. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37899. */
  37900. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37901. /**
  37902. * Clones the current mesh
  37903. * @param name defines the mesh name
  37904. * @param newParent defines the new mesh parent
  37905. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37906. * @returns the new mesh
  37907. */
  37908. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37909. /**
  37910. * Disposes all the submeshes of the current meshnp
  37911. * @returns the current mesh
  37912. */
  37913. releaseSubMeshes(): AbstractMesh;
  37914. /**
  37915. * Releases resources associated with this abstract mesh.
  37916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37918. */
  37919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37920. /**
  37921. * Adds the passed mesh as a child to the current mesh
  37922. * @param mesh defines the child mesh
  37923. * @returns the current mesh
  37924. */
  37925. addChild(mesh: AbstractMesh): AbstractMesh;
  37926. /**
  37927. * Removes the passed mesh from the current mesh children list
  37928. * @param mesh defines the child mesh
  37929. * @returns the current mesh
  37930. */
  37931. removeChild(mesh: AbstractMesh): AbstractMesh;
  37932. /** @hidden */
  37933. private _initFacetData;
  37934. /**
  37935. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37936. * This method can be called within the render loop.
  37937. * 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
  37938. * @returns the current mesh
  37939. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37940. */
  37941. updateFacetData(): AbstractMesh;
  37942. /**
  37943. * Returns the facetLocalNormals array.
  37944. * The normals are expressed in the mesh local spac
  37945. * @returns an array of Vector3
  37946. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37947. */
  37948. getFacetLocalNormals(): Vector3[];
  37949. /**
  37950. * Returns the facetLocalPositions array.
  37951. * The facet positions are expressed in the mesh local space
  37952. * @returns an array of Vector3
  37953. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37954. */
  37955. getFacetLocalPositions(): Vector3[];
  37956. /**
  37957. * Returns the facetLocalPartioning array
  37958. * @returns an array of array of numbers
  37959. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37960. */
  37961. getFacetLocalPartitioning(): number[][];
  37962. /**
  37963. * Returns the i-th facet position in the world system.
  37964. * This method allocates a new Vector3 per call
  37965. * @param i defines the facet index
  37966. * @returns a new Vector3
  37967. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37968. */
  37969. getFacetPosition(i: number): Vector3;
  37970. /**
  37971. * Sets the reference Vector3 with the i-th facet position in the world system
  37972. * @param i defines the facet index
  37973. * @param ref defines the target vector
  37974. * @returns the current mesh
  37975. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37976. */
  37977. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37978. /**
  37979. * Returns the i-th facet normal in the world system.
  37980. * This method allocates a new Vector3 per call
  37981. * @param i defines the facet index
  37982. * @returns a new Vector3
  37983. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37984. */
  37985. getFacetNormal(i: number): Vector3;
  37986. /**
  37987. * Sets the reference Vector3 with the i-th facet normal in the world system
  37988. * @param i defines the facet index
  37989. * @param ref defines the target vector
  37990. * @returns the current mesh
  37991. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37992. */
  37993. getFacetNormalToRef(i: number, ref: Vector3): this;
  37994. /**
  37995. * 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)
  37996. * @param x defines x coordinate
  37997. * @param y defines y coordinate
  37998. * @param z defines z coordinate
  37999. * @returns the array of facet indexes
  38000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38001. */
  38002. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  38003. /**
  38004. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  38005. * @param projected sets as the (x,y,z) world projection on the facet
  38006. * @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
  38007. * @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
  38008. * @param x defines x coordinate
  38009. * @param y defines y coordinate
  38010. * @param z defines z coordinate
  38011. * @returns the face index if found (or null instead)
  38012. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38013. */
  38014. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38015. /**
  38016. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  38017. * @param projected sets as the (x,y,z) local projection on the facet
  38018. * @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
  38019. * @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
  38020. * @param x defines x coordinate
  38021. * @param y defines y coordinate
  38022. * @param z defines z coordinate
  38023. * @returns the face index if found (or null instead)
  38024. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38025. */
  38026. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38027. /**
  38028. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  38029. * @returns the parameters
  38030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38031. */
  38032. getFacetDataParameters(): any;
  38033. /**
  38034. * Disables the feature FacetData and frees the related memory
  38035. * @returns the current mesh
  38036. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38037. */
  38038. disableFacetData(): AbstractMesh;
  38039. /**
  38040. * Updates the AbstractMesh indices array
  38041. * @param indices defines the data source
  38042. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  38043. * @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)
  38044. * @returns the current mesh
  38045. */
  38046. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  38047. /**
  38048. * Creates new normals data for the mesh
  38049. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  38050. * @returns the current mesh
  38051. */
  38052. createNormals(updatable: boolean): AbstractMesh;
  38053. /**
  38054. * Align the mesh with a normal
  38055. * @param normal defines the normal to use
  38056. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  38057. * @returns the current mesh
  38058. */
  38059. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  38060. /** @hidden */
  38061. _checkOcclusionQuery(): boolean;
  38062. /**
  38063. * Disables the mesh edge rendering mode
  38064. * @returns the currentAbstractMesh
  38065. */
  38066. disableEdgesRendering(): AbstractMesh;
  38067. /**
  38068. * Enables the edge rendering mode on the mesh.
  38069. * This mode makes the mesh edges visible
  38070. * @param epsilon defines the maximal distance between two angles to detect a face
  38071. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  38072. * @param options options to the edge renderer
  38073. * @returns the currentAbstractMesh
  38074. * @see https://www.babylonjs-playground.com/#19O9TU#0
  38075. */
  38076. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  38077. /**
  38078. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  38079. * @returns an array of particle systems in the scene that use the mesh as an emitter
  38080. */
  38081. getConnectedParticleSystems(): IParticleSystem[];
  38082. }
  38083. }
  38084. declare module "babylonjs/Actions/actionEvent" {
  38085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38086. import { Nullable } from "babylonjs/types";
  38087. import { Sprite } from "babylonjs/Sprites/sprite";
  38088. import { Scene } from "babylonjs/scene";
  38089. import { Vector2 } from "babylonjs/Maths/math.vector";
  38090. /**
  38091. * Interface used to define ActionEvent
  38092. */
  38093. export interface IActionEvent {
  38094. /** The mesh or sprite that triggered the action */
  38095. source: any;
  38096. /** The X mouse cursor position at the time of the event */
  38097. pointerX: number;
  38098. /** The Y mouse cursor position at the time of the event */
  38099. pointerY: number;
  38100. /** The mesh that is currently pointed at (can be null) */
  38101. meshUnderPointer: Nullable<AbstractMesh>;
  38102. /** the original (browser) event that triggered the ActionEvent */
  38103. sourceEvent?: any;
  38104. /** additional data for the event */
  38105. additionalData?: any;
  38106. }
  38107. /**
  38108. * ActionEvent is the event being sent when an action is triggered.
  38109. */
  38110. export class ActionEvent implements IActionEvent {
  38111. /** The mesh or sprite that triggered the action */
  38112. source: any;
  38113. /** The X mouse cursor position at the time of the event */
  38114. pointerX: number;
  38115. /** The Y mouse cursor position at the time of the event */
  38116. pointerY: number;
  38117. /** The mesh that is currently pointed at (can be null) */
  38118. meshUnderPointer: Nullable<AbstractMesh>;
  38119. /** the original (browser) event that triggered the ActionEvent */
  38120. sourceEvent?: any;
  38121. /** additional data for the event */
  38122. additionalData?: any;
  38123. /**
  38124. * Creates a new ActionEvent
  38125. * @param source The mesh or sprite that triggered the action
  38126. * @param pointerX The X mouse cursor position at the time of the event
  38127. * @param pointerY The Y mouse cursor position at the time of the event
  38128. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  38129. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  38130. * @param additionalData additional data for the event
  38131. */
  38132. constructor(
  38133. /** The mesh or sprite that triggered the action */
  38134. source: any,
  38135. /** The X mouse cursor position at the time of the event */
  38136. pointerX: number,
  38137. /** The Y mouse cursor position at the time of the event */
  38138. pointerY: number,
  38139. /** The mesh that is currently pointed at (can be null) */
  38140. meshUnderPointer: Nullable<AbstractMesh>,
  38141. /** the original (browser) event that triggered the ActionEvent */
  38142. sourceEvent?: any,
  38143. /** additional data for the event */
  38144. additionalData?: any);
  38145. /**
  38146. * Helper function to auto-create an ActionEvent from a source mesh.
  38147. * @param source The source mesh that triggered the event
  38148. * @param evt The original (browser) event
  38149. * @param additionalData additional data for the event
  38150. * @returns the new ActionEvent
  38151. */
  38152. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  38153. /**
  38154. * Helper function to auto-create an ActionEvent from a source sprite
  38155. * @param source The source sprite that triggered the event
  38156. * @param scene Scene associated with the sprite
  38157. * @param evt The original (browser) event
  38158. * @param additionalData additional data for the event
  38159. * @returns the new ActionEvent
  38160. */
  38161. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  38162. /**
  38163. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  38164. * @param scene the scene where the event occurred
  38165. * @param evt The original (browser) event
  38166. * @returns the new ActionEvent
  38167. */
  38168. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  38169. /**
  38170. * Helper function to auto-create an ActionEvent from a primitive
  38171. * @param prim defines the target primitive
  38172. * @param pointerPos defines the pointer position
  38173. * @param evt The original (browser) event
  38174. * @param additionalData additional data for the event
  38175. * @returns the new ActionEvent
  38176. */
  38177. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  38178. }
  38179. }
  38180. declare module "babylonjs/Actions/abstractActionManager" {
  38181. import { IDisposable } from "babylonjs/scene";
  38182. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  38183. import { IAction } from "babylonjs/Actions/action";
  38184. import { Nullable } from "babylonjs/types";
  38185. /**
  38186. * Abstract class used to decouple action Manager from scene and meshes.
  38187. * Do not instantiate.
  38188. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  38189. */
  38190. export abstract class AbstractActionManager implements IDisposable {
  38191. /** Gets the list of active triggers */
  38192. static Triggers: {
  38193. [key: string]: number;
  38194. };
  38195. /** Gets the cursor to use when hovering items */
  38196. hoverCursor: string;
  38197. /** Gets the list of actions */
  38198. actions: IAction[];
  38199. /**
  38200. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  38201. */
  38202. isRecursive: boolean;
  38203. /**
  38204. * Releases all associated resources
  38205. */
  38206. abstract dispose(): void;
  38207. /**
  38208. * Does this action manager has pointer triggers
  38209. */
  38210. abstract get hasPointerTriggers(): boolean;
  38211. /**
  38212. * Does this action manager has pick triggers
  38213. */
  38214. abstract get hasPickTriggers(): boolean;
  38215. /**
  38216. * Process a specific trigger
  38217. * @param trigger defines the trigger to process
  38218. * @param evt defines the event details to be processed
  38219. */
  38220. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  38221. /**
  38222. * Does this action manager handles actions of any of the given triggers
  38223. * @param triggers defines the triggers to be tested
  38224. * @return a boolean indicating whether one (or more) of the triggers is handled
  38225. */
  38226. abstract hasSpecificTriggers(triggers: number[]): boolean;
  38227. /**
  38228. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  38229. * speed.
  38230. * @param triggerA defines the trigger to be tested
  38231. * @param triggerB defines the trigger to be tested
  38232. * @return a boolean indicating whether one (or more) of the triggers is handled
  38233. */
  38234. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  38235. /**
  38236. * Does this action manager handles actions of a given trigger
  38237. * @param trigger defines the trigger to be tested
  38238. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  38239. * @return whether the trigger is handled
  38240. */
  38241. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  38242. /**
  38243. * Serialize this manager to a JSON object
  38244. * @param name defines the property name to store this manager
  38245. * @returns a JSON representation of this manager
  38246. */
  38247. abstract serialize(name: string): any;
  38248. /**
  38249. * Registers an action to this action manager
  38250. * @param action defines the action to be registered
  38251. * @return the action amended (prepared) after registration
  38252. */
  38253. abstract registerAction(action: IAction): Nullable<IAction>;
  38254. /**
  38255. * Unregisters an action to this action manager
  38256. * @param action defines the action to be unregistered
  38257. * @return a boolean indicating whether the action has been unregistered
  38258. */
  38259. abstract unregisterAction(action: IAction): Boolean;
  38260. /**
  38261. * Does exist one action manager with at least one trigger
  38262. **/
  38263. static get HasTriggers(): boolean;
  38264. /**
  38265. * Does exist one action manager with at least one pick trigger
  38266. **/
  38267. static get HasPickTriggers(): boolean;
  38268. /**
  38269. * Does exist one action manager that handles actions of a given trigger
  38270. * @param trigger defines the trigger to be tested
  38271. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  38272. **/
  38273. static HasSpecificTrigger(trigger: number): boolean;
  38274. }
  38275. }
  38276. declare module "babylonjs/node" {
  38277. import { Scene } from "babylonjs/scene";
  38278. import { Nullable } from "babylonjs/types";
  38279. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38280. import { Engine } from "babylonjs/Engines/engine";
  38281. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  38282. import { Observable } from "babylonjs/Misc/observable";
  38283. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38284. import { IInspectable } from "babylonjs/Misc/iInspectable";
  38285. import { Animatable } from "babylonjs/Animations/animatable";
  38286. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  38287. import { Animation } from "babylonjs/Animations/animation";
  38288. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38290. /**
  38291. * Defines how a node can be built from a string name.
  38292. */
  38293. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  38294. /**
  38295. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  38296. */
  38297. export class Node implements IBehaviorAware<Node> {
  38298. /** @hidden */
  38299. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  38300. private static _NodeConstructors;
  38301. /**
  38302. * Add a new node constructor
  38303. * @param type defines the type name of the node to construct
  38304. * @param constructorFunc defines the constructor function
  38305. */
  38306. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  38307. /**
  38308. * Returns a node constructor based on type name
  38309. * @param type defines the type name
  38310. * @param name defines the new node name
  38311. * @param scene defines the hosting scene
  38312. * @param options defines optional options to transmit to constructors
  38313. * @returns the new constructor or null
  38314. */
  38315. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  38316. /**
  38317. * Gets or sets the name of the node
  38318. */
  38319. name: string;
  38320. /**
  38321. * Gets or sets the id of the node
  38322. */
  38323. id: string;
  38324. /**
  38325. * Gets or sets the unique id of the node
  38326. */
  38327. uniqueId: number;
  38328. /**
  38329. * Gets or sets a string used to store user defined state for the node
  38330. */
  38331. state: string;
  38332. /**
  38333. * Gets or sets an object used to store user defined information for the node
  38334. */
  38335. metadata: any;
  38336. /**
  38337. * For internal use only. Please do not use.
  38338. */
  38339. reservedDataStore: any;
  38340. /**
  38341. * List of inspectable custom properties (used by the Inspector)
  38342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  38343. */
  38344. inspectableCustomProperties: IInspectable[];
  38345. private _doNotSerialize;
  38346. /**
  38347. * Gets or sets a boolean used to define if the node must be serialized
  38348. */
  38349. get doNotSerialize(): boolean;
  38350. set doNotSerialize(value: boolean);
  38351. /** @hidden */
  38352. _isDisposed: boolean;
  38353. /**
  38354. * Gets a list of Animations associated with the node
  38355. */
  38356. animations: import("babylonjs/Animations/animation").Animation[];
  38357. protected _ranges: {
  38358. [name: string]: Nullable<AnimationRange>;
  38359. };
  38360. /**
  38361. * Callback raised when the node is ready to be used
  38362. */
  38363. onReady: Nullable<(node: Node) => void>;
  38364. private _isEnabled;
  38365. private _isParentEnabled;
  38366. private _isReady;
  38367. /** @hidden */
  38368. _currentRenderId: number;
  38369. private _parentUpdateId;
  38370. /** @hidden */
  38371. _childUpdateId: number;
  38372. /** @hidden */
  38373. _waitingParentId: Nullable<string>;
  38374. /** @hidden */
  38375. _scene: Scene;
  38376. /** @hidden */
  38377. _cache: any;
  38378. private _parentNode;
  38379. private _children;
  38380. /** @hidden */
  38381. _worldMatrix: Matrix;
  38382. /** @hidden */
  38383. _worldMatrixDeterminant: number;
  38384. /** @hidden */
  38385. _worldMatrixDeterminantIsDirty: boolean;
  38386. /** @hidden */
  38387. private _sceneRootNodesIndex;
  38388. /**
  38389. * Gets a boolean indicating if the node has been disposed
  38390. * @returns true if the node was disposed
  38391. */
  38392. isDisposed(): boolean;
  38393. /**
  38394. * Gets or sets the parent of the node (without keeping the current position in the scene)
  38395. * @see https://doc.babylonjs.com/how_to/parenting
  38396. */
  38397. set parent(parent: Nullable<Node>);
  38398. get parent(): Nullable<Node>;
  38399. /** @hidden */
  38400. _addToSceneRootNodes(): void;
  38401. /** @hidden */
  38402. _removeFromSceneRootNodes(): void;
  38403. private _animationPropertiesOverride;
  38404. /**
  38405. * Gets or sets the animation properties override
  38406. */
  38407. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38408. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38409. /**
  38410. * Gets a string identifying the name of the class
  38411. * @returns "Node" string
  38412. */
  38413. getClassName(): string;
  38414. /** @hidden */
  38415. readonly _isNode: boolean;
  38416. /**
  38417. * An event triggered when the mesh is disposed
  38418. */
  38419. onDisposeObservable: Observable<Node>;
  38420. private _onDisposeObserver;
  38421. /**
  38422. * Sets a callback that will be raised when the node will be disposed
  38423. */
  38424. set onDispose(callback: () => void);
  38425. /**
  38426. * Creates a new Node
  38427. * @param name the name and id to be given to this node
  38428. * @param scene the scene this node will be added to
  38429. */
  38430. constructor(name: string, scene?: Nullable<Scene>);
  38431. /**
  38432. * Gets the scene of the node
  38433. * @returns a scene
  38434. */
  38435. getScene(): Scene;
  38436. /**
  38437. * Gets the engine of the node
  38438. * @returns a Engine
  38439. */
  38440. getEngine(): Engine;
  38441. private _behaviors;
  38442. /**
  38443. * Attach a behavior to the node
  38444. * @see https://doc.babylonjs.com/features/behaviour
  38445. * @param behavior defines the behavior to attach
  38446. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  38447. * @returns the current Node
  38448. */
  38449. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  38450. /**
  38451. * Remove an attached behavior
  38452. * @see https://doc.babylonjs.com/features/behaviour
  38453. * @param behavior defines the behavior to attach
  38454. * @returns the current Node
  38455. */
  38456. removeBehavior(behavior: Behavior<Node>): Node;
  38457. /**
  38458. * Gets the list of attached behaviors
  38459. * @see https://doc.babylonjs.com/features/behaviour
  38460. */
  38461. get behaviors(): Behavior<Node>[];
  38462. /**
  38463. * Gets an attached behavior by name
  38464. * @param name defines the name of the behavior to look for
  38465. * @see https://doc.babylonjs.com/features/behaviour
  38466. * @returns null if behavior was not found else the requested behavior
  38467. */
  38468. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38469. /**
  38470. * Returns the latest update of the World matrix
  38471. * @returns a Matrix
  38472. */
  38473. getWorldMatrix(): Matrix;
  38474. /** @hidden */
  38475. _getWorldMatrixDeterminant(): number;
  38476. /**
  38477. * Returns directly the latest state of the mesh World matrix.
  38478. * A Matrix is returned.
  38479. */
  38480. get worldMatrixFromCache(): Matrix;
  38481. /** @hidden */
  38482. _initCache(): void;
  38483. /** @hidden */
  38484. updateCache(force?: boolean): void;
  38485. /** @hidden */
  38486. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38487. /** @hidden */
  38488. _updateCache(ignoreParentClass?: boolean): void;
  38489. /** @hidden */
  38490. _isSynchronized(): boolean;
  38491. /** @hidden */
  38492. _markSyncedWithParent(): void;
  38493. /** @hidden */
  38494. isSynchronizedWithParent(): boolean;
  38495. /** @hidden */
  38496. isSynchronized(): boolean;
  38497. /**
  38498. * Is this node ready to be used/rendered
  38499. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38500. * @return true if the node is ready
  38501. */
  38502. isReady(completeCheck?: boolean): boolean;
  38503. /**
  38504. * Is this node enabled?
  38505. * 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
  38506. * @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
  38507. * @return whether this node (and its parent) is enabled
  38508. */
  38509. isEnabled(checkAncestors?: boolean): boolean;
  38510. /** @hidden */
  38511. protected _syncParentEnabledState(): void;
  38512. /**
  38513. * Set the enabled state of this node
  38514. * @param value defines the new enabled state
  38515. */
  38516. setEnabled(value: boolean): void;
  38517. /**
  38518. * Is this node a descendant of the given node?
  38519. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38520. * @param ancestor defines the parent node to inspect
  38521. * @returns a boolean indicating if this node is a descendant of the given node
  38522. */
  38523. isDescendantOf(ancestor: Node): boolean;
  38524. /** @hidden */
  38525. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38526. /**
  38527. * Will return all nodes that have this node as ascendant
  38528. * @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
  38529. * @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
  38530. * @return all children nodes of all types
  38531. */
  38532. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38533. /**
  38534. * Get all child-meshes of this node
  38535. * @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)
  38536. * @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
  38537. * @returns an array of AbstractMesh
  38538. */
  38539. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38540. /**
  38541. * Get all direct children of this node
  38542. * @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
  38543. * @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)
  38544. * @returns an array of Node
  38545. */
  38546. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38547. /** @hidden */
  38548. _setReady(state: boolean): void;
  38549. /**
  38550. * Get an animation by name
  38551. * @param name defines the name of the animation to look for
  38552. * @returns null if not found else the requested animation
  38553. */
  38554. getAnimationByName(name: string): Nullable<Animation>;
  38555. /**
  38556. * Creates an animation range for this node
  38557. * @param name defines the name of the range
  38558. * @param from defines the starting key
  38559. * @param to defines the end key
  38560. */
  38561. createAnimationRange(name: string, from: number, to: number): void;
  38562. /**
  38563. * Delete a specific animation range
  38564. * @param name defines the name of the range to delete
  38565. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38566. */
  38567. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38568. /**
  38569. * Get an animation range by name
  38570. * @param name defines the name of the animation range to look for
  38571. * @returns null if not found else the requested animation range
  38572. */
  38573. getAnimationRange(name: string): Nullable<AnimationRange>;
  38574. /**
  38575. * Gets the list of all animation ranges defined on this node
  38576. * @returns an array
  38577. */
  38578. getAnimationRanges(): Nullable<AnimationRange>[];
  38579. /**
  38580. * Will start the animation sequence
  38581. * @param name defines the range frames for animation sequence
  38582. * @param loop defines if the animation should loop (false by default)
  38583. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38584. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38585. * @returns the object created for this animation. If range does not exist, it will return null
  38586. */
  38587. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38588. /**
  38589. * Serialize animation ranges into a JSON compatible object
  38590. * @returns serialization object
  38591. */
  38592. serializeAnimationRanges(): any;
  38593. /**
  38594. * Computes the world matrix of the node
  38595. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38596. * @returns the world matrix
  38597. */
  38598. computeWorldMatrix(force?: boolean): Matrix;
  38599. /**
  38600. * Releases resources associated with this node.
  38601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38603. */
  38604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38605. /**
  38606. * Parse animation range data from a serialization object and store them into a given node
  38607. * @param node defines where to store the animation ranges
  38608. * @param parsedNode defines the serialization object to read data from
  38609. * @param scene defines the hosting scene
  38610. */
  38611. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38612. /**
  38613. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38614. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38615. * @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
  38616. * @returns the new bounding vectors
  38617. */
  38618. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38619. min: Vector3;
  38620. max: Vector3;
  38621. };
  38622. }
  38623. }
  38624. declare module "babylonjs/Animations/animation" {
  38625. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38626. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38627. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38628. import { Nullable } from "babylonjs/types";
  38629. import { Scene } from "babylonjs/scene";
  38630. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38631. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38632. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38633. import { Node } from "babylonjs/node";
  38634. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38635. import { Size } from "babylonjs/Maths/math.size";
  38636. import { Animatable } from "babylonjs/Animations/animatable";
  38637. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38638. /**
  38639. * @hidden
  38640. */
  38641. export class _IAnimationState {
  38642. key: number;
  38643. repeatCount: number;
  38644. workValue?: any;
  38645. loopMode?: number;
  38646. offsetValue?: any;
  38647. highLimitValue?: any;
  38648. }
  38649. /**
  38650. * Class used to store any kind of animation
  38651. */
  38652. export class Animation {
  38653. /**Name of the animation */
  38654. name: string;
  38655. /**Property to animate */
  38656. targetProperty: string;
  38657. /**The frames per second of the animation */
  38658. framePerSecond: number;
  38659. /**The data type of the animation */
  38660. dataType: number;
  38661. /**The loop mode of the animation */
  38662. loopMode?: number | undefined;
  38663. /**Specifies if blending should be enabled */
  38664. enableBlending?: boolean | undefined;
  38665. /**
  38666. * Use matrix interpolation instead of using direct key value when animating matrices
  38667. */
  38668. static AllowMatricesInterpolation: boolean;
  38669. /**
  38670. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38671. */
  38672. static AllowMatrixDecomposeForInterpolation: boolean;
  38673. /** Define the Url to load snippets */
  38674. static SnippetUrl: string;
  38675. /** Snippet ID if the animation was created from the snippet server */
  38676. snippetId: string;
  38677. /**
  38678. * Stores the key frames of the animation
  38679. */
  38680. private _keys;
  38681. /**
  38682. * Stores the easing function of the animation
  38683. */
  38684. private _easingFunction;
  38685. /**
  38686. * @hidden Internal use only
  38687. */
  38688. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38689. /**
  38690. * The set of event that will be linked to this animation
  38691. */
  38692. private _events;
  38693. /**
  38694. * Stores an array of target property paths
  38695. */
  38696. targetPropertyPath: string[];
  38697. /**
  38698. * Stores the blending speed of the animation
  38699. */
  38700. blendingSpeed: number;
  38701. /**
  38702. * Stores the animation ranges for the animation
  38703. */
  38704. private _ranges;
  38705. /**
  38706. * @hidden Internal use
  38707. */
  38708. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38709. /**
  38710. * Sets up an animation
  38711. * @param property The property to animate
  38712. * @param animationType The animation type to apply
  38713. * @param framePerSecond The frames per second of the animation
  38714. * @param easingFunction The easing function used in the animation
  38715. * @returns The created animation
  38716. */
  38717. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38718. /**
  38719. * Create and start an animation on a node
  38720. * @param name defines the name of the global animation that will be run on all nodes
  38721. * @param node defines the root node where the animation will take place
  38722. * @param targetProperty defines property to animate
  38723. * @param framePerSecond defines the number of frame per second yo use
  38724. * @param totalFrame defines the number of frames in total
  38725. * @param from defines the initial value
  38726. * @param to defines the final value
  38727. * @param loopMode defines which loop mode you want to use (off by default)
  38728. * @param easingFunction defines the easing function to use (linear by default)
  38729. * @param onAnimationEnd defines the callback to call when animation end
  38730. * @returns the animatable created for this animation
  38731. */
  38732. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38733. /**
  38734. * Create and start an animation on a node and its descendants
  38735. * @param name defines the name of the global animation that will be run on all nodes
  38736. * @param node defines the root node where the animation will take place
  38737. * @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
  38738. * @param targetProperty defines property to animate
  38739. * @param framePerSecond defines the number of frame per second to use
  38740. * @param totalFrame defines the number of frames in total
  38741. * @param from defines the initial value
  38742. * @param to defines the final value
  38743. * @param loopMode defines which loop mode you want to use (off by default)
  38744. * @param easingFunction defines the easing function to use (linear by default)
  38745. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38746. * @returns the list of animatables created for all nodes
  38747. * @example https://www.babylonjs-playground.com/#MH0VLI
  38748. */
  38749. 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[]>;
  38750. /**
  38751. * Creates a new animation, merges it with the existing animations and starts it
  38752. * @param name Name of the animation
  38753. * @param node Node which contains the scene that begins the animations
  38754. * @param targetProperty Specifies which property to animate
  38755. * @param framePerSecond The frames per second of the animation
  38756. * @param totalFrame The total number of frames
  38757. * @param from The frame at the beginning of the animation
  38758. * @param to The frame at the end of the animation
  38759. * @param loopMode Specifies the loop mode of the animation
  38760. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38761. * @param onAnimationEnd Callback to run once the animation is complete
  38762. * @returns Nullable animation
  38763. */
  38764. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38765. /**
  38766. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38767. * @param sourceAnimation defines the Animation containing keyframes to convert
  38768. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38769. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38770. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38771. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38772. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38773. */
  38774. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38775. /**
  38776. * Transition property of an host to the target Value
  38777. * @param property The property to transition
  38778. * @param targetValue The target Value of the property
  38779. * @param host The object where the property to animate belongs
  38780. * @param scene Scene used to run the animation
  38781. * @param frameRate Framerate (in frame/s) to use
  38782. * @param transition The transition type we want to use
  38783. * @param duration The duration of the animation, in milliseconds
  38784. * @param onAnimationEnd Callback trigger at the end of the animation
  38785. * @returns Nullable animation
  38786. */
  38787. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38788. /**
  38789. * Return the array of runtime animations currently using this animation
  38790. */
  38791. get runtimeAnimations(): RuntimeAnimation[];
  38792. /**
  38793. * Specifies if any of the runtime animations are currently running
  38794. */
  38795. get hasRunningRuntimeAnimations(): boolean;
  38796. /**
  38797. * Initializes the animation
  38798. * @param name Name of the animation
  38799. * @param targetProperty Property to animate
  38800. * @param framePerSecond The frames per second of the animation
  38801. * @param dataType The data type of the animation
  38802. * @param loopMode The loop mode of the animation
  38803. * @param enableBlending Specifies if blending should be enabled
  38804. */
  38805. constructor(
  38806. /**Name of the animation */
  38807. name: string,
  38808. /**Property to animate */
  38809. targetProperty: string,
  38810. /**The frames per second of the animation */
  38811. framePerSecond: number,
  38812. /**The data type of the animation */
  38813. dataType: number,
  38814. /**The loop mode of the animation */
  38815. loopMode?: number | undefined,
  38816. /**Specifies if blending should be enabled */
  38817. enableBlending?: boolean | undefined);
  38818. /**
  38819. * Converts the animation to a string
  38820. * @param fullDetails support for multiple levels of logging within scene loading
  38821. * @returns String form of the animation
  38822. */
  38823. toString(fullDetails?: boolean): string;
  38824. /**
  38825. * Add an event to this animation
  38826. * @param event Event to add
  38827. */
  38828. addEvent(event: AnimationEvent): void;
  38829. /**
  38830. * Remove all events found at the given frame
  38831. * @param frame The frame to remove events from
  38832. */
  38833. removeEvents(frame: number): void;
  38834. /**
  38835. * Retrieves all the events from the animation
  38836. * @returns Events from the animation
  38837. */
  38838. getEvents(): AnimationEvent[];
  38839. /**
  38840. * Creates an animation range
  38841. * @param name Name of the animation range
  38842. * @param from Starting frame of the animation range
  38843. * @param to Ending frame of the animation
  38844. */
  38845. createRange(name: string, from: number, to: number): void;
  38846. /**
  38847. * Deletes an animation range by name
  38848. * @param name Name of the animation range to delete
  38849. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38850. */
  38851. deleteRange(name: string, deleteFrames?: boolean): void;
  38852. /**
  38853. * Gets the animation range by name, or null if not defined
  38854. * @param name Name of the animation range
  38855. * @returns Nullable animation range
  38856. */
  38857. getRange(name: string): Nullable<AnimationRange>;
  38858. /**
  38859. * Gets the key frames from the animation
  38860. * @returns The key frames of the animation
  38861. */
  38862. getKeys(): Array<IAnimationKey>;
  38863. /**
  38864. * Gets the highest frame rate of the animation
  38865. * @returns Highest frame rate of the animation
  38866. */
  38867. getHighestFrame(): number;
  38868. /**
  38869. * Gets the easing function of the animation
  38870. * @returns Easing function of the animation
  38871. */
  38872. getEasingFunction(): IEasingFunction;
  38873. /**
  38874. * Sets the easing function of the animation
  38875. * @param easingFunction A custom mathematical formula for animation
  38876. */
  38877. setEasingFunction(easingFunction: EasingFunction): void;
  38878. /**
  38879. * Interpolates a scalar linearly
  38880. * @param startValue Start value of the animation curve
  38881. * @param endValue End value of the animation curve
  38882. * @param gradient Scalar amount to interpolate
  38883. * @returns Interpolated scalar value
  38884. */
  38885. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38886. /**
  38887. * Interpolates a scalar cubically
  38888. * @param startValue Start value of the animation curve
  38889. * @param outTangent End tangent of the animation
  38890. * @param endValue End value of the animation curve
  38891. * @param inTangent Start tangent of the animation curve
  38892. * @param gradient Scalar amount to interpolate
  38893. * @returns Interpolated scalar value
  38894. */
  38895. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38896. /**
  38897. * Interpolates a quaternion using a spherical linear interpolation
  38898. * @param startValue Start value of the animation curve
  38899. * @param endValue End value of the animation curve
  38900. * @param gradient Scalar amount to interpolate
  38901. * @returns Interpolated quaternion value
  38902. */
  38903. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38904. /**
  38905. * Interpolates a quaternion cubically
  38906. * @param startValue Start value of the animation curve
  38907. * @param outTangent End tangent of the animation curve
  38908. * @param endValue End value of the animation curve
  38909. * @param inTangent Start tangent of the animation curve
  38910. * @param gradient Scalar amount to interpolate
  38911. * @returns Interpolated quaternion value
  38912. */
  38913. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38914. /**
  38915. * Interpolates a Vector3 linearl
  38916. * @param startValue Start value of the animation curve
  38917. * @param endValue End value of the animation curve
  38918. * @param gradient Scalar amount to interpolate
  38919. * @returns Interpolated scalar value
  38920. */
  38921. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38922. /**
  38923. * Interpolates a Vector3 cubically
  38924. * @param startValue Start value of the animation curve
  38925. * @param outTangent End tangent of the animation
  38926. * @param endValue End value of the animation curve
  38927. * @param inTangent Start tangent of the animation curve
  38928. * @param gradient Scalar amount to interpolate
  38929. * @returns InterpolatedVector3 value
  38930. */
  38931. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38932. /**
  38933. * Interpolates a Vector2 linearly
  38934. * @param startValue Start value of the animation curve
  38935. * @param endValue End value of the animation curve
  38936. * @param gradient Scalar amount to interpolate
  38937. * @returns Interpolated Vector2 value
  38938. */
  38939. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38940. /**
  38941. * Interpolates a Vector2 cubically
  38942. * @param startValue Start value of the animation curve
  38943. * @param outTangent End tangent of the animation
  38944. * @param endValue End value of the animation curve
  38945. * @param inTangent Start tangent of the animation curve
  38946. * @param gradient Scalar amount to interpolate
  38947. * @returns Interpolated Vector2 value
  38948. */
  38949. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38950. /**
  38951. * Interpolates a size linearly
  38952. * @param startValue Start value of the animation curve
  38953. * @param endValue End value of the animation curve
  38954. * @param gradient Scalar amount to interpolate
  38955. * @returns Interpolated Size value
  38956. */
  38957. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38958. /**
  38959. * Interpolates a Color3 linearly
  38960. * @param startValue Start value of the animation curve
  38961. * @param endValue End value of the animation curve
  38962. * @param gradient Scalar amount to interpolate
  38963. * @returns Interpolated Color3 value
  38964. */
  38965. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38966. /**
  38967. * Interpolates a Color4 linearly
  38968. * @param startValue Start value of the animation curve
  38969. * @param endValue End value of the animation curve
  38970. * @param gradient Scalar amount to interpolate
  38971. * @returns Interpolated Color3 value
  38972. */
  38973. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38974. /**
  38975. * @hidden Internal use only
  38976. */
  38977. _getKeyValue(value: any): any;
  38978. /**
  38979. * @hidden Internal use only
  38980. */
  38981. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38982. /**
  38983. * Defines the function to use to interpolate matrices
  38984. * @param startValue defines the start matrix
  38985. * @param endValue defines the end matrix
  38986. * @param gradient defines the gradient between both matrices
  38987. * @param result defines an optional target matrix where to store the interpolation
  38988. * @returns the interpolated matrix
  38989. */
  38990. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38991. /**
  38992. * Makes a copy of the animation
  38993. * @returns Cloned animation
  38994. */
  38995. clone(): Animation;
  38996. /**
  38997. * Sets the key frames of the animation
  38998. * @param values The animation key frames to set
  38999. */
  39000. setKeys(values: Array<IAnimationKey>): void;
  39001. /**
  39002. * Serializes the animation to an object
  39003. * @returns Serialized object
  39004. */
  39005. serialize(): any;
  39006. /**
  39007. * Float animation type
  39008. */
  39009. static readonly ANIMATIONTYPE_FLOAT: number;
  39010. /**
  39011. * Vector3 animation type
  39012. */
  39013. static readonly ANIMATIONTYPE_VECTOR3: number;
  39014. /**
  39015. * Quaternion animation type
  39016. */
  39017. static readonly ANIMATIONTYPE_QUATERNION: number;
  39018. /**
  39019. * Matrix animation type
  39020. */
  39021. static readonly ANIMATIONTYPE_MATRIX: number;
  39022. /**
  39023. * Color3 animation type
  39024. */
  39025. static readonly ANIMATIONTYPE_COLOR3: number;
  39026. /**
  39027. * Color3 animation type
  39028. */
  39029. static readonly ANIMATIONTYPE_COLOR4: number;
  39030. /**
  39031. * Vector2 animation type
  39032. */
  39033. static readonly ANIMATIONTYPE_VECTOR2: number;
  39034. /**
  39035. * Size animation type
  39036. */
  39037. static readonly ANIMATIONTYPE_SIZE: number;
  39038. /**
  39039. * Relative Loop Mode
  39040. */
  39041. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  39042. /**
  39043. * Cycle Loop Mode
  39044. */
  39045. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  39046. /**
  39047. * Constant Loop Mode
  39048. */
  39049. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  39050. /** @hidden */
  39051. static _UniversalLerp(left: any, right: any, amount: number): any;
  39052. /**
  39053. * Parses an animation object and creates an animation
  39054. * @param parsedAnimation Parsed animation object
  39055. * @returns Animation object
  39056. */
  39057. static Parse(parsedAnimation: any): Animation;
  39058. /**
  39059. * Appends the serialized animations from the source animations
  39060. * @param source Source containing the animations
  39061. * @param destination Target to store the animations
  39062. */
  39063. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39064. /**
  39065. * Creates a new animation or an array of animations from a snippet saved in a remote file
  39066. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  39067. * @param url defines the url to load from
  39068. * @returns a promise that will resolve to the new animation or an array of animations
  39069. */
  39070. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  39071. /**
  39072. * Creates an animation or an array of animations from a snippet saved by the Inspector
  39073. * @param snippetId defines the snippet to load
  39074. * @returns a promise that will resolve to the new animation or a new array of animations
  39075. */
  39076. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  39077. }
  39078. }
  39079. declare module "babylonjs/Animations/animatable.interface" {
  39080. import { Nullable } from "babylonjs/types";
  39081. import { Animation } from "babylonjs/Animations/animation";
  39082. /**
  39083. * Interface containing an array of animations
  39084. */
  39085. export interface IAnimatable {
  39086. /**
  39087. * Array of animations
  39088. */
  39089. animations: Nullable<Array<Animation>>;
  39090. }
  39091. }
  39092. declare module "babylonjs/Misc/decorators" {
  39093. import { Nullable } from "babylonjs/types";
  39094. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39095. import { Scene } from "babylonjs/scene";
  39096. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39097. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39098. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39100. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  39101. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39102. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39103. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39104. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39105. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39106. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39107. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39108. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39109. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39110. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39111. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39112. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39113. /**
  39114. * Decorator used to define property that can be serialized as reference to a camera
  39115. * @param sourceName defines the name of the property to decorate
  39116. */
  39117. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39118. /**
  39119. * Class used to help serialization objects
  39120. */
  39121. export class SerializationHelper {
  39122. /** @hidden */
  39123. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  39124. /** @hidden */
  39125. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  39126. /** @hidden */
  39127. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  39128. /** @hidden */
  39129. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  39130. /**
  39131. * Appends the serialized animations from the source animations
  39132. * @param source Source containing the animations
  39133. * @param destination Target to store the animations
  39134. */
  39135. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39136. /**
  39137. * Static function used to serialized a specific entity
  39138. * @param entity defines the entity to serialize
  39139. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  39140. * @returns a JSON compatible object representing the serialization of the entity
  39141. */
  39142. static Serialize<T>(entity: T, serializationObject?: any): any;
  39143. /**
  39144. * Creates a new entity from a serialization data object
  39145. * @param creationFunction defines a function used to instanciated the new entity
  39146. * @param source defines the source serialization data
  39147. * @param scene defines the hosting scene
  39148. * @param rootUrl defines the root url for resources
  39149. * @returns a new entity
  39150. */
  39151. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  39152. /**
  39153. * Clones an object
  39154. * @param creationFunction defines the function used to instanciate the new object
  39155. * @param source defines the source object
  39156. * @returns the cloned object
  39157. */
  39158. static Clone<T>(creationFunction: () => T, source: T): T;
  39159. /**
  39160. * Instanciates a new object based on a source one (some data will be shared between both object)
  39161. * @param creationFunction defines the function used to instanciate the new object
  39162. * @param source defines the source object
  39163. * @returns the new object
  39164. */
  39165. static Instanciate<T>(creationFunction: () => T, source: T): T;
  39166. }
  39167. }
  39168. declare module "babylonjs/Cameras/camera" {
  39169. import { SmartArray } from "babylonjs/Misc/smartArray";
  39170. import { Observable } from "babylonjs/Misc/observable";
  39171. import { Nullable } from "babylonjs/types";
  39172. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39173. import { Scene } from "babylonjs/scene";
  39174. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39175. import { Node } from "babylonjs/node";
  39176. import { Mesh } from "babylonjs/Meshes/mesh";
  39177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39178. import { ICullable } from "babylonjs/Culling/boundingInfo";
  39179. import { Viewport } from "babylonjs/Maths/math.viewport";
  39180. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39181. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39183. import { Ray } from "babylonjs/Culling/ray";
  39184. /**
  39185. * This is the base class of all the camera used in the application.
  39186. * @see https://doc.babylonjs.com/features/cameras
  39187. */
  39188. export class Camera extends Node {
  39189. /** @hidden */
  39190. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  39191. /**
  39192. * This is the default projection mode used by the cameras.
  39193. * It helps recreating a feeling of perspective and better appreciate depth.
  39194. * This is the best way to simulate real life cameras.
  39195. */
  39196. static readonly PERSPECTIVE_CAMERA: number;
  39197. /**
  39198. * This helps creating camera with an orthographic mode.
  39199. * 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.
  39200. */
  39201. static readonly ORTHOGRAPHIC_CAMERA: number;
  39202. /**
  39203. * This is the default FOV mode for perspective cameras.
  39204. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  39205. */
  39206. static readonly FOVMODE_VERTICAL_FIXED: number;
  39207. /**
  39208. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  39209. */
  39210. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  39211. /**
  39212. * This specifies ther is no need for a camera rig.
  39213. * Basically only one eye is rendered corresponding to the camera.
  39214. */
  39215. static readonly RIG_MODE_NONE: number;
  39216. /**
  39217. * Simulates a camera Rig with one blue eye and one red eye.
  39218. * This can be use with 3d blue and red glasses.
  39219. */
  39220. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  39221. /**
  39222. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  39223. */
  39224. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  39225. /**
  39226. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  39227. */
  39228. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  39229. /**
  39230. * Defines that both eyes of the camera will be rendered over under each other.
  39231. */
  39232. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  39233. /**
  39234. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  39235. */
  39236. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  39237. /**
  39238. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  39239. */
  39240. static readonly RIG_MODE_VR: number;
  39241. /**
  39242. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  39243. */
  39244. static readonly RIG_MODE_WEBVR: number;
  39245. /**
  39246. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  39247. */
  39248. static readonly RIG_MODE_CUSTOM: number;
  39249. /**
  39250. * Defines if by default attaching controls should prevent the default javascript event to continue.
  39251. */
  39252. static ForceAttachControlToAlwaysPreventDefault: boolean;
  39253. /**
  39254. * Define the input manager associated with the camera.
  39255. */
  39256. inputs: CameraInputsManager<Camera>;
  39257. /** @hidden */
  39258. _position: Vector3;
  39259. /**
  39260. * Define the current local position of the camera in the scene
  39261. */
  39262. get position(): Vector3;
  39263. set position(newPosition: Vector3);
  39264. protected _upVector: Vector3;
  39265. /**
  39266. * The vector the camera should consider as up.
  39267. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  39268. */
  39269. set upVector(vec: Vector3);
  39270. get upVector(): Vector3;
  39271. /**
  39272. * Define the current limit on the left side for an orthographic camera
  39273. * In scene unit
  39274. */
  39275. orthoLeft: Nullable<number>;
  39276. /**
  39277. * Define the current limit on the right side for an orthographic camera
  39278. * In scene unit
  39279. */
  39280. orthoRight: Nullable<number>;
  39281. /**
  39282. * Define the current limit on the bottom side for an orthographic camera
  39283. * In scene unit
  39284. */
  39285. orthoBottom: Nullable<number>;
  39286. /**
  39287. * Define the current limit on the top side for an orthographic camera
  39288. * In scene unit
  39289. */
  39290. orthoTop: Nullable<number>;
  39291. /**
  39292. * Field Of View is set in Radians. (default is 0.8)
  39293. */
  39294. fov: number;
  39295. /**
  39296. * Define the minimum distance the camera can see from.
  39297. * This is important to note that the depth buffer are not infinite and the closer it starts
  39298. * the more your scene might encounter depth fighting issue.
  39299. */
  39300. minZ: number;
  39301. /**
  39302. * Define the maximum distance the camera can see to.
  39303. * This is important to note that the depth buffer are not infinite and the further it end
  39304. * the more your scene might encounter depth fighting issue.
  39305. */
  39306. maxZ: number;
  39307. /**
  39308. * Define the default inertia of the camera.
  39309. * This helps giving a smooth feeling to the camera movement.
  39310. */
  39311. inertia: number;
  39312. /**
  39313. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  39314. */
  39315. mode: number;
  39316. /**
  39317. * Define whether the camera is intermediate.
  39318. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  39319. */
  39320. isIntermediate: boolean;
  39321. /**
  39322. * Define the viewport of the camera.
  39323. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  39324. */
  39325. viewport: Viewport;
  39326. /**
  39327. * Restricts the camera to viewing objects with the same layerMask.
  39328. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  39329. */
  39330. layerMask: number;
  39331. /**
  39332. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  39333. */
  39334. fovMode: number;
  39335. /**
  39336. * Rig mode of the camera.
  39337. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  39338. * This is normally controlled byt the camera themselves as internal use.
  39339. */
  39340. cameraRigMode: number;
  39341. /**
  39342. * Defines the distance between both "eyes" in case of a RIG
  39343. */
  39344. interaxialDistance: number;
  39345. /**
  39346. * Defines if stereoscopic rendering is done side by side or over under.
  39347. */
  39348. isStereoscopicSideBySide: boolean;
  39349. /**
  39350. * 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
  39351. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  39352. * else in the scene. (Eg. security camera)
  39353. *
  39354. * 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)
  39355. */
  39356. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  39357. /**
  39358. * When set, the camera will render to this render target instead of the default canvas
  39359. *
  39360. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  39361. */
  39362. outputRenderTarget: Nullable<RenderTargetTexture>;
  39363. /**
  39364. * Observable triggered when the camera view matrix has changed.
  39365. */
  39366. onViewMatrixChangedObservable: Observable<Camera>;
  39367. /**
  39368. * Observable triggered when the camera Projection matrix has changed.
  39369. */
  39370. onProjectionMatrixChangedObservable: Observable<Camera>;
  39371. /**
  39372. * Observable triggered when the inputs have been processed.
  39373. */
  39374. onAfterCheckInputsObservable: Observable<Camera>;
  39375. /**
  39376. * Observable triggered when reset has been called and applied to the camera.
  39377. */
  39378. onRestoreStateObservable: Observable<Camera>;
  39379. /**
  39380. * Is this camera a part of a rig system?
  39381. */
  39382. isRigCamera: boolean;
  39383. /**
  39384. * If isRigCamera set to true this will be set with the parent camera.
  39385. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  39386. */
  39387. rigParent?: Camera;
  39388. /** @hidden */
  39389. _cameraRigParams: any;
  39390. /** @hidden */
  39391. _rigCameras: Camera[];
  39392. /** @hidden */
  39393. _rigPostProcess: Nullable<PostProcess>;
  39394. protected _webvrViewMatrix: Matrix;
  39395. /** @hidden */
  39396. _skipRendering: boolean;
  39397. /** @hidden */
  39398. _projectionMatrix: Matrix;
  39399. /** @hidden */
  39400. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  39401. /** @hidden */
  39402. _activeMeshes: SmartArray<AbstractMesh>;
  39403. protected _globalPosition: Vector3;
  39404. /** @hidden */
  39405. _computedViewMatrix: Matrix;
  39406. private _doNotComputeProjectionMatrix;
  39407. private _transformMatrix;
  39408. private _frustumPlanes;
  39409. private _refreshFrustumPlanes;
  39410. private _storedFov;
  39411. private _stateStored;
  39412. /**
  39413. * Instantiates a new camera object.
  39414. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  39415. * @see https://doc.babylonjs.com/features/cameras
  39416. * @param name Defines the name of the camera in the scene
  39417. * @param position Defines the position of the camera
  39418. * @param scene Defines the scene the camera belongs too
  39419. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  39420. */
  39421. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39422. /**
  39423. * Store current camera state (fov, position, etc..)
  39424. * @returns the camera
  39425. */
  39426. storeState(): Camera;
  39427. /**
  39428. * Restores the camera state values if it has been stored. You must call storeState() first
  39429. */
  39430. protected _restoreStateValues(): boolean;
  39431. /**
  39432. * Restored camera state. You must call storeState() first.
  39433. * @returns true if restored and false otherwise
  39434. */
  39435. restoreState(): boolean;
  39436. /**
  39437. * Gets the class name of the camera.
  39438. * @returns the class name
  39439. */
  39440. getClassName(): string;
  39441. /** @hidden */
  39442. readonly _isCamera: boolean;
  39443. /**
  39444. * Gets a string representation of the camera useful for debug purpose.
  39445. * @param fullDetails Defines that a more verboe level of logging is required
  39446. * @returns the string representation
  39447. */
  39448. toString(fullDetails?: boolean): string;
  39449. /**
  39450. * Gets the current world space position of the camera.
  39451. */
  39452. get globalPosition(): Vector3;
  39453. /**
  39454. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  39455. * @returns the active meshe list
  39456. */
  39457. getActiveMeshes(): SmartArray<AbstractMesh>;
  39458. /**
  39459. * Check whether a mesh is part of the current active mesh list of the camera
  39460. * @param mesh Defines the mesh to check
  39461. * @returns true if active, false otherwise
  39462. */
  39463. isActiveMesh(mesh: Mesh): boolean;
  39464. /**
  39465. * Is this camera ready to be used/rendered
  39466. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  39467. * @return true if the camera is ready
  39468. */
  39469. isReady(completeCheck?: boolean): boolean;
  39470. /** @hidden */
  39471. _initCache(): void;
  39472. /** @hidden */
  39473. _updateCache(ignoreParentClass?: boolean): void;
  39474. /** @hidden */
  39475. _isSynchronized(): boolean;
  39476. /** @hidden */
  39477. _isSynchronizedViewMatrix(): boolean;
  39478. /** @hidden */
  39479. _isSynchronizedProjectionMatrix(): boolean;
  39480. /**
  39481. * Attach the input controls to a specific dom element to get the input from.
  39482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39483. */
  39484. attachControl(noPreventDefault?: boolean): void;
  39485. /**
  39486. * Attach the input controls to a specific dom element to get the input from.
  39487. * @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
  39488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39489. * BACK COMPAT SIGNATURE ONLY.
  39490. */
  39491. attachControl(ignored: any, noPreventDefault?: boolean): void;
  39492. /**
  39493. * Detach the current controls from the specified dom element.
  39494. */
  39495. detachControl(): void;
  39496. /**
  39497. * Detach the current controls from the specified dom element.
  39498. * @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
  39499. */
  39500. detachControl(ignored: any): void;
  39501. /**
  39502. * Update the camera state according to the different inputs gathered during the frame.
  39503. */
  39504. update(): void;
  39505. /** @hidden */
  39506. _checkInputs(): void;
  39507. /** @hidden */
  39508. get rigCameras(): Camera[];
  39509. /**
  39510. * Gets the post process used by the rig cameras
  39511. */
  39512. get rigPostProcess(): Nullable<PostProcess>;
  39513. /**
  39514. * Internal, gets the first post proces.
  39515. * @returns the first post process to be run on this camera.
  39516. */
  39517. _getFirstPostProcess(): Nullable<PostProcess>;
  39518. private _cascadePostProcessesToRigCams;
  39519. /**
  39520. * Attach a post process to the camera.
  39521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39522. * @param postProcess The post process to attach to the camera
  39523. * @param insertAt The position of the post process in case several of them are in use in the scene
  39524. * @returns the position the post process has been inserted at
  39525. */
  39526. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  39527. /**
  39528. * Detach a post process to the camera.
  39529. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39530. * @param postProcess The post process to detach from the camera
  39531. */
  39532. detachPostProcess(postProcess: PostProcess): void;
  39533. /**
  39534. * Gets the current world matrix of the camera
  39535. */
  39536. getWorldMatrix(): Matrix;
  39537. /** @hidden */
  39538. _getViewMatrix(): Matrix;
  39539. /**
  39540. * Gets the current view matrix of the camera.
  39541. * @param force forces the camera to recompute the matrix without looking at the cached state
  39542. * @returns the view matrix
  39543. */
  39544. getViewMatrix(force?: boolean): Matrix;
  39545. /**
  39546. * Freeze the projection matrix.
  39547. * It will prevent the cache check of the camera projection compute and can speed up perf
  39548. * if no parameter of the camera are meant to change
  39549. * @param projection Defines manually a projection if necessary
  39550. */
  39551. freezeProjectionMatrix(projection?: Matrix): void;
  39552. /**
  39553. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  39554. */
  39555. unfreezeProjectionMatrix(): void;
  39556. /**
  39557. * Gets the current projection matrix of the camera.
  39558. * @param force forces the camera to recompute the matrix without looking at the cached state
  39559. * @returns the projection matrix
  39560. */
  39561. getProjectionMatrix(force?: boolean): Matrix;
  39562. /**
  39563. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  39564. * @returns a Matrix
  39565. */
  39566. getTransformationMatrix(): Matrix;
  39567. private _updateFrustumPlanes;
  39568. /**
  39569. * Checks if a cullable object (mesh...) is in the camera frustum
  39570. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  39571. * @param target The object to check
  39572. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  39573. * @returns true if the object is in frustum otherwise false
  39574. */
  39575. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  39576. /**
  39577. * Checks if a cullable object (mesh...) is in the camera frustum
  39578. * Unlike isInFrustum this cheks the full bounding box
  39579. * @param target The object to check
  39580. * @returns true if the object is in frustum otherwise false
  39581. */
  39582. isCompletelyInFrustum(target: ICullable): boolean;
  39583. /**
  39584. * Gets a ray in the forward direction from the camera.
  39585. * @param length Defines the length of the ray to create
  39586. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39587. * @param origin Defines the start point of the ray which defaults to the camera position
  39588. * @returns the forward ray
  39589. */
  39590. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39591. /**
  39592. * Gets a ray in the forward direction from the camera.
  39593. * @param refRay the ray to (re)use when setting the values
  39594. * @param length Defines the length of the ray to create
  39595. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39596. * @param origin Defines the start point of the ray which defaults to the camera position
  39597. * @returns the forward ray
  39598. */
  39599. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39600. /**
  39601. * Releases resources associated with this node.
  39602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39604. */
  39605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  39606. /** @hidden */
  39607. _isLeftCamera: boolean;
  39608. /**
  39609. * Gets the left camera of a rig setup in case of Rigged Camera
  39610. */
  39611. get isLeftCamera(): boolean;
  39612. /** @hidden */
  39613. _isRightCamera: boolean;
  39614. /**
  39615. * Gets the right camera of a rig setup in case of Rigged Camera
  39616. */
  39617. get isRightCamera(): boolean;
  39618. /**
  39619. * Gets the left camera of a rig setup in case of Rigged Camera
  39620. */
  39621. get leftCamera(): Nullable<FreeCamera>;
  39622. /**
  39623. * Gets the right camera of a rig setup in case of Rigged Camera
  39624. */
  39625. get rightCamera(): Nullable<FreeCamera>;
  39626. /**
  39627. * Gets the left camera target of a rig setup in case of Rigged Camera
  39628. * @returns the target position
  39629. */
  39630. getLeftTarget(): Nullable<Vector3>;
  39631. /**
  39632. * Gets the right camera target of a rig setup in case of Rigged Camera
  39633. * @returns the target position
  39634. */
  39635. getRightTarget(): Nullable<Vector3>;
  39636. /**
  39637. * @hidden
  39638. */
  39639. setCameraRigMode(mode: number, rigParams: any): void;
  39640. /** @hidden */
  39641. static _setStereoscopicRigMode(camera: Camera): void;
  39642. /** @hidden */
  39643. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  39644. /** @hidden */
  39645. static _setVRRigMode(camera: Camera, rigParams: any): void;
  39646. /** @hidden */
  39647. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  39648. /** @hidden */
  39649. _getVRProjectionMatrix(): Matrix;
  39650. protected _updateCameraRotationMatrix(): void;
  39651. protected _updateWebVRCameraRotationMatrix(): void;
  39652. /**
  39653. * This function MUST be overwritten by the different WebVR cameras available.
  39654. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39655. * @hidden
  39656. */
  39657. _getWebVRProjectionMatrix(): Matrix;
  39658. /**
  39659. * This function MUST be overwritten by the different WebVR cameras available.
  39660. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39661. * @hidden
  39662. */
  39663. _getWebVRViewMatrix(): Matrix;
  39664. /** @hidden */
  39665. setCameraRigParameter(name: string, value: any): void;
  39666. /**
  39667. * needs to be overridden by children so sub has required properties to be copied
  39668. * @hidden
  39669. */
  39670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  39671. /**
  39672. * May need to be overridden by children
  39673. * @hidden
  39674. */
  39675. _updateRigCameras(): void;
  39676. /** @hidden */
  39677. _setupInputs(): void;
  39678. /**
  39679. * Serialiaze the camera setup to a json represention
  39680. * @returns the JSON representation
  39681. */
  39682. serialize(): any;
  39683. /**
  39684. * Clones the current camera.
  39685. * @param name The cloned camera name
  39686. * @returns the cloned camera
  39687. */
  39688. clone(name: string): Camera;
  39689. /**
  39690. * Gets the direction of the camera relative to a given local axis.
  39691. * @param localAxis Defines the reference axis to provide a relative direction.
  39692. * @return the direction
  39693. */
  39694. getDirection(localAxis: Vector3): Vector3;
  39695. /**
  39696. * Returns the current camera absolute rotation
  39697. */
  39698. get absoluteRotation(): Quaternion;
  39699. /**
  39700. * Gets the direction of the camera relative to a given local axis into a passed vector.
  39701. * @param localAxis Defines the reference axis to provide a relative direction.
  39702. * @param result Defines the vector to store the result in
  39703. */
  39704. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  39705. /**
  39706. * Gets a camera constructor for a given camera type
  39707. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  39708. * @param name The name of the camera the result will be able to instantiate
  39709. * @param scene The scene the result will construct the camera in
  39710. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  39711. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  39712. * @returns a factory method to construc the camera
  39713. */
  39714. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  39715. /**
  39716. * Compute the world matrix of the camera.
  39717. * @returns the camera world matrix
  39718. */
  39719. computeWorldMatrix(): Matrix;
  39720. /**
  39721. * Parse a JSON and creates the camera from the parsed information
  39722. * @param parsedCamera The JSON to parse
  39723. * @param scene The scene to instantiate the camera in
  39724. * @returns the newly constructed camera
  39725. */
  39726. static Parse(parsedCamera: any, scene: Scene): Camera;
  39727. }
  39728. }
  39729. declare module "babylonjs/PostProcesses/postProcessManager" {
  39730. import { Nullable } from "babylonjs/types";
  39731. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39732. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39733. import { Scene } from "babylonjs/scene";
  39734. /**
  39735. * PostProcessManager is used to manage one or more post processes or post process pipelines
  39736. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  39737. */
  39738. export class PostProcessManager {
  39739. private _scene;
  39740. private _indexBuffer;
  39741. private _vertexBuffers;
  39742. /**
  39743. * Creates a new instance PostProcess
  39744. * @param scene The scene that the post process is associated with.
  39745. */
  39746. constructor(scene: Scene);
  39747. private _prepareBuffers;
  39748. private _buildIndexBuffer;
  39749. /**
  39750. * Rebuilds the vertex buffers of the manager.
  39751. * @hidden
  39752. */
  39753. _rebuild(): void;
  39754. /**
  39755. * Prepares a frame to be run through a post process.
  39756. * @param sourceTexture The input texture to the post procesess. (default: null)
  39757. * @param postProcesses An array of post processes to be run. (default: null)
  39758. * @returns True if the post processes were able to be run.
  39759. * @hidden
  39760. */
  39761. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39762. /**
  39763. * Manually render a set of post processes to a texture.
  39764. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39765. * @param postProcesses An array of post processes to be run.
  39766. * @param targetTexture The target texture to render to.
  39767. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39768. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39769. * @param lodLevel defines which lod of the texture to render to
  39770. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39771. */
  39772. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39773. /**
  39774. * Finalize the result of the output of the postprocesses.
  39775. * @param doNotPresent If true the result will not be displayed to the screen.
  39776. * @param targetTexture The target texture to render to.
  39777. * @param faceIndex The index of the face to bind the target texture to.
  39778. * @param postProcesses The array of post processes to render.
  39779. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39780. * @hidden
  39781. */
  39782. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39783. /**
  39784. * Disposes of the post process manager.
  39785. */
  39786. dispose(): void;
  39787. }
  39788. }
  39789. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39790. import { Observable } from "babylonjs/Misc/observable";
  39791. import { SmartArray } from "babylonjs/Misc/smartArray";
  39792. import { Nullable, Immutable } from "babylonjs/types";
  39793. import { Camera } from "babylonjs/Cameras/camera";
  39794. import { Scene } from "babylonjs/scene";
  39795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39796. import { Color4 } from "babylonjs/Maths/math.color";
  39797. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39801. import { Texture } from "babylonjs/Materials/Textures/texture";
  39802. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39803. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39804. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39805. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39806. import { Engine } from "babylonjs/Engines/engine";
  39807. /**
  39808. * This Helps creating a texture that will be created from a camera in your scene.
  39809. * It is basically a dynamic texture that could be used to create special effects for instance.
  39810. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39811. */
  39812. export class RenderTargetTexture extends Texture {
  39813. /**
  39814. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39815. */
  39816. static readonly REFRESHRATE_RENDER_ONCE: number;
  39817. /**
  39818. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39819. */
  39820. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39821. /**
  39822. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39823. * the central point of your effect and can save a lot of performances.
  39824. */
  39825. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39826. /**
  39827. * Use this predicate to dynamically define the list of mesh you want to render.
  39828. * If set, the renderList property will be overwritten.
  39829. */
  39830. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39831. private _renderList;
  39832. /**
  39833. * Use this list to define the list of mesh you want to render.
  39834. */
  39835. get renderList(): Nullable<Array<AbstractMesh>>;
  39836. set renderList(value: Nullable<Array<AbstractMesh>>);
  39837. /**
  39838. * Use this function to overload the renderList array at rendering time.
  39839. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39840. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39841. * the cube (if the RTT is a cube, else layerOrFace=0).
  39842. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39843. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39844. * hold dummy elements!
  39845. */
  39846. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39847. private _hookArray;
  39848. /**
  39849. * Define if particles should be rendered in your texture.
  39850. */
  39851. renderParticles: boolean;
  39852. /**
  39853. * Define if sprites should be rendered in your texture.
  39854. */
  39855. renderSprites: boolean;
  39856. /**
  39857. * Define the camera used to render the texture.
  39858. */
  39859. activeCamera: Nullable<Camera>;
  39860. /**
  39861. * Override the mesh isReady function with your own one.
  39862. */
  39863. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39864. /**
  39865. * Override the render function of the texture with your own one.
  39866. */
  39867. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39868. /**
  39869. * Define if camera post processes should be use while rendering the texture.
  39870. */
  39871. useCameraPostProcesses: boolean;
  39872. /**
  39873. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39874. */
  39875. ignoreCameraViewport: boolean;
  39876. private _postProcessManager;
  39877. private _postProcesses;
  39878. private _resizeObserver;
  39879. /**
  39880. * An event triggered when the texture is unbind.
  39881. */
  39882. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39883. /**
  39884. * An event triggered when the texture is unbind.
  39885. */
  39886. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39887. private _onAfterUnbindObserver;
  39888. /**
  39889. * Set a after unbind callback in the texture.
  39890. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39891. */
  39892. set onAfterUnbind(callback: () => void);
  39893. /**
  39894. * An event triggered before rendering the texture
  39895. */
  39896. onBeforeRenderObservable: Observable<number>;
  39897. private _onBeforeRenderObserver;
  39898. /**
  39899. * Set a before render callback in the texture.
  39900. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39901. */
  39902. set onBeforeRender(callback: (faceIndex: number) => void);
  39903. /**
  39904. * An event triggered after rendering the texture
  39905. */
  39906. onAfterRenderObservable: Observable<number>;
  39907. private _onAfterRenderObserver;
  39908. /**
  39909. * Set a after render callback in the texture.
  39910. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39911. */
  39912. set onAfterRender(callback: (faceIndex: number) => void);
  39913. /**
  39914. * An event triggered after the texture clear
  39915. */
  39916. onClearObservable: Observable<Engine>;
  39917. private _onClearObserver;
  39918. /**
  39919. * Set a clear callback in the texture.
  39920. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39921. */
  39922. set onClear(callback: (Engine: Engine) => void);
  39923. /**
  39924. * An event triggered when the texture is resized.
  39925. */
  39926. onResizeObservable: Observable<RenderTargetTexture>;
  39927. /**
  39928. * Define the clear color of the Render Target if it should be different from the scene.
  39929. */
  39930. clearColor: Color4;
  39931. protected _size: number | {
  39932. width: number;
  39933. height: number;
  39934. layers?: number;
  39935. };
  39936. protected _initialSizeParameter: number | {
  39937. width: number;
  39938. height: number;
  39939. } | {
  39940. ratio: number;
  39941. };
  39942. protected _sizeRatio: Nullable<number>;
  39943. /** @hidden */
  39944. _generateMipMaps: boolean;
  39945. protected _renderingManager: RenderingManager;
  39946. /** @hidden */
  39947. _waitingRenderList?: string[];
  39948. protected _doNotChangeAspectRatio: boolean;
  39949. protected _currentRefreshId: number;
  39950. protected _refreshRate: number;
  39951. protected _textureMatrix: Matrix;
  39952. protected _samples: number;
  39953. protected _renderTargetOptions: RenderTargetCreationOptions;
  39954. /**
  39955. * Gets render target creation options that were used.
  39956. */
  39957. get renderTargetOptions(): RenderTargetCreationOptions;
  39958. protected _onRatioRescale(): void;
  39959. /**
  39960. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39961. * It must define where the camera used to render the texture is set
  39962. */
  39963. boundingBoxPosition: Vector3;
  39964. private _boundingBoxSize;
  39965. /**
  39966. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39967. * When defined, the cubemap will switch to local mode
  39968. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39969. * @example https://www.babylonjs-playground.com/#RNASML
  39970. */
  39971. set boundingBoxSize(value: Vector3);
  39972. get boundingBoxSize(): Vector3;
  39973. /**
  39974. * In case the RTT has been created with a depth texture, get the associated
  39975. * depth texture.
  39976. * Otherwise, return null.
  39977. */
  39978. get depthStencilTexture(): Nullable<InternalTexture>;
  39979. /**
  39980. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39981. * or used a shadow, depth texture...
  39982. * @param name The friendly name of the texture
  39983. * @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)
  39984. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39985. * @param generateMipMaps True if mip maps need to be generated after render.
  39986. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39987. * @param type The type of the buffer in the RTT (int, half float, float...)
  39988. * @param isCube True if a cube texture needs to be created
  39989. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39990. * @param generateDepthBuffer True to generate a depth buffer
  39991. * @param generateStencilBuffer True to generate a stencil buffer
  39992. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39993. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39994. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39995. * @param samples sample count to use when creating the RTT
  39996. */
  39997. constructor(name: string, size: number | {
  39998. width: number;
  39999. height: number;
  40000. layers?: number;
  40001. } | {
  40002. ratio: number;
  40003. }, 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);
  40004. /**
  40005. * Creates a depth stencil texture.
  40006. * This is only available in WebGL 2 or with the depth texture extension available.
  40007. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  40008. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  40009. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  40010. * @param samples sample count of the depth/stencil texture
  40011. */
  40012. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  40013. private _processSizeParameter;
  40014. /**
  40015. * Define the number of samples to use in case of MSAA.
  40016. * It defaults to one meaning no MSAA has been enabled.
  40017. */
  40018. get samples(): number;
  40019. set samples(value: number);
  40020. /**
  40021. * Resets the refresh counter of the texture and start bak from scratch.
  40022. * Could be useful to regenerate the texture if it is setup to render only once.
  40023. */
  40024. resetRefreshCounter(): void;
  40025. /**
  40026. * Define the refresh rate of the texture or the rendering frequency.
  40027. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  40028. */
  40029. get refreshRate(): number;
  40030. set refreshRate(value: number);
  40031. /**
  40032. * Adds a post process to the render target rendering passes.
  40033. * @param postProcess define the post process to add
  40034. */
  40035. addPostProcess(postProcess: PostProcess): void;
  40036. /**
  40037. * Clear all the post processes attached to the render target
  40038. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  40039. */
  40040. clearPostProcesses(dispose?: boolean): void;
  40041. /**
  40042. * Remove one of the post process from the list of attached post processes to the texture
  40043. * @param postProcess define the post process to remove from the list
  40044. */
  40045. removePostProcess(postProcess: PostProcess): void;
  40046. /** @hidden */
  40047. _shouldRender(): boolean;
  40048. /**
  40049. * Gets the actual render size of the texture.
  40050. * @returns the width of the render size
  40051. */
  40052. getRenderSize(): number;
  40053. /**
  40054. * Gets the actual render width of the texture.
  40055. * @returns the width of the render size
  40056. */
  40057. getRenderWidth(): number;
  40058. /**
  40059. * Gets the actual render height of the texture.
  40060. * @returns the height of the render size
  40061. */
  40062. getRenderHeight(): number;
  40063. /**
  40064. * Gets the actual number of layers of the texture.
  40065. * @returns the number of layers
  40066. */
  40067. getRenderLayers(): number;
  40068. /**
  40069. * Get if the texture can be rescaled or not.
  40070. */
  40071. get canRescale(): boolean;
  40072. /**
  40073. * Resize the texture using a ratio.
  40074. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  40075. */
  40076. scale(ratio: number): void;
  40077. /**
  40078. * Get the texture reflection matrix used to rotate/transform the reflection.
  40079. * @returns the reflection matrix
  40080. */
  40081. getReflectionTextureMatrix(): Matrix;
  40082. /**
  40083. * Resize the texture to a new desired size.
  40084. * Be carrefull as it will recreate all the data in the new texture.
  40085. * @param size Define the new size. It can be:
  40086. * - a number for squared texture,
  40087. * - an object containing { width: number, height: number }
  40088. * - or an object containing a ratio { ratio: number }
  40089. */
  40090. resize(size: number | {
  40091. width: number;
  40092. height: number;
  40093. } | {
  40094. ratio: number;
  40095. }): void;
  40096. private _defaultRenderListPrepared;
  40097. /**
  40098. * Renders all the objects from the render list into the texture.
  40099. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  40100. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  40101. */
  40102. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  40103. private _bestReflectionRenderTargetDimension;
  40104. private _prepareRenderingManager;
  40105. /**
  40106. * @hidden
  40107. * @param faceIndex face index to bind to if this is a cubetexture
  40108. * @param layer defines the index of the texture to bind in the array
  40109. */
  40110. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  40111. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40112. private renderToTarget;
  40113. /**
  40114. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40115. * This allowed control for front to back rendering or reversly depending of the special needs.
  40116. *
  40117. * @param renderingGroupId The rendering group id corresponding to its index
  40118. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40119. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40120. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40121. */
  40122. 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;
  40123. /**
  40124. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40125. *
  40126. * @param renderingGroupId The rendering group id corresponding to its index
  40127. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40128. */
  40129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  40130. /**
  40131. * Clones the texture.
  40132. * @returns the cloned texture
  40133. */
  40134. clone(): RenderTargetTexture;
  40135. /**
  40136. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  40137. * @returns The JSON representation of the texture
  40138. */
  40139. serialize(): any;
  40140. /**
  40141. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  40142. */
  40143. disposeFramebufferObjects(): void;
  40144. /**
  40145. * Dispose the texture and release its associated resources.
  40146. */
  40147. dispose(): void;
  40148. /** @hidden */
  40149. _rebuild(): void;
  40150. /**
  40151. * Clear the info related to rendering groups preventing retention point in material dispose.
  40152. */
  40153. freeRenderingGroups(): void;
  40154. /**
  40155. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  40156. * @returns the view count
  40157. */
  40158. getViewCount(): number;
  40159. }
  40160. }
  40161. declare module "babylonjs/Materials/effect" {
  40162. import { Observable } from "babylonjs/Misc/observable";
  40163. import { FloatArray, Nullable } from "babylonjs/types";
  40164. import { IDisposable } from "babylonjs/scene";
  40165. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40167. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  40168. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40169. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40170. import { Engine } from "babylonjs/Engines/engine";
  40171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40172. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40173. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40174. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40175. /**
  40176. * Options to be used when creating an effect.
  40177. */
  40178. export interface IEffectCreationOptions {
  40179. /**
  40180. * Atrributes that will be used in the shader.
  40181. */
  40182. attributes: string[];
  40183. /**
  40184. * Uniform varible names that will be set in the shader.
  40185. */
  40186. uniformsNames: string[];
  40187. /**
  40188. * Uniform buffer variable names that will be set in the shader.
  40189. */
  40190. uniformBuffersNames: string[];
  40191. /**
  40192. * Sampler texture variable names that will be set in the shader.
  40193. */
  40194. samplers: string[];
  40195. /**
  40196. * Define statements that will be set in the shader.
  40197. */
  40198. defines: any;
  40199. /**
  40200. * Possible fallbacks for this effect to improve performance when needed.
  40201. */
  40202. fallbacks: Nullable<IEffectFallbacks>;
  40203. /**
  40204. * Callback that will be called when the shader is compiled.
  40205. */
  40206. onCompiled: Nullable<(effect: Effect) => void>;
  40207. /**
  40208. * Callback that will be called if an error occurs during shader compilation.
  40209. */
  40210. onError: Nullable<(effect: Effect, errors: string) => void>;
  40211. /**
  40212. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40213. */
  40214. indexParameters?: any;
  40215. /**
  40216. * Max number of lights that can be used in the shader.
  40217. */
  40218. maxSimultaneousLights?: number;
  40219. /**
  40220. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  40221. */
  40222. transformFeedbackVaryings?: Nullable<string[]>;
  40223. /**
  40224. * 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
  40225. */
  40226. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  40227. /**
  40228. * Is this effect rendering to several color attachments ?
  40229. */
  40230. multiTarget?: boolean;
  40231. }
  40232. /**
  40233. * Effect containing vertex and fragment shader that can be executed on an object.
  40234. */
  40235. export class Effect implements IDisposable {
  40236. /**
  40237. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40238. */
  40239. static ShadersRepository: string;
  40240. /**
  40241. * Enable logging of the shader code when a compilation error occurs
  40242. */
  40243. static LogShaderCodeOnCompilationError: boolean;
  40244. /**
  40245. * Name of the effect.
  40246. */
  40247. name: any;
  40248. /**
  40249. * String container all the define statements that should be set on the shader.
  40250. */
  40251. defines: string;
  40252. /**
  40253. * Callback that will be called when the shader is compiled.
  40254. */
  40255. onCompiled: Nullable<(effect: Effect) => void>;
  40256. /**
  40257. * Callback that will be called if an error occurs during shader compilation.
  40258. */
  40259. onError: Nullable<(effect: Effect, errors: string) => void>;
  40260. /**
  40261. * Callback that will be called when effect is bound.
  40262. */
  40263. onBind: Nullable<(effect: Effect) => void>;
  40264. /**
  40265. * Unique ID of the effect.
  40266. */
  40267. uniqueId: number;
  40268. /**
  40269. * Observable that will be called when the shader is compiled.
  40270. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  40271. */
  40272. onCompileObservable: Observable<Effect>;
  40273. /**
  40274. * Observable that will be called if an error occurs during shader compilation.
  40275. */
  40276. onErrorObservable: Observable<Effect>;
  40277. /** @hidden */
  40278. _onBindObservable: Nullable<Observable<Effect>>;
  40279. /**
  40280. * @hidden
  40281. * Specifies if the effect was previously ready
  40282. */
  40283. _wasPreviouslyReady: boolean;
  40284. /**
  40285. * Observable that will be called when effect is bound.
  40286. */
  40287. get onBindObservable(): Observable<Effect>;
  40288. /** @hidden */
  40289. _bonesComputationForcedToCPU: boolean;
  40290. /** @hidden */
  40291. _uniformBuffersNames: {
  40292. [key: string]: number;
  40293. };
  40294. /** @hidden */
  40295. _samplerList: string[];
  40296. /** @hidden */
  40297. _multiTarget: boolean;
  40298. private static _uniqueIdSeed;
  40299. private _engine;
  40300. private _uniformBuffersNamesList;
  40301. private _uniformsNames;
  40302. private _samplers;
  40303. private _isReady;
  40304. private _compilationError;
  40305. private _allFallbacksProcessed;
  40306. private _attributesNames;
  40307. private _attributes;
  40308. private _attributeLocationByName;
  40309. private _uniforms;
  40310. /**
  40311. * Key for the effect.
  40312. * @hidden
  40313. */
  40314. _key: string;
  40315. private _indexParameters;
  40316. private _fallbacks;
  40317. private _vertexSourceCodeOverride;
  40318. private _fragmentSourceCodeOverride;
  40319. private _transformFeedbackVaryings;
  40320. /**
  40321. * Compiled shader to webGL program.
  40322. * @hidden
  40323. */
  40324. _pipelineContext: Nullable<IPipelineContext>;
  40325. /** @hidden */
  40326. _vertexSourceCode: string;
  40327. /** @hidden */
  40328. _fragmentSourceCode: string;
  40329. /** @hidden */
  40330. private _rawVertexSourceCode;
  40331. /** @hidden */
  40332. private _rawFragmentSourceCode;
  40333. private static _baseCache;
  40334. private _processingContext;
  40335. /**
  40336. * Instantiates an effect.
  40337. * An effect can be used to create/manage/execute vertex and fragment shaders.
  40338. * @param baseName Name of the effect.
  40339. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  40340. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  40341. * @param samplers List of sampler variables that will be passed to the shader.
  40342. * @param engine Engine to be used to render the effect
  40343. * @param defines Define statements to be added to the shader.
  40344. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  40345. * @param onCompiled Callback that will be called when the shader is compiled.
  40346. * @param onError Callback that will be called if an error occurs during shader compilation.
  40347. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40348. * @param key Effect Key identifying uniquely compiled shader variants
  40349. */
  40350. 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);
  40351. private _useFinalCode;
  40352. /**
  40353. * Unique key for this effect
  40354. */
  40355. get key(): string;
  40356. /**
  40357. * If the effect has been compiled and prepared.
  40358. * @returns if the effect is compiled and prepared.
  40359. */
  40360. isReady(): boolean;
  40361. private _isReadyInternal;
  40362. /**
  40363. * The engine the effect was initialized with.
  40364. * @returns the engine.
  40365. */
  40366. getEngine(): Engine;
  40367. /**
  40368. * The pipeline context for this effect
  40369. * @returns the associated pipeline context
  40370. */
  40371. getPipelineContext(): Nullable<IPipelineContext>;
  40372. /**
  40373. * The set of names of attribute variables for the shader.
  40374. * @returns An array of attribute names.
  40375. */
  40376. getAttributesNames(): string[];
  40377. /**
  40378. * Returns the attribute at the given index.
  40379. * @param index The index of the attribute.
  40380. * @returns The location of the attribute.
  40381. */
  40382. getAttributeLocation(index: number): number;
  40383. /**
  40384. * Returns the attribute based on the name of the variable.
  40385. * @param name of the attribute to look up.
  40386. * @returns the attribute location.
  40387. */
  40388. getAttributeLocationByName(name: string): number;
  40389. /**
  40390. * The number of attributes.
  40391. * @returns the numnber of attributes.
  40392. */
  40393. getAttributesCount(): number;
  40394. /**
  40395. * Gets the index of a uniform variable.
  40396. * @param uniformName of the uniform to look up.
  40397. * @returns the index.
  40398. */
  40399. getUniformIndex(uniformName: string): number;
  40400. /**
  40401. * Returns the attribute based on the name of the variable.
  40402. * @param uniformName of the uniform to look up.
  40403. * @returns the location of the uniform.
  40404. */
  40405. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  40406. /**
  40407. * Returns an array of sampler variable names
  40408. * @returns The array of sampler variable names.
  40409. */
  40410. getSamplers(): string[];
  40411. /**
  40412. * Returns an array of uniform variable names
  40413. * @returns The array of uniform variable names.
  40414. */
  40415. getUniformNames(): string[];
  40416. /**
  40417. * Returns an array of uniform buffer variable names
  40418. * @returns The array of uniform buffer variable names.
  40419. */
  40420. getUniformBuffersNames(): string[];
  40421. /**
  40422. * Returns the index parameters used to create the effect
  40423. * @returns The index parameters object
  40424. */
  40425. getIndexParameters(): any;
  40426. /**
  40427. * The error from the last compilation.
  40428. * @returns the error string.
  40429. */
  40430. getCompilationError(): string;
  40431. /**
  40432. * Gets a boolean indicating that all fallbacks were used during compilation
  40433. * @returns true if all fallbacks were used
  40434. */
  40435. allFallbacksProcessed(): boolean;
  40436. /**
  40437. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  40438. * @param func The callback to be used.
  40439. */
  40440. executeWhenCompiled(func: (effect: Effect) => void): void;
  40441. private _checkIsReady;
  40442. private _loadShader;
  40443. /**
  40444. * Gets the vertex shader source code of this effect
  40445. */
  40446. get vertexSourceCode(): string;
  40447. /**
  40448. * Gets the fragment shader source code of this effect
  40449. */
  40450. get fragmentSourceCode(): string;
  40451. /**
  40452. * Gets the vertex shader source code before it has been processed by the preprocessor
  40453. */
  40454. get rawVertexSourceCode(): string;
  40455. /**
  40456. * Gets the fragment shader source code before it has been processed by the preprocessor
  40457. */
  40458. get rawFragmentSourceCode(): string;
  40459. /**
  40460. * Recompiles the webGL program
  40461. * @param vertexSourceCode The source code for the vertex shader.
  40462. * @param fragmentSourceCode The source code for the fragment shader.
  40463. * @param onCompiled Callback called when completed.
  40464. * @param onError Callback called on error.
  40465. * @hidden
  40466. */
  40467. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  40468. /**
  40469. * Prepares the effect
  40470. * @hidden
  40471. */
  40472. _prepareEffect(): void;
  40473. private _getShaderCodeAndErrorLine;
  40474. private _processCompilationErrors;
  40475. /**
  40476. * Checks if the effect is supported. (Must be called after compilation)
  40477. */
  40478. get isSupported(): boolean;
  40479. /**
  40480. * Binds a texture to the engine to be used as output of the shader.
  40481. * @param channel Name of the output variable.
  40482. * @param texture Texture to bind.
  40483. * @hidden
  40484. */
  40485. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  40486. /**
  40487. * Sets a texture on the engine to be used in the shader.
  40488. * @param channel Name of the sampler variable.
  40489. * @param texture Texture to set.
  40490. */
  40491. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  40492. /**
  40493. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  40494. * @param channel Name of the sampler variable.
  40495. * @param texture Texture to set.
  40496. */
  40497. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  40498. /**
  40499. * Sets an array of textures on the engine to be used in the shader.
  40500. * @param channel Name of the variable.
  40501. * @param textures Textures to set.
  40502. */
  40503. setTextureArray(channel: string, textures: ThinTexture[]): void;
  40504. /**
  40505. * 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)
  40506. * @param channel Name of the sampler variable.
  40507. * @param postProcess Post process to get the input texture from.
  40508. */
  40509. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  40510. /**
  40511. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  40512. * 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)
  40513. * @param channel Name of the sampler variable.
  40514. * @param postProcess Post process to get the output texture from.
  40515. */
  40516. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  40517. /**
  40518. * Binds a buffer to a uniform.
  40519. * @param buffer Buffer to bind.
  40520. * @param name Name of the uniform variable to bind to.
  40521. */
  40522. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  40523. /**
  40524. * Binds block to a uniform.
  40525. * @param blockName Name of the block to bind.
  40526. * @param index Index to bind.
  40527. */
  40528. bindUniformBlock(blockName: string, index: number): void;
  40529. /**
  40530. * Sets an interger value on a uniform variable.
  40531. * @param uniformName Name of the variable.
  40532. * @param value Value to be set.
  40533. * @returns this effect.
  40534. */
  40535. setInt(uniformName: string, value: number): Effect;
  40536. /**
  40537. * Sets an int2 value on a uniform variable.
  40538. * @param uniformName Name of the variable.
  40539. * @param x First int in int2.
  40540. * @param y Second int in int2.
  40541. * @returns this effect.
  40542. */
  40543. setInt2(uniformName: string, x: number, y: number): Effect;
  40544. /**
  40545. * Sets an int3 value on a uniform variable.
  40546. * @param uniformName Name of the variable.
  40547. * @param x First int in int3.
  40548. * @param y Second int in int3.
  40549. * @param z Third int in int3.
  40550. * @returns this effect.
  40551. */
  40552. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  40553. /**
  40554. * Sets an int4 value on a uniform variable.
  40555. * @param uniformName Name of the variable.
  40556. * @param x First int in int4.
  40557. * @param y Second int in int4.
  40558. * @param z Third int in int4.
  40559. * @param w Fourth int in int4.
  40560. * @returns this effect.
  40561. */
  40562. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40563. /**
  40564. * Sets an int array on a uniform variable.
  40565. * @param uniformName Name of the variable.
  40566. * @param array array to be set.
  40567. * @returns this effect.
  40568. */
  40569. setIntArray(uniformName: string, array: Int32Array): Effect;
  40570. /**
  40571. * 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)
  40572. * @param uniformName Name of the variable.
  40573. * @param array array to be set.
  40574. * @returns this effect.
  40575. */
  40576. setIntArray2(uniformName: string, array: Int32Array): Effect;
  40577. /**
  40578. * 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)
  40579. * @param uniformName Name of the variable.
  40580. * @param array array to be set.
  40581. * @returns this effect.
  40582. */
  40583. setIntArray3(uniformName: string, array: Int32Array): Effect;
  40584. /**
  40585. * 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)
  40586. * @param uniformName Name of the variable.
  40587. * @param array array to be set.
  40588. * @returns this effect.
  40589. */
  40590. setIntArray4(uniformName: string, array: Int32Array): Effect;
  40591. /**
  40592. * Sets an float array on a uniform variable.
  40593. * @param uniformName Name of the variable.
  40594. * @param array array to be set.
  40595. * @returns this effect.
  40596. */
  40597. setFloatArray(uniformName: string, array: FloatArray): Effect;
  40598. /**
  40599. * 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)
  40600. * @param uniformName Name of the variable.
  40601. * @param array array to be set.
  40602. * @returns this effect.
  40603. */
  40604. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  40605. /**
  40606. * 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)
  40607. * @param uniformName Name of the variable.
  40608. * @param array array to be set.
  40609. * @returns this effect.
  40610. */
  40611. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  40612. /**
  40613. * 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)
  40614. * @param uniformName Name of the variable.
  40615. * @param array array to be set.
  40616. * @returns this effect.
  40617. */
  40618. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  40619. /**
  40620. * Sets an array on a uniform variable.
  40621. * @param uniformName Name of the variable.
  40622. * @param array array to be set.
  40623. * @returns this effect.
  40624. */
  40625. setArray(uniformName: string, array: number[]): Effect;
  40626. /**
  40627. * 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)
  40628. * @param uniformName Name of the variable.
  40629. * @param array array to be set.
  40630. * @returns this effect.
  40631. */
  40632. setArray2(uniformName: string, array: number[]): Effect;
  40633. /**
  40634. * 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)
  40635. * @param uniformName Name of the variable.
  40636. * @param array array to be set.
  40637. * @returns this effect.
  40638. */
  40639. setArray3(uniformName: string, array: number[]): Effect;
  40640. /**
  40641. * 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)
  40642. * @param uniformName Name of the variable.
  40643. * @param array array to be set.
  40644. * @returns this effect.
  40645. */
  40646. setArray4(uniformName: string, array: number[]): Effect;
  40647. /**
  40648. * Sets matrices on a uniform variable.
  40649. * @param uniformName Name of the variable.
  40650. * @param matrices matrices to be set.
  40651. * @returns this effect.
  40652. */
  40653. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  40654. /**
  40655. * Sets matrix on a uniform variable.
  40656. * @param uniformName Name of the variable.
  40657. * @param matrix matrix to be set.
  40658. * @returns this effect.
  40659. */
  40660. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  40661. /**
  40662. * 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)
  40663. * @param uniformName Name of the variable.
  40664. * @param matrix matrix to be set.
  40665. * @returns this effect.
  40666. */
  40667. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40668. /**
  40669. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  40670. * @param uniformName Name of the variable.
  40671. * @param matrix matrix to be set.
  40672. * @returns this effect.
  40673. */
  40674. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40675. /**
  40676. * Sets a float on a uniform variable.
  40677. * @param uniformName Name of the variable.
  40678. * @param value value to be set.
  40679. * @returns this effect.
  40680. */
  40681. setFloat(uniformName: string, value: number): Effect;
  40682. /**
  40683. * Sets a boolean on a uniform variable.
  40684. * @param uniformName Name of the variable.
  40685. * @param bool value to be set.
  40686. * @returns this effect.
  40687. */
  40688. setBool(uniformName: string, bool: boolean): Effect;
  40689. /**
  40690. * Sets a Vector2 on a uniform variable.
  40691. * @param uniformName Name of the variable.
  40692. * @param vector2 vector2 to be set.
  40693. * @returns this effect.
  40694. */
  40695. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  40696. /**
  40697. * Sets a float2 on a uniform variable.
  40698. * @param uniformName Name of the variable.
  40699. * @param x First float in float2.
  40700. * @param y Second float in float2.
  40701. * @returns this effect.
  40702. */
  40703. setFloat2(uniformName: string, x: number, y: number): Effect;
  40704. /**
  40705. * Sets a Vector3 on a uniform variable.
  40706. * @param uniformName Name of the variable.
  40707. * @param vector3 Value to be set.
  40708. * @returns this effect.
  40709. */
  40710. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  40711. /**
  40712. * Sets a float3 on a uniform variable.
  40713. * @param uniformName Name of the variable.
  40714. * @param x First float in float3.
  40715. * @param y Second float in float3.
  40716. * @param z Third float in float3.
  40717. * @returns this effect.
  40718. */
  40719. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  40720. /**
  40721. * Sets a Vector4 on a uniform variable.
  40722. * @param uniformName Name of the variable.
  40723. * @param vector4 Value to be set.
  40724. * @returns this effect.
  40725. */
  40726. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  40727. /**
  40728. * Sets a float4 on a uniform variable.
  40729. * @param uniformName Name of the variable.
  40730. * @param x First float in float4.
  40731. * @param y Second float in float4.
  40732. * @param z Third float in float4.
  40733. * @param w Fourth float in float4.
  40734. * @returns this effect.
  40735. */
  40736. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40737. /**
  40738. * Sets a Color3 on a uniform variable.
  40739. * @param uniformName Name of the variable.
  40740. * @param color3 Value to be set.
  40741. * @returns this effect.
  40742. */
  40743. setColor3(uniformName: string, color3: IColor3Like): Effect;
  40744. /**
  40745. * Sets a Color4 on a uniform variable.
  40746. * @param uniformName Name of the variable.
  40747. * @param color3 Value to be set.
  40748. * @param alpha Alpha value to be set.
  40749. * @returns this effect.
  40750. */
  40751. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  40752. /**
  40753. * Sets a Color4 on a uniform variable
  40754. * @param uniformName defines the name of the variable
  40755. * @param color4 defines the value to be set
  40756. * @returns this effect.
  40757. */
  40758. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  40759. /**
  40760. * Release all associated resources.
  40761. **/
  40762. dispose(): void;
  40763. /**
  40764. * This function will add a new shader to the shader store
  40765. * @param name the name of the shader
  40766. * @param pixelShader optional pixel shader content
  40767. * @param vertexShader optional vertex shader content
  40768. */
  40769. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  40770. /**
  40771. * Store of each shader (The can be looked up using effect.key)
  40772. */
  40773. static ShadersStore: {
  40774. [key: string]: string;
  40775. };
  40776. /**
  40777. * Store of each included file for a shader (The can be looked up using effect.key)
  40778. */
  40779. static IncludesShadersStore: {
  40780. [key: string]: string;
  40781. };
  40782. /**
  40783. * Resets the cache of effects.
  40784. */
  40785. static ResetCache(): void;
  40786. }
  40787. }
  40788. declare module "babylonjs/Engines/engineCapabilities" {
  40789. /**
  40790. * Interface used to describe the capabilities of the engine relatively to the current browser
  40791. */
  40792. export interface EngineCapabilities {
  40793. /** Maximum textures units per fragment shader */
  40794. maxTexturesImageUnits: number;
  40795. /** Maximum texture units per vertex shader */
  40796. maxVertexTextureImageUnits: number;
  40797. /** Maximum textures units in the entire pipeline */
  40798. maxCombinedTexturesImageUnits: number;
  40799. /** Maximum texture size */
  40800. maxTextureSize: number;
  40801. /** Maximum texture samples */
  40802. maxSamples?: number;
  40803. /** Maximum cube texture size */
  40804. maxCubemapTextureSize: number;
  40805. /** Maximum render texture size */
  40806. maxRenderTextureSize: number;
  40807. /** Maximum number of vertex attributes */
  40808. maxVertexAttribs: number;
  40809. /** Maximum number of varyings */
  40810. maxVaryingVectors: number;
  40811. /** Maximum number of uniforms per vertex shader */
  40812. maxVertexUniformVectors: number;
  40813. /** Maximum number of uniforms per fragment shader */
  40814. maxFragmentUniformVectors: number;
  40815. /** Defines if standard derivates (dx/dy) are supported */
  40816. standardDerivatives: boolean;
  40817. /** Defines if s3tc texture compression is supported */
  40818. s3tc?: WEBGL_compressed_texture_s3tc;
  40819. /** Defines if pvrtc texture compression is supported */
  40820. pvrtc: any;
  40821. /** Defines if etc1 texture compression is supported */
  40822. etc1: any;
  40823. /** Defines if etc2 texture compression is supported */
  40824. etc2: any;
  40825. /** Defines if astc texture compression is supported */
  40826. astc: any;
  40827. /** Defines if bptc texture compression is supported */
  40828. bptc: any;
  40829. /** Defines if float textures are supported */
  40830. textureFloat: boolean;
  40831. /** Defines if vertex array objects are supported */
  40832. vertexArrayObject: boolean;
  40833. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40834. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40835. /** Gets the maximum level of anisotropy supported */
  40836. maxAnisotropy: number;
  40837. /** Defines if instancing is supported */
  40838. instancedArrays: boolean;
  40839. /** Defines if 32 bits indices are supported */
  40840. uintIndices: boolean;
  40841. /** Defines if high precision shaders are supported */
  40842. highPrecisionShaderSupported: boolean;
  40843. /** Defines if depth reading in the fragment shader is supported */
  40844. fragmentDepthSupported: boolean;
  40845. /** Defines if float texture linear filtering is supported*/
  40846. textureFloatLinearFiltering: boolean;
  40847. /** Defines if rendering to float textures is supported */
  40848. textureFloatRender: boolean;
  40849. /** Defines if half float textures are supported*/
  40850. textureHalfFloat: boolean;
  40851. /** Defines if half float texture linear filtering is supported*/
  40852. textureHalfFloatLinearFiltering: boolean;
  40853. /** Defines if rendering to half float textures is supported */
  40854. textureHalfFloatRender: boolean;
  40855. /** Defines if textureLOD shader command is supported */
  40856. textureLOD: boolean;
  40857. /** Defines if draw buffers extension is supported */
  40858. drawBuffersExtension: boolean;
  40859. /** Defines if depth textures are supported */
  40860. depthTextureExtension: boolean;
  40861. /** Defines if float color buffer are supported */
  40862. colorBufferFloat: boolean;
  40863. /** Gets disjoint timer query extension (null if not supported) */
  40864. timerQuery?: EXT_disjoint_timer_query;
  40865. /** Defines if timestamp can be used with timer query */
  40866. canUseTimestampForTimerQuery: boolean;
  40867. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40868. multiview?: any;
  40869. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40870. oculusMultiview?: any;
  40871. /** Function used to let the system compiles shaders in background */
  40872. parallelShaderCompile?: {
  40873. COMPLETION_STATUS_KHR: number;
  40874. };
  40875. /** Max number of texture samples for MSAA */
  40876. maxMSAASamples: number;
  40877. /** Defines if the blend min max extension is supported */
  40878. blendMinMax: boolean;
  40879. /** 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 */
  40880. canUseGLInstanceID: boolean;
  40881. }
  40882. }
  40883. declare module "babylonjs/States/depthCullingState" {
  40884. import { Nullable } from "babylonjs/types";
  40885. /**
  40886. * @hidden
  40887. **/
  40888. export class DepthCullingState {
  40889. private _isDepthTestDirty;
  40890. private _isDepthMaskDirty;
  40891. private _isDepthFuncDirty;
  40892. private _isCullFaceDirty;
  40893. private _isCullDirty;
  40894. private _isZOffsetDirty;
  40895. private _isFrontFaceDirty;
  40896. private _depthTest;
  40897. private _depthMask;
  40898. private _depthFunc;
  40899. private _cull;
  40900. private _cullFace;
  40901. private _zOffset;
  40902. private _frontFace;
  40903. /**
  40904. * Initializes the state.
  40905. */
  40906. constructor();
  40907. get isDirty(): boolean;
  40908. get zOffset(): number;
  40909. set zOffset(value: number);
  40910. get cullFace(): Nullable<number>;
  40911. set cullFace(value: Nullable<number>);
  40912. get cull(): Nullable<boolean>;
  40913. set cull(value: Nullable<boolean>);
  40914. get depthFunc(): Nullable<number>;
  40915. set depthFunc(value: Nullable<number>);
  40916. get depthMask(): boolean;
  40917. set depthMask(value: boolean);
  40918. get depthTest(): boolean;
  40919. set depthTest(value: boolean);
  40920. get frontFace(): Nullable<number>;
  40921. set frontFace(value: Nullable<number>);
  40922. reset(): void;
  40923. apply(gl: WebGLRenderingContext): void;
  40924. }
  40925. }
  40926. declare module "babylonjs/States/stencilState" {
  40927. /**
  40928. * @hidden
  40929. **/
  40930. export class StencilState {
  40931. /** 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 */
  40932. static readonly ALWAYS: number;
  40933. /** Passed to stencilOperation to specify that stencil value must be kept */
  40934. static readonly KEEP: number;
  40935. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40936. static readonly REPLACE: number;
  40937. private _isStencilTestDirty;
  40938. private _isStencilMaskDirty;
  40939. private _isStencilFuncDirty;
  40940. private _isStencilOpDirty;
  40941. private _stencilTest;
  40942. private _stencilMask;
  40943. private _stencilFunc;
  40944. private _stencilFuncRef;
  40945. private _stencilFuncMask;
  40946. private _stencilOpStencilFail;
  40947. private _stencilOpDepthFail;
  40948. private _stencilOpStencilDepthPass;
  40949. get isDirty(): boolean;
  40950. get stencilFunc(): number;
  40951. set stencilFunc(value: number);
  40952. get stencilFuncRef(): number;
  40953. set stencilFuncRef(value: number);
  40954. get stencilFuncMask(): number;
  40955. set stencilFuncMask(value: number);
  40956. get stencilOpStencilFail(): number;
  40957. set stencilOpStencilFail(value: number);
  40958. get stencilOpDepthFail(): number;
  40959. set stencilOpDepthFail(value: number);
  40960. get stencilOpStencilDepthPass(): number;
  40961. set stencilOpStencilDepthPass(value: number);
  40962. get stencilMask(): number;
  40963. set stencilMask(value: number);
  40964. get stencilTest(): boolean;
  40965. set stencilTest(value: boolean);
  40966. constructor();
  40967. reset(): void;
  40968. apply(gl: WebGLRenderingContext): void;
  40969. }
  40970. }
  40971. declare module "babylonjs/States/alphaCullingState" {
  40972. import { Nullable } from "babylonjs/types";
  40973. /**
  40974. * @hidden
  40975. **/
  40976. export class AlphaState {
  40977. _blendFunctionParameters: Nullable<number>[];
  40978. _blendEquationParameters: Nullable<number>[];
  40979. _blendConstants: Nullable<number>[];
  40980. _isBlendConstantsDirty: boolean;
  40981. private _alphaBlend;
  40982. private _isAlphaBlendDirty;
  40983. private _isBlendFunctionParametersDirty;
  40984. private _isBlendEquationParametersDirty;
  40985. /**
  40986. * Initializes the state.
  40987. */
  40988. constructor();
  40989. get isDirty(): boolean;
  40990. get alphaBlend(): boolean;
  40991. set alphaBlend(value: boolean);
  40992. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40993. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40994. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40995. reset(): void;
  40996. apply(gl: WebGLRenderingContext): void;
  40997. }
  40998. }
  40999. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  41000. import { Nullable } from "babylonjs/types";
  41001. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41002. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41004. /** @hidden */
  41005. export class WebGLShaderProcessor implements IShaderProcessor {
  41006. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41007. }
  41008. }
  41009. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  41010. import { Nullable } from "babylonjs/types";
  41011. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41012. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41013. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41014. /** @hidden */
  41015. export class WebGL2ShaderProcessor implements IShaderProcessor {
  41016. attributeProcessor(attribute: string): string;
  41017. varyingProcessor(varying: string, isFragment: boolean): string;
  41018. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41019. }
  41020. }
  41021. declare module "babylonjs/Engines/instancingAttributeInfo" {
  41022. /**
  41023. * Interface for attribute information associated with buffer instanciation
  41024. */
  41025. export interface InstancingAttributeInfo {
  41026. /**
  41027. * Name of the GLSL attribute
  41028. * if attribute index is not specified, this is used to retrieve the index from the effect
  41029. */
  41030. attributeName: string;
  41031. /**
  41032. * Index/offset of the attribute in the vertex shader
  41033. * if not specified, this will be computes from the name.
  41034. */
  41035. index?: number;
  41036. /**
  41037. * size of the attribute, 1, 2, 3 or 4
  41038. */
  41039. attributeSize: number;
  41040. /**
  41041. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  41042. */
  41043. offset: number;
  41044. /**
  41045. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  41046. * default to 1
  41047. */
  41048. divisor?: number;
  41049. /**
  41050. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  41051. * default is FLOAT
  41052. */
  41053. attributeType?: number;
  41054. /**
  41055. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  41056. */
  41057. normalized?: boolean;
  41058. }
  41059. }
  41060. declare module "babylonjs/Engines/engineFeatures" {
  41061. /** @hidden */
  41062. export interface EngineFeatures {
  41063. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  41064. forceBitmapOverHTMLImageElement: boolean;
  41065. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  41066. supportRenderAndCopyToLodForFloatTextures: boolean;
  41067. /** Indicates that the engine support handling depth/stencil textures */
  41068. supportDepthStencilTexture: boolean;
  41069. /** Indicates that the engine support shadow samplers */
  41070. supportShadowSamplers: boolean;
  41071. /** 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 */
  41072. uniformBufferHardCheckMatrix: boolean;
  41073. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  41074. allowTexturePrefiltering: boolean;
  41075. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  41076. trackUbosInFrame: boolean;
  41077. /** Indicates that the Cascaded Shadow Map technic is supported */
  41078. supportCSM: boolean;
  41079. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  41080. basisNeedsPOT: boolean;
  41081. /** Indicates that the engine supports 3D textures */
  41082. support3DTextures: boolean;
  41083. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  41084. needTypeSuffixInShaderConstants: boolean;
  41085. /** Indicates that MSAA is supported */
  41086. supportMSAA: boolean;
  41087. /** Indicates that SSAO2 is supported */
  41088. supportSSAO2: boolean;
  41089. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  41090. supportExtendedTextureFormats: boolean;
  41091. /** Indicates that the switch/case construct is supported in shaders */
  41092. supportSwitchCaseInShader: boolean;
  41093. /** @hidden */
  41094. _collectUbosUpdatedInFrame: boolean;
  41095. }
  41096. }
  41097. declare module "babylonjs/Engines/WebGL/webGLHardwareTexture" {
  41098. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41099. import { Nullable } from "babylonjs/types";
  41100. /** @hidden */
  41101. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  41102. private _webGLTexture;
  41103. private _context;
  41104. get underlyingResource(): Nullable<WebGLTexture>;
  41105. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  41106. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  41107. set(hardwareTexture: WebGLTexture): void;
  41108. reset(): void;
  41109. release(): void;
  41110. }
  41111. }
  41112. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  41113. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41114. import { Nullable } from "babylonjs/types";
  41115. module "babylonjs/Engines/thinEngine" {
  41116. interface ThinEngine {
  41117. /**
  41118. * Update a video texture
  41119. * @param texture defines the texture to update
  41120. * @param video defines the video element to use
  41121. * @param invertY defines if data must be stored with Y axis inverted
  41122. */
  41123. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  41124. }
  41125. }
  41126. }
  41127. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  41128. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41129. import { Nullable } from "babylonjs/types";
  41130. module "babylonjs/Engines/thinEngine" {
  41131. interface ThinEngine {
  41132. /**
  41133. * Creates a dynamic texture
  41134. * @param width defines the width of the texture
  41135. * @param height defines the height of the texture
  41136. * @param generateMipMaps defines if the engine should generate the mip levels
  41137. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  41138. * @returns the dynamic texture inside an InternalTexture
  41139. */
  41140. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  41141. /**
  41142. * Update the content of a dynamic texture
  41143. * @param texture defines the texture to update
  41144. * @param source defines the source containing the data
  41145. * @param invertY defines if data must be stored with Y axis inverted
  41146. * @param premulAlpha defines if alpha is stored as premultiplied
  41147. * @param format defines the format of the data
  41148. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  41149. */
  41150. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  41151. }
  41152. }
  41153. }
  41154. declare module "babylonjs/Materials/Textures/videoTexture" {
  41155. import { Observable } from "babylonjs/Misc/observable";
  41156. import { Nullable } from "babylonjs/types";
  41157. import { Scene } from "babylonjs/scene";
  41158. import { Texture } from "babylonjs/Materials/Textures/texture";
  41159. import "babylonjs/Engines/Extensions/engine.videoTexture";
  41160. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  41161. /**
  41162. * Settings for finer control over video usage
  41163. */
  41164. export interface VideoTextureSettings {
  41165. /**
  41166. * Applies `autoplay` to video, if specified
  41167. */
  41168. autoPlay?: boolean;
  41169. /**
  41170. * Applies `muted` to video, if specified
  41171. */
  41172. muted?: boolean;
  41173. /**
  41174. * Applies `loop` to video, if specified
  41175. */
  41176. loop?: boolean;
  41177. /**
  41178. * Automatically updates internal texture from video at every frame in the render loop
  41179. */
  41180. autoUpdateTexture: boolean;
  41181. /**
  41182. * Image src displayed during the video loading or until the user interacts with the video.
  41183. */
  41184. poster?: string;
  41185. }
  41186. /**
  41187. * If you want to display a video in your scene, this is the special texture for that.
  41188. * This special texture works similar to other textures, with the exception of a few parameters.
  41189. * @see https://doc.babylonjs.com/how_to/video_texture
  41190. */
  41191. export class VideoTexture extends Texture {
  41192. /**
  41193. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  41194. */
  41195. readonly autoUpdateTexture: boolean;
  41196. /**
  41197. * The video instance used by the texture internally
  41198. */
  41199. readonly video: HTMLVideoElement;
  41200. private _onUserActionRequestedObservable;
  41201. /**
  41202. * Event triggerd when a dom action is required by the user to play the video.
  41203. * This happens due to recent changes in browser policies preventing video to auto start.
  41204. */
  41205. get onUserActionRequestedObservable(): Observable<Texture>;
  41206. private _generateMipMaps;
  41207. private _stillImageCaptured;
  41208. private _displayingPosterTexture;
  41209. private _settings;
  41210. private _createInternalTextureOnEvent;
  41211. private _frameId;
  41212. private _currentSrc;
  41213. /**
  41214. * Creates a video texture.
  41215. * If you want to display a video in your scene, this is the special texture for that.
  41216. * This special texture works similar to other textures, with the exception of a few parameters.
  41217. * @see https://doc.babylonjs.com/how_to/video_texture
  41218. * @param name optional name, will detect from video source, if not defined
  41219. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  41220. * @param scene is obviously the current scene.
  41221. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  41222. * @param invertY is false by default but can be used to invert video on Y axis
  41223. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  41224. * @param settings allows finer control over video usage
  41225. */
  41226. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  41227. private _getName;
  41228. private _getVideo;
  41229. private _createInternalTexture;
  41230. private reset;
  41231. /**
  41232. * @hidden Internal method to initiate `update`.
  41233. */
  41234. _rebuild(): void;
  41235. /**
  41236. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  41237. */
  41238. update(): void;
  41239. /**
  41240. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  41241. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  41242. */
  41243. updateTexture(isVisible: boolean): void;
  41244. protected _updateInternalTexture: () => void;
  41245. /**
  41246. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  41247. * @param url New url.
  41248. */
  41249. updateURL(url: string): void;
  41250. /**
  41251. * Clones the texture.
  41252. * @returns the cloned texture
  41253. */
  41254. clone(): VideoTexture;
  41255. /**
  41256. * Dispose the texture and release its associated resources.
  41257. */
  41258. dispose(): void;
  41259. /**
  41260. * Creates a video texture straight from a stream.
  41261. * @param scene Define the scene the texture should be created in
  41262. * @param stream Define the stream the texture should be created from
  41263. * @returns The created video texture as a promise
  41264. */
  41265. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  41266. /**
  41267. * Creates a video texture straight from your WebCam video feed.
  41268. * @param scene Define the scene the texture should be created in
  41269. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41270. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41271. * @returns The created video texture as a promise
  41272. */
  41273. static CreateFromWebCamAsync(scene: Scene, constraints: {
  41274. minWidth: number;
  41275. maxWidth: number;
  41276. minHeight: number;
  41277. maxHeight: number;
  41278. deviceId: string;
  41279. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  41280. /**
  41281. * Creates a video texture straight from your WebCam video feed.
  41282. * @param scene Define the scene the texture should be created in
  41283. * @param onReady Define a callback to triggered once the texture will be ready
  41284. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41285. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41286. */
  41287. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  41288. minWidth: number;
  41289. maxWidth: number;
  41290. minHeight: number;
  41291. maxHeight: number;
  41292. deviceId: string;
  41293. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  41294. }
  41295. }
  41296. declare module "babylonjs/Engines/thinEngine" {
  41297. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  41298. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  41299. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41300. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41301. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  41302. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  41303. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  41304. import { Observable } from "babylonjs/Misc/observable";
  41305. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  41306. import { StencilState } from "babylonjs/States/stencilState";
  41307. import { AlphaState } from "babylonjs/States/alphaCullingState";
  41308. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41309. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41310. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41311. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  41312. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41313. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41314. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41315. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  41316. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  41317. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41318. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  41319. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  41320. import { EngineFeatures } from "babylonjs/Engines/engineFeatures";
  41321. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41322. import { WebRequest } from "babylonjs/Misc/webRequest";
  41323. import { LoadFileError } from "babylonjs/Misc/fileTools";
  41324. /**
  41325. * Defines the interface used by objects working like Scene
  41326. * @hidden
  41327. */
  41328. export interface ISceneLike {
  41329. _addPendingData(data: any): void;
  41330. _removePendingData(data: any): void;
  41331. offlineProvider: IOfflineProvider;
  41332. }
  41333. /**
  41334. * Information about the current host
  41335. */
  41336. export interface HostInformation {
  41337. /**
  41338. * Defines if the current host is a mobile
  41339. */
  41340. isMobile: boolean;
  41341. }
  41342. /** Interface defining initialization parameters for Engine class */
  41343. export interface EngineOptions extends WebGLContextAttributes {
  41344. /**
  41345. * Defines if the engine should no exceed a specified device ratio
  41346. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  41347. */
  41348. limitDeviceRatio?: number;
  41349. /**
  41350. * Defines if webvr should be enabled automatically
  41351. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41352. */
  41353. autoEnableWebVR?: boolean;
  41354. /**
  41355. * Defines if webgl2 should be turned off even if supported
  41356. * @see https://doc.babylonjs.com/features/webgl2
  41357. */
  41358. disableWebGL2Support?: boolean;
  41359. /**
  41360. * Defines if webaudio should be initialized as well
  41361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41362. */
  41363. audioEngine?: boolean;
  41364. /**
  41365. * Defines if animations should run using a deterministic lock step
  41366. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41367. */
  41368. deterministicLockstep?: boolean;
  41369. /** Defines the maximum steps to use with deterministic lock step mode */
  41370. lockstepMaxSteps?: number;
  41371. /** Defines the seconds between each deterministic lock step */
  41372. timeStep?: number;
  41373. /**
  41374. * Defines that engine should ignore context lost events
  41375. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  41376. */
  41377. doNotHandleContextLost?: boolean;
  41378. /**
  41379. * Defines that engine should ignore modifying touch action attribute and style
  41380. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  41381. */
  41382. doNotHandleTouchAction?: boolean;
  41383. /**
  41384. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  41385. */
  41386. useHighPrecisionFloats?: boolean;
  41387. /**
  41388. * Make the canvas XR Compatible for XR sessions
  41389. */
  41390. xrCompatible?: boolean;
  41391. /**
  41392. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  41393. */
  41394. useHighPrecisionMatrix?: boolean;
  41395. /**
  41396. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  41397. */
  41398. failIfMajorPerformanceCaveat?: boolean;
  41399. }
  41400. /**
  41401. * The base engine class (root of all engines)
  41402. */
  41403. export class ThinEngine {
  41404. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  41405. static ExceptionList: ({
  41406. key: string;
  41407. capture: string;
  41408. captureConstraint: number;
  41409. targets: string[];
  41410. } | {
  41411. key: string;
  41412. capture: null;
  41413. captureConstraint: null;
  41414. targets: string[];
  41415. })[];
  41416. /** @hidden */
  41417. static _TextureLoaders: IInternalTextureLoader[];
  41418. /**
  41419. * Returns the current npm package of the sdk
  41420. */
  41421. static get NpmPackage(): string;
  41422. /**
  41423. * Returns the current version of the framework
  41424. */
  41425. static get Version(): string;
  41426. /**
  41427. * Returns a string describing the current engine
  41428. */
  41429. get description(): string;
  41430. /**
  41431. * Returns the name of the engine
  41432. */
  41433. get name(): string;
  41434. /**
  41435. * Returns the version of the engine
  41436. */
  41437. get version(): number;
  41438. /**
  41439. * Gets or sets the epsilon value used by collision engine
  41440. */
  41441. static CollisionsEpsilon: number;
  41442. /**
  41443. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  41444. */
  41445. static get ShadersRepository(): string;
  41446. static set ShadersRepository(value: string);
  41447. /** @hidden */
  41448. _shaderProcessor: Nullable<IShaderProcessor>;
  41449. /**
  41450. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  41451. */
  41452. forcePOTTextures: boolean;
  41453. /**
  41454. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  41455. */
  41456. isFullscreen: boolean;
  41457. /**
  41458. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  41459. */
  41460. cullBackFaces: boolean;
  41461. /**
  41462. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  41463. */
  41464. renderEvenInBackground: boolean;
  41465. /**
  41466. * Gets or sets a boolean indicating that cache can be kept between frames
  41467. */
  41468. preventCacheWipeBetweenFrames: boolean;
  41469. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  41470. validateShaderPrograms: boolean;
  41471. /**
  41472. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  41473. * This can provide greater z depth for distant objects.
  41474. */
  41475. useReverseDepthBuffer: boolean;
  41476. /**
  41477. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  41478. */
  41479. disableUniformBuffers: boolean;
  41480. private _frameId;
  41481. /**
  41482. * Gets the current frame id
  41483. */
  41484. get frameId(): number;
  41485. /** @hidden */
  41486. _uniformBuffers: UniformBuffer[];
  41487. /**
  41488. * Gets a boolean indicating that the engine supports uniform buffers
  41489. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  41490. */
  41491. get supportsUniformBuffers(): boolean;
  41492. /** @hidden */
  41493. _gl: WebGLRenderingContext;
  41494. /** @hidden */
  41495. _webGLVersion: number;
  41496. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  41497. protected _windowIsBackground: boolean;
  41498. protected _creationOptions: EngineOptions;
  41499. protected _highPrecisionShadersAllowed: boolean;
  41500. /** @hidden */
  41501. get _shouldUseHighPrecisionShader(): boolean;
  41502. /**
  41503. * Gets a boolean indicating that only power of 2 textures are supported
  41504. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  41505. */
  41506. get needPOTTextures(): boolean;
  41507. /** @hidden */
  41508. _badOS: boolean;
  41509. /** @hidden */
  41510. _badDesktopOS: boolean;
  41511. protected _hardwareScalingLevel: number;
  41512. /** @hidden */
  41513. _caps: EngineCapabilities;
  41514. /** @hidden */
  41515. _features: EngineFeatures;
  41516. protected _isStencilEnable: boolean;
  41517. private _glVersion;
  41518. private _glRenderer;
  41519. private _glVendor;
  41520. /** @hidden */
  41521. _videoTextureSupported: boolean;
  41522. protected _renderingQueueLaunched: boolean;
  41523. protected _activeRenderLoops: (() => void)[];
  41524. /**
  41525. * Observable signaled when a context lost event is raised
  41526. */
  41527. onContextLostObservable: Observable<ThinEngine>;
  41528. /**
  41529. * Observable signaled when a context restored event is raised
  41530. */
  41531. onContextRestoredObservable: Observable<ThinEngine>;
  41532. private _onContextLost;
  41533. private _onContextRestored;
  41534. protected _contextWasLost: boolean;
  41535. /** @hidden */
  41536. _doNotHandleContextLost: boolean;
  41537. /**
  41538. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  41539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  41540. */
  41541. get doNotHandleContextLost(): boolean;
  41542. set doNotHandleContextLost(value: boolean);
  41543. /**
  41544. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  41545. */
  41546. disableVertexArrayObjects: boolean;
  41547. /** @hidden */
  41548. protected _colorWrite: boolean;
  41549. /** @hidden */
  41550. protected _colorWriteChanged: boolean;
  41551. /** @hidden */
  41552. protected _depthCullingState: DepthCullingState;
  41553. /** @hidden */
  41554. protected _stencilState: StencilState;
  41555. /** @hidden */
  41556. _alphaState: AlphaState;
  41557. /** @hidden */
  41558. _alphaMode: number;
  41559. /** @hidden */
  41560. _alphaEquation: number;
  41561. /** @hidden */
  41562. _internalTexturesCache: InternalTexture[];
  41563. /** @hidden */
  41564. protected _activeChannel: number;
  41565. private _currentTextureChannel;
  41566. /** @hidden */
  41567. protected _boundTexturesCache: {
  41568. [key: string]: Nullable<InternalTexture>;
  41569. };
  41570. /** @hidden */
  41571. protected _currentEffect: Nullable<Effect>;
  41572. /** @hidden */
  41573. protected _currentProgram: Nullable<WebGLProgram>;
  41574. protected _compiledEffects: {
  41575. [key: string]: Effect;
  41576. };
  41577. private _vertexAttribArraysEnabled;
  41578. /** @hidden */
  41579. protected _cachedViewport: Nullable<IViewportLike>;
  41580. private _cachedVertexArrayObject;
  41581. /** @hidden */
  41582. protected _cachedVertexBuffers: any;
  41583. /** @hidden */
  41584. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  41585. /** @hidden */
  41586. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  41587. /** @hidden */
  41588. _currentRenderTarget: Nullable<InternalTexture>;
  41589. private _uintIndicesCurrentlySet;
  41590. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  41591. /** @hidden */
  41592. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  41593. /** @hidden */
  41594. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  41595. private _currentBufferPointers;
  41596. private _currentInstanceLocations;
  41597. private _currentInstanceBuffers;
  41598. private _textureUnits;
  41599. /** @hidden */
  41600. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41601. /** @hidden */
  41602. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41603. /** @hidden */
  41604. _boundRenderFunction: any;
  41605. private _vaoRecordInProgress;
  41606. private _mustWipeVertexAttributes;
  41607. private _emptyTexture;
  41608. private _emptyCubeTexture;
  41609. private _emptyTexture3D;
  41610. private _emptyTexture2DArray;
  41611. /** @hidden */
  41612. _frameHandler: number;
  41613. private _nextFreeTextureSlots;
  41614. private _maxSimultaneousTextures;
  41615. private _activeRequests;
  41616. /** @hidden */
  41617. _transformTextureUrl: Nullable<(url: string) => string>;
  41618. /**
  41619. * Gets information about the current host
  41620. */
  41621. hostInformation: HostInformation;
  41622. protected get _supportsHardwareTextureRescaling(): boolean;
  41623. private _framebufferDimensionsObject;
  41624. /**
  41625. * sets the object from which width and height will be taken from when getting render width and height
  41626. * Will fallback to the gl object
  41627. * @param dimensions the framebuffer width and height that will be used.
  41628. */
  41629. set framebufferDimensionsObject(dimensions: Nullable<{
  41630. framebufferWidth: number;
  41631. framebufferHeight: number;
  41632. }>);
  41633. /**
  41634. * Gets the current viewport
  41635. */
  41636. get currentViewport(): Nullable<IViewportLike>;
  41637. /**
  41638. * Gets the default empty texture
  41639. */
  41640. get emptyTexture(): InternalTexture;
  41641. /**
  41642. * Gets the default empty 3D texture
  41643. */
  41644. get emptyTexture3D(): InternalTexture;
  41645. /**
  41646. * Gets the default empty 2D array texture
  41647. */
  41648. get emptyTexture2DArray(): InternalTexture;
  41649. /**
  41650. * Gets the default empty cube texture
  41651. */
  41652. get emptyCubeTexture(): InternalTexture;
  41653. /**
  41654. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  41655. */
  41656. premultipliedAlpha: boolean;
  41657. /**
  41658. * Observable event triggered before each texture is initialized
  41659. */
  41660. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  41661. /** @hidden */
  41662. protected _isWebGPU: boolean;
  41663. /**
  41664. * Gets a boolean indicating if the engine runs in WebGPU or not.
  41665. */
  41666. get isWebGPU(): boolean;
  41667. /** @hidden */
  41668. protected _shaderPlatformName: string;
  41669. /**
  41670. * Gets the shader platfrom name used by the effects.
  41671. */
  41672. get shaderPlatformName(): string;
  41673. /**
  41674. * Creates a new engine
  41675. * @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
  41676. * @param antialias defines enable antialiasing (default: false)
  41677. * @param options defines further options to be sent to the getContext() function
  41678. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41679. */
  41680. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41681. /**
  41682. * @hidden
  41683. */
  41684. _debugPushGroup(groupName: string, targetObject?: number): void;
  41685. /**
  41686. * @hidden
  41687. */
  41688. _debugPopGroup(targetObject?: number): void;
  41689. /**
  41690. * @hidden
  41691. */
  41692. _debugInsertMarker(text: string, targetObject?: number): void;
  41693. /**
  41694. * Shared initialization across engines types.
  41695. * @param canvas The canvas associated with this instance of the engine.
  41696. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  41697. * @param audioEngine Defines if an audio engine should be created by default
  41698. */
  41699. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  41700. /**
  41701. * Gets a shader processor implementation fitting with the current engine type.
  41702. * @returns The shader processor implementation.
  41703. */
  41704. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  41705. /** @hidden */
  41706. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  41707. private _rebuildInternalTextures;
  41708. private _rebuildEffects;
  41709. /**
  41710. * Gets a boolean indicating if all created effects are ready
  41711. * @returns true if all effects are ready
  41712. */
  41713. areAllEffectsReady(): boolean;
  41714. protected _rebuildBuffers(): void;
  41715. protected _initGLContext(): void;
  41716. protected _initFeatures(): void;
  41717. /**
  41718. * Gets version of the current webGL context
  41719. * Keep it for back compat - use version instead
  41720. */
  41721. get webGLVersion(): number;
  41722. /**
  41723. * Gets a string identifying the name of the class
  41724. * @returns "Engine" string
  41725. */
  41726. getClassName(): string;
  41727. /**
  41728. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  41729. */
  41730. get isStencilEnable(): boolean;
  41731. /** @hidden */
  41732. _prepareWorkingCanvas(): void;
  41733. /**
  41734. * Reset the texture cache to empty state
  41735. */
  41736. resetTextureCache(): void;
  41737. /**
  41738. * Gets an object containing information about the current webGL context
  41739. * @returns an object containing the vender, the renderer and the version of the current webGL context
  41740. */
  41741. getGlInfo(): {
  41742. vendor: string;
  41743. renderer: string;
  41744. version: string;
  41745. };
  41746. /**
  41747. * Defines the hardware scaling level.
  41748. * By default the hardware scaling level is computed from the window device ratio.
  41749. * 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.
  41750. * @param level defines the level to use
  41751. */
  41752. setHardwareScalingLevel(level: number): void;
  41753. /**
  41754. * Gets the current hardware scaling level.
  41755. * By default the hardware scaling level is computed from the window device ratio.
  41756. * 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.
  41757. * @returns a number indicating the current hardware scaling level
  41758. */
  41759. getHardwareScalingLevel(): number;
  41760. /**
  41761. * Gets the list of loaded textures
  41762. * @returns an array containing all loaded textures
  41763. */
  41764. getLoadedTexturesCache(): InternalTexture[];
  41765. /**
  41766. * Gets the object containing all engine capabilities
  41767. * @returns the EngineCapabilities object
  41768. */
  41769. getCaps(): EngineCapabilities;
  41770. /**
  41771. * stop executing a render loop function and remove it from the execution array
  41772. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  41773. */
  41774. stopRenderLoop(renderFunction?: () => void): void;
  41775. /** @hidden */
  41776. _renderLoop(): void;
  41777. /**
  41778. * Gets the HTML canvas attached with the current webGL context
  41779. * @returns a HTML canvas
  41780. */
  41781. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  41782. /**
  41783. * Gets host window
  41784. * @returns the host window object
  41785. */
  41786. getHostWindow(): Nullable<Window>;
  41787. /**
  41788. * Gets the current render width
  41789. * @param useScreen defines if screen size must be used (or the current render target if any)
  41790. * @returns a number defining the current render width
  41791. */
  41792. getRenderWidth(useScreen?: boolean): number;
  41793. /**
  41794. * Gets the current render height
  41795. * @param useScreen defines if screen size must be used (or the current render target if any)
  41796. * @returns a number defining the current render height
  41797. */
  41798. getRenderHeight(useScreen?: boolean): number;
  41799. /**
  41800. * Can be used to override the current requestAnimationFrame requester.
  41801. * @hidden
  41802. */
  41803. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  41804. /**
  41805. * Register and execute a render loop. The engine can have more than one render function
  41806. * @param renderFunction defines the function to continuously execute
  41807. */
  41808. runRenderLoop(renderFunction: () => void): void;
  41809. /**
  41810. * Clear the current render buffer or the current render target (if any is set up)
  41811. * @param color defines the color to use
  41812. * @param backBuffer defines if the back buffer must be cleared
  41813. * @param depth defines if the depth buffer must be cleared
  41814. * @param stencil defines if the stencil buffer must be cleared
  41815. */
  41816. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41817. protected _viewportCached: {
  41818. x: number;
  41819. y: number;
  41820. z: number;
  41821. w: number;
  41822. };
  41823. /** @hidden */
  41824. _viewport(x: number, y: number, width: number, height: number): void;
  41825. /**
  41826. * Set the WebGL's viewport
  41827. * @param viewport defines the viewport element to be used
  41828. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41829. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41830. */
  41831. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41832. /**
  41833. * Begin a new frame
  41834. */
  41835. beginFrame(): void;
  41836. /**
  41837. * Enf the current frame
  41838. */
  41839. endFrame(): void;
  41840. /**
  41841. * Resize the view according to the canvas' size
  41842. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41843. */
  41844. resize(forceSetSize?: boolean): void;
  41845. /**
  41846. * Force a specific size of the canvas
  41847. * @param width defines the new canvas' width
  41848. * @param height defines the new canvas' height
  41849. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41850. * @returns true if the size was changed
  41851. */
  41852. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41853. /**
  41854. * Binds the frame buffer to the specified texture.
  41855. * @param texture The texture to render to or null for the default canvas
  41856. * @param faceIndex The face of the texture to render to in case of cube texture
  41857. * @param requiredWidth The width of the target to render to
  41858. * @param requiredHeight The height of the target to render to
  41859. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41860. * @param lodLevel defines the lod level to bind to the frame buffer
  41861. * @param layer defines the 2d array index to bind to frame buffer to
  41862. */
  41863. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41864. /** @hidden */
  41865. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41866. /**
  41867. * Unbind the current render target texture from the webGL context
  41868. * @param texture defines the render target texture to unbind
  41869. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41870. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41871. */
  41872. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41873. /**
  41874. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  41875. */
  41876. flushFramebuffer(): void;
  41877. /**
  41878. * Unbind the current render target and bind the default framebuffer
  41879. */
  41880. restoreDefaultFramebuffer(): void;
  41881. /** @hidden */
  41882. protected _resetVertexBufferBinding(): void;
  41883. /**
  41884. * Creates a vertex buffer
  41885. * @param data the data for the vertex buffer
  41886. * @returns the new WebGL static buffer
  41887. */
  41888. createVertexBuffer(data: DataArray): DataBuffer;
  41889. private _createVertexBuffer;
  41890. /**
  41891. * Creates a dynamic vertex buffer
  41892. * @param data the data for the dynamic vertex buffer
  41893. * @returns the new WebGL dynamic buffer
  41894. */
  41895. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  41896. protected _resetIndexBufferBinding(): void;
  41897. /**
  41898. * Creates a new index buffer
  41899. * @param indices defines the content of the index buffer
  41900. * @param updatable defines if the index buffer must be updatable
  41901. * @returns a new webGL buffer
  41902. */
  41903. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  41904. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  41905. /**
  41906. * Bind a webGL buffer to the webGL context
  41907. * @param buffer defines the buffer to bind
  41908. */
  41909. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  41910. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  41911. private bindBuffer;
  41912. /**
  41913. * update the bound buffer with the given data
  41914. * @param data defines the data to update
  41915. */
  41916. updateArrayBuffer(data: Float32Array): void;
  41917. private _vertexAttribPointer;
  41918. /** @hidden */
  41919. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41920. private _bindVertexBuffersAttributes;
  41921. /**
  41922. * Records a vertex array object
  41923. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41924. * @param vertexBuffers defines the list of vertex buffers to store
  41925. * @param indexBuffer defines the index buffer to store
  41926. * @param effect defines the effect to store
  41927. * @returns the new vertex array object
  41928. */
  41929. recordVertexArrayObject(vertexBuffers: {
  41930. [key: string]: VertexBuffer;
  41931. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  41932. /**
  41933. * Bind a specific vertex array object
  41934. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41935. * @param vertexArrayObject defines the vertex array object to bind
  41936. * @param indexBuffer defines the index buffer to bind
  41937. */
  41938. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41939. /**
  41940. * Bind webGl buffers directly to the webGL context
  41941. * @param vertexBuffer defines the vertex buffer to bind
  41942. * @param indexBuffer defines the index buffer to bind
  41943. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41944. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41945. * @param effect defines the effect associated with the vertex buffer
  41946. */
  41947. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41948. private _unbindVertexArrayObject;
  41949. /**
  41950. * Bind a list of vertex buffers to the webGL context
  41951. * @param vertexBuffers defines the list of vertex buffers to bind
  41952. * @param indexBuffer defines the index buffer to bind
  41953. * @param effect defines the effect associated with the vertex buffers
  41954. */
  41955. bindBuffers(vertexBuffers: {
  41956. [key: string]: Nullable<VertexBuffer>;
  41957. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  41958. /**
  41959. * Unbind all instance attributes
  41960. */
  41961. unbindInstanceAttributes(): void;
  41962. /**
  41963. * Release and free the memory of a vertex array object
  41964. * @param vao defines the vertex array object to delete
  41965. */
  41966. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41967. /** @hidden */
  41968. _releaseBuffer(buffer: DataBuffer): boolean;
  41969. protected _deleteBuffer(buffer: DataBuffer): void;
  41970. /**
  41971. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  41972. * @param instancesBuffer defines the webGL buffer to update and bind
  41973. * @param data defines the data to store in the buffer
  41974. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41975. */
  41976. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41977. /**
  41978. * Bind the content of a webGL buffer used with instantiation
  41979. * @param instancesBuffer defines the webGL buffer to bind
  41980. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41981. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41982. */
  41983. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41984. /**
  41985. * Disable the instance attribute corresponding to the name in parameter
  41986. * @param name defines the name of the attribute to disable
  41987. */
  41988. disableInstanceAttributeByName(name: string): void;
  41989. /**
  41990. * Disable the instance attribute corresponding to the location in parameter
  41991. * @param attributeLocation defines the attribute location of the attribute to disable
  41992. */
  41993. disableInstanceAttribute(attributeLocation: number): void;
  41994. /**
  41995. * Disable the attribute corresponding to the location in parameter
  41996. * @param attributeLocation defines the attribute location of the attribute to disable
  41997. */
  41998. disableAttributeByIndex(attributeLocation: number): void;
  41999. /**
  42000. * Send a draw order
  42001. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42002. * @param indexStart defines the starting index
  42003. * @param indexCount defines the number of index to draw
  42004. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42005. */
  42006. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42007. /**
  42008. * Draw a list of points
  42009. * @param verticesStart defines the index of first vertex to draw
  42010. * @param verticesCount defines the count of vertices to draw
  42011. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42012. */
  42013. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42014. /**
  42015. * Draw a list of unindexed primitives
  42016. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42017. * @param verticesStart defines the index of first vertex to draw
  42018. * @param verticesCount defines the count of vertices to draw
  42019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42020. */
  42021. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42022. /**
  42023. * Draw a list of indexed primitives
  42024. * @param fillMode defines the primitive to use
  42025. * @param indexStart defines the starting index
  42026. * @param indexCount defines the number of index to draw
  42027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42028. */
  42029. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42030. /**
  42031. * Draw a list of unindexed primitives
  42032. * @param fillMode defines the primitive to use
  42033. * @param verticesStart defines the index of first vertex to draw
  42034. * @param verticesCount defines the count of vertices to draw
  42035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42036. */
  42037. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42038. private _drawMode;
  42039. /** @hidden */
  42040. protected _reportDrawCall(): void;
  42041. /** @hidden */
  42042. _releaseEffect(effect: Effect): void;
  42043. /** @hidden */
  42044. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42045. /**
  42046. * Create a new effect (used to store vertex/fragment shaders)
  42047. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  42048. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  42049. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  42050. * @param samplers defines an array of string used to represent textures
  42051. * @param defines defines the string containing the defines to use to compile the shaders
  42052. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  42053. * @param onCompiled defines a function to call when the effect creation is successful
  42054. * @param onError defines a function to call when the effect creation has failed
  42055. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  42056. * @returns the new Effect
  42057. */
  42058. 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;
  42059. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  42060. private _compileShader;
  42061. private _compileRawShader;
  42062. /** @hidden */
  42063. _getShaderSource(shader: WebGLShader): Nullable<string>;
  42064. /**
  42065. * Directly creates a webGL program
  42066. * @param pipelineContext defines the pipeline context to attach to
  42067. * @param vertexCode defines the vertex shader code to use
  42068. * @param fragmentCode defines the fragment shader code to use
  42069. * @param context defines the webGL context to use (if not set, the current one will be used)
  42070. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42071. * @returns the new webGL program
  42072. */
  42073. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42074. /**
  42075. * Creates a webGL program
  42076. * @param pipelineContext defines the pipeline context to attach to
  42077. * @param vertexCode defines the vertex shader code to use
  42078. * @param fragmentCode defines the fragment shader code to use
  42079. * @param defines defines the string containing the defines to use to compile the shaders
  42080. * @param context defines the webGL context to use (if not set, the current one will be used)
  42081. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42082. * @returns the new webGL program
  42083. */
  42084. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42085. /**
  42086. * Creates a new pipeline context
  42087. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  42088. * @returns the new pipeline
  42089. */
  42090. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  42091. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42092. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  42093. /** @hidden */
  42094. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  42095. /** @hidden */
  42096. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  42097. /** @hidden */
  42098. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  42099. /**
  42100. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42101. * @param pipelineContext defines the pipeline context to use
  42102. * @param uniformsNames defines the list of uniform names
  42103. * @returns an array of webGL uniform locations
  42104. */
  42105. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42106. /**
  42107. * Gets the list of active attributes for a given webGL program
  42108. * @param pipelineContext defines the pipeline context to use
  42109. * @param attributesNames defines the list of attribute names to get
  42110. * @returns an array of indices indicating the offset of each attribute
  42111. */
  42112. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42113. /**
  42114. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42115. * @param effect defines the effect to activate
  42116. */
  42117. enableEffect(effect: Nullable<Effect>): void;
  42118. /**
  42119. * Set the value of an uniform to a number (int)
  42120. * @param uniform defines the webGL uniform location where to store the value
  42121. * @param value defines the int number to store
  42122. * @returns true if the value was set
  42123. */
  42124. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42125. /**
  42126. * Set the value of an uniform to a int2
  42127. * @param uniform defines the webGL uniform location where to store the value
  42128. * @param x defines the 1st component of the value
  42129. * @param y defines the 2nd component of the value
  42130. * @returns true if the value was set
  42131. */
  42132. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42133. /**
  42134. * Set the value of an uniform to a int3
  42135. * @param uniform defines the webGL uniform location where to store the value
  42136. * @param x defines the 1st component of the value
  42137. * @param y defines the 2nd component of the value
  42138. * @param z defines the 3rd component of the value
  42139. * @returns true if the value was set
  42140. */
  42141. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42142. /**
  42143. * Set the value of an uniform to a int4
  42144. * @param uniform defines the webGL uniform location where to store the value
  42145. * @param x defines the 1st component of the value
  42146. * @param y defines the 2nd component of the value
  42147. * @param z defines the 3rd component of the value
  42148. * @param w defines the 4th component of the value
  42149. * @returns true if the value was set
  42150. */
  42151. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42152. /**
  42153. * Set the value of an uniform to an array of int32
  42154. * @param uniform defines the webGL uniform location where to store the value
  42155. * @param array defines the array of int32 to store
  42156. * @returns true if the value was set
  42157. */
  42158. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42159. /**
  42160. * Set the value of an uniform to an array of int32 (stored as vec2)
  42161. * @param uniform defines the webGL uniform location where to store the value
  42162. * @param array defines the array of int32 to store
  42163. * @returns true if the value was set
  42164. */
  42165. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42166. /**
  42167. * Set the value of an uniform to an array of int32 (stored as vec3)
  42168. * @param uniform defines the webGL uniform location where to store the value
  42169. * @param array defines the array of int32 to store
  42170. * @returns true if the value was set
  42171. */
  42172. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42173. /**
  42174. * Set the value of an uniform to an array of int32 (stored as vec4)
  42175. * @param uniform defines the webGL uniform location where to store the value
  42176. * @param array defines the array of int32 to store
  42177. * @returns true if the value was set
  42178. */
  42179. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42180. /**
  42181. * Set the value of an uniform to an array of number
  42182. * @param uniform defines the webGL uniform location where to store the value
  42183. * @param array defines the array of number to store
  42184. * @returns true if the value was set
  42185. */
  42186. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42187. /**
  42188. * Set the value of an uniform to an array of number (stored as vec2)
  42189. * @param uniform defines the webGL uniform location where to store the value
  42190. * @param array defines the array of number to store
  42191. * @returns true if the value was set
  42192. */
  42193. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42194. /**
  42195. * Set the value of an uniform to an array of number (stored as vec3)
  42196. * @param uniform defines the webGL uniform location where to store the value
  42197. * @param array defines the array of number to store
  42198. * @returns true if the value was set
  42199. */
  42200. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42201. /**
  42202. * Set the value of an uniform to an array of number (stored as vec4)
  42203. * @param uniform defines the webGL uniform location where to store the value
  42204. * @param array defines the array of number to store
  42205. * @returns true if the value was set
  42206. */
  42207. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42208. /**
  42209. * Set the value of an uniform to an array of float32 (stored as matrices)
  42210. * @param uniform defines the webGL uniform location where to store the value
  42211. * @param matrices defines the array of float32 to store
  42212. * @returns true if the value was set
  42213. */
  42214. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  42215. /**
  42216. * Set the value of an uniform to a matrix (3x3)
  42217. * @param uniform defines the webGL uniform location where to store the value
  42218. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  42219. * @returns true if the value was set
  42220. */
  42221. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42222. /**
  42223. * Set the value of an uniform to a matrix (2x2)
  42224. * @param uniform defines the webGL uniform location where to store the value
  42225. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  42226. * @returns true if the value was set
  42227. */
  42228. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42229. /**
  42230. * Set the value of an uniform to a number (float)
  42231. * @param uniform defines the webGL uniform location where to store the value
  42232. * @param value defines the float number to store
  42233. * @returns true if the value was transfered
  42234. */
  42235. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42236. /**
  42237. * Set the value of an uniform to a vec2
  42238. * @param uniform defines the webGL uniform location where to store the value
  42239. * @param x defines the 1st component of the value
  42240. * @param y defines the 2nd component of the value
  42241. * @returns true if the value was set
  42242. */
  42243. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42244. /**
  42245. * Set the value of an uniform to a vec3
  42246. * @param uniform defines the webGL uniform location where to store the value
  42247. * @param x defines the 1st component of the value
  42248. * @param y defines the 2nd component of the value
  42249. * @param z defines the 3rd component of the value
  42250. * @returns true if the value was set
  42251. */
  42252. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42253. /**
  42254. * Set the value of an uniform to a vec4
  42255. * @param uniform defines the webGL uniform location where to store the value
  42256. * @param x defines the 1st component of the value
  42257. * @param y defines the 2nd component of the value
  42258. * @param z defines the 3rd component of the value
  42259. * @param w defines the 4th component of the value
  42260. * @returns true if the value was set
  42261. */
  42262. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42263. /**
  42264. * Apply all cached states (depth, culling, stencil and alpha)
  42265. */
  42266. applyStates(): void;
  42267. /**
  42268. * Enable or disable color writing
  42269. * @param enable defines the state to set
  42270. */
  42271. setColorWrite(enable: boolean): void;
  42272. /**
  42273. * Gets a boolean indicating if color writing is enabled
  42274. * @returns the current color writing state
  42275. */
  42276. getColorWrite(): boolean;
  42277. /**
  42278. * Gets the depth culling state manager
  42279. */
  42280. get depthCullingState(): DepthCullingState;
  42281. /**
  42282. * Gets the alpha state manager
  42283. */
  42284. get alphaState(): AlphaState;
  42285. /**
  42286. * Gets the stencil state manager
  42287. */
  42288. get stencilState(): StencilState;
  42289. /**
  42290. * Clears the list of texture accessible through engine.
  42291. * This can help preventing texture load conflict due to name collision.
  42292. */
  42293. clearInternalTexturesCache(): void;
  42294. /**
  42295. * Force the entire cache to be cleared
  42296. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  42297. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  42298. */
  42299. wipeCaches(bruteForce?: boolean): void;
  42300. /** @hidden */
  42301. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  42302. min: number;
  42303. mag: number;
  42304. };
  42305. /** @hidden */
  42306. protected _createTexture(): WebGLTexture;
  42307. /** @hidden */
  42308. _createHardwareTexture(): HardwareTextureWrapper;
  42309. 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 | {
  42310. width: number;
  42311. height: number;
  42312. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42313. width: number;
  42314. height: number;
  42315. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42316. width: number;
  42317. height: number;
  42318. }, 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;
  42319. /**
  42320. * Usually called from Texture.ts.
  42321. * Passed information to create a WebGLTexture
  42322. * @param url defines a value which contains one of the following:
  42323. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  42324. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  42325. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  42326. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  42327. * @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)
  42328. * @param scene needed for loading to the correct scene
  42329. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  42330. * @param onLoad optional callback to be called upon successful completion
  42331. * @param onError optional callback to be called upon failure
  42332. * @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
  42333. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  42334. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  42335. * @param forcedExtension defines the extension to use to pick the right loader
  42336. * @param mimeType defines an optional mime type
  42337. * @param loaderOptions options to be passed to the loader
  42338. * @returns a InternalTexture for assignment back into BABYLON.Texture
  42339. */
  42340. 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;
  42341. /**
  42342. * Loads an image as an HTMLImageElement.
  42343. * @param input url string, ArrayBuffer, or Blob to load
  42344. * @param onLoad callback called when the image successfully loads
  42345. * @param onError callback called when the image fails to load
  42346. * @param offlineProvider offline provider for caching
  42347. * @param mimeType optional mime type
  42348. * @returns the HTMLImageElement of the loaded image
  42349. * @hidden
  42350. */
  42351. 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>;
  42352. /**
  42353. * @hidden
  42354. */
  42355. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42356. private _unpackFlipYCached;
  42357. /**
  42358. * In case you are sharing the context with other applications, it might
  42359. * be interested to not cache the unpack flip y state to ensure a consistent
  42360. * value would be set.
  42361. */
  42362. enableUnpackFlipYCached: boolean;
  42363. /** @hidden */
  42364. _unpackFlipY(value: boolean): void;
  42365. /** @hidden */
  42366. _getUnpackAlignement(): number;
  42367. private _getTextureTarget;
  42368. /**
  42369. * Update the sampling mode of a given texture
  42370. * @param samplingMode defines the required sampling mode
  42371. * @param texture defines the texture to update
  42372. * @param generateMipMaps defines whether to generate mipmaps for the texture
  42373. */
  42374. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  42375. /**
  42376. * Update the dimensions of a texture
  42377. * @param texture texture to update
  42378. * @param width new width of the texture
  42379. * @param height new height of the texture
  42380. * @param depth new depth of the texture
  42381. */
  42382. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  42383. /**
  42384. * Update the sampling mode of a given texture
  42385. * @param texture defines the texture to update
  42386. * @param wrapU defines the texture wrap mode of the u coordinates
  42387. * @param wrapV defines the texture wrap mode of the v coordinates
  42388. * @param wrapR defines the texture wrap mode of the r coordinates
  42389. */
  42390. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  42391. /** @hidden */
  42392. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  42393. width: number;
  42394. height: number;
  42395. layers?: number;
  42396. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  42397. /** @hidden */
  42398. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42399. /** @hidden */
  42400. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  42401. /**
  42402. * Update a portion of an internal texture
  42403. * @param texture defines the texture to update
  42404. * @param imageData defines the data to store into the texture
  42405. * @param xOffset defines the x coordinates of the update rectangle
  42406. * @param yOffset defines the y coordinates of the update rectangle
  42407. * @param width defines the width of the update rectangle
  42408. * @param height defines the height of the update rectangle
  42409. * @param faceIndex defines the face index if texture is a cube (0 by default)
  42410. * @param lod defines the lod level to update (0 by default)
  42411. */
  42412. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  42413. /** @hidden */
  42414. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42415. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  42416. private _prepareWebGLTexture;
  42417. /** @hidden */
  42418. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  42419. private _getDepthStencilBuffer;
  42420. /** @hidden */
  42421. _releaseFramebufferObjects(texture: InternalTexture): void;
  42422. /** @hidden */
  42423. _releaseTexture(texture: InternalTexture): void;
  42424. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  42425. protected _setProgram(program: WebGLProgram): void;
  42426. protected _boundUniforms: {
  42427. [key: number]: WebGLUniformLocation;
  42428. };
  42429. /**
  42430. * Binds an effect to the webGL context
  42431. * @param effect defines the effect to bind
  42432. */
  42433. bindSamplers(effect: Effect): void;
  42434. private _activateCurrentTexture;
  42435. /** @hidden */
  42436. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  42437. /** @hidden */
  42438. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  42439. /**
  42440. * Unbind all textures from the webGL context
  42441. */
  42442. unbindAllTextures(): void;
  42443. /**
  42444. * Sets a texture to the according uniform.
  42445. * @param channel The texture channel
  42446. * @param uniform The uniform to set
  42447. * @param texture The texture to apply
  42448. * @param name The name of the uniform in the effect
  42449. */
  42450. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  42451. private _bindSamplerUniformToChannel;
  42452. private _getTextureWrapMode;
  42453. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  42454. /**
  42455. * Sets an array of texture to the webGL context
  42456. * @param channel defines the channel where the texture array must be set
  42457. * @param uniform defines the associated uniform location
  42458. * @param textures defines the array of textures to bind
  42459. * @param name name of the channel
  42460. */
  42461. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  42462. /** @hidden */
  42463. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  42464. private _setTextureParameterFloat;
  42465. private _setTextureParameterInteger;
  42466. /**
  42467. * Unbind all vertex attributes from the webGL context
  42468. */
  42469. unbindAllAttributes(): void;
  42470. /**
  42471. * 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
  42472. */
  42473. releaseEffects(): void;
  42474. /**
  42475. * Dispose and release all associated resources
  42476. */
  42477. dispose(): void;
  42478. /**
  42479. * Attach a new callback raised when context lost event is fired
  42480. * @param callback defines the callback to call
  42481. */
  42482. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42483. /**
  42484. * Attach a new callback raised when context restored event is fired
  42485. * @param callback defines the callback to call
  42486. */
  42487. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42488. /**
  42489. * Get the current error code of the webGL context
  42490. * @returns the error code
  42491. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42492. */
  42493. getError(): number;
  42494. private _canRenderToFloatFramebuffer;
  42495. private _canRenderToHalfFloatFramebuffer;
  42496. private _canRenderToFramebuffer;
  42497. /** @hidden */
  42498. _getWebGLTextureType(type: number): number;
  42499. /** @hidden */
  42500. _getInternalFormat(format: number): number;
  42501. /** @hidden */
  42502. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  42503. /** @hidden */
  42504. _getRGBAMultiSampleBufferFormat(type: number): number;
  42505. /** @hidden */
  42506. _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;
  42507. /**
  42508. * Loads a file from a url
  42509. * @param url url to load
  42510. * @param onSuccess callback called when the file successfully loads
  42511. * @param onProgress callback called while file is loading (if the server supports this mode)
  42512. * @param offlineProvider defines the offline provider for caching
  42513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42514. * @param onError callback called when the file fails to load
  42515. * @returns a file request object
  42516. * @hidden
  42517. */
  42518. 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;
  42519. /**
  42520. * Reads pixels from the current frame buffer. Please note that this function can be slow
  42521. * @param x defines the x coordinate of the rectangle where pixels must be read
  42522. * @param y defines the y coordinate of the rectangle where pixels must be read
  42523. * @param width defines the width of the rectangle where pixels must be read
  42524. * @param height defines the height of the rectangle where pixels must be read
  42525. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  42526. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  42527. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  42528. */
  42529. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42530. private static _IsSupported;
  42531. private static _HasMajorPerformanceCaveat;
  42532. /**
  42533. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42534. */
  42535. static get IsSupported(): boolean;
  42536. /**
  42537. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42538. * @returns true if the engine can be created
  42539. * @ignorenaming
  42540. */
  42541. static isSupported(): boolean;
  42542. /**
  42543. * 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)
  42544. */
  42545. static get HasMajorPerformanceCaveat(): boolean;
  42546. /**
  42547. * Find the next highest power of two.
  42548. * @param x Number to start search from.
  42549. * @return Next highest power of two.
  42550. */
  42551. static CeilingPOT(x: number): number;
  42552. /**
  42553. * Find the next lowest power of two.
  42554. * @param x Number to start search from.
  42555. * @return Next lowest power of two.
  42556. */
  42557. static FloorPOT(x: number): number;
  42558. /**
  42559. * Find the nearest power of two.
  42560. * @param x Number to start search from.
  42561. * @return Next nearest power of two.
  42562. */
  42563. static NearestPOT(x: number): number;
  42564. /**
  42565. * Get the closest exponent of two
  42566. * @param value defines the value to approximate
  42567. * @param max defines the maximum value to return
  42568. * @param mode defines how to define the closest value
  42569. * @returns closest exponent of two of the given value
  42570. */
  42571. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  42572. /**
  42573. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  42574. * @param func - the function to be called
  42575. * @param requester - the object that will request the next frame. Falls back to window.
  42576. * @returns frame number
  42577. */
  42578. static QueueNewFrame(func: () => void, requester?: any): number;
  42579. /**
  42580. * Gets host document
  42581. * @returns the host document object
  42582. */
  42583. getHostDocument(): Nullable<Document>;
  42584. }
  42585. }
  42586. declare module "babylonjs/Materials/Textures/internalTexture" {
  42587. import { Observable } from "babylonjs/Misc/observable";
  42588. import { Nullable, int } from "babylonjs/types";
  42589. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  42590. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  42591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42592. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  42593. /**
  42594. * Defines the source of the internal texture
  42595. */
  42596. export enum InternalTextureSource {
  42597. /**
  42598. * The source of the texture data is unknown
  42599. */
  42600. Unknown = 0,
  42601. /**
  42602. * Texture data comes from an URL
  42603. */
  42604. Url = 1,
  42605. /**
  42606. * Texture data is only used for temporary storage
  42607. */
  42608. Temp = 2,
  42609. /**
  42610. * Texture data comes from raw data (ArrayBuffer)
  42611. */
  42612. Raw = 3,
  42613. /**
  42614. * Texture content is dynamic (video or dynamic texture)
  42615. */
  42616. Dynamic = 4,
  42617. /**
  42618. * Texture content is generated by rendering to it
  42619. */
  42620. RenderTarget = 5,
  42621. /**
  42622. * Texture content is part of a multi render target process
  42623. */
  42624. MultiRenderTarget = 6,
  42625. /**
  42626. * Texture data comes from a cube data file
  42627. */
  42628. Cube = 7,
  42629. /**
  42630. * Texture data comes from a raw cube data
  42631. */
  42632. CubeRaw = 8,
  42633. /**
  42634. * Texture data come from a prefiltered cube data file
  42635. */
  42636. CubePrefiltered = 9,
  42637. /**
  42638. * Texture content is raw 3D data
  42639. */
  42640. Raw3D = 10,
  42641. /**
  42642. * Texture content is raw 2D array data
  42643. */
  42644. Raw2DArray = 11,
  42645. /**
  42646. * Texture content is a depth texture
  42647. */
  42648. Depth = 12,
  42649. /**
  42650. * Texture data comes from a raw cube data encoded with RGBD
  42651. */
  42652. CubeRawRGBD = 13
  42653. }
  42654. /**
  42655. * Class used to store data associated with WebGL texture data for the engine
  42656. * This class should not be used directly
  42657. */
  42658. export class InternalTexture {
  42659. /** @hidden */
  42660. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  42661. /**
  42662. * Defines if the texture is ready
  42663. */
  42664. isReady: boolean;
  42665. /**
  42666. * Defines if the texture is a cube texture
  42667. */
  42668. isCube: boolean;
  42669. /**
  42670. * Defines if the texture contains 3D data
  42671. */
  42672. is3D: boolean;
  42673. /**
  42674. * Defines if the texture contains 2D array data
  42675. */
  42676. is2DArray: boolean;
  42677. /**
  42678. * Defines if the texture contains multiview data
  42679. */
  42680. isMultiview: boolean;
  42681. /**
  42682. * Gets the URL used to load this texture
  42683. */
  42684. url: string;
  42685. /** @hidden */
  42686. _originalUrl: string;
  42687. /**
  42688. * Gets the sampling mode of the texture
  42689. */
  42690. samplingMode: number;
  42691. /**
  42692. * Gets a boolean indicating if the texture needs mipmaps generation
  42693. */
  42694. generateMipMaps: boolean;
  42695. /**
  42696. * Gets the number of samples used by the texture (WebGL2+ only)
  42697. */
  42698. samples: number;
  42699. /**
  42700. * Gets the type of the texture (int, float...)
  42701. */
  42702. type: number;
  42703. /**
  42704. * Gets the format of the texture (RGB, RGBA...)
  42705. */
  42706. format: number;
  42707. /**
  42708. * Observable called when the texture is loaded
  42709. */
  42710. onLoadedObservable: Observable<InternalTexture>;
  42711. /**
  42712. * Gets the width of the texture
  42713. */
  42714. width: number;
  42715. /**
  42716. * Gets the height of the texture
  42717. */
  42718. height: number;
  42719. /**
  42720. * Gets the depth of the texture
  42721. */
  42722. depth: number;
  42723. /**
  42724. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  42725. */
  42726. baseWidth: number;
  42727. /**
  42728. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  42729. */
  42730. baseHeight: number;
  42731. /**
  42732. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  42733. */
  42734. baseDepth: number;
  42735. /**
  42736. * Gets a boolean indicating if the texture is inverted on Y axis
  42737. */
  42738. invertY: boolean;
  42739. /** @hidden */
  42740. _invertVScale: boolean;
  42741. /** @hidden */
  42742. _associatedChannel: number;
  42743. /** @hidden */
  42744. _source: InternalTextureSource;
  42745. /** @hidden */
  42746. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  42747. /** @hidden */
  42748. _bufferView: Nullable<ArrayBufferView>;
  42749. /** @hidden */
  42750. _bufferViewArray: Nullable<ArrayBufferView[]>;
  42751. /** @hidden */
  42752. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  42753. /** @hidden */
  42754. _size: number;
  42755. /** @hidden */
  42756. _extension: string;
  42757. /** @hidden */
  42758. _files: Nullable<string[]>;
  42759. /** @hidden */
  42760. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  42761. /** @hidden */
  42762. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  42763. /** @hidden */
  42764. _framebuffer: Nullable<WebGLFramebuffer>;
  42765. /** @hidden */
  42766. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  42767. /** @hidden */
  42768. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  42769. /** @hidden */
  42770. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  42771. /** @hidden */
  42772. _attachments: Nullable<number[]>;
  42773. /** @hidden */
  42774. _textureArray: Nullable<InternalTexture[]>;
  42775. /** @hidden */
  42776. _cachedCoordinatesMode: Nullable<number>;
  42777. /** @hidden */
  42778. _cachedWrapU: Nullable<number>;
  42779. /** @hidden */
  42780. _cachedWrapV: Nullable<number>;
  42781. /** @hidden */
  42782. _cachedWrapR: Nullable<number>;
  42783. /** @hidden */
  42784. _cachedAnisotropicFilteringLevel: Nullable<number>;
  42785. /** @hidden */
  42786. _isDisabled: boolean;
  42787. /** @hidden */
  42788. _compression: Nullable<string>;
  42789. /** @hidden */
  42790. _generateStencilBuffer: boolean;
  42791. /** @hidden */
  42792. _generateDepthBuffer: boolean;
  42793. /** @hidden */
  42794. _comparisonFunction: number;
  42795. /** @hidden */
  42796. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  42797. /** @hidden */
  42798. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  42799. /** @hidden */
  42800. _sphericalPolynomialComputed: boolean;
  42801. /** @hidden */
  42802. _lodGenerationScale: number;
  42803. /** @hidden */
  42804. _lodGenerationOffset: number;
  42805. /** @hidden */
  42806. _depthStencilTexture: Nullable<InternalTexture>;
  42807. /** @hidden */
  42808. _colorTextureArray: Nullable<WebGLTexture>;
  42809. /** @hidden */
  42810. _depthStencilTextureArray: Nullable<WebGLTexture>;
  42811. /** @hidden */
  42812. _lodTextureHigh: Nullable<BaseTexture>;
  42813. /** @hidden */
  42814. _lodTextureMid: Nullable<BaseTexture>;
  42815. /** @hidden */
  42816. _lodTextureLow: Nullable<BaseTexture>;
  42817. /** @hidden */
  42818. _isRGBD: boolean;
  42819. /** @hidden */
  42820. _linearSpecularLOD: boolean;
  42821. /** @hidden */
  42822. _irradianceTexture: Nullable<BaseTexture>;
  42823. /** @hidden */
  42824. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  42825. /** @hidden */
  42826. _references: number;
  42827. /** @hidden */
  42828. _gammaSpace: Nullable<boolean>;
  42829. /** @hidden */
  42830. _hasAlpha: Nullable<boolean>;
  42831. private _engine;
  42832. private _uniqueId;
  42833. private static _Counter;
  42834. /** Gets the unique id of the internal texture */
  42835. get uniqueId(): number;
  42836. /**
  42837. * Gets the Engine the texture belongs to.
  42838. * @returns The babylon engine
  42839. */
  42840. getEngine(): ThinEngine;
  42841. /**
  42842. * Gets the data source type of the texture
  42843. */
  42844. get source(): InternalTextureSource;
  42845. /**
  42846. * Creates a new InternalTexture
  42847. * @param engine defines the engine to use
  42848. * @param source defines the type of data that will be used
  42849. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42850. */
  42851. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42852. /**
  42853. * Increments the number of references (ie. the number of Texture that point to it)
  42854. */
  42855. incrementReferences(): void;
  42856. /**
  42857. * Change the size of the texture (not the size of the content)
  42858. * @param width defines the new width
  42859. * @param height defines the new height
  42860. * @param depth defines the new depth (1 by default)
  42861. */
  42862. updateSize(width: int, height: int, depth?: int): void;
  42863. /** @hidden */
  42864. _rebuild(): void;
  42865. /** @hidden */
  42866. _swapAndDie(target: InternalTexture): void;
  42867. /**
  42868. * Dispose the current allocated resources
  42869. */
  42870. dispose(): void;
  42871. }
  42872. }
  42873. declare module "babylonjs/Loading/loadingScreen" {
  42874. /**
  42875. * Interface used to present a loading screen while loading a scene
  42876. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42877. */
  42878. export interface ILoadingScreen {
  42879. /**
  42880. * Function called to display the loading screen
  42881. */
  42882. displayLoadingUI: () => void;
  42883. /**
  42884. * Function called to hide the loading screen
  42885. */
  42886. hideLoadingUI: () => void;
  42887. /**
  42888. * Gets or sets the color to use for the background
  42889. */
  42890. loadingUIBackgroundColor: string;
  42891. /**
  42892. * Gets or sets the text to display while loading
  42893. */
  42894. loadingUIText: string;
  42895. }
  42896. /**
  42897. * Class used for the default loading screen
  42898. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42899. */
  42900. export class DefaultLoadingScreen implements ILoadingScreen {
  42901. private _renderingCanvas;
  42902. private _loadingText;
  42903. private _loadingDivBackgroundColor;
  42904. private _loadingDiv;
  42905. private _loadingTextDiv;
  42906. /** Gets or sets the logo url to use for the default loading screen */
  42907. static DefaultLogoUrl: string;
  42908. /** Gets or sets the spinner url to use for the default loading screen */
  42909. static DefaultSpinnerUrl: string;
  42910. /**
  42911. * Creates a new default loading screen
  42912. * @param _renderingCanvas defines the canvas used to render the scene
  42913. * @param _loadingText defines the default text to display
  42914. * @param _loadingDivBackgroundColor defines the default background color
  42915. */
  42916. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  42917. /**
  42918. * Function called to display the loading screen
  42919. */
  42920. displayLoadingUI(): void;
  42921. /**
  42922. * Function called to hide the loading screen
  42923. */
  42924. hideLoadingUI(): void;
  42925. /**
  42926. * Gets or sets the text to display while loading
  42927. */
  42928. set loadingUIText(text: string);
  42929. get loadingUIText(): string;
  42930. /**
  42931. * Gets or sets the color to use for the background
  42932. */
  42933. get loadingUIBackgroundColor(): string;
  42934. set loadingUIBackgroundColor(color: string);
  42935. private _resizeLoadingUI;
  42936. }
  42937. }
  42938. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  42939. /**
  42940. * Interface for any object that can request an animation frame
  42941. */
  42942. export interface ICustomAnimationFrameRequester {
  42943. /**
  42944. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  42945. */
  42946. renderFunction?: Function;
  42947. /**
  42948. * Called to request the next frame to render to
  42949. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  42950. */
  42951. requestAnimationFrame: Function;
  42952. /**
  42953. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  42954. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  42955. */
  42956. requestID?: number;
  42957. }
  42958. }
  42959. declare module "babylonjs/Misc/performanceMonitor" {
  42960. /**
  42961. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  42962. */
  42963. export class PerformanceMonitor {
  42964. private _enabled;
  42965. private _rollingFrameTime;
  42966. private _lastFrameTimeMs;
  42967. /**
  42968. * constructor
  42969. * @param frameSampleSize The number of samples required to saturate the sliding window
  42970. */
  42971. constructor(frameSampleSize?: number);
  42972. /**
  42973. * Samples current frame
  42974. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  42975. */
  42976. sampleFrame(timeMs?: number): void;
  42977. /**
  42978. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42979. */
  42980. get averageFrameTime(): number;
  42981. /**
  42982. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42983. */
  42984. get averageFrameTimeVariance(): number;
  42985. /**
  42986. * Returns the frame time of the most recent frame
  42987. */
  42988. get instantaneousFrameTime(): number;
  42989. /**
  42990. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  42991. */
  42992. get averageFPS(): number;
  42993. /**
  42994. * Returns the average framerate in frames per second using the most recent frame time
  42995. */
  42996. get instantaneousFPS(): number;
  42997. /**
  42998. * Returns true if enough samples have been taken to completely fill the sliding window
  42999. */
  43000. get isSaturated(): boolean;
  43001. /**
  43002. * Enables contributions to the sliding window sample set
  43003. */
  43004. enable(): void;
  43005. /**
  43006. * Disables contributions to the sliding window sample set
  43007. * Samples will not be interpolated over the disabled period
  43008. */
  43009. disable(): void;
  43010. /**
  43011. * Returns true if sampling is enabled
  43012. */
  43013. get isEnabled(): boolean;
  43014. /**
  43015. * Resets performance monitor
  43016. */
  43017. reset(): void;
  43018. }
  43019. /**
  43020. * RollingAverage
  43021. *
  43022. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  43023. */
  43024. export class RollingAverage {
  43025. /**
  43026. * Current average
  43027. */
  43028. average: number;
  43029. /**
  43030. * Current variance
  43031. */
  43032. variance: number;
  43033. protected _samples: Array<number>;
  43034. protected _sampleCount: number;
  43035. protected _pos: number;
  43036. protected _m2: number;
  43037. /**
  43038. * constructor
  43039. * @param length The number of samples required to saturate the sliding window
  43040. */
  43041. constructor(length: number);
  43042. /**
  43043. * Adds a sample to the sample set
  43044. * @param v The sample value
  43045. */
  43046. add(v: number): void;
  43047. /**
  43048. * Returns previously added values or null if outside of history or outside the sliding window domain
  43049. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  43050. * @return Value previously recorded with add() or null if outside of range
  43051. */
  43052. history(i: number): number;
  43053. /**
  43054. * Returns true if enough samples have been taken to completely fill the sliding window
  43055. * @return true if sample-set saturated
  43056. */
  43057. isSaturated(): boolean;
  43058. /**
  43059. * Resets the rolling average (equivalent to 0 samples taken so far)
  43060. */
  43061. reset(): void;
  43062. /**
  43063. * Wraps a value around the sample range boundaries
  43064. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  43065. * @return Wrapped position in sample range
  43066. */
  43067. protected _wrapPosition(i: number): number;
  43068. }
  43069. }
  43070. declare module "babylonjs/Misc/perfCounter" {
  43071. /**
  43072. * This class is used to track a performance counter which is number based.
  43073. * The user has access to many properties which give statistics of different nature.
  43074. *
  43075. * The implementer can track two kinds of Performance Counter: time and count.
  43076. * 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.
  43077. * 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.
  43078. */
  43079. export class PerfCounter {
  43080. /**
  43081. * Gets or sets a global boolean to turn on and off all the counters
  43082. */
  43083. static Enabled: boolean;
  43084. /**
  43085. * Returns the smallest value ever
  43086. */
  43087. get min(): number;
  43088. /**
  43089. * Returns the biggest value ever
  43090. */
  43091. get max(): number;
  43092. /**
  43093. * Returns the average value since the performance counter is running
  43094. */
  43095. get average(): number;
  43096. /**
  43097. * Returns the average value of the last second the counter was monitored
  43098. */
  43099. get lastSecAverage(): number;
  43100. /**
  43101. * Returns the current value
  43102. */
  43103. get current(): number;
  43104. /**
  43105. * Gets the accumulated total
  43106. */
  43107. get total(): number;
  43108. /**
  43109. * Gets the total value count
  43110. */
  43111. get count(): number;
  43112. /**
  43113. * Creates a new counter
  43114. */
  43115. constructor();
  43116. /**
  43117. * Call this method to start monitoring a new frame.
  43118. * 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.
  43119. */
  43120. fetchNewFrame(): void;
  43121. /**
  43122. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  43123. * @param newCount the count value to add to the monitored count
  43124. * @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.
  43125. */
  43126. addCount(newCount: number, fetchResult: boolean): void;
  43127. /**
  43128. * Start monitoring this performance counter
  43129. */
  43130. beginMonitoring(): void;
  43131. /**
  43132. * Compute the time lapsed since the previous beginMonitoring() call.
  43133. * @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
  43134. */
  43135. endMonitoring(newFrame?: boolean): void;
  43136. private _fetchResult;
  43137. private _startMonitoringTime;
  43138. private _min;
  43139. private _max;
  43140. private _average;
  43141. private _current;
  43142. private _totalValueCount;
  43143. private _totalAccumulated;
  43144. private _lastSecAverage;
  43145. private _lastSecAccumulated;
  43146. private _lastSecTime;
  43147. private _lastSecValueCount;
  43148. }
  43149. }
  43150. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  43151. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43152. import { Nullable } from "babylonjs/types";
  43153. module "babylonjs/Engines/thinEngine" {
  43154. interface ThinEngine {
  43155. /** @hidden */
  43156. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  43157. }
  43158. }
  43159. }
  43160. declare module "babylonjs/Audio/analyser" {
  43161. import { Scene } from "babylonjs/scene";
  43162. /**
  43163. * Class used to work with sound analyzer using fast fourier transform (FFT)
  43164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43165. */
  43166. export class Analyser {
  43167. /**
  43168. * Gets or sets the smoothing
  43169. * @ignorenaming
  43170. */
  43171. SMOOTHING: number;
  43172. /**
  43173. * Gets or sets the FFT table size
  43174. * @ignorenaming
  43175. */
  43176. FFT_SIZE: number;
  43177. /**
  43178. * Gets or sets the bar graph amplitude
  43179. * @ignorenaming
  43180. */
  43181. BARGRAPHAMPLITUDE: number;
  43182. /**
  43183. * Gets or sets the position of the debug canvas
  43184. * @ignorenaming
  43185. */
  43186. DEBUGCANVASPOS: {
  43187. x: number;
  43188. y: number;
  43189. };
  43190. /**
  43191. * Gets or sets the debug canvas size
  43192. * @ignorenaming
  43193. */
  43194. DEBUGCANVASSIZE: {
  43195. width: number;
  43196. height: number;
  43197. };
  43198. private _byteFreqs;
  43199. private _byteTime;
  43200. private _floatFreqs;
  43201. private _webAudioAnalyser;
  43202. private _debugCanvas;
  43203. private _debugCanvasContext;
  43204. private _scene;
  43205. private _registerFunc;
  43206. private _audioEngine;
  43207. /**
  43208. * Creates a new analyser
  43209. * @param scene defines hosting scene
  43210. */
  43211. constructor(scene: Scene);
  43212. /**
  43213. * Get the number of data values you will have to play with for the visualization
  43214. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  43215. * @returns a number
  43216. */
  43217. getFrequencyBinCount(): number;
  43218. /**
  43219. * Gets the current frequency data as a byte array
  43220. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43221. * @returns a Uint8Array
  43222. */
  43223. getByteFrequencyData(): Uint8Array;
  43224. /**
  43225. * Gets the current waveform as a byte array
  43226. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  43227. * @returns a Uint8Array
  43228. */
  43229. getByteTimeDomainData(): Uint8Array;
  43230. /**
  43231. * Gets the current frequency data as a float array
  43232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43233. * @returns a Float32Array
  43234. */
  43235. getFloatFrequencyData(): Float32Array;
  43236. /**
  43237. * Renders the debug canvas
  43238. */
  43239. drawDebugCanvas(): void;
  43240. /**
  43241. * Stops rendering the debug canvas and removes it
  43242. */
  43243. stopDebugCanvas(): void;
  43244. /**
  43245. * Connects two audio nodes
  43246. * @param inputAudioNode defines first node to connect
  43247. * @param outputAudioNode defines second node to connect
  43248. */
  43249. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  43250. /**
  43251. * Releases all associated resources
  43252. */
  43253. dispose(): void;
  43254. }
  43255. }
  43256. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  43257. import { Observable } from "babylonjs/Misc/observable";
  43258. import { IDisposable } from "babylonjs/scene";
  43259. import { Nullable } from "babylonjs/types";
  43260. import { Analyser } from "babylonjs/Audio/analyser";
  43261. /**
  43262. * This represents an audio engine and it is responsible
  43263. * to play, synchronize and analyse sounds throughout the application.
  43264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43265. */
  43266. export interface IAudioEngine extends IDisposable {
  43267. /**
  43268. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  43269. */
  43270. readonly canUseWebAudio: boolean;
  43271. /**
  43272. * Gets the current AudioContext if available.
  43273. */
  43274. readonly audioContext: Nullable<AudioContext>;
  43275. /**
  43276. * The master gain node defines the global audio volume of your audio engine.
  43277. */
  43278. readonly masterGain: GainNode;
  43279. /**
  43280. * Gets whether or not mp3 are supported by your browser.
  43281. */
  43282. readonly isMP3supported: boolean;
  43283. /**
  43284. * Gets whether or not ogg are supported by your browser.
  43285. */
  43286. readonly isOGGsupported: boolean;
  43287. /**
  43288. * Defines if Babylon should emit a warning if WebAudio is not supported.
  43289. * @ignoreNaming
  43290. */
  43291. WarnedWebAudioUnsupported: boolean;
  43292. /**
  43293. * Defines if the audio engine relies on a custom unlocked button.
  43294. * In this case, the embedded button will not be displayed.
  43295. */
  43296. useCustomUnlockedButton: boolean;
  43297. /**
  43298. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  43299. */
  43300. readonly unlocked: boolean;
  43301. /**
  43302. * Event raised when audio has been unlocked on the browser.
  43303. */
  43304. onAudioUnlockedObservable: Observable<IAudioEngine>;
  43305. /**
  43306. * Event raised when audio has been locked on the browser.
  43307. */
  43308. onAudioLockedObservable: Observable<IAudioEngine>;
  43309. /**
  43310. * Flags the audio engine in Locked state.
  43311. * This happens due to new browser policies preventing audio to autoplay.
  43312. */
  43313. lock(): void;
  43314. /**
  43315. * Unlocks the audio engine once a user action has been done on the dom.
  43316. * This is helpful to resume play once browser policies have been satisfied.
  43317. */
  43318. unlock(): void;
  43319. /**
  43320. * Gets the global volume sets on the master gain.
  43321. * @returns the global volume if set or -1 otherwise
  43322. */
  43323. getGlobalVolume(): number;
  43324. /**
  43325. * Sets the global volume of your experience (sets on the master gain).
  43326. * @param newVolume Defines the new global volume of the application
  43327. */
  43328. setGlobalVolume(newVolume: number): void;
  43329. /**
  43330. * Connect the audio engine to an audio analyser allowing some amazing
  43331. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43333. * @param analyser The analyser to connect to the engine
  43334. */
  43335. connectToAnalyser(analyser: Analyser): void;
  43336. }
  43337. }
  43338. declare module "babylonjs/Engines/engine" {
  43339. import { Observable } from "babylonjs/Misc/observable";
  43340. import { Nullable } from "babylonjs/types";
  43341. import { Scene } from "babylonjs/scene";
  43342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43344. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  43345. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43346. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43347. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  43348. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  43349. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  43350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43351. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  43352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43353. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43354. import "babylonjs/Engines/Extensions/engine.alpha";
  43355. import "babylonjs/Engines/Extensions/engine.readTexture";
  43356. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  43357. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  43358. import { Material } from "babylonjs/Materials/material";
  43359. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43360. /**
  43361. * Defines the interface used by display changed events
  43362. */
  43363. export interface IDisplayChangedEventArgs {
  43364. /** Gets the vrDisplay object (if any) */
  43365. vrDisplay: Nullable<any>;
  43366. /** Gets a boolean indicating if webVR is supported */
  43367. vrSupported: boolean;
  43368. }
  43369. /**
  43370. * Defines the interface used by objects containing a viewport (like a camera)
  43371. */
  43372. interface IViewportOwnerLike {
  43373. /**
  43374. * Gets or sets the viewport
  43375. */
  43376. viewport: IViewportLike;
  43377. }
  43378. /**
  43379. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  43380. */
  43381. export class Engine extends ThinEngine {
  43382. /** Defines that alpha blending is disabled */
  43383. static readonly ALPHA_DISABLE: number;
  43384. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  43385. static readonly ALPHA_ADD: number;
  43386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  43387. static readonly ALPHA_COMBINE: number;
  43388. /** Defines that alpha blending to DEST - SRC * DEST */
  43389. static readonly ALPHA_SUBTRACT: number;
  43390. /** Defines that alpha blending to SRC * DEST */
  43391. static readonly ALPHA_MULTIPLY: number;
  43392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  43393. static readonly ALPHA_MAXIMIZED: number;
  43394. /** Defines that alpha blending to SRC + DEST */
  43395. static readonly ALPHA_ONEONE: number;
  43396. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  43397. static readonly ALPHA_PREMULTIPLIED: number;
  43398. /**
  43399. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  43400. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  43401. */
  43402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  43403. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  43404. static readonly ALPHA_INTERPOLATE: number;
  43405. /**
  43406. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  43407. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  43408. */
  43409. static readonly ALPHA_SCREENMODE: number;
  43410. /** Defines that the ressource is not delayed*/
  43411. static readonly DELAYLOADSTATE_NONE: number;
  43412. /** Defines that the ressource was successfully delay loaded */
  43413. static readonly DELAYLOADSTATE_LOADED: number;
  43414. /** Defines that the ressource is currently delay loading */
  43415. static readonly DELAYLOADSTATE_LOADING: number;
  43416. /** Defines that the ressource is delayed and has not started loading */
  43417. static readonly DELAYLOADSTATE_NOTLOADED: number;
  43418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  43419. static readonly NEVER: number;
  43420. /** 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 */
  43421. static readonly ALWAYS: number;
  43422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  43423. static readonly LESS: number;
  43424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  43425. static readonly EQUAL: number;
  43426. /** 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 */
  43427. static readonly LEQUAL: number;
  43428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  43429. static readonly GREATER: number;
  43430. /** 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 */
  43431. static readonly GEQUAL: number;
  43432. /** 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 */
  43433. static readonly NOTEQUAL: number;
  43434. /** Passed to stencilOperation to specify that stencil value must be kept */
  43435. static readonly KEEP: number;
  43436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  43437. static readonly REPLACE: number;
  43438. /** Passed to stencilOperation to specify that stencil value must be incremented */
  43439. static readonly INCR: number;
  43440. /** Passed to stencilOperation to specify that stencil value must be decremented */
  43441. static readonly DECR: number;
  43442. /** Passed to stencilOperation to specify that stencil value must be inverted */
  43443. static readonly INVERT: number;
  43444. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  43445. static readonly INCR_WRAP: number;
  43446. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  43447. static readonly DECR_WRAP: number;
  43448. /** Texture is not repeating outside of 0..1 UVs */
  43449. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  43450. /** Texture is repeating outside of 0..1 UVs */
  43451. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  43452. /** Texture is repeating and mirrored */
  43453. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  43454. /** ALPHA */
  43455. static readonly TEXTUREFORMAT_ALPHA: number;
  43456. /** LUMINANCE */
  43457. static readonly TEXTUREFORMAT_LUMINANCE: number;
  43458. /** LUMINANCE_ALPHA */
  43459. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  43460. /** RGB */
  43461. static readonly TEXTUREFORMAT_RGB: number;
  43462. /** RGBA */
  43463. static readonly TEXTUREFORMAT_RGBA: number;
  43464. /** RED */
  43465. static readonly TEXTUREFORMAT_RED: number;
  43466. /** RED (2nd reference) */
  43467. static readonly TEXTUREFORMAT_R: number;
  43468. /** RG */
  43469. static readonly TEXTUREFORMAT_RG: number;
  43470. /** RED_INTEGER */
  43471. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  43472. /** RED_INTEGER (2nd reference) */
  43473. static readonly TEXTUREFORMAT_R_INTEGER: number;
  43474. /** RG_INTEGER */
  43475. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  43476. /** RGB_INTEGER */
  43477. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  43478. /** RGBA_INTEGER */
  43479. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  43480. /** UNSIGNED_BYTE */
  43481. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  43482. /** UNSIGNED_BYTE (2nd reference) */
  43483. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  43484. /** FLOAT */
  43485. static readonly TEXTURETYPE_FLOAT: number;
  43486. /** HALF_FLOAT */
  43487. static readonly TEXTURETYPE_HALF_FLOAT: number;
  43488. /** BYTE */
  43489. static readonly TEXTURETYPE_BYTE: number;
  43490. /** SHORT */
  43491. static readonly TEXTURETYPE_SHORT: number;
  43492. /** UNSIGNED_SHORT */
  43493. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  43494. /** INT */
  43495. static readonly TEXTURETYPE_INT: number;
  43496. /** UNSIGNED_INT */
  43497. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  43498. /** UNSIGNED_SHORT_4_4_4_4 */
  43499. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  43500. /** UNSIGNED_SHORT_5_5_5_1 */
  43501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  43502. /** UNSIGNED_SHORT_5_6_5 */
  43503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  43504. /** UNSIGNED_INT_2_10_10_10_REV */
  43505. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  43506. /** UNSIGNED_INT_24_8 */
  43507. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  43508. /** UNSIGNED_INT_10F_11F_11F_REV */
  43509. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  43510. /** UNSIGNED_INT_5_9_9_9_REV */
  43511. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  43512. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  43513. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  43514. /** nearest is mag = nearest and min = nearest and mip = none */
  43515. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  43516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43517. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  43518. /** Trilinear is mag = linear and min = linear and mip = linear */
  43519. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  43520. /** nearest is mag = nearest and min = nearest and mip = linear */
  43521. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  43522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43523. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  43524. /** Trilinear is mag = linear and min = linear and mip = linear */
  43525. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  43526. /** mag = nearest and min = nearest and mip = nearest */
  43527. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  43528. /** mag = nearest and min = linear and mip = nearest */
  43529. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  43530. /** mag = nearest and min = linear and mip = linear */
  43531. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  43532. /** mag = nearest and min = linear and mip = none */
  43533. static readonly TEXTURE_NEAREST_LINEAR: number;
  43534. /** mag = nearest and min = nearest and mip = none */
  43535. static readonly TEXTURE_NEAREST_NEAREST: number;
  43536. /** mag = linear and min = nearest and mip = nearest */
  43537. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  43538. /** mag = linear and min = nearest and mip = linear */
  43539. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  43540. /** mag = linear and min = linear and mip = none */
  43541. static readonly TEXTURE_LINEAR_LINEAR: number;
  43542. /** mag = linear and min = nearest and mip = none */
  43543. static readonly TEXTURE_LINEAR_NEAREST: number;
  43544. /** Explicit coordinates mode */
  43545. static readonly TEXTURE_EXPLICIT_MODE: number;
  43546. /** Spherical coordinates mode */
  43547. static readonly TEXTURE_SPHERICAL_MODE: number;
  43548. /** Planar coordinates mode */
  43549. static readonly TEXTURE_PLANAR_MODE: number;
  43550. /** Cubic coordinates mode */
  43551. static readonly TEXTURE_CUBIC_MODE: number;
  43552. /** Projection coordinates mode */
  43553. static readonly TEXTURE_PROJECTION_MODE: number;
  43554. /** Skybox coordinates mode */
  43555. static readonly TEXTURE_SKYBOX_MODE: number;
  43556. /** Inverse Cubic coordinates mode */
  43557. static readonly TEXTURE_INVCUBIC_MODE: number;
  43558. /** Equirectangular coordinates mode */
  43559. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  43560. /** Equirectangular Fixed coordinates mode */
  43561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  43562. /** Equirectangular Fixed Mirrored coordinates mode */
  43563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  43564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  43565. static readonly SCALEMODE_FLOOR: number;
  43566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  43567. static readonly SCALEMODE_NEAREST: number;
  43568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  43569. static readonly SCALEMODE_CEILING: number;
  43570. /**
  43571. * Returns the current npm package of the sdk
  43572. */
  43573. static get NpmPackage(): string;
  43574. /**
  43575. * Returns the current version of the framework
  43576. */
  43577. static get Version(): string;
  43578. /** Gets the list of created engines */
  43579. static get Instances(): Engine[];
  43580. /**
  43581. * Gets the latest created engine
  43582. */
  43583. static get LastCreatedEngine(): Nullable<Engine>;
  43584. /**
  43585. * Gets the latest created scene
  43586. */
  43587. static get LastCreatedScene(): Nullable<Scene>;
  43588. /**
  43589. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  43590. * @param flag defines which part of the materials must be marked as dirty
  43591. * @param predicate defines a predicate used to filter which materials should be affected
  43592. */
  43593. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  43594. /**
  43595. * Method called to create the default loading screen.
  43596. * This can be overriden in your own app.
  43597. * @param canvas The rendering canvas element
  43598. * @returns The loading screen
  43599. */
  43600. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  43601. /**
  43602. * Method called to create the default rescale post process on each engine.
  43603. */
  43604. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  43605. /**
  43606. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  43607. **/
  43608. enableOfflineSupport: boolean;
  43609. /**
  43610. * 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)
  43611. **/
  43612. disableManifestCheck: boolean;
  43613. /**
  43614. * Gets the list of created scenes
  43615. */
  43616. scenes: Scene[];
  43617. /**
  43618. * Event raised when a new scene is created
  43619. */
  43620. onNewSceneAddedObservable: Observable<Scene>;
  43621. /**
  43622. * Gets the list of created postprocesses
  43623. */
  43624. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43625. /**
  43626. * Gets a boolean indicating if the pointer is currently locked
  43627. */
  43628. isPointerLock: boolean;
  43629. /**
  43630. * Observable event triggered each time the rendering canvas is resized
  43631. */
  43632. onResizeObservable: Observable<Engine>;
  43633. /**
  43634. * Observable event triggered each time the canvas loses focus
  43635. */
  43636. onCanvasBlurObservable: Observable<Engine>;
  43637. /**
  43638. * Observable event triggered each time the canvas gains focus
  43639. */
  43640. onCanvasFocusObservable: Observable<Engine>;
  43641. /**
  43642. * Observable event triggered each time the canvas receives pointerout event
  43643. */
  43644. onCanvasPointerOutObservable: Observable<PointerEvent>;
  43645. /**
  43646. * Observable raised when the engine begins a new frame
  43647. */
  43648. onBeginFrameObservable: Observable<Engine>;
  43649. /**
  43650. * If set, will be used to request the next animation frame for the render loop
  43651. */
  43652. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  43653. /**
  43654. * Observable raised when the engine ends the current frame
  43655. */
  43656. onEndFrameObservable: Observable<Engine>;
  43657. /**
  43658. * Observable raised when the engine is about to compile a shader
  43659. */
  43660. onBeforeShaderCompilationObservable: Observable<Engine>;
  43661. /**
  43662. * Observable raised when the engine has jsut compiled a shader
  43663. */
  43664. onAfterShaderCompilationObservable: Observable<Engine>;
  43665. /**
  43666. * Gets the audio engine
  43667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43668. * @ignorenaming
  43669. */
  43670. static audioEngine: IAudioEngine;
  43671. /**
  43672. * Default AudioEngine factory responsible of creating the Audio Engine.
  43673. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  43674. */
  43675. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  43676. /**
  43677. * Default offline support factory responsible of creating a tool used to store data locally.
  43678. * By default, this will create a Database object if the workload has been embedded.
  43679. */
  43680. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  43681. private _loadingScreen;
  43682. private _pointerLockRequested;
  43683. private _rescalePostProcess;
  43684. protected _deterministicLockstep: boolean;
  43685. protected _lockstepMaxSteps: number;
  43686. protected _timeStep: number;
  43687. protected get _supportsHardwareTextureRescaling(): boolean;
  43688. private _fps;
  43689. private _deltaTime;
  43690. /** @hidden */
  43691. _drawCalls: PerfCounter;
  43692. /** 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 */
  43693. canvasTabIndex: number;
  43694. /**
  43695. * Turn this value on if you want to pause FPS computation when in background
  43696. */
  43697. disablePerformanceMonitorInBackground: boolean;
  43698. private _performanceMonitor;
  43699. /**
  43700. * Gets the performance monitor attached to this engine
  43701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43702. */
  43703. get performanceMonitor(): PerformanceMonitor;
  43704. private _onFocus;
  43705. private _onBlur;
  43706. private _onCanvasPointerOut;
  43707. private _onCanvasBlur;
  43708. private _onCanvasFocus;
  43709. private _onFullscreenChange;
  43710. private _onPointerLockChange;
  43711. /**
  43712. * Gets the HTML element used to attach event listeners
  43713. * @returns a HTML element
  43714. */
  43715. getInputElement(): Nullable<HTMLElement>;
  43716. /**
  43717. * Creates a new engine
  43718. * @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
  43719. * @param antialias defines enable antialiasing (default: false)
  43720. * @param options defines further options to be sent to the getContext() function
  43721. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  43722. */
  43723. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  43724. /**
  43725. * Shared initialization across engines types.
  43726. * @param canvas The canvas associated with this instance of the engine.
  43727. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  43728. * @param audioEngine Defines if an audio engine should be created by default
  43729. */
  43730. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  43731. /**
  43732. * Gets current aspect ratio
  43733. * @param viewportOwner defines the camera to use to get the aspect ratio
  43734. * @param useScreen defines if screen size must be used (or the current render target if any)
  43735. * @returns a number defining the aspect ratio
  43736. */
  43737. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  43738. /**
  43739. * Gets current screen aspect ratio
  43740. * @returns a number defining the aspect ratio
  43741. */
  43742. getScreenAspectRatio(): number;
  43743. /**
  43744. * Gets the client rect of the HTML canvas attached with the current webGL context
  43745. * @returns a client rectanglee
  43746. */
  43747. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  43748. /**
  43749. * Gets the client rect of the HTML element used for events
  43750. * @returns a client rectanglee
  43751. */
  43752. getInputElementClientRect(): Nullable<ClientRect>;
  43753. /**
  43754. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43756. * @returns true if engine is in deterministic lock step mode
  43757. */
  43758. isDeterministicLockStep(): boolean;
  43759. /**
  43760. * Gets the max steps when engine is running in deterministic lock step
  43761. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43762. * @returns the max steps
  43763. */
  43764. getLockstepMaxSteps(): number;
  43765. /**
  43766. * Returns the time in ms between steps when using deterministic lock step.
  43767. * @returns time step in (ms)
  43768. */
  43769. getTimeStep(): number;
  43770. /**
  43771. * Force the mipmap generation for the given render target texture
  43772. * @param texture defines the render target texture to use
  43773. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  43774. */
  43775. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  43776. /** States */
  43777. /**
  43778. * Set various states to the webGL context
  43779. * @param culling defines backface culling state
  43780. * @param zOffset defines the value to apply to zOffset (0 by default)
  43781. * @param force defines if states must be applied even if cache is up to date
  43782. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43783. */
  43784. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43785. /**
  43786. * Set the z offset to apply to current rendering
  43787. * @param value defines the offset to apply
  43788. */
  43789. setZOffset(value: number): void;
  43790. /**
  43791. * Gets the current value of the zOffset
  43792. * @returns the current zOffset state
  43793. */
  43794. getZOffset(): number;
  43795. /**
  43796. * Gets a boolean indicating if depth testing is enabled
  43797. * @returns the current state
  43798. */
  43799. getDepthBuffer(): boolean;
  43800. /**
  43801. * Enable or disable depth buffering
  43802. * @param enable defines the state to set
  43803. */
  43804. setDepthBuffer(enable: boolean): void;
  43805. /**
  43806. * Gets a boolean indicating if depth writing is enabled
  43807. * @returns the current depth writing state
  43808. */
  43809. getDepthWrite(): boolean;
  43810. /**
  43811. * Enable or disable depth writing
  43812. * @param enable defines the state to set
  43813. */
  43814. setDepthWrite(enable: boolean): void;
  43815. /**
  43816. * Gets a boolean indicating if stencil buffer is enabled
  43817. * @returns the current stencil buffer state
  43818. */
  43819. getStencilBuffer(): boolean;
  43820. /**
  43821. * Enable or disable the stencil buffer
  43822. * @param enable defines if the stencil buffer must be enabled or disabled
  43823. */
  43824. setStencilBuffer(enable: boolean): void;
  43825. /**
  43826. * Gets the current stencil mask
  43827. * @returns a number defining the new stencil mask to use
  43828. */
  43829. getStencilMask(): number;
  43830. /**
  43831. * Sets the current stencil mask
  43832. * @param mask defines the new stencil mask to use
  43833. */
  43834. setStencilMask(mask: number): void;
  43835. /**
  43836. * Gets the current stencil function
  43837. * @returns a number defining the stencil function to use
  43838. */
  43839. getStencilFunction(): number;
  43840. /**
  43841. * Gets the current stencil reference value
  43842. * @returns a number defining the stencil reference value to use
  43843. */
  43844. getStencilFunctionReference(): number;
  43845. /**
  43846. * Gets the current stencil mask
  43847. * @returns a number defining the stencil mask to use
  43848. */
  43849. getStencilFunctionMask(): number;
  43850. /**
  43851. * Sets the current stencil function
  43852. * @param stencilFunc defines the new stencil function to use
  43853. */
  43854. setStencilFunction(stencilFunc: number): void;
  43855. /**
  43856. * Sets the current stencil reference
  43857. * @param reference defines the new stencil reference to use
  43858. */
  43859. setStencilFunctionReference(reference: number): void;
  43860. /**
  43861. * Sets the current stencil mask
  43862. * @param mask defines the new stencil mask to use
  43863. */
  43864. setStencilFunctionMask(mask: number): void;
  43865. /**
  43866. * Gets the current stencil operation when stencil fails
  43867. * @returns a number defining stencil operation to use when stencil fails
  43868. */
  43869. getStencilOperationFail(): number;
  43870. /**
  43871. * Gets the current stencil operation when depth fails
  43872. * @returns a number defining stencil operation to use when depth fails
  43873. */
  43874. getStencilOperationDepthFail(): number;
  43875. /**
  43876. * Gets the current stencil operation when stencil passes
  43877. * @returns a number defining stencil operation to use when stencil passes
  43878. */
  43879. getStencilOperationPass(): number;
  43880. /**
  43881. * Sets the stencil operation to use when stencil fails
  43882. * @param operation defines the stencil operation to use when stencil fails
  43883. */
  43884. setStencilOperationFail(operation: number): void;
  43885. /**
  43886. * Sets the stencil operation to use when depth fails
  43887. * @param operation defines the stencil operation to use when depth fails
  43888. */
  43889. setStencilOperationDepthFail(operation: number): void;
  43890. /**
  43891. * Sets the stencil operation to use when stencil passes
  43892. * @param operation defines the stencil operation to use when stencil passes
  43893. */
  43894. setStencilOperationPass(operation: number): void;
  43895. /**
  43896. * Sets a boolean indicating if the dithering state is enabled or disabled
  43897. * @param value defines the dithering state
  43898. */
  43899. setDitheringState(value: boolean): void;
  43900. /**
  43901. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  43902. * @param value defines the rasterizer state
  43903. */
  43904. setRasterizerState(value: boolean): void;
  43905. /**
  43906. * Gets the current depth function
  43907. * @returns a number defining the depth function
  43908. */
  43909. getDepthFunction(): Nullable<number>;
  43910. /**
  43911. * Sets the current depth function
  43912. * @param depthFunc defines the function to use
  43913. */
  43914. setDepthFunction(depthFunc: number): void;
  43915. /**
  43916. * Sets the current depth function to GREATER
  43917. */
  43918. setDepthFunctionToGreater(): void;
  43919. /**
  43920. * Sets the current depth function to GEQUAL
  43921. */
  43922. setDepthFunctionToGreaterOrEqual(): void;
  43923. /**
  43924. * Sets the current depth function to LESS
  43925. */
  43926. setDepthFunctionToLess(): void;
  43927. /**
  43928. * Sets the current depth function to LEQUAL
  43929. */
  43930. setDepthFunctionToLessOrEqual(): void;
  43931. private _cachedStencilBuffer;
  43932. private _cachedStencilFunction;
  43933. private _cachedStencilMask;
  43934. private _cachedStencilOperationPass;
  43935. private _cachedStencilOperationFail;
  43936. private _cachedStencilOperationDepthFail;
  43937. private _cachedStencilReference;
  43938. /**
  43939. * Caches the the state of the stencil buffer
  43940. */
  43941. cacheStencilState(): void;
  43942. /**
  43943. * Restores the state of the stencil buffer
  43944. */
  43945. restoreStencilState(): void;
  43946. /**
  43947. * Directly set the WebGL Viewport
  43948. * @param x defines the x coordinate of the viewport (in screen space)
  43949. * @param y defines the y coordinate of the viewport (in screen space)
  43950. * @param width defines the width of the viewport (in screen space)
  43951. * @param height defines the height of the viewport (in screen space)
  43952. * @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
  43953. */
  43954. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  43955. /**
  43956. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  43957. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43958. * @param y defines the y-coordinate of the corner of the clear rectangle
  43959. * @param width defines the width of the clear rectangle
  43960. * @param height defines the height of the clear rectangle
  43961. * @param clearColor defines the clear color
  43962. */
  43963. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  43964. /**
  43965. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  43966. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43967. * @param y defines the y-coordinate of the corner of the clear rectangle
  43968. * @param width defines the width of the clear rectangle
  43969. * @param height defines the height of the clear rectangle
  43970. */
  43971. enableScissor(x: number, y: number, width: number, height: number): void;
  43972. /**
  43973. * Disable previously set scissor test rectangle
  43974. */
  43975. disableScissor(): void;
  43976. protected _reportDrawCall(): void;
  43977. /**
  43978. * Initializes a webVR display and starts listening to display change events
  43979. * The onVRDisplayChangedObservable will be notified upon these changes
  43980. * @returns The onVRDisplayChangedObservable
  43981. */
  43982. initWebVR(): Observable<IDisplayChangedEventArgs>;
  43983. /** @hidden */
  43984. _prepareVRComponent(): void;
  43985. /** @hidden */
  43986. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  43987. /** @hidden */
  43988. _submitVRFrame(): void;
  43989. /**
  43990. * Call this function to leave webVR mode
  43991. * Will do nothing if webVR is not supported or if there is no webVR device
  43992. * @see https://doc.babylonjs.com/how_to/webvr_camera
  43993. */
  43994. disableVR(): void;
  43995. /**
  43996. * Gets a boolean indicating that the system is in VR mode and is presenting
  43997. * @returns true if VR mode is engaged
  43998. */
  43999. isVRPresenting(): boolean;
  44000. /** @hidden */
  44001. _requestVRFrame(): void;
  44002. /** @hidden */
  44003. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44004. /**
  44005. * Gets the source code of the vertex shader associated with a specific webGL program
  44006. * @param program defines the program to use
  44007. * @returns a string containing the source code of the vertex shader associated with the program
  44008. */
  44009. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  44010. /**
  44011. * Gets the source code of the fragment shader associated with a specific webGL program
  44012. * @param program defines the program to use
  44013. * @returns a string containing the source code of the fragment shader associated with the program
  44014. */
  44015. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  44016. /**
  44017. * Sets a depth stencil texture from a render target to the according uniform.
  44018. * @param channel The texture channel
  44019. * @param uniform The uniform to set
  44020. * @param texture The render target texture containing the depth stencil texture to apply
  44021. * @param name The texture name
  44022. */
  44023. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  44024. /**
  44025. * Sets a texture to the webGL context from a postprocess
  44026. * @param channel defines the channel to use
  44027. * @param postProcess defines the source postprocess
  44028. * @param name name of the channel
  44029. */
  44030. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44031. /**
  44032. * Binds the output of the passed in post process to the texture channel specified
  44033. * @param channel The channel the texture should be bound to
  44034. * @param postProcess The post process which's output should be bound
  44035. * @param name name of the channel
  44036. */
  44037. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44038. protected _rebuildBuffers(): void;
  44039. /** @hidden */
  44040. _renderFrame(): void;
  44041. _renderLoop(): void;
  44042. /** @hidden */
  44043. _renderViews(): boolean;
  44044. /**
  44045. * Toggle full screen mode
  44046. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44047. */
  44048. switchFullscreen(requestPointerLock: boolean): void;
  44049. /**
  44050. * Enters full screen mode
  44051. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44052. */
  44053. enterFullscreen(requestPointerLock: boolean): void;
  44054. /**
  44055. * Exits full screen mode
  44056. */
  44057. exitFullscreen(): void;
  44058. /**
  44059. * Enters Pointerlock mode
  44060. */
  44061. enterPointerlock(): void;
  44062. /**
  44063. * Exits Pointerlock mode
  44064. */
  44065. exitPointerlock(): void;
  44066. /**
  44067. * Begin a new frame
  44068. */
  44069. beginFrame(): void;
  44070. /**
  44071. * End the current frame
  44072. */
  44073. endFrame(): void;
  44074. /**
  44075. * Resize the view according to the canvas' size
  44076. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44077. */
  44078. resize(forceSetSize?: boolean): void;
  44079. /**
  44080. * Force a specific size of the canvas
  44081. * @param width defines the new canvas' width
  44082. * @param height defines the new canvas' height
  44083. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44084. * @returns true if the size was changed
  44085. */
  44086. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44087. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44088. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44089. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44090. _releaseTexture(texture: InternalTexture): void;
  44091. /**
  44092. * @hidden
  44093. * Rescales a texture
  44094. * @param source input texutre
  44095. * @param destination destination texture
  44096. * @param scene scene to use to render the resize
  44097. * @param internalFormat format to use when resizing
  44098. * @param onComplete callback to be called when resize has completed
  44099. */
  44100. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  44101. /**
  44102. * Gets the current framerate
  44103. * @returns a number representing the framerate
  44104. */
  44105. getFps(): number;
  44106. /**
  44107. * Gets the time spent between current and previous frame
  44108. * @returns a number representing the delta time in ms
  44109. */
  44110. getDeltaTime(): number;
  44111. private _measureFps;
  44112. /** @hidden */
  44113. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  44114. /**
  44115. * Updates the sample count of a render target texture
  44116. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44117. * @param texture defines the texture to update
  44118. * @param samples defines the sample count to set
  44119. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44120. */
  44121. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  44122. /**
  44123. * Updates a depth texture Comparison Mode and Function.
  44124. * If the comparison Function is equal to 0, the mode will be set to none.
  44125. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  44126. * @param texture The texture to set the comparison function for
  44127. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  44128. */
  44129. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  44130. /**
  44131. * Creates a webGL buffer to use with instanciation
  44132. * @param capacity defines the size of the buffer
  44133. * @returns the webGL buffer
  44134. */
  44135. createInstancesBuffer(capacity: number): DataBuffer;
  44136. /**
  44137. * Delete a webGL buffer used with instanciation
  44138. * @param buffer defines the webGL buffer to delete
  44139. */
  44140. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  44141. private _clientWaitAsync;
  44142. /** @hidden */
  44143. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  44144. dispose(): void;
  44145. private _disableTouchAction;
  44146. /**
  44147. * Display the loading screen
  44148. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44149. */
  44150. displayLoadingUI(): void;
  44151. /**
  44152. * Hide the loading screen
  44153. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44154. */
  44155. hideLoadingUI(): void;
  44156. /**
  44157. * Gets the current loading screen object
  44158. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44159. */
  44160. get loadingScreen(): ILoadingScreen;
  44161. /**
  44162. * Sets the current loading screen object
  44163. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44164. */
  44165. set loadingScreen(loadingScreen: ILoadingScreen);
  44166. /**
  44167. * Sets the current loading screen text
  44168. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44169. */
  44170. set loadingUIText(text: string);
  44171. /**
  44172. * Sets the current loading screen background color
  44173. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44174. */
  44175. set loadingUIBackgroundColor(color: string);
  44176. /** Pointerlock and fullscreen */
  44177. /**
  44178. * Ask the browser to promote the current element to pointerlock mode
  44179. * @param element defines the DOM element to promote
  44180. */
  44181. static _RequestPointerlock(element: HTMLElement): void;
  44182. /**
  44183. * Asks the browser to exit pointerlock mode
  44184. */
  44185. static _ExitPointerlock(): void;
  44186. /**
  44187. * Ask the browser to promote the current element to fullscreen rendering mode
  44188. * @param element defines the DOM element to promote
  44189. */
  44190. static _RequestFullscreen(element: HTMLElement): void;
  44191. /**
  44192. * Asks the browser to exit fullscreen mode
  44193. */
  44194. static _ExitFullscreen(): void;
  44195. }
  44196. }
  44197. declare module "babylonjs/Engines/engineStore" {
  44198. import { Nullable } from "babylonjs/types";
  44199. import { Engine } from "babylonjs/Engines/engine";
  44200. import { Scene } from "babylonjs/scene";
  44201. /**
  44202. * The engine store class is responsible to hold all the instances of Engine and Scene created
  44203. * during the life time of the application.
  44204. */
  44205. export class EngineStore {
  44206. /** Gets the list of created engines */
  44207. static Instances: import("babylonjs/Engines/engine").Engine[];
  44208. /** @hidden */
  44209. static _LastCreatedScene: Nullable<Scene>;
  44210. /**
  44211. * Gets the latest created engine
  44212. */
  44213. static get LastCreatedEngine(): Nullable<Engine>;
  44214. /**
  44215. * Gets the latest created scene
  44216. */
  44217. static get LastCreatedScene(): Nullable<Scene>;
  44218. /**
  44219. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44220. * @ignorenaming
  44221. */
  44222. static UseFallbackTexture: boolean;
  44223. /**
  44224. * Texture content used if a texture cannot loaded
  44225. * @ignorenaming
  44226. */
  44227. static FallbackTexture: string;
  44228. }
  44229. }
  44230. declare module "babylonjs/Misc/promise" {
  44231. /**
  44232. * Helper class that provides a small promise polyfill
  44233. */
  44234. export class PromisePolyfill {
  44235. /**
  44236. * Static function used to check if the polyfill is required
  44237. * If this is the case then the function will inject the polyfill to window.Promise
  44238. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  44239. */
  44240. static Apply(force?: boolean): void;
  44241. }
  44242. }
  44243. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  44244. /**
  44245. * Interface for screenshot methods with describe argument called `size` as object with options
  44246. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  44247. */
  44248. export interface IScreenshotSize {
  44249. /**
  44250. * number in pixels for canvas height
  44251. */
  44252. height?: number;
  44253. /**
  44254. * multiplier allowing render at a higher or lower resolution
  44255. * If value is defined then height and width will be ignored and taken from camera
  44256. */
  44257. precision?: number;
  44258. /**
  44259. * number in pixels for canvas width
  44260. */
  44261. width?: number;
  44262. }
  44263. }
  44264. declare module "babylonjs/Misc/tools" {
  44265. import { Nullable, float } from "babylonjs/types";
  44266. import { DomManagement } from "babylonjs/Misc/domManagement";
  44267. import { WebRequest } from "babylonjs/Misc/webRequest";
  44268. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44269. import { ReadFileError } from "babylonjs/Misc/fileTools";
  44270. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44271. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  44272. import { Camera } from "babylonjs/Cameras/camera";
  44273. import { Engine } from "babylonjs/Engines/engine";
  44274. interface IColor4Like {
  44275. r: float;
  44276. g: float;
  44277. b: float;
  44278. a: float;
  44279. }
  44280. /**
  44281. * Class containing a set of static utilities functions
  44282. */
  44283. export class Tools {
  44284. /**
  44285. * Gets or sets the base URL to use to load assets
  44286. */
  44287. static get BaseUrl(): string;
  44288. static set BaseUrl(value: string);
  44289. /**
  44290. * Enable/Disable Custom HTTP Request Headers globally.
  44291. * default = false
  44292. * @see CustomRequestHeaders
  44293. */
  44294. static UseCustomRequestHeaders: boolean;
  44295. /**
  44296. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  44297. * i.e. when loading files, where the server/service expects an Authorization header
  44298. */
  44299. static CustomRequestHeaders: {
  44300. [key: string]: string;
  44301. };
  44302. /**
  44303. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  44304. */
  44305. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  44306. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  44307. /**
  44308. * Default behaviour for cors in the application.
  44309. * It can be a string if the expected behavior is identical in the entire app.
  44310. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  44311. */
  44312. static get CorsBehavior(): string | ((url: string | string[]) => string);
  44313. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  44314. /**
  44315. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44316. * @ignorenaming
  44317. */
  44318. static get UseFallbackTexture(): boolean;
  44319. static set UseFallbackTexture(value: boolean);
  44320. /**
  44321. * Use this object to register external classes like custom textures or material
  44322. * to allow the laoders to instantiate them
  44323. */
  44324. static get RegisteredExternalClasses(): {
  44325. [key: string]: Object;
  44326. };
  44327. static set RegisteredExternalClasses(classes: {
  44328. [key: string]: Object;
  44329. });
  44330. /**
  44331. * Texture content used if a texture cannot loaded
  44332. * @ignorenaming
  44333. */
  44334. static get fallbackTexture(): string;
  44335. static set fallbackTexture(value: string);
  44336. /**
  44337. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  44338. * @param u defines the coordinate on X axis
  44339. * @param v defines the coordinate on Y axis
  44340. * @param width defines the width of the source data
  44341. * @param height defines the height of the source data
  44342. * @param pixels defines the source byte array
  44343. * @param color defines the output color
  44344. */
  44345. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  44346. /**
  44347. * Interpolates between a and b via alpha
  44348. * @param a The lower value (returned when alpha = 0)
  44349. * @param b The upper value (returned when alpha = 1)
  44350. * @param alpha The interpolation-factor
  44351. * @return The mixed value
  44352. */
  44353. static Mix(a: number, b: number, alpha: number): number;
  44354. /**
  44355. * Tries to instantiate a new object from a given class name
  44356. * @param className defines the class name to instantiate
  44357. * @returns the new object or null if the system was not able to do the instantiation
  44358. */
  44359. static Instantiate(className: string): any;
  44360. /**
  44361. * Provides a slice function that will work even on IE
  44362. * @param data defines the array to slice
  44363. * @param start defines the start of the data (optional)
  44364. * @param end defines the end of the data (optional)
  44365. * @returns the new sliced array
  44366. */
  44367. static Slice<T>(data: T, start?: number, end?: number): T;
  44368. /**
  44369. * Provides a slice function that will work even on IE
  44370. * The difference between this and Slice is that this will force-convert to array
  44371. * @param data defines the array to slice
  44372. * @param start defines the start of the data (optional)
  44373. * @param end defines the end of the data (optional)
  44374. * @returns the new sliced array
  44375. */
  44376. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  44377. /**
  44378. * Polyfill for setImmediate
  44379. * @param action defines the action to execute after the current execution block
  44380. */
  44381. static SetImmediate(action: () => void): void;
  44382. /**
  44383. * Function indicating if a number is an exponent of 2
  44384. * @param value defines the value to test
  44385. * @returns true if the value is an exponent of 2
  44386. */
  44387. static IsExponentOfTwo(value: number): boolean;
  44388. private static _tmpFloatArray;
  44389. /**
  44390. * Returns the nearest 32-bit single precision float representation of a Number
  44391. * @param value A Number. If the parameter is of a different type, it will get converted
  44392. * to a number or to NaN if it cannot be converted
  44393. * @returns number
  44394. */
  44395. static FloatRound(value: number): number;
  44396. /**
  44397. * Extracts the filename from a path
  44398. * @param path defines the path to use
  44399. * @returns the filename
  44400. */
  44401. static GetFilename(path: string): string;
  44402. /**
  44403. * Extracts the "folder" part of a path (everything before the filename).
  44404. * @param uri The URI to extract the info from
  44405. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  44406. * @returns The "folder" part of the path
  44407. */
  44408. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  44409. /**
  44410. * Extracts text content from a DOM element hierarchy
  44411. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  44412. */
  44413. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  44414. /**
  44415. * Convert an angle in radians to degrees
  44416. * @param angle defines the angle to convert
  44417. * @returns the angle in degrees
  44418. */
  44419. static ToDegrees(angle: number): number;
  44420. /**
  44421. * Convert an angle in degrees to radians
  44422. * @param angle defines the angle to convert
  44423. * @returns the angle in radians
  44424. */
  44425. static ToRadians(angle: number): number;
  44426. /**
  44427. * Returns an array if obj is not an array
  44428. * @param obj defines the object to evaluate as an array
  44429. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  44430. * @returns either obj directly if obj is an array or a new array containing obj
  44431. */
  44432. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  44433. /**
  44434. * Gets the pointer prefix to use
  44435. * @param engine defines the engine we are finding the prefix for
  44436. * @returns "pointer" if touch is enabled. Else returns "mouse"
  44437. */
  44438. static GetPointerPrefix(engine: Engine): string;
  44439. /**
  44440. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  44441. * @param url define the url we are trying
  44442. * @param element define the dom element where to configure the cors policy
  44443. */
  44444. static SetCorsBehavior(url: string | string[], element: {
  44445. crossOrigin: string | null;
  44446. }): void;
  44447. /**
  44448. * Removes unwanted characters from an url
  44449. * @param url defines the url to clean
  44450. * @returns the cleaned url
  44451. */
  44452. static CleanUrl(url: string): string;
  44453. /**
  44454. * Gets or sets a function used to pre-process url before using them to load assets
  44455. */
  44456. static get PreprocessUrl(): (url: string) => string;
  44457. static set PreprocessUrl(processor: (url: string) => string);
  44458. /**
  44459. * Loads an image as an HTMLImageElement.
  44460. * @param input url string, ArrayBuffer, or Blob to load
  44461. * @param onLoad callback called when the image successfully loads
  44462. * @param onError callback called when the image fails to load
  44463. * @param offlineProvider offline provider for caching
  44464. * @param mimeType optional mime type
  44465. * @returns the HTMLImageElement of the loaded image
  44466. */
  44467. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  44468. /**
  44469. * Loads a file from a url
  44470. * @param url url string, ArrayBuffer, or Blob to load
  44471. * @param onSuccess callback called when the file successfully loads
  44472. * @param onProgress callback called while file is loading (if the server supports this mode)
  44473. * @param offlineProvider defines the offline provider for caching
  44474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44475. * @param onError callback called when the file fails to load
  44476. * @returns a file request object
  44477. */
  44478. 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;
  44479. /**
  44480. * Loads a file from a url
  44481. * @param url the file url to load
  44482. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44483. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  44484. */
  44485. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  44486. /**
  44487. * Load a script (identified by an url). When the url returns, the
  44488. * content of this file is added into a new script element, attached to the DOM (body element)
  44489. * @param scriptUrl defines the url of the script to laod
  44490. * @param onSuccess defines the callback called when the script is loaded
  44491. * @param onError defines the callback to call if an error occurs
  44492. * @param scriptId defines the id of the script element
  44493. */
  44494. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  44495. /**
  44496. * Load an asynchronous script (identified by an url). When the url returns, the
  44497. * content of this file is added into a new script element, attached to the DOM (body element)
  44498. * @param scriptUrl defines the url of the script to laod
  44499. * @param scriptId defines the id of the script element
  44500. * @returns a promise request object
  44501. */
  44502. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  44503. /**
  44504. * Loads a file from a blob
  44505. * @param fileToLoad defines the blob to use
  44506. * @param callback defines the callback to call when data is loaded
  44507. * @param progressCallback defines the callback to call during loading process
  44508. * @returns a file request object
  44509. */
  44510. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  44511. /**
  44512. * Reads a file from a File object
  44513. * @param file defines the file to load
  44514. * @param onSuccess defines the callback to call when data is loaded
  44515. * @param onProgress defines the callback to call during loading process
  44516. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44517. * @param onError defines the callback to call when an error occurs
  44518. * @returns a file request object
  44519. */
  44520. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44521. /**
  44522. * Creates a data url from a given string content
  44523. * @param content defines the content to convert
  44524. * @returns the new data url link
  44525. */
  44526. static FileAsURL(content: string): string;
  44527. /**
  44528. * Format the given number to a specific decimal format
  44529. * @param value defines the number to format
  44530. * @param decimals defines the number of decimals to use
  44531. * @returns the formatted string
  44532. */
  44533. static Format(value: number, decimals?: number): string;
  44534. /**
  44535. * Tries to copy an object by duplicating every property
  44536. * @param source defines the source object
  44537. * @param destination defines the target object
  44538. * @param doNotCopyList defines a list of properties to avoid
  44539. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  44540. */
  44541. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  44542. /**
  44543. * Gets a boolean indicating if the given object has no own property
  44544. * @param obj defines the object to test
  44545. * @returns true if object has no own property
  44546. */
  44547. static IsEmpty(obj: any): boolean;
  44548. /**
  44549. * Function used to register events at window level
  44550. * @param windowElement defines the Window object to use
  44551. * @param events defines the events to register
  44552. */
  44553. static RegisterTopRootEvents(windowElement: Window, events: {
  44554. name: string;
  44555. handler: Nullable<(e: FocusEvent) => any>;
  44556. }[]): void;
  44557. /**
  44558. * Function used to unregister events from window level
  44559. * @param windowElement defines the Window object to use
  44560. * @param events defines the events to unregister
  44561. */
  44562. static UnregisterTopRootEvents(windowElement: Window, events: {
  44563. name: string;
  44564. handler: Nullable<(e: FocusEvent) => any>;
  44565. }[]): void;
  44566. /**
  44567. * @ignore
  44568. */
  44569. static _ScreenshotCanvas: HTMLCanvasElement;
  44570. /**
  44571. * Dumps the current bound framebuffer
  44572. * @param width defines the rendering width
  44573. * @param height defines the rendering height
  44574. * @param engine defines the hosting engine
  44575. * @param successCallback defines the callback triggered once the data are available
  44576. * @param mimeType defines the mime type of the result
  44577. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44578. * @return a void promise
  44579. */
  44580. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  44581. /**
  44582. * Dumps an array buffer
  44583. * @param width defines the rendering width
  44584. * @param height defines the rendering height
  44585. * @param data the data array
  44586. * @param successCallback defines the callback triggered once the data are available
  44587. * @param mimeType defines the mime type of the result
  44588. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44589. * @param invertY true to invert the picture in the Y dimension
  44590. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44591. */
  44592. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  44593. /**
  44594. * Dumps an array buffer
  44595. * @param width defines the rendering width
  44596. * @param height defines the rendering height
  44597. * @param data the data array
  44598. * @param successCallback defines the callback triggered once the data are available
  44599. * @param mimeType defines the mime type of the result
  44600. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44601. * @param invertY true to invert the picture in the Y dimension
  44602. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44603. * @return a promise that resolve to the final data
  44604. */
  44605. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44606. /**
  44607. * Converts the canvas data to blob.
  44608. * This acts as a polyfill for browsers not supporting the to blob function.
  44609. * @param canvas Defines the canvas to extract the data from
  44610. * @param successCallback Defines the callback triggered once the data are available
  44611. * @param mimeType Defines the mime type of the result
  44612. */
  44613. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  44614. /**
  44615. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  44616. * @param successCallback defines the callback triggered once the data are available
  44617. * @param mimeType defines the mime type of the result
  44618. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  44619. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  44620. */
  44621. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  44622. /**
  44623. * Downloads a blob in the browser
  44624. * @param blob defines the blob to download
  44625. * @param fileName defines the name of the downloaded file
  44626. */
  44627. static Download(blob: Blob, fileName: string): void;
  44628. /**
  44629. * Will return the right value of the noPreventDefault variable
  44630. * Needed to keep backwards compatibility to the old API.
  44631. *
  44632. * @param args arguments passed to the attachControl function
  44633. * @returns the correct value for noPreventDefault
  44634. */
  44635. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  44636. /**
  44637. * Captures a screenshot of the current rendering
  44638. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44639. * @param engine defines the rendering engine
  44640. * @param camera defines the source camera
  44641. * @param size This parameter can be set to a single number or to an object with the
  44642. * following (optional) properties: precision, width, height. If a single number is passed,
  44643. * it will be used for both width and height. If an object is passed, the screenshot size
  44644. * will be derived from the parameters. The precision property is a multiplier allowing
  44645. * rendering at a higher or lower resolution
  44646. * @param successCallback defines the callback receives a single parameter which contains the
  44647. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44648. * src parameter of an <img> to display it
  44649. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44650. * Check your browser for supported MIME types
  44651. */
  44652. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  44653. /**
  44654. * Captures a screenshot of the current rendering
  44655. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44656. * @param engine defines the rendering engine
  44657. * @param camera defines the source camera
  44658. * @param size This parameter can be set to a single number or to an object with the
  44659. * following (optional) properties: precision, width, height. If a single number is passed,
  44660. * it will be used for both width and height. If an object is passed, the screenshot size
  44661. * will be derived from the parameters. The precision property is a multiplier allowing
  44662. * rendering at a higher or lower resolution
  44663. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44664. * Check your browser for supported MIME types
  44665. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44666. * to the src parameter of an <img> to display it
  44667. */
  44668. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  44669. /**
  44670. * Generates an image screenshot from the specified camera.
  44671. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44672. * @param engine The engine to use for rendering
  44673. * @param camera The camera to use for rendering
  44674. * @param size This parameter can be set to a single number or to an object with the
  44675. * following (optional) properties: precision, width, height. If a single number is passed,
  44676. * it will be used for both width and height. If an object is passed, the screenshot size
  44677. * will be derived from the parameters. The precision property is a multiplier allowing
  44678. * rendering at a higher or lower resolution
  44679. * @param successCallback The callback receives a single parameter which contains the
  44680. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44681. * src parameter of an <img> to display it
  44682. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44683. * Check your browser for supported MIME types
  44684. * @param samples Texture samples (default: 1)
  44685. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44686. * @param fileName A name for for the downloaded file.
  44687. */
  44688. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  44689. /**
  44690. * Generates an image screenshot from the specified camera.
  44691. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44692. * @param engine The engine to use for rendering
  44693. * @param camera The camera to use for rendering
  44694. * @param size This parameter can be set to a single number or to an object with the
  44695. * following (optional) properties: precision, width, height. If a single number is passed,
  44696. * it will be used for both width and height. If an object is passed, the screenshot size
  44697. * will be derived from the parameters. The precision property is a multiplier allowing
  44698. * rendering at a higher or lower resolution
  44699. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44700. * Check your browser for supported MIME types
  44701. * @param samples Texture samples (default: 1)
  44702. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44703. * @param fileName A name for for the downloaded file.
  44704. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44705. * to the src parameter of an <img> to display it
  44706. */
  44707. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  44708. /**
  44709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  44710. * Be aware Math.random() could cause collisions, but:
  44711. * "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"
  44712. * @returns a pseudo random id
  44713. */
  44714. static RandomId(): string;
  44715. /**
  44716. * Test if the given uri is a base64 string
  44717. * @param uri The uri to test
  44718. * @return True if the uri is a base64 string or false otherwise
  44719. */
  44720. static IsBase64(uri: string): boolean;
  44721. /**
  44722. * Decode the given base64 uri.
  44723. * @param uri The uri to decode
  44724. * @return The decoded base64 data.
  44725. */
  44726. static DecodeBase64(uri: string): ArrayBuffer;
  44727. /**
  44728. * Gets the absolute url.
  44729. * @param url the input url
  44730. * @return the absolute url
  44731. */
  44732. static GetAbsoluteUrl(url: string): string;
  44733. /**
  44734. * No log
  44735. */
  44736. static readonly NoneLogLevel: number;
  44737. /**
  44738. * Only message logs
  44739. */
  44740. static readonly MessageLogLevel: number;
  44741. /**
  44742. * Only warning logs
  44743. */
  44744. static readonly WarningLogLevel: number;
  44745. /**
  44746. * Only error logs
  44747. */
  44748. static readonly ErrorLogLevel: number;
  44749. /**
  44750. * All logs
  44751. */
  44752. static readonly AllLogLevel: number;
  44753. /**
  44754. * Gets a value indicating the number of loading errors
  44755. * @ignorenaming
  44756. */
  44757. static get errorsCount(): number;
  44758. /**
  44759. * Callback called when a new log is added
  44760. */
  44761. static OnNewCacheEntry: (entry: string) => void;
  44762. /**
  44763. * Log a message to the console
  44764. * @param message defines the message to log
  44765. */
  44766. static Log(message: string): void;
  44767. /**
  44768. * Write a warning message to the console
  44769. * @param message defines the message to log
  44770. */
  44771. static Warn(message: string): void;
  44772. /**
  44773. * Write an error message to the console
  44774. * @param message defines the message to log
  44775. */
  44776. static Error(message: string): void;
  44777. /**
  44778. * Gets current log cache (list of logs)
  44779. */
  44780. static get LogCache(): string;
  44781. /**
  44782. * Clears the log cache
  44783. */
  44784. static ClearLogCache(): void;
  44785. /**
  44786. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  44787. */
  44788. static set LogLevels(level: number);
  44789. /**
  44790. * Checks if the window object exists
  44791. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  44792. */
  44793. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  44794. /**
  44795. * No performance log
  44796. */
  44797. static readonly PerformanceNoneLogLevel: number;
  44798. /**
  44799. * Use user marks to log performance
  44800. */
  44801. static readonly PerformanceUserMarkLogLevel: number;
  44802. /**
  44803. * Log performance to the console
  44804. */
  44805. static readonly PerformanceConsoleLogLevel: number;
  44806. private static _performance;
  44807. /**
  44808. * Sets the current performance log level
  44809. */
  44810. static set PerformanceLogLevel(level: number);
  44811. private static _StartPerformanceCounterDisabled;
  44812. private static _EndPerformanceCounterDisabled;
  44813. private static _StartUserMark;
  44814. private static _EndUserMark;
  44815. private static _StartPerformanceConsole;
  44816. private static _EndPerformanceConsole;
  44817. /**
  44818. * Starts a performance counter
  44819. */
  44820. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44821. /**
  44822. * Ends a specific performance coutner
  44823. */
  44824. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44825. /**
  44826. * Gets either window.performance.now() if supported or Date.now() else
  44827. */
  44828. static get Now(): number;
  44829. /**
  44830. * This method will return the name of the class used to create the instance of the given object.
  44831. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  44832. * @param object the object to get the class name from
  44833. * @param isType defines if the object is actually a type
  44834. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  44835. */
  44836. static GetClassName(object: any, isType?: boolean): string;
  44837. /**
  44838. * Gets the first element of an array satisfying a given predicate
  44839. * @param array defines the array to browse
  44840. * @param predicate defines the predicate to use
  44841. * @returns null if not found or the element
  44842. */
  44843. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  44844. /**
  44845. * This method will return the name of the full name of the class, including its owning module (if any).
  44846. * 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).
  44847. * @param object the object to get the class name from
  44848. * @param isType defines if the object is actually a type
  44849. * @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.
  44850. * @ignorenaming
  44851. */
  44852. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  44853. /**
  44854. * Returns a promise that resolves after the given amount of time.
  44855. * @param delay Number of milliseconds to delay
  44856. * @returns Promise that resolves after the given amount of time
  44857. */
  44858. static DelayAsync(delay: number): Promise<void>;
  44859. /**
  44860. * Utility function to detect if the current user agent is Safari
  44861. * @returns whether or not the current user agent is safari
  44862. */
  44863. static IsSafari(): boolean;
  44864. }
  44865. /**
  44866. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  44867. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  44868. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  44869. * @param name The name of the class, case should be preserved
  44870. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  44871. */
  44872. export function className(name: string, module?: string): (target: Object) => void;
  44873. /**
  44874. * An implementation of a loop for asynchronous functions.
  44875. */
  44876. export class AsyncLoop {
  44877. /**
  44878. * Defines the number of iterations for the loop
  44879. */
  44880. iterations: number;
  44881. /**
  44882. * Defines the current index of the loop.
  44883. */
  44884. index: number;
  44885. private _done;
  44886. private _fn;
  44887. private _successCallback;
  44888. /**
  44889. * Constructor.
  44890. * @param iterations the number of iterations.
  44891. * @param func the function to run each iteration
  44892. * @param successCallback the callback that will be called upon succesful execution
  44893. * @param offset starting offset.
  44894. */
  44895. constructor(
  44896. /**
  44897. * Defines the number of iterations for the loop
  44898. */
  44899. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  44900. /**
  44901. * Execute the next iteration. Must be called after the last iteration was finished.
  44902. */
  44903. executeNext(): void;
  44904. /**
  44905. * Break the loop and run the success callback.
  44906. */
  44907. breakLoop(): void;
  44908. /**
  44909. * Create and run an async loop.
  44910. * @param iterations the number of iterations.
  44911. * @param fn the function to run each iteration
  44912. * @param successCallback the callback that will be called upon succesful execution
  44913. * @param offset starting offset.
  44914. * @returns the created async loop object
  44915. */
  44916. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  44917. /**
  44918. * A for-loop that will run a given number of iterations synchronous and the rest async.
  44919. * @param iterations total number of iterations
  44920. * @param syncedIterations number of synchronous iterations in each async iteration.
  44921. * @param fn the function to call each iteration.
  44922. * @param callback a success call back that will be called when iterating stops.
  44923. * @param breakFunction a break condition (optional)
  44924. * @param timeout timeout settings for the setTimeout function. default - 0.
  44925. * @returns the created async loop object
  44926. */
  44927. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  44928. }
  44929. }
  44930. declare module "babylonjs/Misc/stringDictionary" {
  44931. import { Nullable } from "babylonjs/types";
  44932. /**
  44933. * This class implement a typical dictionary using a string as key and the generic type T as value.
  44934. * The underlying implementation relies on an associative array to ensure the best performances.
  44935. * The value can be anything including 'null' but except 'undefined'
  44936. */
  44937. export class StringDictionary<T> {
  44938. /**
  44939. * This will clear this dictionary and copy the content from the 'source' one.
  44940. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  44941. * @param source the dictionary to take the content from and copy to this dictionary
  44942. */
  44943. copyFrom(source: StringDictionary<T>): void;
  44944. /**
  44945. * Get a value based from its key
  44946. * @param key the given key to get the matching value from
  44947. * @return the value if found, otherwise undefined is returned
  44948. */
  44949. get(key: string): T | undefined;
  44950. /**
  44951. * Get a value from its key or add it if it doesn't exist.
  44952. * This method will ensure you that a given key/data will be present in the dictionary.
  44953. * @param key the given key to get the matching value from
  44954. * @param factory the factory that will create the value if the key is not present in the dictionary.
  44955. * The factory will only be invoked if there's no data for the given key.
  44956. * @return the value corresponding to the key.
  44957. */
  44958. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  44959. /**
  44960. * Get a value from its key if present in the dictionary otherwise add it
  44961. * @param key the key to get the value from
  44962. * @param val if there's no such key/value pair in the dictionary add it with this value
  44963. * @return the value corresponding to the key
  44964. */
  44965. getOrAdd(key: string, val: T): T;
  44966. /**
  44967. * Check if there's a given key in the dictionary
  44968. * @param key the key to check for
  44969. * @return true if the key is present, false otherwise
  44970. */
  44971. contains(key: string): boolean;
  44972. /**
  44973. * Add a new key and its corresponding value
  44974. * @param key the key to add
  44975. * @param value the value corresponding to the key
  44976. * @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
  44977. */
  44978. add(key: string, value: T): boolean;
  44979. /**
  44980. * Update a specific value associated to a key
  44981. * @param key defines the key to use
  44982. * @param value defines the value to store
  44983. * @returns true if the value was updated (or false if the key was not found)
  44984. */
  44985. set(key: string, value: T): boolean;
  44986. /**
  44987. * Get the element of the given key and remove it from the dictionary
  44988. * @param key defines the key to search
  44989. * @returns the value associated with the key or null if not found
  44990. */
  44991. getAndRemove(key: string): Nullable<T>;
  44992. /**
  44993. * Remove a key/value from the dictionary.
  44994. * @param key the key to remove
  44995. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  44996. */
  44997. remove(key: string): boolean;
  44998. /**
  44999. * Clear the whole content of the dictionary
  45000. */
  45001. clear(): void;
  45002. /**
  45003. * Gets the current count
  45004. */
  45005. get count(): number;
  45006. /**
  45007. * Execute a callback on each key/val of the dictionary.
  45008. * Note that you can remove any element in this dictionary in the callback implementation
  45009. * @param callback the callback to execute on a given key/value pair
  45010. */
  45011. forEach(callback: (key: string, val: T) => void): void;
  45012. /**
  45013. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  45014. * If the callback returns null or undefined the method will iterate to the next key/value pair
  45015. * Note that you can remove any element in this dictionary in the callback implementation
  45016. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  45017. * @returns the first item
  45018. */
  45019. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  45020. private _count;
  45021. private _data;
  45022. }
  45023. }
  45024. declare module "babylonjs/Collisions/collisionCoordinator" {
  45025. import { Nullable } from "babylonjs/types";
  45026. import { Scene } from "babylonjs/scene";
  45027. import { Vector3 } from "babylonjs/Maths/math.vector";
  45028. import { Collider } from "babylonjs/Collisions/collider";
  45029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45030. /** @hidden */
  45031. export interface ICollisionCoordinator {
  45032. createCollider(): Collider;
  45033. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45034. init(scene: Scene): void;
  45035. }
  45036. /** @hidden */
  45037. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  45038. private _scene;
  45039. private _scaledPosition;
  45040. private _scaledVelocity;
  45041. private _finalPosition;
  45042. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45043. createCollider(): Collider;
  45044. init(scene: Scene): void;
  45045. private _collideWithWorld;
  45046. }
  45047. }
  45048. declare module "babylonjs/Inputs/scene.inputManager" {
  45049. import { Nullable } from "babylonjs/types";
  45050. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45051. import { Vector2 } from "babylonjs/Maths/math.vector";
  45052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45053. import { Scene } from "babylonjs/scene";
  45054. /**
  45055. * Class used to manage all inputs for the scene.
  45056. */
  45057. export class InputManager {
  45058. /** The distance in pixel that you have to move to prevent some events */
  45059. static DragMovementThreshold: number;
  45060. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  45061. static LongPressDelay: number;
  45062. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  45063. static DoubleClickDelay: number;
  45064. /** If you need to check double click without raising a single click at first click, enable this flag */
  45065. static ExclusiveDoubleClickMode: boolean;
  45066. /** 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. */
  45067. private _alreadyAttached;
  45068. private _alreadyAttachedTo;
  45069. private _wheelEventName;
  45070. private _onPointerMove;
  45071. private _onPointerDown;
  45072. private _onPointerUp;
  45073. private _initClickEvent;
  45074. private _initActionManager;
  45075. private _delayedSimpleClick;
  45076. private _delayedSimpleClickTimeout;
  45077. private _previousDelayedSimpleClickTimeout;
  45078. private _meshPickProceed;
  45079. private _previousButtonPressed;
  45080. private _currentPickResult;
  45081. private _previousPickResult;
  45082. private _totalPointersPressed;
  45083. private _doubleClickOccured;
  45084. private _pointerOverMesh;
  45085. private _pickedDownMesh;
  45086. private _pickedUpMesh;
  45087. private _pointerX;
  45088. private _pointerY;
  45089. private _unTranslatedPointerX;
  45090. private _unTranslatedPointerY;
  45091. private _startingPointerPosition;
  45092. private _previousStartingPointerPosition;
  45093. private _startingPointerTime;
  45094. private _previousStartingPointerTime;
  45095. private _pointerCaptures;
  45096. private _meshUnderPointerId;
  45097. private _onKeyDown;
  45098. private _onKeyUp;
  45099. private _keyboardIsAttached;
  45100. private _onCanvasFocusObserver;
  45101. private _onCanvasBlurObserver;
  45102. private _scene;
  45103. /**
  45104. * Creates a new InputManager
  45105. * @param scene defines the hosting scene
  45106. */
  45107. constructor(scene: Scene);
  45108. /**
  45109. * Gets the mesh that is currently under the pointer
  45110. */
  45111. get meshUnderPointer(): Nullable<AbstractMesh>;
  45112. /**
  45113. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  45114. * @param pointerId the pointer id to use
  45115. * @returns The mesh under this pointer id or null if not found
  45116. */
  45117. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  45118. /**
  45119. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  45120. */
  45121. get unTranslatedPointer(): Vector2;
  45122. /**
  45123. * Gets or sets the current on-screen X position of the pointer
  45124. */
  45125. get pointerX(): number;
  45126. set pointerX(value: number);
  45127. /**
  45128. * Gets or sets the current on-screen Y position of the pointer
  45129. */
  45130. get pointerY(): number;
  45131. set pointerY(value: number);
  45132. private _updatePointerPosition;
  45133. private _processPointerMove;
  45134. private _setRayOnPointerInfo;
  45135. private _checkPrePointerObservable;
  45136. /**
  45137. * Use this method to simulate a pointer move on a mesh
  45138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45141. */
  45142. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45143. /**
  45144. * Use this method to simulate a pointer down on a mesh
  45145. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45146. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45147. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45148. */
  45149. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45150. private _processPointerDown;
  45151. /** @hidden */
  45152. _isPointerSwiping(): boolean;
  45153. /**
  45154. * Use this method to simulate a pointer up on a mesh
  45155. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45156. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45157. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45158. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45159. */
  45160. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  45161. private _processPointerUp;
  45162. /**
  45163. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45164. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45165. * @returns true if the pointer was captured
  45166. */
  45167. isPointerCaptured(pointerId?: number): boolean;
  45168. /**
  45169. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45170. * @param attachUp defines if you want to attach events to pointerup
  45171. * @param attachDown defines if you want to attach events to pointerdown
  45172. * @param attachMove defines if you want to attach events to pointermove
  45173. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  45174. */
  45175. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  45176. /**
  45177. * Detaches all event handlers
  45178. */
  45179. detachControl(): void;
  45180. /**
  45181. * Force the value of meshUnderPointer
  45182. * @param mesh defines the mesh to use
  45183. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  45184. */
  45185. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45186. /**
  45187. * Gets the mesh under the pointer
  45188. * @returns a Mesh or null if no mesh is under the pointer
  45189. */
  45190. getPointerOverMesh(): Nullable<AbstractMesh>;
  45191. }
  45192. }
  45193. declare module "babylonjs/Animations/animationGroup" {
  45194. import { Animatable } from "babylonjs/Animations/animatable";
  45195. import { Animation } from "babylonjs/Animations/animation";
  45196. import { Scene, IDisposable } from "babylonjs/scene";
  45197. import { Observable } from "babylonjs/Misc/observable";
  45198. import { Nullable } from "babylonjs/types";
  45199. import "babylonjs/Animations/animatable";
  45200. /**
  45201. * This class defines the direct association between an animation and a target
  45202. */
  45203. export class TargetedAnimation {
  45204. /**
  45205. * Animation to perform
  45206. */
  45207. animation: Animation;
  45208. /**
  45209. * Target to animate
  45210. */
  45211. target: any;
  45212. /**
  45213. * Returns the string "TargetedAnimation"
  45214. * @returns "TargetedAnimation"
  45215. */
  45216. getClassName(): string;
  45217. /**
  45218. * Serialize the object
  45219. * @returns the JSON object representing the current entity
  45220. */
  45221. serialize(): any;
  45222. }
  45223. /**
  45224. * Use this class to create coordinated animations on multiple targets
  45225. */
  45226. export class AnimationGroup implements IDisposable {
  45227. /** The name of the animation group */
  45228. name: string;
  45229. private _scene;
  45230. private _targetedAnimations;
  45231. private _animatables;
  45232. private _from;
  45233. private _to;
  45234. private _isStarted;
  45235. private _isPaused;
  45236. private _speedRatio;
  45237. private _loopAnimation;
  45238. private _isAdditive;
  45239. /**
  45240. * Gets or sets the unique id of the node
  45241. */
  45242. uniqueId: number;
  45243. /**
  45244. * This observable will notify when one animation have ended
  45245. */
  45246. onAnimationEndObservable: Observable<TargetedAnimation>;
  45247. /**
  45248. * Observer raised when one animation loops
  45249. */
  45250. onAnimationLoopObservable: Observable<TargetedAnimation>;
  45251. /**
  45252. * Observer raised when all animations have looped
  45253. */
  45254. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  45255. /**
  45256. * This observable will notify when all animations have ended.
  45257. */
  45258. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  45259. /**
  45260. * This observable will notify when all animations have paused.
  45261. */
  45262. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  45263. /**
  45264. * This observable will notify when all animations are playing.
  45265. */
  45266. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  45267. /**
  45268. * Gets the first frame
  45269. */
  45270. get from(): number;
  45271. /**
  45272. * Gets the last frame
  45273. */
  45274. get to(): number;
  45275. /**
  45276. * Define if the animations are started
  45277. */
  45278. get isStarted(): boolean;
  45279. /**
  45280. * Gets a value indicating that the current group is playing
  45281. */
  45282. get isPlaying(): boolean;
  45283. /**
  45284. * Gets or sets the speed ratio to use for all animations
  45285. */
  45286. get speedRatio(): number;
  45287. /**
  45288. * Gets or sets the speed ratio to use for all animations
  45289. */
  45290. set speedRatio(value: number);
  45291. /**
  45292. * Gets or sets if all animations should loop or not
  45293. */
  45294. get loopAnimation(): boolean;
  45295. set loopAnimation(value: boolean);
  45296. /**
  45297. * Gets or sets if all animations should be evaluated additively
  45298. */
  45299. get isAdditive(): boolean;
  45300. set isAdditive(value: boolean);
  45301. /**
  45302. * Gets the targeted animations for this animation group
  45303. */
  45304. get targetedAnimations(): Array<TargetedAnimation>;
  45305. /**
  45306. * returning the list of animatables controlled by this animation group.
  45307. */
  45308. get animatables(): Array<Animatable>;
  45309. /**
  45310. * Gets the list of target animations
  45311. */
  45312. get children(): TargetedAnimation[];
  45313. /**
  45314. * Instantiates a new Animation Group.
  45315. * This helps managing several animations at once.
  45316. * @see https://doc.babylonjs.com/how_to/group
  45317. * @param name Defines the name of the group
  45318. * @param scene Defines the scene the group belongs to
  45319. */
  45320. constructor(
  45321. /** The name of the animation group */
  45322. name: string, scene?: Nullable<Scene>);
  45323. /**
  45324. * Add an animation (with its target) in the group
  45325. * @param animation defines the animation we want to add
  45326. * @param target defines the target of the animation
  45327. * @returns the TargetedAnimation object
  45328. */
  45329. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  45330. /**
  45331. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  45332. * It can add constant keys at begin or end
  45333. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  45334. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  45335. * @returns the animation group
  45336. */
  45337. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  45338. private _animationLoopCount;
  45339. private _animationLoopFlags;
  45340. private _processLoop;
  45341. /**
  45342. * Start all animations on given targets
  45343. * @param loop defines if animations must loop
  45344. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  45345. * @param from defines the from key (optional)
  45346. * @param to defines the to key (optional)
  45347. * @param isAdditive defines the additive state for the resulting animatables (optional)
  45348. * @returns the current animation group
  45349. */
  45350. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  45351. /**
  45352. * Pause all animations
  45353. * @returns the animation group
  45354. */
  45355. pause(): AnimationGroup;
  45356. /**
  45357. * Play all animations to initial state
  45358. * This function will start() the animations if they were not started or will restart() them if they were paused
  45359. * @param loop defines if animations must loop
  45360. * @returns the animation group
  45361. */
  45362. play(loop?: boolean): AnimationGroup;
  45363. /**
  45364. * Reset all animations to initial state
  45365. * @returns the animation group
  45366. */
  45367. reset(): AnimationGroup;
  45368. /**
  45369. * Restart animations from key 0
  45370. * @returns the animation group
  45371. */
  45372. restart(): AnimationGroup;
  45373. /**
  45374. * Stop all animations
  45375. * @returns the animation group
  45376. */
  45377. stop(): AnimationGroup;
  45378. /**
  45379. * Set animation weight for all animatables
  45380. * @param weight defines the weight to use
  45381. * @return the animationGroup
  45382. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45383. */
  45384. setWeightForAllAnimatables(weight: number): AnimationGroup;
  45385. /**
  45386. * Synchronize and normalize all animatables with a source animatable
  45387. * @param root defines the root animatable to synchronize with
  45388. * @return the animationGroup
  45389. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45390. */
  45391. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  45392. /**
  45393. * Goes to a specific frame in this animation group
  45394. * @param frame the frame number to go to
  45395. * @return the animationGroup
  45396. */
  45397. goToFrame(frame: number): AnimationGroup;
  45398. /**
  45399. * Dispose all associated resources
  45400. */
  45401. dispose(): void;
  45402. private _checkAnimationGroupEnded;
  45403. /**
  45404. * Clone the current animation group and returns a copy
  45405. * @param newName defines the name of the new group
  45406. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  45407. * @returns the new aniamtion group
  45408. */
  45409. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  45410. /**
  45411. * Serializes the animationGroup to an object
  45412. * @returns Serialized object
  45413. */
  45414. serialize(): any;
  45415. /**
  45416. * Returns a new AnimationGroup object parsed from the source provided.
  45417. * @param parsedAnimationGroup defines the source
  45418. * @param scene defines the scene that will receive the animationGroup
  45419. * @returns a new AnimationGroup
  45420. */
  45421. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  45422. /**
  45423. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  45424. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  45425. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  45426. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  45427. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  45428. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  45429. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  45430. */
  45431. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  45432. /**
  45433. * Returns the string "AnimationGroup"
  45434. * @returns "AnimationGroup"
  45435. */
  45436. getClassName(): string;
  45437. /**
  45438. * Creates a detailled string about the object
  45439. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  45440. * @returns a string representing the object
  45441. */
  45442. toString(fullDetails?: boolean): string;
  45443. }
  45444. }
  45445. declare module "babylonjs/Instrumentation/timeToken" {
  45446. import { Nullable } from "babylonjs/types";
  45447. /**
  45448. * @hidden
  45449. **/
  45450. export class _TimeToken {
  45451. _startTimeQuery: Nullable<WebGLQuery>;
  45452. _endTimeQuery: Nullable<WebGLQuery>;
  45453. _timeElapsedQuery: Nullable<WebGLQuery>;
  45454. _timeElapsedQueryEnded: boolean;
  45455. }
  45456. }
  45457. declare module "babylonjs/Engines/WebGPU/webgpuConstants" {
  45458. /** @hidden */
  45459. export enum ExtensionName {
  45460. DepthClamping = "depth-clamping",
  45461. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45462. Depth32FloatStencil8 = "depth32float-stencil8",
  45463. PipelineStatisticsQuery = "pipeline-statistics-query",
  45464. TextureCompressionBC = "texture-compression-bc",
  45465. TimestampQuery = "timestamp-query"
  45466. }
  45467. /** @hidden */
  45468. export enum AddressMode {
  45469. ClampToEdge = "clamp-to-edge",
  45470. Repeat = "repeat",
  45471. MirrorRepeat = "mirror-repeat"
  45472. }
  45473. /** @hidden */
  45474. export enum BindingType {
  45475. UniformBuffer = "uniform-buffer",
  45476. StorageBuffer = "storage-buffer",
  45477. ReadonlyStorageBuffer = "readonly-storage-buffer",
  45478. Sampler = "sampler",
  45479. ComparisonSampler = "comparison-sampler",
  45480. SampledTexture = "sampled-texture",
  45481. ReadonlyStorageTexture = "readonly-storage-texture",
  45482. WriteonlyStorageTexture = "writeonly-storage-texture"
  45483. }
  45484. /** @hidden */
  45485. export enum BlendFactor {
  45486. Zero = "zero",
  45487. One = "one",
  45488. SrcColor = "src-color",
  45489. OneMinusSrcColor = "one-minus-src-color",
  45490. SrcAlpha = "src-alpha",
  45491. OneMinusSrcAlpha = "one-minus-src-alpha",
  45492. DstColor = "dst-color",
  45493. OneMinusDstColor = "one-minus-dst-color",
  45494. DstAlpha = "dst-alpha",
  45495. OneMinusDstAlpha = "one-minus-dst-alpha",
  45496. SrcAlphaSaturated = "src-alpha-saturated",
  45497. BlendColor = "blend-color",
  45498. OneMinusBlendColor = "one-minus-blend-color"
  45499. }
  45500. /** @hidden */
  45501. export enum BlendOperation {
  45502. Add = "add",
  45503. Subtract = "subtract",
  45504. ReverseSubtract = "reverse-subtract",
  45505. Min = "min",
  45506. Max = "max"
  45507. }
  45508. /** @hidden */
  45509. export enum CompareFunction {
  45510. Never = "never",
  45511. Less = "less",
  45512. Equal = "equal",
  45513. LessEqual = "less-equal",
  45514. Greater = "greater",
  45515. NotEqual = "not-equal",
  45516. GreaterEqual = "greater-equal",
  45517. Always = "always"
  45518. }
  45519. /** @hidden */
  45520. export enum CullMode {
  45521. None = "none",
  45522. Front = "front",
  45523. Back = "back"
  45524. }
  45525. /** @hidden */
  45526. export enum FilterMode {
  45527. Nearest = "nearest",
  45528. Linear = "linear"
  45529. }
  45530. /** @hidden */
  45531. export enum FrontFace {
  45532. CCW = "ccw",
  45533. CW = "cw"
  45534. }
  45535. /** @hidden */
  45536. export enum IndexFormat {
  45537. Uint16 = "uint16",
  45538. Uint32 = "uint32"
  45539. }
  45540. /** @hidden */
  45541. export enum InputStepMode {
  45542. Vertex = "vertex",
  45543. Instance = "instance"
  45544. }
  45545. /** @hidden */
  45546. export enum LoadOp {
  45547. Load = "load"
  45548. }
  45549. /** @hidden */
  45550. export enum PrimitiveTopology {
  45551. PointList = "point-list",
  45552. LineList = "line-list",
  45553. LineStrip = "line-strip",
  45554. TriangleList = "triangle-list",
  45555. TriangleStrip = "triangle-strip"
  45556. }
  45557. /** @hidden */
  45558. export enum StencilOperation {
  45559. Keep = "keep",
  45560. Zero = "zero",
  45561. Replace = "replace",
  45562. Invert = "invert",
  45563. IncrementClamp = "increment-clamp",
  45564. DecrementClamp = "decrement-clamp",
  45565. IncrementWrap = "increment-wrap",
  45566. DecrementWrap = "decrement-wrap"
  45567. }
  45568. /** @hidden */
  45569. export enum StoreOp {
  45570. Store = "store",
  45571. Clear = "clear"
  45572. }
  45573. /** @hidden */
  45574. export enum TextureDimension {
  45575. E1d = "1d",
  45576. E2d = "2d",
  45577. E3d = "3d"
  45578. }
  45579. /** @hidden */
  45580. export enum TextureFormat {
  45581. R8Unorm = "r8unorm",
  45582. R8Snorm = "r8snorm",
  45583. R8Uint = "r8uint",
  45584. R8Sint = "r8sint",
  45585. R16Uint = "r16uint",
  45586. R16Sint = "r16sint",
  45587. R16Float = "r16float",
  45588. RG8Unorm = "rg8unorm",
  45589. RG8Snorm = "rg8snorm",
  45590. RG8Uint = "rg8uint",
  45591. RG8Sint = "rg8sint",
  45592. R32Uint = "r32uint",
  45593. R32Sint = "r32sint",
  45594. R32Float = "r32float",
  45595. RG16Uint = "rg16uint",
  45596. RG16Sint = "rg16sint",
  45597. RG16Float = "rg16float",
  45598. RGBA8Unorm = "rgba8unorm",
  45599. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45600. RGBA8Snorm = "rgba8snorm",
  45601. RGBA8Uint = "rgba8uint",
  45602. RGBA8Sint = "rgba8sint",
  45603. BGRA8Unorm = "bgra8unorm",
  45604. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45605. RGB9E5UFloat = "rgb9e5ufloat",
  45606. RGB10A2Unorm = "rgb10a2unorm",
  45607. RG11B10UFloat = "rg11b10ufloat",
  45608. RG32Uint = "rg32uint",
  45609. RG32Sint = "rg32sint",
  45610. RG32Float = "rg32float",
  45611. RGBA16Uint = "rgba16uint",
  45612. RGBA16Sint = "rgba16sint",
  45613. RGBA16Float = "rgba16float",
  45614. RGBA32Uint = "rgba32uint",
  45615. RGBA32Sint = "rgba32sint",
  45616. RGBA32Float = "rgba32float",
  45617. Stencil8 = "stencil8",
  45618. Depth16Unorm = "depth16unorm",
  45619. Depth24Plus = "depth24plus",
  45620. Depth24PlusStencil8 = "depth24plus-stencil8",
  45621. Depth32Float = "depth32float",
  45622. BC1RGBAUNorm = "bc1-rgba-unorm",
  45623. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45624. BC2RGBAUnorm = "bc2-rgba-unorm",
  45625. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45626. BC3RGBAUnorm = "bc3-rgba-unorm",
  45627. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45628. BC4RUnorm = "bc4-r-unorm",
  45629. BC4RSnorm = "bc4-r-snorm",
  45630. BC5RGUnorm = "bc5-rg-unorm",
  45631. BC5RGSnorm = "bc5-rg-snorm",
  45632. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45633. BC6HRGBFloat = "bc6h-rgb-float",
  45634. BC7RGBAUnorm = "bc7-rgba-unorm",
  45635. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45636. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45637. Depth32FloatStencil8 = "depth32float-stencil8"
  45638. }
  45639. /** @hidden */
  45640. export enum TextureComponentType {
  45641. Float = "float",
  45642. Sint = "sint",
  45643. Uint = "uint",
  45644. DepthComparison = "depth-comparison"
  45645. }
  45646. /** @hidden */
  45647. export enum TextureViewDimension {
  45648. E1d = "1d",
  45649. E2d = "2d",
  45650. E2dArray = "2d-array",
  45651. Cube = "cube",
  45652. CubeArray = "cube-array",
  45653. E3d = "3d"
  45654. }
  45655. /** @hidden */
  45656. export enum VertexFormat {
  45657. Uchar2 = "uchar2",
  45658. Uchar4 = "uchar4",
  45659. Char2 = "char2",
  45660. Char4 = "char4",
  45661. Uchar2Norm = "uchar2norm",
  45662. Uchar4Norm = "uchar4norm",
  45663. Char2Norm = "char2norm",
  45664. Char4Norm = "char4norm",
  45665. Ushort2 = "ushort2",
  45666. Ushort4 = "ushort4",
  45667. Short2 = "short2",
  45668. Short4 = "short4",
  45669. Ushort2Norm = "ushort2norm",
  45670. Ushort4Norm = "ushort4norm",
  45671. Short2Norm = "short2norm",
  45672. Short4Norm = "short4norm",
  45673. Half2 = "half2",
  45674. Half4 = "half4",
  45675. Float = "float",
  45676. Float2 = "float2",
  45677. Float3 = "float3",
  45678. Float4 = "float4",
  45679. Uint = "uint",
  45680. Uint2 = "uint2",
  45681. Uint3 = "uint3",
  45682. Uint4 = "uint4",
  45683. Int = "int",
  45684. Int2 = "int2",
  45685. Int3 = "int3",
  45686. Int4 = "int4"
  45687. }
  45688. /** @hidden */
  45689. export enum TextureAspect {
  45690. All = "all",
  45691. StencilOnly = "stencil-only",
  45692. DepthOnly = "depth-only"
  45693. }
  45694. /** @hidden */
  45695. export enum CompilationMessageType {
  45696. Error = "error",
  45697. Warning = "warning",
  45698. Info = "info"
  45699. }
  45700. /** @hidden */
  45701. export enum QueryType {
  45702. Occlusion = "occlusion"
  45703. }
  45704. /** @hidden */
  45705. export enum BufferUsage {
  45706. MapRead = 1,
  45707. MapWrite = 2,
  45708. CopySrc = 4,
  45709. CopyDst = 8,
  45710. Index = 16,
  45711. Vertex = 32,
  45712. Uniform = 64,
  45713. Storage = 128,
  45714. Indirect = 256,
  45715. QueryResolve = 512
  45716. }
  45717. /** @hidden */
  45718. export enum ColorWrite {
  45719. Red = 1,
  45720. Green = 2,
  45721. Blue = 4,
  45722. Alpha = 8,
  45723. All = 15
  45724. }
  45725. /** @hidden */
  45726. export enum ShaderStage {
  45727. Vertex = 1,
  45728. Fragment = 2,
  45729. Compute = 4
  45730. }
  45731. /** @hidden */
  45732. export enum TextureUsage {
  45733. CopySrc = 1,
  45734. CopyDst = 2,
  45735. Sampled = 4,
  45736. Storage = 8,
  45737. OutputAttachment = 16
  45738. }
  45739. /** @hidden */
  45740. export enum MapMode {
  45741. Read = 1,
  45742. Write = 2
  45743. }
  45744. }
  45745. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext" {
  45746. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  45747. /** @hidden */
  45748. export interface WebGPUBindingInfo {
  45749. setIndex: number;
  45750. bindingIndex: number;
  45751. }
  45752. /** @hidden */
  45753. export interface WebGPUTextureSamplerBindingDescription {
  45754. sampler: WebGPUBindingInfo;
  45755. isTextureArray: boolean;
  45756. textures: Array<WebGPUBindingInfo>;
  45757. }
  45758. /** @hidden
  45759. * If the binding is a UBO, isSampler=isTexture=false
  45760. */
  45761. export interface WebGPUBindingDescription {
  45762. name: string;
  45763. usedInVertex: boolean;
  45764. usedInFragment: boolean;
  45765. isSampler: boolean;
  45766. isComparisonSampler?: boolean;
  45767. isTexture: boolean;
  45768. componentType?: GPUTextureComponentType;
  45769. textureDimension?: GPUTextureViewDimension;
  45770. }
  45771. /**
  45772. * @hidden
  45773. */
  45774. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45775. uboNextBindingIndex: number;
  45776. freeSetIndex: number;
  45777. freeBindingIndex: number;
  45778. availableVaryings: {
  45779. [key: string]: number;
  45780. };
  45781. availableAttributes: {
  45782. [key: string]: number;
  45783. };
  45784. availableUBOs: {
  45785. [key: string]: {
  45786. setIndex: number;
  45787. bindingIndex: number;
  45788. };
  45789. };
  45790. availableSamplers: {
  45791. [key: string]: WebGPUTextureSamplerBindingDescription;
  45792. };
  45793. leftOverUniforms: {
  45794. name: string;
  45795. type: string;
  45796. length: number;
  45797. }[];
  45798. orderedAttributes: string[];
  45799. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45800. private _attributeNextLocation;
  45801. private _varyingNextLocation;
  45802. constructor();
  45803. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45804. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45805. getNextFreeUBOBinding(): {
  45806. setIndex: number;
  45807. bindingIndex: number;
  45808. };
  45809. private _getNextFreeBinding;
  45810. }
  45811. }
  45812. declare module "babylonjs/Engines/WebGPU/webgpuPipelineContext" {
  45813. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45814. import { Nullable } from "babylonjs/types";
  45815. import { WebGPUEngine } from "babylonjs/Engines/webgpuEngine";
  45816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45817. import { Effect } from "babylonjs/Materials/effect";
  45818. import { WebGPUShaderProcessingContext } from "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext";
  45819. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45820. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  45821. /** @hidden */
  45822. export interface IWebGPUPipelineContextSamplerCache {
  45823. samplerBinding: number;
  45824. firstTextureName: string;
  45825. }
  45826. /** @hidden */
  45827. export interface IWebGPUPipelineContextTextureCache {
  45828. textureBinding: number;
  45829. texture: InternalTexture;
  45830. }
  45831. /** @hidden */
  45832. export interface IWebGPUPipelineContextVertexInputsCache {
  45833. indexBuffer: Nullable<GPUBuffer>;
  45834. indexOffset: number;
  45835. vertexStartSlot: number;
  45836. vertexBuffers: GPUBuffer[];
  45837. vertexOffsets: number[];
  45838. }
  45839. /** @hidden */
  45840. export interface IWebGPURenderPipelineStageDescriptor {
  45841. vertexStage: GPUProgrammableStageDescriptor;
  45842. fragmentStage?: GPUProgrammableStageDescriptor;
  45843. }
  45844. /** @hidden */
  45845. export class WebGPUPipelineContext implements IPipelineContext {
  45846. engine: WebGPUEngine;
  45847. shaderProcessingContext: WebGPUShaderProcessingContext;
  45848. leftOverUniformsByName: {
  45849. [name: string]: string;
  45850. };
  45851. sources: {
  45852. vertex: string;
  45853. fragment: string;
  45854. rawVertex: string;
  45855. rawFragment: string;
  45856. };
  45857. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45858. samplers: {
  45859. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45860. };
  45861. textures: {
  45862. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  45863. };
  45864. bindGroupLayouts: GPUBindGroupLayout[];
  45865. /**
  45866. * Stores the uniform buffer
  45867. */
  45868. uniformBuffer: Nullable<UniformBuffer>;
  45869. onCompiled?: () => void;
  45870. get isAsync(): boolean;
  45871. get isReady(): boolean;
  45872. /** @hidden */
  45873. _name: string;
  45874. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  45875. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  45876. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  45877. [key: string]: number;
  45878. }, uniformsNames: string[], uniforms: {
  45879. [key: string]: Nullable<WebGLUniformLocation>;
  45880. }, samplerList: string[], samplers: {
  45881. [key: string]: number;
  45882. }, attributesNames: string[], attributes: number[]): void;
  45883. /** @hidden */
  45884. /**
  45885. * Build the uniform buffer used in the material.
  45886. */
  45887. buildUniformLayout(): void;
  45888. /**
  45889. * Release all associated resources.
  45890. **/
  45891. dispose(): void;
  45892. /**
  45893. * Sets an integer value on a uniform variable.
  45894. * @param uniformName Name of the variable.
  45895. * @param value Value to be set.
  45896. */
  45897. setInt(uniformName: string, value: number): void;
  45898. /**
  45899. * Sets an int2 value on a uniform variable.
  45900. * @param uniformName Name of the variable.
  45901. * @param x First int in int2.
  45902. * @param y Second int in int2.
  45903. */
  45904. setInt2(uniformName: string, x: number, y: number): void;
  45905. /**
  45906. * Sets an int3 value on a uniform variable.
  45907. * @param uniformName Name of the variable.
  45908. * @param x First int in int3.
  45909. * @param y Second int in int3.
  45910. * @param z Third int in int3.
  45911. */
  45912. setInt3(uniformName: string, x: number, y: number, z: number): void;
  45913. /**
  45914. * Sets an int4 value on a uniform variable.
  45915. * @param uniformName Name of the variable.
  45916. * @param x First int in int4.
  45917. * @param y Second int in int4.
  45918. * @param z Third int in int4.
  45919. * @param w Fourth int in int4.
  45920. */
  45921. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45922. /**
  45923. * Sets an int array on a uniform variable.
  45924. * @param uniformName Name of the variable.
  45925. * @param array array to be set.
  45926. */
  45927. setIntArray(uniformName: string, array: Int32Array): void;
  45928. /**
  45929. * 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)
  45930. * @param uniformName Name of the variable.
  45931. * @param array array to be set.
  45932. */
  45933. setIntArray2(uniformName: string, array: Int32Array): void;
  45934. /**
  45935. * 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)
  45936. * @param uniformName Name of the variable.
  45937. * @param array array to be set.
  45938. */
  45939. setIntArray3(uniformName: string, array: Int32Array): void;
  45940. /**
  45941. * 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)
  45942. * @param uniformName Name of the variable.
  45943. * @param array array to be set.
  45944. */
  45945. setIntArray4(uniformName: string, array: Int32Array): void;
  45946. /**
  45947. * Sets an array on a uniform variable.
  45948. * @param uniformName Name of the variable.
  45949. * @param array array to be set.
  45950. */
  45951. setArray(uniformName: string, array: number[]): void;
  45952. /**
  45953. * 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)
  45954. * @param uniformName Name of the variable.
  45955. * @param array array to be set.
  45956. */
  45957. setArray2(uniformName: string, array: number[]): void;
  45958. /**
  45959. * 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)
  45960. * @param uniformName Name of the variable.
  45961. * @param array array to be set.
  45962. * @returns this effect.
  45963. */
  45964. setArray3(uniformName: string, array: number[]): void;
  45965. /**
  45966. * 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)
  45967. * @param uniformName Name of the variable.
  45968. * @param array array to be set.
  45969. */
  45970. setArray4(uniformName: string, array: number[]): void;
  45971. /**
  45972. * Sets matrices on a uniform variable.
  45973. * @param uniformName Name of the variable.
  45974. * @param matrices matrices to be set.
  45975. */
  45976. setMatrices(uniformName: string, matrices: Float32Array): void;
  45977. /**
  45978. * Sets matrix on a uniform variable.
  45979. * @param uniformName Name of the variable.
  45980. * @param matrix matrix to be set.
  45981. */
  45982. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  45983. /**
  45984. * 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)
  45985. * @param uniformName Name of the variable.
  45986. * @param matrix matrix to be set.
  45987. */
  45988. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  45989. /**
  45990. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  45991. * @param uniformName Name of the variable.
  45992. * @param matrix matrix to be set.
  45993. */
  45994. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  45995. /**
  45996. * Sets a float on a uniform variable.
  45997. * @param uniformName Name of the variable.
  45998. * @param value value to be set.
  45999. * @returns this effect.
  46000. */
  46001. setFloat(uniformName: string, value: number): void;
  46002. /**
  46003. * Sets a Vector2 on a uniform variable.
  46004. * @param uniformName Name of the variable.
  46005. * @param vector2 vector2 to be set.
  46006. */
  46007. setVector2(uniformName: string, vector2: IVector2Like): void;
  46008. /**
  46009. * Sets a float2 on a uniform variable.
  46010. * @param uniformName Name of the variable.
  46011. * @param x First float in float2.
  46012. * @param y Second float in float2.
  46013. */
  46014. setFloat2(uniformName: string, x: number, y: number): void;
  46015. /**
  46016. * Sets a Vector3 on a uniform variable.
  46017. * @param uniformName Name of the variable.
  46018. * @param vector3 Value to be set.
  46019. */
  46020. setVector3(uniformName: string, vector3: IVector3Like): void;
  46021. /**
  46022. * Sets a float3 on a uniform variable.
  46023. * @param uniformName Name of the variable.
  46024. * @param x First float in float3.
  46025. * @param y Second float in float3.
  46026. * @param z Third float in float3.
  46027. */
  46028. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  46029. /**
  46030. * Sets a Vector4 on a uniform variable.
  46031. * @param uniformName Name of the variable.
  46032. * @param vector4 Value to be set.
  46033. */
  46034. setVector4(uniformName: string, vector4: IVector4Like): void;
  46035. /**
  46036. * Sets a float4 on a uniform variable.
  46037. * @param uniformName Name of the variable.
  46038. * @param x First float in float4.
  46039. * @param y Second float in float4.
  46040. * @param z Third float in float4.
  46041. * @param w Fourth float in float4.
  46042. * @returns this effect.
  46043. */
  46044. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46045. /**
  46046. * Sets a Color3 on a uniform variable.
  46047. * @param uniformName Name of the variable.
  46048. * @param color3 Value to be set.
  46049. */
  46050. setColor3(uniformName: string, color3: IColor3Like): void;
  46051. /**
  46052. * Sets a Color4 on a uniform variable.
  46053. * @param uniformName Name of the variable.
  46054. * @param color3 Value to be set.
  46055. * @param alpha Alpha value to be set.
  46056. */
  46057. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  46058. /**
  46059. * Sets a Color4 on a uniform variable
  46060. * @param uniformName defines the name of the variable
  46061. * @param color4 defines the value to be set
  46062. */
  46063. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  46064. _getVertexShaderCode(): string | null;
  46065. _getFragmentShaderCode(): string | null;
  46066. }
  46067. }
  46068. declare module "babylonjs/Meshes/WebGPU/webgpuDataBuffer" {
  46069. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46070. /** @hidden */
  46071. export class WebGPUDataBuffer extends DataBuffer {
  46072. private _buffer;
  46073. constructor(resource: GPUBuffer);
  46074. get underlyingResource(): any;
  46075. }
  46076. }
  46077. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  46078. /**
  46079. * Class used to inline functions in shader code
  46080. */
  46081. export class ShaderCodeInliner {
  46082. private static readonly _RegexpFindFunctionNameAndType;
  46083. private _sourceCode;
  46084. private _functionDescr;
  46085. private _numMaxIterations;
  46086. /** Gets or sets the token used to mark the functions to inline */
  46087. inlineToken: string;
  46088. /** Gets or sets the debug mode */
  46089. debug: boolean;
  46090. /** Gets the code after the inlining process */
  46091. get code(): string;
  46092. /**
  46093. * Initializes the inliner
  46094. * @param sourceCode shader code source to inline
  46095. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  46096. */
  46097. constructor(sourceCode: string, numMaxIterations?: number);
  46098. /**
  46099. * Start the processing of the shader code
  46100. */
  46101. processCode(): void;
  46102. private _collectFunctions;
  46103. private _processInlining;
  46104. private _extractBetweenMarkers;
  46105. private _skipWhitespaces;
  46106. private _isIdentifierChar;
  46107. private _removeComments;
  46108. private _replaceFunctionCallsByCode;
  46109. private _findBackward;
  46110. private _escapeRegExp;
  46111. private _replaceNames;
  46112. }
  46113. }
  46114. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessors" {
  46115. import { Nullable } from "babylonjs/types";
  46116. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46117. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46118. /** @hidden */
  46119. export class WebGPUShaderProcessor implements IShaderProcessor {
  46120. protected _missingVaryings: Array<string>;
  46121. protected _textureArrayProcessing: Array<string>;
  46122. protected _preProcessors: {
  46123. [key: string]: string;
  46124. };
  46125. private _getArraySize;
  46126. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  46127. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  46128. [key: string]: string;
  46129. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46130. attributeProcessor(attribute: string, preProcessors: {
  46131. [key: string]: string;
  46132. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46133. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  46134. [key: string]: string;
  46135. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46136. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46137. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46138. private _applyTextureArrayProcessing;
  46139. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  46140. vertexCode: string;
  46141. fragmentCode: string;
  46142. };
  46143. }
  46144. }
  46145. declare module "babylonjs/Engines/WebGPU/webgpuBufferManager" {
  46146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46147. import { WebGPUDataBuffer } from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  46148. import { Nullable } from "babylonjs/types";
  46149. /** @hidden */
  46150. export class WebGPUBufferManager {
  46151. private _device;
  46152. private _deferredReleaseBuffers;
  46153. private static _IsGPUBuffer;
  46154. constructor(device: GPUDevice);
  46155. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  46156. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  46157. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  46158. private _FromHalfFloat;
  46159. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  46160. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  46161. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  46162. destroyDeferredBuffers(): void;
  46163. }
  46164. }
  46165. declare module "babylonjs/Engines/WebGPU/webgpuHardwareTexture" {
  46166. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46167. import { Nullable } from "babylonjs/types";
  46168. /** @hidden */
  46169. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  46170. private _webgpuTexture;
  46171. private _webgpuMSAATexture;
  46172. get underlyingResource(): Nullable<GPUTexture>;
  46173. get msaaTexture(): Nullable<GPUTexture>;
  46174. set msaaTexture(texture: Nullable<GPUTexture>);
  46175. view: Nullable<GPUTextureView>;
  46176. format: GPUTextureFormat;
  46177. textureUsages: number;
  46178. constructor(existingTexture?: Nullable<GPUTexture>);
  46179. set(hardwareTexture: GPUTexture): void;
  46180. setMSAATexture(hardwareTexture: GPUTexture): void;
  46181. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  46182. createView(descriptor?: GPUTextureViewDescriptor): void;
  46183. reset(): void;
  46184. release(): void;
  46185. }
  46186. }
  46187. declare module "babylonjs/Engines/WebGPU/webgpuTextureHelper" {
  46188. import { WebGPUBufferManager } from "babylonjs/Engines/WebGPU/webgpuBufferManager";
  46189. import { Nullable } from "babylonjs/types";
  46190. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46191. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46192. import { IColor4Like } from "babylonjs/Maths/math.like";
  46193. /** @hidden */
  46194. export class WebGPUTextureHelper {
  46195. private _device;
  46196. private _glslang;
  46197. private _bufferManager;
  46198. private _mipmapSampler;
  46199. private _invertYPreMultiplyAlphaSampler;
  46200. private _pipelines;
  46201. private _compiledShaders;
  46202. private _deferredReleaseTextures;
  46203. private _commandEncoderForCreation;
  46204. static ComputeNumMipmapLevels(width: number, height: number): number;
  46205. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  46206. private _getPipeline;
  46207. private static _GetTextureTypeFromFormat;
  46208. private static _GetBlockInformationFromFormat;
  46209. private static _IsHardwareTexture;
  46210. private static _IsInternalTexture;
  46211. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  46212. static IsImageBitmap(imageBitmap: ImageBitmap | {
  46213. width: number;
  46214. height: number;
  46215. }): imageBitmap is ImageBitmap;
  46216. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  46217. width: number;
  46218. height: number;
  46219. }): imageBitmap is ImageBitmap[];
  46220. setCommandEncoder(encoder: GPUCommandEncoder): void;
  46221. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  46222. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  46223. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46224. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  46225. createTexture(imageBitmap: ImageBitmap | {
  46226. width: number;
  46227. height: number;
  46228. layers: number;
  46229. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46230. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  46231. width: number;
  46232. height: number;
  46233. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46234. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  46235. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46236. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  46237. createMSAATexture(texture: InternalTexture, samples: number): void;
  46238. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46239. 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;
  46240. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  46241. releaseTexture(texture: InternalTexture | GPUTexture): void;
  46242. destroyDeferredTextures(): void;
  46243. }
  46244. }
  46245. declare module "babylonjs/Engines/WebGPU/webgpuRenderPassWrapper" {
  46246. import { Nullable } from "babylonjs/types";
  46247. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46248. /** @hidden */
  46249. export class WebGPURenderPassWrapper {
  46250. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  46251. renderPass: Nullable<GPURenderPassEncoder>;
  46252. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46253. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46254. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  46255. depthTextureFormat: GPUTextureFormat | undefined;
  46256. constructor();
  46257. reset(fullReset?: boolean): void;
  46258. }
  46259. }
  46260. declare module "babylonjs/Engines/WebGPU/webgpuCacheSampler" {
  46261. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46262. /** @hidden */
  46263. export class WebGPUCacheSampler {
  46264. private _samplers;
  46265. private _device;
  46266. constructor(device: GPUDevice);
  46267. private static _GetSamplerHashCode;
  46268. private static _GetSamplerFilterDescriptor;
  46269. private static _GetWrappingMode;
  46270. private static _GetSamplerWrappingDescriptor;
  46271. private static _GetSamplerDescriptor;
  46272. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  46273. }
  46274. }
  46275. declare module "babylonjs/Engines/WebGPU/webgpuShaderManager" {
  46276. import { IWebGPURenderPipelineStageDescriptor } from "babylonjs/Engines/WebGPU/webgpuPipelineContext";
  46277. /** @hidden */
  46278. export class WebGPUShaderManager {
  46279. private _shaders;
  46280. private _device;
  46281. constructor(device: GPUDevice);
  46282. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  46283. }
  46284. }
  46285. declare module "babylonjs/Shaders/clearQuad.vertex" {
  46286. /** @hidden */
  46287. export var clearQuadVertexShader: {
  46288. name: string;
  46289. shader: string;
  46290. };
  46291. }
  46292. declare module "babylonjs/Shaders/clearQuad.fragment" {
  46293. /** @hidden */
  46294. export var clearQuadPixelShader: {
  46295. name: string;
  46296. shader: string;
  46297. };
  46298. }
  46299. declare module "babylonjs/Engines/webgpuEngine" {
  46300. import { Nullable, DataArray, IndicesArray, FloatArray, Immutable } from "babylonjs/types";
  46301. import { Engine } from "babylonjs/Engines/engine";
  46302. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  46303. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46305. import { IEffectCreationOptions, Effect } from "babylonjs/Materials/effect";
  46306. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  46307. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46308. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46310. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46311. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46312. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46313. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  46314. import { Scene } from "babylonjs/scene";
  46315. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  46316. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46317. import { IColor4Like } from "babylonjs/Maths/math.like";
  46318. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46319. import "babylonjs/Shaders/clearQuad.vertex";
  46320. import "babylonjs/Shaders/clearQuad.fragment";
  46321. /**
  46322. * Options to load the associated Glslang library
  46323. */
  46324. export interface GlslangOptions {
  46325. /**
  46326. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  46327. */
  46328. glslang?: any;
  46329. /**
  46330. * Defines the URL of the glslang JS File.
  46331. */
  46332. jsPath?: string;
  46333. /**
  46334. * Defines the URL of the glslang WASM File.
  46335. */
  46336. wasmPath?: string;
  46337. }
  46338. /**
  46339. * Options to create the WebGPU engine
  46340. */
  46341. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  46342. /**
  46343. * If delta time between frames should be constant
  46344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46345. */
  46346. deterministicLockstep?: boolean;
  46347. /**
  46348. * Maximum about of steps between frames (Default: 4)
  46349. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46350. */
  46351. lockstepMaxSteps?: number;
  46352. /**
  46353. * Defines the seconds between each deterministic lock step
  46354. */
  46355. timeStep?: number;
  46356. /**
  46357. * Defines that engine should ignore modifying touch action attribute and style
  46358. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  46359. */
  46360. doNotHandleTouchAction?: boolean;
  46361. /**
  46362. * Defines if webaudio should be initialized as well
  46363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  46364. */
  46365. audioEngine?: boolean;
  46366. /**
  46367. * Defines the category of adapter to use.
  46368. * Is it the discrete or integrated device.
  46369. */
  46370. powerPreference?: GPUPowerPreference;
  46371. /**
  46372. * Defines the device descriptor used to create a device.
  46373. */
  46374. deviceDescriptor?: GPUDeviceDescriptor;
  46375. /**
  46376. * Defines the requested Swap Chain Format.
  46377. */
  46378. swapChainFormat?: GPUTextureFormat;
  46379. /**
  46380. * Defines wether MSAA is enabled on the canvas.
  46381. */
  46382. antialiasing?: boolean;
  46383. /**
  46384. * Defines wether the stencil buffer should be enabled.
  46385. */
  46386. stencil?: boolean;
  46387. /**
  46388. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  46389. */
  46390. enableGPUDebugMarkers?: boolean;
  46391. }
  46392. /**
  46393. * The web GPU engine class provides support for WebGPU version of babylon.js.
  46394. */
  46395. export class WebGPUEngine extends Engine {
  46396. private static readonly _glslangDefaultOptions;
  46397. private readonly _uploadEncoderDescriptor;
  46398. private readonly _renderEncoderDescriptor;
  46399. private readonly _renderTargetEncoderDescriptor;
  46400. private readonly _clearDepthValue;
  46401. private readonly _clearReverseDepthValue;
  46402. private readonly _clearStencilValue;
  46403. private readonly _defaultSampleCount;
  46404. private _canvas;
  46405. private _options;
  46406. private _glslang;
  46407. private _adapter;
  46408. private _adapterSupportedExtensions;
  46409. private _device;
  46410. private _deviceEnabledExtensions;
  46411. private _context;
  46412. private _swapChain;
  46413. private _swapChainTexture;
  46414. private _mainPassSampleCount;
  46415. private _textureHelper;
  46416. private _bufferManager;
  46417. private _shaderManager;
  46418. private _cacheSampler;
  46419. private _emptyVertexBuffer;
  46420. private _lastCachedWrapU;
  46421. private _lastCachedWrapV;
  46422. private _lastCachedWrapR;
  46423. private _mrtAttachments;
  46424. private _counters;
  46425. private _mainTexture;
  46426. private _depthTexture;
  46427. private _mainTextureExtends;
  46428. private _depthTextureFormat;
  46429. private _colorFormat;
  46430. private _uploadEncoder;
  46431. private _renderEncoder;
  46432. private _renderTargetEncoder;
  46433. private _commandBuffers;
  46434. private _currentRenderPass;
  46435. private _mainRenderPassWrapper;
  46436. private _rttRenderPassWrapper;
  46437. private _pendingDebugCommands;
  46438. private _currentVertexBuffers;
  46439. private _currentIndexBuffer;
  46440. private __colorWrite;
  46441. private _uniformsBuffers;
  46442. private _forceEnableEffect;
  46443. /** @hidden */
  46444. dbgShowShaderCode: boolean;
  46445. /** @hidden */
  46446. dbgSanityChecks: boolean;
  46447. /** @hidden */
  46448. dbgGenerateLogs: boolean;
  46449. /** @hidden */
  46450. dbgVerboseLogsForFirstFrames: boolean;
  46451. /** @hidden */
  46452. dbgVerboseLogsNumFrames: number;
  46453. /** @hidden */
  46454. dbgShowWarningsNotImplemented: boolean;
  46455. /**
  46456. * Gets a boolean indicating that the engine supports uniform buffers
  46457. */
  46458. get supportsUniformBuffers(): boolean;
  46459. /** Gets the supported extensions by the WebGPU adapter */
  46460. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46461. /** Gets the currently enabled extensions on the WebGPU device */
  46462. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46463. /**
  46464. * Returns the name of the engine
  46465. */
  46466. get name(): string;
  46467. /**
  46468. * Returns a string describing the current engine
  46469. */
  46470. get description(): string;
  46471. /**
  46472. * Returns the version of the engine
  46473. */
  46474. get version(): number;
  46475. /**
  46476. * Create a new instance of the gpu engine.
  46477. * @param canvas Defines the canvas to use to display the result
  46478. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46479. */
  46480. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46481. /**
  46482. * Initializes the WebGPU context and dependencies.
  46483. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46484. * @returns a promise notifying the readiness of the engine.
  46485. */
  46486. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46487. private _initGlslang;
  46488. private _initializeLimits;
  46489. private _initializeContextAndSwapChain;
  46490. private _initializeMainAttachments;
  46491. /**
  46492. * Force a specific size of the canvas
  46493. * @param width defines the new canvas' width
  46494. * @param height defines the new canvas' height
  46495. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46496. * @returns true if the size was changed
  46497. */
  46498. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46499. /**
  46500. * Gets a shader processor implementation fitting with the current engine type.
  46501. * @returns The shader processor implementation.
  46502. */
  46503. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46504. /** @hidden */
  46505. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46506. /**
  46507. * Force the entire cache to be cleared
  46508. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46509. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46510. */
  46511. wipeCaches(bruteForce?: boolean): void;
  46512. /**
  46513. * Enable or disable color writing
  46514. * @param enable defines the state to set
  46515. */
  46516. setColorWrite(enable: boolean): void;
  46517. /**
  46518. * Gets a boolean indicating if color writing is enabled
  46519. * @returns the current color writing state
  46520. */
  46521. getColorWrite(): boolean;
  46522. private _viewportsCurrent;
  46523. private _resetCurrentViewport;
  46524. private _applyViewport;
  46525. /** @hidden */
  46526. _viewport(x: number, y: number, width: number, height: number): void;
  46527. private _scissorsCurrent;
  46528. protected _scissorCached: {
  46529. x: number;
  46530. y: number;
  46531. z: number;
  46532. w: number;
  46533. };
  46534. private _resetCurrentScissor;
  46535. private _applyScissor;
  46536. private _scissorIsActive;
  46537. enableScissor(x: number, y: number, width: number, height: number): void;
  46538. disableScissor(): void;
  46539. /**
  46540. * Clear the current render buffer or the current render target (if any is set up)
  46541. * @param color defines the color to use
  46542. * @param backBuffer defines if the back buffer must be cleared
  46543. * @param depth defines if the depth buffer must be cleared
  46544. * @param stencil defines if the stencil buffer must be cleared
  46545. */
  46546. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46547. /**
  46548. * Creates a vertex buffer
  46549. * @param data the data for the vertex buffer
  46550. * @returns the new buffer
  46551. */
  46552. createVertexBuffer(data: DataArray): DataBuffer;
  46553. /**
  46554. * Creates a vertex buffer
  46555. * @param data the data for the dynamic vertex buffer
  46556. * @returns the new buffer
  46557. */
  46558. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46559. /**
  46560. * Updates a vertex buffer.
  46561. * @param vertexBuffer the vertex buffer to update
  46562. * @param data the data used to update the vertex buffer
  46563. * @param byteOffset the byte offset of the data
  46564. * @param byteLength the byte length of the data
  46565. */
  46566. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46567. /**
  46568. * Creates a new index buffer
  46569. * @param indices defines the content of the index buffer
  46570. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46571. * @returns a new buffer
  46572. */
  46573. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46574. /**
  46575. * Update an index buffer
  46576. * @param indexBuffer defines the target index buffer
  46577. * @param indices defines the data to update
  46578. * @param offset defines the offset in the target index buffer where update should start
  46579. */
  46580. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46581. /** @hidden */
  46582. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46583. /** @hidden */
  46584. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46585. /**
  46586. * Bind a list of vertex buffers with the engine
  46587. * @param vertexBuffers defines the list of vertex buffers to bind
  46588. * @param indexBuffer defines the index buffer to bind
  46589. * @param effect defines the effect associated with the vertex buffers
  46590. */
  46591. bindBuffers(vertexBuffers: {
  46592. [key: string]: Nullable<VertexBuffer>;
  46593. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  46594. /** @hidden */
  46595. _releaseBuffer(buffer: DataBuffer): boolean;
  46596. createUniformBuffer(elements: FloatArray): DataBuffer;
  46597. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46598. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46599. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46600. /**
  46601. * Create a new effect (used to store vertex/fragment shaders)
  46602. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46603. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46604. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46605. * @param samplers defines an array of string used to represent textures
  46606. * @param defines defines the string containing the defines to use to compile the shaders
  46607. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  46608. * @param onCompiled defines a function to call when the effect creation is successful
  46609. * @param onError defines a function to call when the effect creation has failed
  46610. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46611. * @returns the new Effect
  46612. */
  46613. 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;
  46614. private _compileRawShaderToSpirV;
  46615. private _compileShaderToSpirV;
  46616. private _createPipelineStageDescriptor;
  46617. private _compileRawPipelineStageDescriptor;
  46618. private _compilePipelineStageDescriptor;
  46619. /** @hidden */
  46620. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46621. /** @hidden */
  46622. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46623. /**
  46624. * Creates a new pipeline context
  46625. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46626. * @returns the new pipeline
  46627. */
  46628. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46629. /** @hidden */
  46630. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46631. /**
  46632. * Gets the list of active attributes for a given WebGPU program
  46633. * @param pipelineContext defines the pipeline context to use
  46634. * @param attributesNames defines the list of attribute names to get
  46635. * @returns an array of indices indicating the offset of each attribute
  46636. */
  46637. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46638. /**
  46639. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46640. * @param effect defines the effect to activate
  46641. */
  46642. enableEffect(effect: Nullable<Effect>): void;
  46643. /** @hidden */
  46644. _releaseEffect(effect: Effect): void;
  46645. /**
  46646. * 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
  46647. */
  46648. releaseEffects(): void;
  46649. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46650. /**
  46651. * Gets a boolean indicating that only power of 2 textures are supported
  46652. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46653. */
  46654. get needPOTTextures(): boolean;
  46655. /** @hidden */
  46656. _createHardwareTexture(): HardwareTextureWrapper;
  46657. /** @hidden */
  46658. _releaseTexture(texture: InternalTexture): void;
  46659. /** @hidden */
  46660. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46661. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46662. /**
  46663. * Usually called from Texture.ts.
  46664. * Passed information to create a hardware texture
  46665. * @param url defines a value which contains one of the following:
  46666. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46667. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46668. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46670. * @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)
  46671. * @param scene needed for loading to the correct scene
  46672. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46673. * @param onLoad optional callback to be called upon successful completion
  46674. * @param onError optional callback to be called upon failure
  46675. * @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
  46676. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46677. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46678. * @param forcedExtension defines the extension to use to pick the right loader
  46679. * @param mimeType defines an optional mime type
  46680. * @param loaderOptions options to be passed to the loader
  46681. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46682. */
  46683. 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;
  46684. /** @hidden */
  46685. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46686. /**
  46687. * Creates a cube texture
  46688. * @param rootUrl defines the url where the files to load is located
  46689. * @param scene defines the current scene
  46690. * @param files defines the list of files to load (1 per face)
  46691. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46692. * @param onLoad defines an optional callback raised when the texture is loaded
  46693. * @param onError defines an optional callback raised if there is an issue to load the texture
  46694. * @param format defines the format of the data
  46695. * @param forcedExtension defines the extension to use to pick the right loader
  46696. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46697. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46698. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46699. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46700. * @param loaderOptions options to be passed to the loader
  46701. * @returns the cube texture as an InternalTexture
  46702. */
  46703. 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;
  46704. /**
  46705. * Creates a raw texture
  46706. * @param data defines the data to store in the texture
  46707. * @param width defines the width of the texture
  46708. * @param height defines the height of the texture
  46709. * @param format defines the format of the data
  46710. * @param generateMipMaps defines if the engine should generate the mip levels
  46711. * @param invertY defines if data must be stored with Y axis inverted
  46712. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  46713. * @param compression defines the compression used (null by default)
  46714. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46715. * @returns the raw texture inside an InternalTexture
  46716. */
  46717. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  46718. /**
  46719. * Creates a new raw cube texture
  46720. * @param data defines the array of data to use to create each face
  46721. * @param size defines the size of the textures
  46722. * @param format defines the format of the data
  46723. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46724. * @param generateMipMaps defines if the engine should generate the mip levels
  46725. * @param invertY defines if data must be stored with Y axis inverted
  46726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46727. * @param compression defines the compression used (null by default)
  46728. * @returns the cube texture as an InternalTexture
  46729. */
  46730. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  46731. /**
  46732. * Creates a new raw cube texture from a specified url
  46733. * @param url defines the url where the data is located
  46734. * @param scene defines the current scene
  46735. * @param size defines the size of the textures
  46736. * @param format defines the format of the data
  46737. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46738. * @param noMipmap defines if the engine should avoid generating the mip levels
  46739. * @param callback defines a callback used to extract texture data from loaded data
  46740. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  46741. * @param onLoad defines a callback called when texture is loaded
  46742. * @param onError defines a callback called if there is an error
  46743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46744. * @param invertY defines if data must be stored with Y axis inverted
  46745. * @returns the cube texture as an InternalTexture
  46746. */
  46747. 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;
  46748. /**
  46749. * Creates a new raw 2D array texture
  46750. * @param data defines the data used to create the texture
  46751. * @param width defines the width of the texture
  46752. * @param height defines the height of the texture
  46753. * @param depth defines the number of layers of the texture
  46754. * @param format defines the format of the texture
  46755. * @param generateMipMaps defines if the engine must generate mip levels
  46756. * @param invertY defines if data must be stored with Y axis inverted
  46757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46758. * @param compression defines the compressed used (can be null)
  46759. * @param textureType defines the compressed used (can be null)
  46760. * @returns a new raw 2D array texture (stored in an InternalTexture)
  46761. */
  46762. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46763. /**
  46764. * Creates a new raw 3D texture
  46765. * @param data defines the data used to create the texture
  46766. * @param width defines the width of the texture
  46767. * @param height defines the height of the texture
  46768. * @param depth defines the depth of the texture
  46769. * @param format defines the format of the texture
  46770. * @param generateMipMaps defines if the engine must generate mip levels
  46771. * @param invertY defines if data must be stored with Y axis inverted
  46772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46773. * @param compression defines the compressed used (can be null)
  46774. * @param textureType defines the compressed used (can be null)
  46775. * @returns a new raw 3D texture (stored in an InternalTexture)
  46776. */
  46777. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46778. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  46779. /**
  46780. * Update the sampling mode of a given texture
  46781. * @param samplingMode defines the required sampling mode
  46782. * @param texture defines the texture to update
  46783. * @param generateMipMaps defines whether to generate mipmaps for the texture
  46784. */
  46785. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  46786. /**
  46787. * Update the sampling mode of a given texture
  46788. * @param texture defines the texture to update
  46789. * @param wrapU defines the texture wrap mode of the u coordinates
  46790. * @param wrapV defines the texture wrap mode of the v coordinates
  46791. * @param wrapR defines the texture wrap mode of the r coordinates
  46792. */
  46793. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  46794. /**
  46795. * Update the dimensions of a texture
  46796. * @param texture texture to update
  46797. * @param width new width of the texture
  46798. * @param height new height of the texture
  46799. * @param depth new depth of the texture
  46800. */
  46801. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  46802. private _setInternalTexture;
  46803. /**
  46804. * Sets a texture to the according uniform.
  46805. * @param channel The texture channel
  46806. * @param unused unused parameter
  46807. * @param texture The texture to apply
  46808. * @param name The name of the uniform in the effect
  46809. */
  46810. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  46811. /**
  46812. * Sets an array of texture to the WebGPU context
  46813. * @param channel defines the channel where the texture array must be set
  46814. * @param unused unused parameter
  46815. * @param textures defines the array of textures to bind
  46816. * @param name name of the channel
  46817. */
  46818. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  46819. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  46820. /** @hidden */
  46821. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  46822. /** @hidden */
  46823. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  46824. private _generateMipmaps;
  46825. /**
  46826. * Update the content of a texture
  46827. * @param texture defines the texture to update
  46828. * @param canvas defines the source containing the data
  46829. * @param invertY defines if data must be stored with Y axis inverted
  46830. * @param premulAlpha defines if alpha is stored as premultiplied
  46831. * @param format defines the format of the data
  46832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46833. */
  46834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  46835. /**
  46836. * Update a portion of an internal texture
  46837. * @param texture defines the texture to update
  46838. * @param imageData defines the data to store into the texture
  46839. * @param xOffset defines the x coordinates of the update rectangle
  46840. * @param yOffset defines the y coordinates of the update rectangle
  46841. * @param width defines the width of the update rectangle
  46842. * @param height defines the height of the update rectangle
  46843. * @param faceIndex defines the face index if texture is a cube (0 by default)
  46844. * @param lod defines the lod level to update (0 by default)
  46845. */
  46846. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  46847. /**
  46848. * Update a video texture
  46849. * @param texture defines the texture to update
  46850. * @param video defines the video element to use
  46851. * @param invertY defines if data must be stored with Y axis inverted
  46852. */
  46853. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  46854. /** @hidden */
  46855. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46856. /** @hidden */
  46857. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  46858. /** @hidden */
  46859. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46860. /** @hidden */
  46861. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  46862. /**
  46863. * Update a raw texture
  46864. * @param texture defines the texture to update
  46865. * @param bufferView defines the data to store in the texture
  46866. * @param format defines the format of the data
  46867. * @param invertY defines if data must be stored with Y axis inverted
  46868. * @param compression defines the compression used (null by default)
  46869. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46870. */
  46871. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  46872. /**
  46873. * Update a raw cube texture
  46874. * @param texture defines the texture to udpdate
  46875. * @param bufferView defines the data to store
  46876. * @param format defines the data format
  46877. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46878. * @param invertY defines if data must be stored with Y axis inverted
  46879. * @param compression defines the compression used (null by default)
  46880. * @param level defines which level of the texture to update
  46881. */
  46882. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46883. /**
  46884. * Update a raw 2D array texture
  46885. * @param texture defines the texture to update
  46886. * @param bufferView defines the data to store
  46887. * @param format defines the data format
  46888. * @param invertY defines if data must be stored with Y axis inverted
  46889. * @param compression defines the used compression (can be null)
  46890. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46891. */
  46892. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46893. /**
  46894. * Update a raw 3D texture
  46895. * @param texture defines the texture to update
  46896. * @param bufferView defines the data to store
  46897. * @param format defines the data format
  46898. * @param invertY defines if data must be stored with Y axis inverted
  46899. * @param compression defines the used compression (can be null)
  46900. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46901. */
  46902. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46903. /**
  46904. * Reads pixels from the current frame buffer. Please note that this function can be slow
  46905. * @param x defines the x coordinate of the rectangle where pixels must be read
  46906. * @param y defines the y coordinate of the rectangle where pixels must be read
  46907. * @param width defines the width of the rectangle where pixels must be read
  46908. * @param height defines the height of the rectangle where pixels must be read
  46909. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  46910. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  46911. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  46912. */
  46913. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46914. /** @hidden */
  46915. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46916. /**
  46917. * Creates a new render target texture
  46918. * @param size defines the size of the texture
  46919. * @param options defines the options used to create the texture
  46920. * @returns a new render target texture stored in an InternalTexture
  46921. */
  46922. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46923. /**
  46924. * Create a multi render target texture
  46925. * @param size defines the size of the texture
  46926. * @param options defines the creation options
  46927. * @returns the cube texture as an InternalTexture
  46928. */
  46929. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46930. /**
  46931. * Creates a new render target cube texture
  46932. * @param size defines the size of the texture
  46933. * @param options defines the options used to create the texture
  46934. * @returns a new render target cube texture stored in an InternalTexture
  46935. */
  46936. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  46937. /** @hidden */
  46938. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  46939. width: number;
  46940. height: number;
  46941. layers?: number;
  46942. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  46943. /** @hidden */
  46944. _createDepthStencilTexture(size: number | {
  46945. width: number;
  46946. height: number;
  46947. layers?: number;
  46948. }, options: DepthTextureCreationOptions): InternalTexture;
  46949. /** @hidden */
  46950. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  46951. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  46952. /**
  46953. * Update the sample count for a given multiple render target texture
  46954. * @param textures defines the textures to update
  46955. * @param samples defines the sample count to set
  46956. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46957. */
  46958. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46959. /**
  46960. * Begin a new frame
  46961. */
  46962. beginFrame(): void;
  46963. /**
  46964. * End the current frame
  46965. */
  46966. endFrame(): void;
  46967. /**
  46968. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46969. */
  46970. flushFramebuffer(): void;
  46971. private _startRenderTargetRenderPass;
  46972. private _endRenderTargetRenderPass;
  46973. private _getCurrentRenderPass;
  46974. private _currentRenderPassIsMRT;
  46975. private _startMainRenderPass;
  46976. private _endMainRenderPass;
  46977. /**
  46978. * Restores the WebGPU state to only draw on the main color attachment
  46979. */
  46980. restoreSingleAttachment(): void;
  46981. /**
  46982. * Creates a layout object to draw/clear on specific textures in a MRT
  46983. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46984. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46985. */
  46986. buildTextureLayout(textureStatus: boolean[]): number[];
  46987. /**
  46988. * Select a subsets of attachments to draw to.
  46989. * @param attachments index of attachments
  46990. */
  46991. bindAttachments(attachments: number[]): void;
  46992. /**
  46993. * Binds the frame buffer to the specified texture.
  46994. * @param texture The texture to render to or null for the default canvas
  46995. * @param faceIndex The face of the texture to render to in case of cube texture
  46996. * @param requiredWidth The width of the target to render to
  46997. * @param requiredHeight The height of the target to render to
  46998. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46999. * @param lodLevel defines the lod level to bind to the frame buffer
  47000. * @param layer defines the 2d array index to bind to frame buffer to
  47001. */
  47002. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  47003. /**
  47004. * Unbind the current render target texture from the WebGPU context
  47005. * @param texture defines the render target texture to unbind
  47006. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47007. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47008. */
  47009. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47010. /**
  47011. * Unbind a list of render target textures from the WebGPU context
  47012. * @param textures defines the render target textures to unbind
  47013. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47014. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47015. */
  47016. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47017. /**
  47018. * Unbind the current render target and bind the default framebuffer
  47019. */
  47020. restoreDefaultFramebuffer(): void;
  47021. setZOffset(value: number): void;
  47022. private _setColorFormat;
  47023. private _setDepthTextureFormat;
  47024. setDepthBuffer(enable: boolean): void;
  47025. setDepthWrite(enable: boolean): void;
  47026. setStencilBuffer(enable: boolean): void;
  47027. setStencilMask(mask: number): void;
  47028. setStencilFunction(stencilFunc: number): void;
  47029. setStencilFunctionReference(reference: number): void;
  47030. setStencilFunctionMask(mask: number): void;
  47031. setStencilOperationFail(operation: number): void;
  47032. setStencilOperationDepthFail(operation: number): void;
  47033. setStencilOperationPass(operation: number): void;
  47034. setDitheringState(value: boolean): void;
  47035. setRasterizerState(value: boolean): void;
  47036. setDepthFunction(depthFunc: number): void;
  47037. setDepthFunctionToGreater(): void;
  47038. setDepthFunctionToGreaterOrEqual(): void;
  47039. setDepthFunctionToLess(): void;
  47040. setDepthFunctionToLessOrEqual(): void;
  47041. private _indexFormatInRenderPass;
  47042. private _getTopology;
  47043. private _getOpFunction;
  47044. private _getDepthStencilStateDescriptor;
  47045. /**
  47046. * Set various states to the context
  47047. * @param culling defines backface culling state
  47048. * @param zOffset defines the value to apply to zOffset (0 by default)
  47049. * @param force defines if states must be applied even if cache is up to date
  47050. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47051. */
  47052. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47053. private _getFrontFace;
  47054. private _getCullMode;
  47055. private _getRasterizationStateDescriptor;
  47056. private _getWriteMask;
  47057. /**
  47058. * Sets the current alpha mode
  47059. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47060. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47061. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47062. */
  47063. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47064. private _getAphaBlendOperation;
  47065. private _getAphaBlendFactor;
  47066. private _getAphaBlendState;
  47067. private _getColorBlendState;
  47068. private _getColorStateDescriptors;
  47069. private _getStages;
  47070. private _getVertexInputDescriptorFormat;
  47071. private _getVertexInputDescriptor;
  47072. private _getPipelineLayout;
  47073. private _getRenderPipeline;
  47074. private _getVertexInputsToRender;
  47075. private _getBindGroupsToRender;
  47076. private _bindVertexInputs;
  47077. private _setRenderBindGroups;
  47078. private _setRenderPipeline;
  47079. /**
  47080. * Draw a list of indexed primitives
  47081. * @param fillMode defines the primitive to use
  47082. * @param indexStart defines the starting index
  47083. * @param indexCount defines the number of index to draw
  47084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47085. */
  47086. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47087. /**
  47088. * Draw a list of unindexed primitives
  47089. * @param fillMode defines the primitive to use
  47090. * @param verticesStart defines the index of first vertex to draw
  47091. * @param verticesCount defines the count of vertices to draw
  47092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47093. */
  47094. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47095. private _bundleEncoder;
  47096. /**
  47097. * Start recording all the gpu calls into a bundle.
  47098. */
  47099. startRecordBundle(): void;
  47100. /**
  47101. * Stops recording the bundle.
  47102. * @returns the recorded bundle
  47103. */
  47104. stopRecordBundle(): GPURenderBundle;
  47105. /**
  47106. * Execute the previously recorded bundle.
  47107. * @param bundles defines the bundle to replay
  47108. */
  47109. executeBundles(bundles: GPURenderBundle[]): void;
  47110. /**
  47111. * Dispose and release all associated resources
  47112. */
  47113. dispose(): void;
  47114. /**
  47115. * Gets the current render width
  47116. * @param useScreen defines if screen size must be used (or the current render target if any)
  47117. * @returns a number defining the current render width
  47118. */
  47119. getRenderWidth(useScreen?: boolean): number;
  47120. /**
  47121. * Gets the current render height
  47122. * @param useScreen defines if screen size must be used (or the current render target if any)
  47123. * @returns a number defining the current render height
  47124. */
  47125. getRenderHeight(useScreen?: boolean): number;
  47126. /**
  47127. * Gets the HTML canvas attached with the current WebGPU context
  47128. * @returns a HTML canvas
  47129. */
  47130. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  47131. /** @hidden */
  47132. _debugPushGroup(groupName: string, targetObject?: number): void;
  47133. /** @hidden */
  47134. _debugPopGroup(targetObject?: number): void;
  47135. /** @hidden */
  47136. _debugInsertMarker(text: string, targetObject?: number): void;
  47137. private _debugFlushPendingCommands;
  47138. /**
  47139. * Get the current error code of the WebGPU context
  47140. * @returns the error code
  47141. */
  47142. getError(): number;
  47143. /** @hidden */
  47144. bindSamplers(effect: Effect): void;
  47145. /** @hidden */
  47146. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  47147. /** @hidden */
  47148. _releaseFramebufferObjects(texture: InternalTexture): void;
  47149. /** @hidden */
  47150. applyStates(): void;
  47151. /**
  47152. * Gets a boolean indicating if all created effects are ready
  47153. * @returns always true - No parallel shader compilation
  47154. */
  47155. areAllEffectsReady(): boolean;
  47156. /** @hidden */
  47157. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47158. /** @hidden */
  47159. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47160. /** @hidden */
  47161. _getUnpackAlignement(): number;
  47162. /** @hidden */
  47163. _unpackFlipY(value: boolean): void;
  47164. /** @hidden */
  47165. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  47166. min: number;
  47167. mag: number;
  47168. };
  47169. /** @hidden */
  47170. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47171. /** @hidden */
  47172. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47173. /** @hidden */
  47174. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47175. /** @hidden */
  47176. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47177. /** @hidden */
  47178. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47179. /** @hidden */
  47180. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47181. /** @hidden */
  47182. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  47183. /** @hidden */
  47184. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  47185. /** @hidden */
  47186. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  47187. /** @hidden */
  47188. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  47189. /** @hidden */
  47190. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  47191. /** @hidden */
  47192. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47193. /** @hidden */
  47194. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47195. /** @hidden */
  47196. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  47197. /** @hidden */
  47198. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  47199. /** @hidden */
  47200. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  47201. /** @hidden */
  47202. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  47203. }
  47204. }
  47205. declare module "babylonjs/scene" {
  47206. import { Nullable } from "babylonjs/types";
  47207. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47208. import { Observable } from "babylonjs/Misc/observable";
  47209. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47210. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  47211. import { Geometry } from "babylonjs/Meshes/geometry";
  47212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47215. import { Mesh } from "babylonjs/Meshes/mesh";
  47216. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47217. import { Bone } from "babylonjs/Bones/bone";
  47218. import { Skeleton } from "babylonjs/Bones/skeleton";
  47219. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  47220. import { Camera } from "babylonjs/Cameras/camera";
  47221. import { AbstractScene } from "babylonjs/abstractScene";
  47222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47223. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47224. import { Material } from "babylonjs/Materials/material";
  47225. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47226. import { Effect } from "babylonjs/Materials/effect";
  47227. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47228. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  47229. import { Light } from "babylonjs/Lights/light";
  47230. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47231. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  47232. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  47233. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  47234. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  47235. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  47236. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  47237. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  47238. import { Engine } from "babylonjs/Engines/engine";
  47239. import { Node } from "babylonjs/node";
  47240. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  47241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  47242. import { WebRequest } from "babylonjs/Misc/webRequest";
  47243. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  47244. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  47245. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47246. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  47247. import { Plane } from "babylonjs/Maths/math.plane";
  47248. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  47249. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  47250. import { Ray } from "babylonjs/Culling/ray";
  47251. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  47252. import { Animation } from "babylonjs/Animations/animation";
  47253. import { Animatable } from "babylonjs/Animations/animatable";
  47254. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47255. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  47256. import { Collider } from "babylonjs/Collisions/collider";
  47257. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47258. /**
  47259. * Define an interface for all classes that will hold resources
  47260. */
  47261. export interface IDisposable {
  47262. /**
  47263. * Releases all held resources
  47264. */
  47265. dispose(): void;
  47266. }
  47267. /** Interface defining initialization parameters for Scene class */
  47268. export interface SceneOptions {
  47269. /**
  47270. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  47271. * It will improve performance when the number of geometries becomes important.
  47272. */
  47273. useGeometryUniqueIdsMap?: boolean;
  47274. /**
  47275. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  47276. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47277. */
  47278. useMaterialMeshMap?: boolean;
  47279. /**
  47280. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  47281. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47282. */
  47283. useClonedMeshMap?: boolean;
  47284. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  47285. virtual?: boolean;
  47286. }
  47287. /**
  47288. * Represents a scene to be rendered by the engine.
  47289. * @see https://doc.babylonjs.com/features/scene
  47290. */
  47291. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  47292. /** The fog is deactivated */
  47293. static readonly FOGMODE_NONE: number;
  47294. /** The fog density is following an exponential function */
  47295. static readonly FOGMODE_EXP: number;
  47296. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  47297. static readonly FOGMODE_EXP2: number;
  47298. /** The fog density is following a linear function. */
  47299. static readonly FOGMODE_LINEAR: number;
  47300. /**
  47301. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  47302. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47303. */
  47304. static MinDeltaTime: number;
  47305. /**
  47306. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  47307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47308. */
  47309. static MaxDeltaTime: number;
  47310. /**
  47311. * Factory used to create the default material.
  47312. * @param name The name of the material to create
  47313. * @param scene The scene to create the material for
  47314. * @returns The default material
  47315. */
  47316. static DefaultMaterialFactory(scene: Scene): Material;
  47317. /**
  47318. * Factory used to create the a collision coordinator.
  47319. * @returns The collision coordinator
  47320. */
  47321. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  47322. /** @hidden */
  47323. _inputManager: InputManager;
  47324. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  47325. cameraToUseForPointers: Nullable<Camera>;
  47326. /** @hidden */
  47327. readonly _isScene: boolean;
  47328. /** @hidden */
  47329. _blockEntityCollection: boolean;
  47330. /**
  47331. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  47332. */
  47333. autoClear: boolean;
  47334. /**
  47335. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  47336. */
  47337. autoClearDepthAndStencil: boolean;
  47338. /**
  47339. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  47340. */
  47341. clearColor: Color4;
  47342. /**
  47343. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  47344. */
  47345. ambientColor: Color3;
  47346. /**
  47347. * This is use to store the default BRDF lookup for PBR materials in your scene.
  47348. * It should only be one of the following (if not the default embedded one):
  47349. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47350. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  47351. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47352. * The material properties need to be setup according to the type of texture in use.
  47353. */
  47354. environmentBRDFTexture: BaseTexture;
  47355. /**
  47356. * Texture used in all pbr material as the reflection texture.
  47357. * As in the majority of the scene they are the same (exception for multi room and so on),
  47358. * this is easier to reference from here than from all the materials.
  47359. */
  47360. get environmentTexture(): Nullable<BaseTexture>;
  47361. /**
  47362. * Texture used in all pbr material as the reflection texture.
  47363. * As in the majority of the scene they are the same (exception for multi room and so on),
  47364. * this is easier to set here than in all the materials.
  47365. */
  47366. set environmentTexture(value: Nullable<BaseTexture>);
  47367. /** @hidden */
  47368. protected _environmentIntensity: number;
  47369. /**
  47370. * Intensity of the environment in all pbr material.
  47371. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47372. * As in the majority of the scene they are the same (exception for multi room and so on),
  47373. * this is easier to reference from here than from all the materials.
  47374. */
  47375. get environmentIntensity(): number;
  47376. /**
  47377. * Intensity of the environment in all pbr material.
  47378. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47379. * As in the majority of the scene they are the same (exception for multi room and so on),
  47380. * this is easier to set here than in all the materials.
  47381. */
  47382. set environmentIntensity(value: number);
  47383. /** @hidden */
  47384. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47385. /**
  47386. * Default image processing configuration used either in the rendering
  47387. * Forward main pass or through the imageProcessingPostProcess if present.
  47388. * As in the majority of the scene they are the same (exception for multi camera),
  47389. * this is easier to reference from here than from all the materials and post process.
  47390. *
  47391. * No setter as we it is a shared configuration, you can set the values instead.
  47392. */
  47393. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47394. private _forceWireframe;
  47395. /**
  47396. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  47397. */
  47398. set forceWireframe(value: boolean);
  47399. get forceWireframe(): boolean;
  47400. private _skipFrustumClipping;
  47401. /**
  47402. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  47403. */
  47404. set skipFrustumClipping(value: boolean);
  47405. get skipFrustumClipping(): boolean;
  47406. private _forcePointsCloud;
  47407. /**
  47408. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  47409. */
  47410. set forcePointsCloud(value: boolean);
  47411. get forcePointsCloud(): boolean;
  47412. /**
  47413. * Gets or sets the active clipplane 1
  47414. */
  47415. clipPlane: Nullable<Plane>;
  47416. /**
  47417. * Gets or sets the active clipplane 2
  47418. */
  47419. clipPlane2: Nullable<Plane>;
  47420. /**
  47421. * Gets or sets the active clipplane 3
  47422. */
  47423. clipPlane3: Nullable<Plane>;
  47424. /**
  47425. * Gets or sets the active clipplane 4
  47426. */
  47427. clipPlane4: Nullable<Plane>;
  47428. /**
  47429. * Gets or sets the active clipplane 5
  47430. */
  47431. clipPlane5: Nullable<Plane>;
  47432. /**
  47433. * Gets or sets the active clipplane 6
  47434. */
  47435. clipPlane6: Nullable<Plane>;
  47436. /**
  47437. * Gets or sets a boolean indicating if animations are enabled
  47438. */
  47439. animationsEnabled: boolean;
  47440. private _animationPropertiesOverride;
  47441. /**
  47442. * Gets or sets the animation properties override
  47443. */
  47444. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47445. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47446. /**
  47447. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47448. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47449. */
  47450. useConstantAnimationDeltaTime: boolean;
  47451. /**
  47452. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47453. * Please note that it requires to run a ray cast through the scene on every frame
  47454. */
  47455. constantlyUpdateMeshUnderPointer: boolean;
  47456. /**
  47457. * Defines the HTML cursor to use when hovering over interactive elements
  47458. */
  47459. hoverCursor: string;
  47460. /**
  47461. * Defines the HTML default cursor to use (empty by default)
  47462. */
  47463. defaultCursor: string;
  47464. /**
  47465. * Defines whether cursors are handled by the scene.
  47466. */
  47467. doNotHandleCursors: boolean;
  47468. /**
  47469. * This is used to call preventDefault() on pointer down
  47470. * in order to block unwanted artifacts like system double clicks
  47471. */
  47472. preventDefaultOnPointerDown: boolean;
  47473. /**
  47474. * This is used to call preventDefault() on pointer up
  47475. * in order to block unwanted artifacts like system double clicks
  47476. */
  47477. preventDefaultOnPointerUp: boolean;
  47478. /**
  47479. * Gets or sets user defined metadata
  47480. */
  47481. metadata: any;
  47482. /**
  47483. * For internal use only. Please do not use.
  47484. */
  47485. reservedDataStore: any;
  47486. /**
  47487. * Gets the name of the plugin used to load this scene (null by default)
  47488. */
  47489. loadingPluginName: string;
  47490. /**
  47491. * Use this array to add regular expressions used to disable offline support for specific urls
  47492. */
  47493. disableOfflineSupportExceptionRules: RegExp[];
  47494. /**
  47495. * An event triggered when the scene is disposed.
  47496. */
  47497. onDisposeObservable: Observable<Scene>;
  47498. private _onDisposeObserver;
  47499. /** Sets a function to be executed when this scene is disposed. */
  47500. set onDispose(callback: () => void);
  47501. /**
  47502. * An event triggered before rendering the scene (right after animations and physics)
  47503. */
  47504. onBeforeRenderObservable: Observable<Scene>;
  47505. private _onBeforeRenderObserver;
  47506. /** Sets a function to be executed before rendering this scene */
  47507. set beforeRender(callback: Nullable<() => void>);
  47508. /**
  47509. * An event triggered after rendering the scene
  47510. */
  47511. onAfterRenderObservable: Observable<Scene>;
  47512. /**
  47513. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47514. */
  47515. onAfterRenderCameraObservable: Observable<Camera>;
  47516. private _onAfterRenderObserver;
  47517. /** Sets a function to be executed after rendering this scene */
  47518. set afterRender(callback: Nullable<() => void>);
  47519. /**
  47520. * An event triggered before animating the scene
  47521. */
  47522. onBeforeAnimationsObservable: Observable<Scene>;
  47523. /**
  47524. * An event triggered after animations processing
  47525. */
  47526. onAfterAnimationsObservable: Observable<Scene>;
  47527. /**
  47528. * An event triggered before draw calls are ready to be sent
  47529. */
  47530. onBeforeDrawPhaseObservable: Observable<Scene>;
  47531. /**
  47532. * An event triggered after draw calls have been sent
  47533. */
  47534. onAfterDrawPhaseObservable: Observable<Scene>;
  47535. /**
  47536. * An event triggered when the scene is ready
  47537. */
  47538. onReadyObservable: Observable<Scene>;
  47539. /**
  47540. * An event triggered before rendering a camera
  47541. */
  47542. onBeforeCameraRenderObservable: Observable<Camera>;
  47543. private _onBeforeCameraRenderObserver;
  47544. /** Sets a function to be executed before rendering a camera*/
  47545. set beforeCameraRender(callback: () => void);
  47546. /**
  47547. * An event triggered after rendering a camera
  47548. */
  47549. onAfterCameraRenderObservable: Observable<Camera>;
  47550. private _onAfterCameraRenderObserver;
  47551. /** Sets a function to be executed after rendering a camera*/
  47552. set afterCameraRender(callback: () => void);
  47553. /**
  47554. * An event triggered when active meshes evaluation is about to start
  47555. */
  47556. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47557. /**
  47558. * An event triggered when active meshes evaluation is done
  47559. */
  47560. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47561. /**
  47562. * An event triggered when particles rendering is about to start
  47563. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47564. */
  47565. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47566. /**
  47567. * An event triggered when particles rendering is done
  47568. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47569. */
  47570. onAfterParticlesRenderingObservable: Observable<Scene>;
  47571. /**
  47572. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47573. */
  47574. onDataLoadedObservable: Observable<Scene>;
  47575. /**
  47576. * An event triggered when a camera is created
  47577. */
  47578. onNewCameraAddedObservable: Observable<Camera>;
  47579. /**
  47580. * An event triggered when a camera is removed
  47581. */
  47582. onCameraRemovedObservable: Observable<Camera>;
  47583. /**
  47584. * An event triggered when a light is created
  47585. */
  47586. onNewLightAddedObservable: Observable<Light>;
  47587. /**
  47588. * An event triggered when a light is removed
  47589. */
  47590. onLightRemovedObservable: Observable<Light>;
  47591. /**
  47592. * An event triggered when a geometry is created
  47593. */
  47594. onNewGeometryAddedObservable: Observable<Geometry>;
  47595. /**
  47596. * An event triggered when a geometry is removed
  47597. */
  47598. onGeometryRemovedObservable: Observable<Geometry>;
  47599. /**
  47600. * An event triggered when a transform node is created
  47601. */
  47602. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47603. /**
  47604. * An event triggered when a transform node is removed
  47605. */
  47606. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47607. /**
  47608. * An event triggered when a mesh is created
  47609. */
  47610. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47611. /**
  47612. * An event triggered when a mesh is removed
  47613. */
  47614. onMeshRemovedObservable: Observable<AbstractMesh>;
  47615. /**
  47616. * An event triggered when a skeleton is created
  47617. */
  47618. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47619. /**
  47620. * An event triggered when a skeleton is removed
  47621. */
  47622. onSkeletonRemovedObservable: Observable<Skeleton>;
  47623. /**
  47624. * An event triggered when a material is created
  47625. */
  47626. onNewMaterialAddedObservable: Observable<Material>;
  47627. /**
  47628. * An event triggered when a multi material is created
  47629. */
  47630. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47631. /**
  47632. * An event triggered when a material is removed
  47633. */
  47634. onMaterialRemovedObservable: Observable<Material>;
  47635. /**
  47636. * An event triggered when a multi material is removed
  47637. */
  47638. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47639. /**
  47640. * An event triggered when a texture is created
  47641. */
  47642. onNewTextureAddedObservable: Observable<BaseTexture>;
  47643. /**
  47644. * An event triggered when a texture is removed
  47645. */
  47646. onTextureRemovedObservable: Observable<BaseTexture>;
  47647. /**
  47648. * An event triggered when render targets are about to be rendered
  47649. * Can happen multiple times per frame.
  47650. */
  47651. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47652. /**
  47653. * An event triggered when render targets were rendered.
  47654. * Can happen multiple times per frame.
  47655. */
  47656. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47657. /**
  47658. * An event triggered before calculating deterministic simulation step
  47659. */
  47660. onBeforeStepObservable: Observable<Scene>;
  47661. /**
  47662. * An event triggered after calculating deterministic simulation step
  47663. */
  47664. onAfterStepObservable: Observable<Scene>;
  47665. /**
  47666. * An event triggered when the activeCamera property is updated
  47667. */
  47668. onActiveCameraChanged: Observable<Scene>;
  47669. /**
  47670. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47671. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47672. * 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)
  47673. */
  47674. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47675. /**
  47676. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47677. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47678. * 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)
  47679. */
  47680. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47681. /**
  47682. * This Observable will when a mesh has been imported into the scene.
  47683. */
  47684. onMeshImportedObservable: Observable<AbstractMesh>;
  47685. /**
  47686. * This Observable will when an animation file has been imported into the scene.
  47687. */
  47688. onAnimationFileImportedObservable: Observable<Scene>;
  47689. /**
  47690. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47691. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47692. */
  47693. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47694. /** @hidden */
  47695. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47696. /**
  47697. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47698. */
  47699. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47700. /**
  47701. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47702. */
  47703. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47704. /**
  47705. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47706. */
  47707. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47708. /** Callback called when a pointer move is detected */
  47709. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47710. /** Callback called when a pointer down is detected */
  47711. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47712. /** Callback called when a pointer up is detected */
  47713. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47714. /** Callback called when a pointer pick is detected */
  47715. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  47716. /**
  47717. * 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).
  47718. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47719. */
  47720. onPrePointerObservable: Observable<PointerInfoPre>;
  47721. /**
  47722. * Observable event triggered each time an input event is received from the rendering canvas
  47723. */
  47724. onPointerObservable: Observable<PointerInfo>;
  47725. /**
  47726. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  47727. */
  47728. get unTranslatedPointer(): Vector2;
  47729. /**
  47730. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  47731. */
  47732. static get DragMovementThreshold(): number;
  47733. static set DragMovementThreshold(value: number);
  47734. /**
  47735. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  47736. */
  47737. static get LongPressDelay(): number;
  47738. static set LongPressDelay(value: number);
  47739. /**
  47740. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  47741. */
  47742. static get DoubleClickDelay(): number;
  47743. static set DoubleClickDelay(value: number);
  47744. /** If you need to check double click without raising a single click at first click, enable this flag */
  47745. static get ExclusiveDoubleClickMode(): boolean;
  47746. static set ExclusiveDoubleClickMode(value: boolean);
  47747. /** @hidden */
  47748. _mirroredCameraPosition: Nullable<Vector3>;
  47749. /**
  47750. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  47751. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  47752. */
  47753. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  47754. /**
  47755. * Observable event triggered each time an keyboard event is received from the hosting window
  47756. */
  47757. onKeyboardObservable: Observable<KeyboardInfo>;
  47758. private _useRightHandedSystem;
  47759. /**
  47760. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  47761. */
  47762. set useRightHandedSystem(value: boolean);
  47763. get useRightHandedSystem(): boolean;
  47764. private _timeAccumulator;
  47765. private _currentStepId;
  47766. private _currentInternalStep;
  47767. /**
  47768. * Sets the step Id used by deterministic lock step
  47769. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47770. * @param newStepId defines the step Id
  47771. */
  47772. setStepId(newStepId: number): void;
  47773. /**
  47774. * Gets the step Id used by deterministic lock step
  47775. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47776. * @returns the step Id
  47777. */
  47778. getStepId(): number;
  47779. /**
  47780. * Gets the internal step used by deterministic lock step
  47781. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47782. * @returns the internal step
  47783. */
  47784. getInternalStep(): number;
  47785. private _fogEnabled;
  47786. /**
  47787. * Gets or sets a boolean indicating if fog is enabled on this scene
  47788. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47789. * (Default is true)
  47790. */
  47791. set fogEnabled(value: boolean);
  47792. get fogEnabled(): boolean;
  47793. private _fogMode;
  47794. /**
  47795. * Gets or sets the fog mode to use
  47796. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47797. * | mode | value |
  47798. * | --- | --- |
  47799. * | FOGMODE_NONE | 0 |
  47800. * | FOGMODE_EXP | 1 |
  47801. * | FOGMODE_EXP2 | 2 |
  47802. * | FOGMODE_LINEAR | 3 |
  47803. */
  47804. set fogMode(value: number);
  47805. get fogMode(): number;
  47806. /**
  47807. * Gets or sets the fog color to use
  47808. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47809. * (Default is Color3(0.2, 0.2, 0.3))
  47810. */
  47811. fogColor: Color3;
  47812. /**
  47813. * Gets or sets the fog density to use
  47814. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47815. * (Default is 0.1)
  47816. */
  47817. fogDensity: number;
  47818. /**
  47819. * Gets or sets the fog start distance to use
  47820. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47821. * (Default is 0)
  47822. */
  47823. fogStart: number;
  47824. /**
  47825. * Gets or sets the fog end distance to use
  47826. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47827. * (Default is 1000)
  47828. */
  47829. fogEnd: number;
  47830. /**
  47831. * Flag indicating that the frame buffer binding is handled by another component
  47832. */
  47833. prePass: boolean;
  47834. private _shadowsEnabled;
  47835. /**
  47836. * Gets or sets a boolean indicating if shadows are enabled on this scene
  47837. */
  47838. set shadowsEnabled(value: boolean);
  47839. get shadowsEnabled(): boolean;
  47840. private _lightsEnabled;
  47841. /**
  47842. * Gets or sets a boolean indicating if lights are enabled on this scene
  47843. */
  47844. set lightsEnabled(value: boolean);
  47845. get lightsEnabled(): boolean;
  47846. /** All of the active cameras added to this scene. */
  47847. activeCameras: Nullable<Camera[]>;
  47848. /** @hidden */
  47849. _activeCamera: Nullable<Camera>;
  47850. /** Gets or sets the current active camera */
  47851. get activeCamera(): Nullable<Camera>;
  47852. set activeCamera(value: Nullable<Camera>);
  47853. private _defaultMaterial;
  47854. /** The default material used on meshes when no material is affected */
  47855. get defaultMaterial(): Material;
  47856. /** The default material used on meshes when no material is affected */
  47857. set defaultMaterial(value: Material);
  47858. private _texturesEnabled;
  47859. /**
  47860. * Gets or sets a boolean indicating if textures are enabled on this scene
  47861. */
  47862. set texturesEnabled(value: boolean);
  47863. get texturesEnabled(): boolean;
  47864. /**
  47865. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  47866. */
  47867. physicsEnabled: boolean;
  47868. /**
  47869. * Gets or sets a boolean indicating if particles are enabled on this scene
  47870. */
  47871. particlesEnabled: boolean;
  47872. /**
  47873. * Gets or sets a boolean indicating if sprites are enabled on this scene
  47874. */
  47875. spritesEnabled: boolean;
  47876. private _skeletonsEnabled;
  47877. /**
  47878. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  47879. */
  47880. set skeletonsEnabled(value: boolean);
  47881. get skeletonsEnabled(): boolean;
  47882. /**
  47883. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  47884. */
  47885. lensFlaresEnabled: boolean;
  47886. /**
  47887. * Gets or sets a boolean indicating if collisions are enabled on this scene
  47888. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47889. */
  47890. collisionsEnabled: boolean;
  47891. private _collisionCoordinator;
  47892. /** @hidden */
  47893. get collisionCoordinator(): ICollisionCoordinator;
  47894. /**
  47895. * Defines the gravity applied to this scene (used only for collisions)
  47896. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47897. */
  47898. gravity: Vector3;
  47899. /**
  47900. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  47901. */
  47902. postProcessesEnabled: boolean;
  47903. /**
  47904. * Gets the current postprocess manager
  47905. */
  47906. postProcessManager: PostProcessManager;
  47907. /**
  47908. * Gets or sets a boolean indicating if render targets are enabled on this scene
  47909. */
  47910. renderTargetsEnabled: boolean;
  47911. /**
  47912. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  47913. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  47914. */
  47915. dumpNextRenderTargets: boolean;
  47916. /**
  47917. * The list of user defined render targets added to the scene
  47918. */
  47919. customRenderTargets: RenderTargetTexture[];
  47920. /**
  47921. * Defines if texture loading must be delayed
  47922. * If true, textures will only be loaded when they need to be rendered
  47923. */
  47924. useDelayedTextureLoading: boolean;
  47925. /**
  47926. * Gets the list of meshes imported to the scene through SceneLoader
  47927. */
  47928. importedMeshesFiles: String[];
  47929. /**
  47930. * Gets or sets a boolean indicating if probes are enabled on this scene
  47931. */
  47932. probesEnabled: boolean;
  47933. /**
  47934. * Gets or sets the current offline provider to use to store scene data
  47935. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47936. */
  47937. offlineProvider: IOfflineProvider;
  47938. /**
  47939. * Gets or sets the action manager associated with the scene
  47940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47941. */
  47942. actionManager: AbstractActionManager;
  47943. private _meshesForIntersections;
  47944. /**
  47945. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  47946. */
  47947. proceduralTexturesEnabled: boolean;
  47948. private _engine;
  47949. private _totalVertices;
  47950. /** @hidden */
  47951. _activeIndices: PerfCounter;
  47952. /** @hidden */
  47953. _activeParticles: PerfCounter;
  47954. /** @hidden */
  47955. _activeBones: PerfCounter;
  47956. private _animationRatio;
  47957. /** @hidden */
  47958. _animationTimeLast: number;
  47959. /** @hidden */
  47960. _animationTime: number;
  47961. /**
  47962. * Gets or sets a general scale for animation speed
  47963. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  47964. */
  47965. animationTimeScale: number;
  47966. /** @hidden */
  47967. _cachedMaterial: Nullable<Material>;
  47968. /** @hidden */
  47969. _cachedEffect: Nullable<Effect>;
  47970. /** @hidden */
  47971. _cachedVisibility: Nullable<number>;
  47972. private _renderId;
  47973. private _frameId;
  47974. private _executeWhenReadyTimeoutId;
  47975. private _intermediateRendering;
  47976. private _viewUpdateFlag;
  47977. private _projectionUpdateFlag;
  47978. /** @hidden */
  47979. _toBeDisposed: Nullable<IDisposable>[];
  47980. private _activeRequests;
  47981. /** @hidden */
  47982. _pendingData: any[];
  47983. private _isDisposed;
  47984. /**
  47985. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  47986. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  47987. */
  47988. dispatchAllSubMeshesOfActiveMeshes: boolean;
  47989. private _activeMeshes;
  47990. private _processedMaterials;
  47991. private _renderTargets;
  47992. /** @hidden */
  47993. _activeParticleSystems: SmartArray<IParticleSystem>;
  47994. private _activeSkeletons;
  47995. private _softwareSkinnedMeshes;
  47996. private _renderingManager;
  47997. /** @hidden */
  47998. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  47999. private _transformMatrix;
  48000. private _sceneUbo;
  48001. /** @hidden */
  48002. _viewMatrix: Matrix;
  48003. /** @hidden */
  48004. _projectionMatrix: Matrix;
  48005. /** @hidden */
  48006. _forcedViewPosition: Nullable<Vector3>;
  48007. /** @hidden */
  48008. _frustumPlanes: Plane[];
  48009. /**
  48010. * Gets the list of frustum planes (built from the active camera)
  48011. */
  48012. get frustumPlanes(): Plane[];
  48013. /**
  48014. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  48015. * This is useful if there are more lights that the maximum simulteanous authorized
  48016. */
  48017. requireLightSorting: boolean;
  48018. /** @hidden */
  48019. readonly useMaterialMeshMap: boolean;
  48020. /** @hidden */
  48021. readonly useClonedMeshMap: boolean;
  48022. private _externalData;
  48023. private _uid;
  48024. /**
  48025. * @hidden
  48026. * Backing store of defined scene components.
  48027. */
  48028. _components: ISceneComponent[];
  48029. /**
  48030. * @hidden
  48031. * Backing store of defined scene components.
  48032. */
  48033. _serializableComponents: ISceneSerializableComponent[];
  48034. /**
  48035. * List of components to register on the next registration step.
  48036. */
  48037. private _transientComponents;
  48038. /**
  48039. * Registers the transient components if needed.
  48040. */
  48041. private _registerTransientComponents;
  48042. /**
  48043. * @hidden
  48044. * Add a component to the scene.
  48045. * Note that the ccomponent could be registered on th next frame if this is called after
  48046. * the register component stage.
  48047. * @param component Defines the component to add to the scene
  48048. */
  48049. _addComponent(component: ISceneComponent): void;
  48050. /**
  48051. * @hidden
  48052. * Gets a component from the scene.
  48053. * @param name defines the name of the component to retrieve
  48054. * @returns the component or null if not present
  48055. */
  48056. _getComponent(name: string): Nullable<ISceneComponent>;
  48057. /**
  48058. * @hidden
  48059. * Defines the actions happening before camera updates.
  48060. */
  48061. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  48062. /**
  48063. * @hidden
  48064. * Defines the actions happening before clear the canvas.
  48065. */
  48066. _beforeClearStage: Stage<SimpleStageAction>;
  48067. /**
  48068. * @hidden
  48069. * Defines the actions when collecting render targets for the frame.
  48070. */
  48071. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48072. /**
  48073. * @hidden
  48074. * Defines the actions happening for one camera in the frame.
  48075. */
  48076. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48077. /**
  48078. * @hidden
  48079. * Defines the actions happening during the per mesh ready checks.
  48080. */
  48081. _isReadyForMeshStage: Stage<MeshStageAction>;
  48082. /**
  48083. * @hidden
  48084. * Defines the actions happening before evaluate active mesh checks.
  48085. */
  48086. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  48087. /**
  48088. * @hidden
  48089. * Defines the actions happening during the evaluate sub mesh checks.
  48090. */
  48091. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  48092. /**
  48093. * @hidden
  48094. * Defines the actions happening during the active mesh stage.
  48095. */
  48096. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  48097. /**
  48098. * @hidden
  48099. * Defines the actions happening during the per camera render target step.
  48100. */
  48101. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  48102. /**
  48103. * @hidden
  48104. * Defines the actions happening just before the active camera is drawing.
  48105. */
  48106. _beforeCameraDrawStage: Stage<CameraStageAction>;
  48107. /**
  48108. * @hidden
  48109. * Defines the actions happening just before a render target is drawing.
  48110. */
  48111. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48112. /**
  48113. * @hidden
  48114. * Defines the actions happening just before a rendering group is drawing.
  48115. */
  48116. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48117. /**
  48118. * @hidden
  48119. * Defines the actions happening just before a mesh is drawing.
  48120. */
  48121. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48122. /**
  48123. * @hidden
  48124. * Defines the actions happening just after a mesh has been drawn.
  48125. */
  48126. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48127. /**
  48128. * @hidden
  48129. * Defines the actions happening just after a rendering group has been drawn.
  48130. */
  48131. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48132. /**
  48133. * @hidden
  48134. * Defines the actions happening just after the active camera has been drawn.
  48135. */
  48136. _afterCameraDrawStage: Stage<CameraStageAction>;
  48137. /**
  48138. * @hidden
  48139. * Defines the actions happening just after a render target has been drawn.
  48140. */
  48141. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48142. /**
  48143. * @hidden
  48144. * Defines the actions happening just after rendering all cameras and computing intersections.
  48145. */
  48146. _afterRenderStage: Stage<SimpleStageAction>;
  48147. /**
  48148. * @hidden
  48149. * Defines the actions happening when a pointer move event happens.
  48150. */
  48151. _pointerMoveStage: Stage<PointerMoveStageAction>;
  48152. /**
  48153. * @hidden
  48154. * Defines the actions happening when a pointer down event happens.
  48155. */
  48156. _pointerDownStage: Stage<PointerUpDownStageAction>;
  48157. /**
  48158. * @hidden
  48159. * Defines the actions happening when a pointer up event happens.
  48160. */
  48161. _pointerUpStage: Stage<PointerUpDownStageAction>;
  48162. /**
  48163. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  48164. */
  48165. private geometriesByUniqueId;
  48166. private _renderBundles;
  48167. /**
  48168. * Creates a new Scene
  48169. * @param engine defines the engine to use to render this scene
  48170. * @param options defines the scene options
  48171. */
  48172. constructor(engine: Engine, options?: SceneOptions);
  48173. /**
  48174. * Gets a string identifying the name of the class
  48175. * @returns "Scene" string
  48176. */
  48177. getClassName(): string;
  48178. private _defaultMeshCandidates;
  48179. /**
  48180. * @hidden
  48181. */
  48182. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48183. private _defaultSubMeshCandidates;
  48184. /**
  48185. * @hidden
  48186. */
  48187. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48188. /**
  48189. * Sets the default candidate providers for the scene.
  48190. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  48191. * and getCollidingSubMeshCandidates to their default function
  48192. */
  48193. setDefaultCandidateProviders(): void;
  48194. /**
  48195. * Gets the mesh that is currently under the pointer
  48196. */
  48197. get meshUnderPointer(): Nullable<AbstractMesh>;
  48198. /**
  48199. * Gets or sets the current on-screen X position of the pointer
  48200. */
  48201. get pointerX(): number;
  48202. set pointerX(value: number);
  48203. /**
  48204. * Gets or sets the current on-screen Y position of the pointer
  48205. */
  48206. get pointerY(): number;
  48207. set pointerY(value: number);
  48208. /**
  48209. * Gets the cached material (ie. the latest rendered one)
  48210. * @returns the cached material
  48211. */
  48212. getCachedMaterial(): Nullable<Material>;
  48213. /**
  48214. * Gets the cached effect (ie. the latest rendered one)
  48215. * @returns the cached effect
  48216. */
  48217. getCachedEffect(): Nullable<Effect>;
  48218. /**
  48219. * Gets the cached visibility state (ie. the latest rendered one)
  48220. * @returns the cached visibility state
  48221. */
  48222. getCachedVisibility(): Nullable<number>;
  48223. /**
  48224. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  48225. * @param material defines the current material
  48226. * @param effect defines the current effect
  48227. * @param visibility defines the current visibility state
  48228. * @returns true if one parameter is not cached
  48229. */
  48230. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  48231. /**
  48232. * Gets the engine associated with the scene
  48233. * @returns an Engine
  48234. */
  48235. getEngine(): Engine;
  48236. /**
  48237. * Gets the total number of vertices rendered per frame
  48238. * @returns the total number of vertices rendered per frame
  48239. */
  48240. getTotalVertices(): number;
  48241. /**
  48242. * Gets the performance counter for total vertices
  48243. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48244. */
  48245. get totalVerticesPerfCounter(): PerfCounter;
  48246. /**
  48247. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  48248. * @returns the total number of active indices rendered per frame
  48249. */
  48250. getActiveIndices(): number;
  48251. /**
  48252. * Gets the performance counter for active indices
  48253. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48254. */
  48255. get totalActiveIndicesPerfCounter(): PerfCounter;
  48256. /**
  48257. * Gets the total number of active particles rendered per frame
  48258. * @returns the total number of active particles rendered per frame
  48259. */
  48260. getActiveParticles(): number;
  48261. /**
  48262. * Gets the performance counter for active particles
  48263. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48264. */
  48265. get activeParticlesPerfCounter(): PerfCounter;
  48266. /**
  48267. * Gets the total number of active bones rendered per frame
  48268. * @returns the total number of active bones rendered per frame
  48269. */
  48270. getActiveBones(): number;
  48271. /**
  48272. * Gets the performance counter for active bones
  48273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48274. */
  48275. get activeBonesPerfCounter(): PerfCounter;
  48276. /**
  48277. * Gets the array of active meshes
  48278. * @returns an array of AbstractMesh
  48279. */
  48280. getActiveMeshes(): SmartArray<AbstractMesh>;
  48281. /**
  48282. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  48283. * @returns a number
  48284. */
  48285. getAnimationRatio(): number;
  48286. /**
  48287. * Gets an unique Id for the current render phase
  48288. * @returns a number
  48289. */
  48290. getRenderId(): number;
  48291. /**
  48292. * Gets an unique Id for the current frame
  48293. * @returns a number
  48294. */
  48295. getFrameId(): number;
  48296. /** Call this function if you want to manually increment the render Id*/
  48297. incrementRenderId(): void;
  48298. private _createUbo;
  48299. /**
  48300. * Use this method to simulate a pointer move on a mesh
  48301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48304. * @returns the current scene
  48305. */
  48306. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48307. /**
  48308. * Use this method to simulate a pointer down on a mesh
  48309. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48310. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48311. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48312. * @returns the current scene
  48313. */
  48314. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48315. /**
  48316. * Use this method to simulate a pointer up on a mesh
  48317. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48318. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48319. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48320. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  48321. * @returns the current scene
  48322. */
  48323. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  48324. /**
  48325. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  48326. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  48327. * @returns true if the pointer was captured
  48328. */
  48329. isPointerCaptured(pointerId?: number): boolean;
  48330. /**
  48331. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  48332. * @param attachUp defines if you want to attach events to pointerup
  48333. * @param attachDown defines if you want to attach events to pointerdown
  48334. * @param attachMove defines if you want to attach events to pointermove
  48335. */
  48336. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  48337. /** Detaches all event handlers*/
  48338. detachControl(): void;
  48339. /**
  48340. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  48341. * Delay loaded resources are not taking in account
  48342. * @return true if all required resources are ready
  48343. */
  48344. isReady(): boolean;
  48345. /** Resets all cached information relative to material (including effect and visibility) */
  48346. resetCachedMaterial(): void;
  48347. /**
  48348. * Registers a function to be called before every frame render
  48349. * @param func defines the function to register
  48350. */
  48351. registerBeforeRender(func: () => void): void;
  48352. /**
  48353. * Unregisters a function called before every frame render
  48354. * @param func defines the function to unregister
  48355. */
  48356. unregisterBeforeRender(func: () => void): void;
  48357. /**
  48358. * Registers a function to be called after every frame render
  48359. * @param func defines the function to register
  48360. */
  48361. registerAfterRender(func: () => void): void;
  48362. /**
  48363. * Unregisters a function called after every frame render
  48364. * @param func defines the function to unregister
  48365. */
  48366. unregisterAfterRender(func: () => void): void;
  48367. private _executeOnceBeforeRender;
  48368. /**
  48369. * The provided function will run before render once and will be disposed afterwards.
  48370. * A timeout delay can be provided so that the function will be executed in N ms.
  48371. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  48372. * @param func The function to be executed.
  48373. * @param timeout optional delay in ms
  48374. */
  48375. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  48376. /** @hidden */
  48377. _addPendingData(data: any): void;
  48378. /** @hidden */
  48379. _removePendingData(data: any): void;
  48380. /**
  48381. * Returns the number of items waiting to be loaded
  48382. * @returns the number of items waiting to be loaded
  48383. */
  48384. getWaitingItemsCount(): number;
  48385. /**
  48386. * Returns a boolean indicating if the scene is still loading data
  48387. */
  48388. get isLoading(): boolean;
  48389. /**
  48390. * Registers a function to be executed when the scene is ready
  48391. * @param {Function} func - the function to be executed
  48392. */
  48393. executeWhenReady(func: () => void): void;
  48394. /**
  48395. * Returns a promise that resolves when the scene is ready
  48396. * @returns A promise that resolves when the scene is ready
  48397. */
  48398. whenReadyAsync(): Promise<void>;
  48399. /** @hidden */
  48400. _checkIsReady(): void;
  48401. /**
  48402. * Gets all animatable attached to the scene
  48403. */
  48404. get animatables(): Animatable[];
  48405. /**
  48406. * Resets the last animation time frame.
  48407. * Useful to override when animations start running when loading a scene for the first time.
  48408. */
  48409. resetLastAnimationTimeFrame(): void;
  48410. /**
  48411. * Gets the current view matrix
  48412. * @returns a Matrix
  48413. */
  48414. getViewMatrix(): Matrix;
  48415. /**
  48416. * Gets the current projection matrix
  48417. * @returns a Matrix
  48418. */
  48419. getProjectionMatrix(): Matrix;
  48420. /**
  48421. * Gets the current transform matrix
  48422. * @returns a Matrix made of View * Projection
  48423. */
  48424. getTransformMatrix(): Matrix;
  48425. /**
  48426. * Sets the current transform matrix
  48427. * @param viewL defines the View matrix to use
  48428. * @param projectionL defines the Projection matrix to use
  48429. * @param viewR defines the right View matrix to use (if provided)
  48430. * @param projectionR defines the right Projection matrix to use (if provided)
  48431. */
  48432. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  48433. /**
  48434. * Gets the uniform buffer used to store scene data
  48435. * @returns a UniformBuffer
  48436. */
  48437. getSceneUniformBuffer(): UniformBuffer;
  48438. /**
  48439. * Gets an unique (relatively to the current scene) Id
  48440. * @returns an unique number for the scene
  48441. */
  48442. getUniqueId(): number;
  48443. /**
  48444. * Add a mesh to the list of scene's meshes
  48445. * @param newMesh defines the mesh to add
  48446. * @param recursive if all child meshes should also be added to the scene
  48447. */
  48448. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48449. /**
  48450. * Remove a mesh for the list of scene's meshes
  48451. * @param toRemove defines the mesh to remove
  48452. * @param recursive if all child meshes should also be removed from the scene
  48453. * @returns the index where the mesh was in the mesh list
  48454. */
  48455. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48456. /**
  48457. * Add a transform node to the list of scene's transform nodes
  48458. * @param newTransformNode defines the transform node to add
  48459. */
  48460. addTransformNode(newTransformNode: TransformNode): void;
  48461. /**
  48462. * Remove a transform node for the list of scene's transform nodes
  48463. * @param toRemove defines the transform node to remove
  48464. * @returns the index where the transform node was in the transform node list
  48465. */
  48466. removeTransformNode(toRemove: TransformNode): number;
  48467. /**
  48468. * Remove a skeleton for the list of scene's skeletons
  48469. * @param toRemove defines the skeleton to remove
  48470. * @returns the index where the skeleton was in the skeleton list
  48471. */
  48472. removeSkeleton(toRemove: Skeleton): number;
  48473. /**
  48474. * Remove a morph target for the list of scene's morph targets
  48475. * @param toRemove defines the morph target to remove
  48476. * @returns the index where the morph target was in the morph target list
  48477. */
  48478. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48479. /**
  48480. * Remove a light for the list of scene's lights
  48481. * @param toRemove defines the light to remove
  48482. * @returns the index where the light was in the light list
  48483. */
  48484. removeLight(toRemove: Light): number;
  48485. /**
  48486. * Remove a camera for the list of scene's cameras
  48487. * @param toRemove defines the camera to remove
  48488. * @returns the index where the camera was in the camera list
  48489. */
  48490. removeCamera(toRemove: Camera): number;
  48491. /**
  48492. * Remove a particle system for the list of scene's particle systems
  48493. * @param toRemove defines the particle system to remove
  48494. * @returns the index where the particle system was in the particle system list
  48495. */
  48496. removeParticleSystem(toRemove: IParticleSystem): number;
  48497. /**
  48498. * Remove a animation for the list of scene's animations
  48499. * @param toRemove defines the animation to remove
  48500. * @returns the index where the animation was in the animation list
  48501. */
  48502. removeAnimation(toRemove: Animation): number;
  48503. /**
  48504. * Will stop the animation of the given target
  48505. * @param target - the target
  48506. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48507. * @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)
  48508. */
  48509. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48510. /**
  48511. * Removes the given animation group from this scene.
  48512. * @param toRemove The animation group to remove
  48513. * @returns The index of the removed animation group
  48514. */
  48515. removeAnimationGroup(toRemove: AnimationGroup): number;
  48516. /**
  48517. * Removes the given multi-material from this scene.
  48518. * @param toRemove The multi-material to remove
  48519. * @returns The index of the removed multi-material
  48520. */
  48521. removeMultiMaterial(toRemove: MultiMaterial): number;
  48522. /**
  48523. * Removes the given material from this scene.
  48524. * @param toRemove The material to remove
  48525. * @returns The index of the removed material
  48526. */
  48527. removeMaterial(toRemove: Material): number;
  48528. /**
  48529. * Removes the given action manager from this scene.
  48530. * @param toRemove The action manager to remove
  48531. * @returns The index of the removed action manager
  48532. */
  48533. removeActionManager(toRemove: AbstractActionManager): number;
  48534. /**
  48535. * Removes the given texture from this scene.
  48536. * @param toRemove The texture to remove
  48537. * @returns The index of the removed texture
  48538. */
  48539. removeTexture(toRemove: BaseTexture): number;
  48540. /**
  48541. * Adds the given light to this scene
  48542. * @param newLight The light to add
  48543. */
  48544. addLight(newLight: Light): void;
  48545. /**
  48546. * Sorts the list list based on light priorities
  48547. */
  48548. sortLightsByPriority(): void;
  48549. /**
  48550. * Adds the given camera to this scene
  48551. * @param newCamera The camera to add
  48552. */
  48553. addCamera(newCamera: Camera): void;
  48554. /**
  48555. * Adds the given skeleton to this scene
  48556. * @param newSkeleton The skeleton to add
  48557. */
  48558. addSkeleton(newSkeleton: Skeleton): void;
  48559. /**
  48560. * Adds the given particle system to this scene
  48561. * @param newParticleSystem The particle system to add
  48562. */
  48563. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48564. /**
  48565. * Adds the given animation to this scene
  48566. * @param newAnimation The animation to add
  48567. */
  48568. addAnimation(newAnimation: Animation): void;
  48569. /**
  48570. * Adds the given animation group to this scene.
  48571. * @param newAnimationGroup The animation group to add
  48572. */
  48573. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48574. /**
  48575. * Adds the given multi-material to this scene
  48576. * @param newMultiMaterial The multi-material to add
  48577. */
  48578. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48579. /**
  48580. * Adds the given material to this scene
  48581. * @param newMaterial The material to add
  48582. */
  48583. addMaterial(newMaterial: Material): void;
  48584. /**
  48585. * Adds the given morph target to this scene
  48586. * @param newMorphTargetManager The morph target to add
  48587. */
  48588. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48589. /**
  48590. * Adds the given geometry to this scene
  48591. * @param newGeometry The geometry to add
  48592. */
  48593. addGeometry(newGeometry: Geometry): void;
  48594. /**
  48595. * Adds the given action manager to this scene
  48596. * @param newActionManager The action manager to add
  48597. */
  48598. addActionManager(newActionManager: AbstractActionManager): void;
  48599. /**
  48600. * Adds the given texture to this scene.
  48601. * @param newTexture The texture to add
  48602. */
  48603. addTexture(newTexture: BaseTexture): void;
  48604. /**
  48605. * Switch active camera
  48606. * @param newCamera defines the new active camera
  48607. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48608. */
  48609. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48610. /**
  48611. * sets the active camera of the scene using its ID
  48612. * @param id defines the camera's ID
  48613. * @return the new active camera or null if none found.
  48614. */
  48615. setActiveCameraByID(id: string): Nullable<Camera>;
  48616. /**
  48617. * sets the active camera of the scene using its name
  48618. * @param name defines the camera's name
  48619. * @returns the new active camera or null if none found.
  48620. */
  48621. setActiveCameraByName(name: string): Nullable<Camera>;
  48622. /**
  48623. * get an animation group using its name
  48624. * @param name defines the material's name
  48625. * @return the animation group or null if none found.
  48626. */
  48627. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48628. /**
  48629. * Get a material using its unique id
  48630. * @param uniqueId defines the material's unique id
  48631. * @return the material or null if none found.
  48632. */
  48633. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48634. /**
  48635. * get a material using its id
  48636. * @param id defines the material's ID
  48637. * @return the material or null if none found.
  48638. */
  48639. getMaterialByID(id: string): Nullable<Material>;
  48640. /**
  48641. * Gets a the last added material using a given id
  48642. * @param id defines the material's ID
  48643. * @return the last material with the given id or null if none found.
  48644. */
  48645. getLastMaterialByID(id: string): Nullable<Material>;
  48646. /**
  48647. * Gets a material using its name
  48648. * @param name defines the material's name
  48649. * @return the material or null if none found.
  48650. */
  48651. getMaterialByName(name: string): Nullable<Material>;
  48652. /**
  48653. * Get a texture using its unique id
  48654. * @param uniqueId defines the texture's unique id
  48655. * @return the texture or null if none found.
  48656. */
  48657. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48658. /**
  48659. * Gets a camera using its id
  48660. * @param id defines the id to look for
  48661. * @returns the camera or null if not found
  48662. */
  48663. getCameraByID(id: string): Nullable<Camera>;
  48664. /**
  48665. * Gets a camera using its unique id
  48666. * @param uniqueId defines the unique id to look for
  48667. * @returns the camera or null if not found
  48668. */
  48669. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48670. /**
  48671. * Gets a camera using its name
  48672. * @param name defines the camera's name
  48673. * @return the camera or null if none found.
  48674. */
  48675. getCameraByName(name: string): Nullable<Camera>;
  48676. /**
  48677. * Gets a bone using its id
  48678. * @param id defines the bone's id
  48679. * @return the bone or null if not found
  48680. */
  48681. getBoneByID(id: string): Nullable<Bone>;
  48682. /**
  48683. * Gets a bone using its id
  48684. * @param name defines the bone's name
  48685. * @return the bone or null if not found
  48686. */
  48687. getBoneByName(name: string): Nullable<Bone>;
  48688. /**
  48689. * Gets a light node using its name
  48690. * @param name defines the the light's name
  48691. * @return the light or null if none found.
  48692. */
  48693. getLightByName(name: string): Nullable<Light>;
  48694. /**
  48695. * Gets a light node using its id
  48696. * @param id defines the light's id
  48697. * @return the light or null if none found.
  48698. */
  48699. getLightByID(id: string): Nullable<Light>;
  48700. /**
  48701. * Gets a light node using its scene-generated unique ID
  48702. * @param uniqueId defines the light's unique id
  48703. * @return the light or null if none found.
  48704. */
  48705. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48706. /**
  48707. * Gets a particle system by id
  48708. * @param id defines the particle system id
  48709. * @return the corresponding system or null if none found
  48710. */
  48711. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48712. /**
  48713. * Gets a geometry using its ID
  48714. * @param id defines the geometry's id
  48715. * @return the geometry or null if none found.
  48716. */
  48717. getGeometryByID(id: string): Nullable<Geometry>;
  48718. private _getGeometryByUniqueID;
  48719. /**
  48720. * Add a new geometry to this scene
  48721. * @param geometry defines the geometry to be added to the scene.
  48722. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  48723. * @return a boolean defining if the geometry was added or not
  48724. */
  48725. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  48726. /**
  48727. * Removes an existing geometry
  48728. * @param geometry defines the geometry to be removed from the scene
  48729. * @return a boolean defining if the geometry was removed or not
  48730. */
  48731. removeGeometry(geometry: Geometry): boolean;
  48732. /**
  48733. * Gets the list of geometries attached to the scene
  48734. * @returns an array of Geometry
  48735. */
  48736. getGeometries(): Geometry[];
  48737. /**
  48738. * Gets the first added mesh found of a given ID
  48739. * @param id defines the id to search for
  48740. * @return the mesh found or null if not found at all
  48741. */
  48742. getMeshByID(id: string): Nullable<AbstractMesh>;
  48743. /**
  48744. * Gets a list of meshes using their id
  48745. * @param id defines the id to search for
  48746. * @returns a list of meshes
  48747. */
  48748. getMeshesByID(id: string): Array<AbstractMesh>;
  48749. /**
  48750. * Gets the first added transform node found of a given ID
  48751. * @param id defines the id to search for
  48752. * @return the found transform node or null if not found at all.
  48753. */
  48754. getTransformNodeByID(id: string): Nullable<TransformNode>;
  48755. /**
  48756. * Gets a transform node with its auto-generated unique id
  48757. * @param uniqueId efines the unique id to search for
  48758. * @return the found transform node or null if not found at all.
  48759. */
  48760. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  48761. /**
  48762. * Gets a list of transform nodes using their id
  48763. * @param id defines the id to search for
  48764. * @returns a list of transform nodes
  48765. */
  48766. getTransformNodesByID(id: string): Array<TransformNode>;
  48767. /**
  48768. * Gets a mesh with its auto-generated unique id
  48769. * @param uniqueId defines the unique id to search for
  48770. * @return the found mesh or null if not found at all.
  48771. */
  48772. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  48773. /**
  48774. * Gets a the last added mesh using a given id
  48775. * @param id defines the id to search for
  48776. * @return the found mesh or null if not found at all.
  48777. */
  48778. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  48779. /**
  48780. * Gets a the last added node (Mesh, Camera, Light) using a given id
  48781. * @param id defines the id to search for
  48782. * @return the found node or null if not found at all
  48783. */
  48784. getLastEntryByID(id: string): Nullable<Node>;
  48785. /**
  48786. * Gets a node (Mesh, Camera, Light) using a given id
  48787. * @param id defines the id to search for
  48788. * @return the found node or null if not found at all
  48789. */
  48790. getNodeByID(id: string): Nullable<Node>;
  48791. /**
  48792. * Gets a node (Mesh, Camera, Light) using a given name
  48793. * @param name defines the name to search for
  48794. * @return the found node or null if not found at all.
  48795. */
  48796. getNodeByName(name: string): Nullable<Node>;
  48797. /**
  48798. * Gets a mesh using a given name
  48799. * @param name defines the name to search for
  48800. * @return the found mesh or null if not found at all.
  48801. */
  48802. getMeshByName(name: string): Nullable<AbstractMesh>;
  48803. /**
  48804. * Gets a transform node using a given name
  48805. * @param name defines the name to search for
  48806. * @return the found transform node or null if not found at all.
  48807. */
  48808. getTransformNodeByName(name: string): Nullable<TransformNode>;
  48809. /**
  48810. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  48811. * @param id defines the id to search for
  48812. * @return the found skeleton or null if not found at all.
  48813. */
  48814. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  48815. /**
  48816. * Gets a skeleton using a given auto generated unique id
  48817. * @param uniqueId defines the unique id to search for
  48818. * @return the found skeleton or null if not found at all.
  48819. */
  48820. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  48821. /**
  48822. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  48823. * @param id defines the id to search for
  48824. * @return the found skeleton or null if not found at all.
  48825. */
  48826. getSkeletonById(id: string): Nullable<Skeleton>;
  48827. /**
  48828. * Gets a skeleton using a given name
  48829. * @param name defines the name to search for
  48830. * @return the found skeleton or null if not found at all.
  48831. */
  48832. getSkeletonByName(name: string): Nullable<Skeleton>;
  48833. /**
  48834. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  48835. * @param id defines the id to search for
  48836. * @return the found morph target manager or null if not found at all.
  48837. */
  48838. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  48839. /**
  48840. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  48841. * @param id defines the id to search for
  48842. * @return the found morph target or null if not found at all.
  48843. */
  48844. getMorphTargetById(id: string): Nullable<MorphTarget>;
  48845. /**
  48846. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  48847. * @param name defines the name to search for
  48848. * @return the found morph target or null if not found at all.
  48849. */
  48850. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  48851. /**
  48852. * Gets a post process using a given name (if many are found, this function will pick the first one)
  48853. * @param name defines the name to search for
  48854. * @return the found post process or null if not found at all.
  48855. */
  48856. getPostProcessByName(name: string): Nullable<PostProcess>;
  48857. /**
  48858. * Gets a boolean indicating if the given mesh is active
  48859. * @param mesh defines the mesh to look for
  48860. * @returns true if the mesh is in the active list
  48861. */
  48862. isActiveMesh(mesh: AbstractMesh): boolean;
  48863. /**
  48864. * Return a unique id as a string which can serve as an identifier for the scene
  48865. */
  48866. get uid(): string;
  48867. /**
  48868. * Add an externaly attached data from its key.
  48869. * This method call will fail and return false, if such key already exists.
  48870. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  48871. * @param key the unique key that identifies the data
  48872. * @param data the data object to associate to the key for this Engine instance
  48873. * @return true if no such key were already present and the data was added successfully, false otherwise
  48874. */
  48875. addExternalData<T>(key: string, data: T): boolean;
  48876. /**
  48877. * Get an externaly attached data from its key
  48878. * @param key the unique key that identifies the data
  48879. * @return the associated data, if present (can be null), or undefined if not present
  48880. */
  48881. getExternalData<T>(key: string): Nullable<T>;
  48882. /**
  48883. * Get an externaly attached data from its key, create it using a factory if it's not already present
  48884. * @param key the unique key that identifies the data
  48885. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  48886. * @return the associated data, can be null if the factory returned null.
  48887. */
  48888. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  48889. /**
  48890. * Remove an externaly attached data from the Engine instance
  48891. * @param key the unique key that identifies the data
  48892. * @return true if the data was successfully removed, false if it doesn't exist
  48893. */
  48894. removeExternalData(key: string): boolean;
  48895. private _evaluateSubMesh;
  48896. /**
  48897. * Clear the processed materials smart array preventing retention point in material dispose.
  48898. */
  48899. freeProcessedMaterials(): void;
  48900. private _preventFreeActiveMeshesAndRenderingGroups;
  48901. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  48902. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  48903. * when disposing several meshes in a row or a hierarchy of meshes.
  48904. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  48905. */
  48906. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  48907. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  48908. /**
  48909. * Clear the active meshes smart array preventing retention point in mesh dispose.
  48910. */
  48911. freeActiveMeshes(): void;
  48912. /**
  48913. * Clear the info related to rendering groups preventing retention points during dispose.
  48914. */
  48915. freeRenderingGroups(): void;
  48916. /** @hidden */
  48917. _isInIntermediateRendering(): boolean;
  48918. /**
  48919. * Lambda returning the list of potentially active meshes.
  48920. */
  48921. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  48922. /**
  48923. * Lambda returning the list of potentially active sub meshes.
  48924. */
  48925. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  48926. /**
  48927. * Lambda returning the list of potentially intersecting sub meshes.
  48928. */
  48929. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  48930. /**
  48931. * Lambda returning the list of potentially colliding sub meshes.
  48932. */
  48933. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  48934. /** @hidden */
  48935. _activeMeshesFrozen: boolean;
  48936. private _skipEvaluateActiveMeshesCompletely;
  48937. /**
  48938. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  48939. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  48940. * @param onSuccess optional success callback
  48941. * @param onError optional error callback
  48942. * @returns the current scene
  48943. */
  48944. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  48945. /**
  48946. * Use this function to restart evaluating active meshes on every frame
  48947. * @returns the current scene
  48948. */
  48949. unfreezeActiveMeshes(): Scene;
  48950. private _evaluateActiveMeshes;
  48951. private _activeMesh;
  48952. /**
  48953. * Update the transform matrix to update from the current active camera
  48954. * @param force defines a boolean used to force the update even if cache is up to date
  48955. */
  48956. updateTransformMatrix(force?: boolean): void;
  48957. private _bindFrameBuffer;
  48958. /** @hidden */
  48959. _allowPostProcessClearColor: boolean;
  48960. /** @hidden */
  48961. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  48962. private _processSubCameras;
  48963. private _checkIntersections;
  48964. /** @hidden */
  48965. _advancePhysicsEngineStep(step: number): void;
  48966. /**
  48967. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  48968. */
  48969. getDeterministicFrameTime: () => number;
  48970. /** @hidden */
  48971. _animate(): void;
  48972. /** Execute all animations (for a frame) */
  48973. animate(): void;
  48974. /**
  48975. * Render the scene
  48976. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  48977. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  48978. */
  48979. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  48980. /**
  48981. * Freeze all materials
  48982. * A frozen material will not be updatable but should be faster to render
  48983. */
  48984. freezeMaterials(): void;
  48985. /**
  48986. * Unfreeze all materials
  48987. * A frozen material will not be updatable but should be faster to render
  48988. */
  48989. unfreezeMaterials(): void;
  48990. /**
  48991. * Releases all held ressources
  48992. */
  48993. dispose(): void;
  48994. /**
  48995. * Gets if the scene is already disposed
  48996. */
  48997. get isDisposed(): boolean;
  48998. /**
  48999. * Call this function to reduce memory footprint of the scene.
  49000. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  49001. */
  49002. clearCachedVertexData(): void;
  49003. /**
  49004. * This function will remove the local cached buffer data from texture.
  49005. * It will save memory but will prevent the texture from being rebuilt
  49006. */
  49007. cleanCachedTextureBuffer(): void;
  49008. /**
  49009. * Get the world extend vectors with an optional filter
  49010. *
  49011. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  49012. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  49013. */
  49014. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  49015. min: Vector3;
  49016. max: Vector3;
  49017. };
  49018. /**
  49019. * Creates a ray that can be used to pick in the scene
  49020. * @param x defines the x coordinate of the origin (on-screen)
  49021. * @param y defines the y coordinate of the origin (on-screen)
  49022. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49023. * @param camera defines the camera to use for the picking
  49024. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49025. * @returns a Ray
  49026. */
  49027. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  49028. /**
  49029. * Creates a ray that can be used to pick in the scene
  49030. * @param x defines the x coordinate of the origin (on-screen)
  49031. * @param y defines the y coordinate of the origin (on-screen)
  49032. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49033. * @param result defines the ray where to store the picking ray
  49034. * @param camera defines the camera to use for the picking
  49035. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49036. * @returns the current scene
  49037. */
  49038. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  49039. /**
  49040. * Creates a ray that can be used to pick in the scene
  49041. * @param x defines the x coordinate of the origin (on-screen)
  49042. * @param y defines the y coordinate of the origin (on-screen)
  49043. * @param camera defines the camera to use for the picking
  49044. * @returns a Ray
  49045. */
  49046. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  49047. /**
  49048. * Creates a ray that can be used to pick in the scene
  49049. * @param x defines the x coordinate of the origin (on-screen)
  49050. * @param y defines the y coordinate of the origin (on-screen)
  49051. * @param result defines the ray where to store the picking ray
  49052. * @param camera defines the camera to use for the picking
  49053. * @returns the current scene
  49054. */
  49055. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  49056. /** Launch a ray to try to pick a mesh in the scene
  49057. * @param x position on screen
  49058. * @param y position on screen
  49059. * @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
  49060. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49061. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49062. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49063. * @returns a PickingInfo
  49064. */
  49065. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49066. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  49067. * @param x position on screen
  49068. * @param y position on screen
  49069. * @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
  49070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49071. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49072. * @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)
  49073. */
  49074. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  49075. /** Use the given ray to pick a mesh in the scene
  49076. * @param ray The ray to use to pick meshes
  49077. * @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
  49078. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49080. * @returns a PickingInfo
  49081. */
  49082. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49083. /**
  49084. * Launch a ray to try to pick a mesh in the scene
  49085. * @param x X position on screen
  49086. * @param y Y position on screen
  49087. * @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
  49088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49089. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49090. * @returns an array of PickingInfo
  49091. */
  49092. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49093. /**
  49094. * Launch a ray to try to pick a mesh in the scene
  49095. * @param ray Ray to use
  49096. * @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
  49097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49098. * @returns an array of PickingInfo
  49099. */
  49100. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49101. /**
  49102. * Force the value of meshUnderPointer
  49103. * @param mesh defines the mesh to use
  49104. * @param pointerId optional pointer id when using more than one pointer
  49105. */
  49106. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  49107. /**
  49108. * Gets the mesh under the pointer
  49109. * @returns a Mesh or null if no mesh is under the pointer
  49110. */
  49111. getPointerOverMesh(): Nullable<AbstractMesh>;
  49112. /** @hidden */
  49113. _rebuildGeometries(): void;
  49114. /** @hidden */
  49115. _rebuildTextures(): void;
  49116. private _getByTags;
  49117. /**
  49118. * Get a list of meshes by tags
  49119. * @param tagsQuery defines the tags query to use
  49120. * @param forEach defines a predicate used to filter results
  49121. * @returns an array of Mesh
  49122. */
  49123. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  49124. /**
  49125. * Get a list of cameras by tags
  49126. * @param tagsQuery defines the tags query to use
  49127. * @param forEach defines a predicate used to filter results
  49128. * @returns an array of Camera
  49129. */
  49130. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  49131. /**
  49132. * Get a list of lights by tags
  49133. * @param tagsQuery defines the tags query to use
  49134. * @param forEach defines a predicate used to filter results
  49135. * @returns an array of Light
  49136. */
  49137. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  49138. /**
  49139. * Get a list of materials by tags
  49140. * @param tagsQuery defines the tags query to use
  49141. * @param forEach defines a predicate used to filter results
  49142. * @returns an array of Material
  49143. */
  49144. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  49145. /**
  49146. * Get a list of transform nodes by tags
  49147. * @param tagsQuery defines the tags query to use
  49148. * @param forEach defines a predicate used to filter results
  49149. * @returns an array of TransformNode
  49150. */
  49151. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  49152. /**
  49153. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  49154. * This allowed control for front to back rendering or reversly depending of the special needs.
  49155. *
  49156. * @param renderingGroupId The rendering group id corresponding to its index
  49157. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  49158. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  49159. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  49160. */
  49161. 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;
  49162. /**
  49163. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  49164. *
  49165. * @param renderingGroupId The rendering group id corresponding to its index
  49166. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49167. * @param depth Automatically clears depth between groups if true and autoClear is true.
  49168. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  49169. */
  49170. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  49171. /**
  49172. * Gets the current auto clear configuration for one rendering group of the rendering
  49173. * manager.
  49174. * @param index the rendering group index to get the information for
  49175. * @returns The auto clear setup for the requested rendering group
  49176. */
  49177. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  49178. private _blockMaterialDirtyMechanism;
  49179. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  49180. get blockMaterialDirtyMechanism(): boolean;
  49181. set blockMaterialDirtyMechanism(value: boolean);
  49182. /**
  49183. * Will flag all materials as dirty to trigger new shader compilation
  49184. * @param flag defines the flag used to specify which material part must be marked as dirty
  49185. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  49186. */
  49187. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  49188. /** @hidden */
  49189. _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;
  49190. /** @hidden */
  49191. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49192. /** @hidden */
  49193. _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;
  49194. /** @hidden */
  49195. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  49196. /** @hidden */
  49197. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  49198. /** @hidden */
  49199. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49200. }
  49201. }
  49202. declare module "babylonjs/assetContainer" {
  49203. import { AbstractScene } from "babylonjs/abstractScene";
  49204. import { Scene } from "babylonjs/scene";
  49205. import { Mesh } from "babylonjs/Meshes/mesh";
  49206. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49207. import { Skeleton } from "babylonjs/Bones/skeleton";
  49208. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49209. import { Animatable } from "babylonjs/Animations/animatable";
  49210. import { Nullable } from "babylonjs/types";
  49211. import { Node } from "babylonjs/node";
  49212. /**
  49213. * Set of assets to keep when moving a scene into an asset container.
  49214. */
  49215. export class KeepAssets extends AbstractScene {
  49216. }
  49217. /**
  49218. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  49219. */
  49220. export class InstantiatedEntries {
  49221. /**
  49222. * List of new root nodes (eg. nodes with no parent)
  49223. */
  49224. rootNodes: TransformNode[];
  49225. /**
  49226. * List of new skeletons
  49227. */
  49228. skeletons: Skeleton[];
  49229. /**
  49230. * List of new animation groups
  49231. */
  49232. animationGroups: AnimationGroup[];
  49233. }
  49234. /**
  49235. * Container with a set of assets that can be added or removed from a scene.
  49236. */
  49237. export class AssetContainer extends AbstractScene {
  49238. private _wasAddedToScene;
  49239. /**
  49240. * The scene the AssetContainer belongs to.
  49241. */
  49242. scene: Scene;
  49243. /**
  49244. * Instantiates an AssetContainer.
  49245. * @param scene The scene the AssetContainer belongs to.
  49246. */
  49247. constructor(scene: Scene);
  49248. /**
  49249. * Instantiate or clone all meshes and add the new ones to the scene.
  49250. * Skeletons and animation groups will all be cloned
  49251. * @param nameFunction defines an optional function used to get new names for clones
  49252. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  49253. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  49254. */
  49255. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  49256. /**
  49257. * Adds all the assets from the container to the scene.
  49258. */
  49259. addAllToScene(): void;
  49260. /**
  49261. * Removes all the assets in the container from the scene
  49262. */
  49263. removeAllFromScene(): void;
  49264. /**
  49265. * Disposes all the assets in the container
  49266. */
  49267. dispose(): void;
  49268. private _moveAssets;
  49269. /**
  49270. * Removes all the assets contained in the scene and adds them to the container.
  49271. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  49272. */
  49273. moveAllFromScene(keepAssets?: KeepAssets): void;
  49274. /**
  49275. * 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.
  49276. * @returns the root mesh
  49277. */
  49278. createRootMesh(): Mesh;
  49279. /**
  49280. * Merge animations (direct and animation groups) from this asset container into a scene
  49281. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49282. * @param animatables set of animatables to retarget to a node from the scene
  49283. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  49284. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  49285. */
  49286. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  49287. }
  49288. }
  49289. declare module "babylonjs/abstractScene" {
  49290. import { Scene } from "babylonjs/scene";
  49291. import { Nullable } from "babylonjs/types";
  49292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49293. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49294. import { Geometry } from "babylonjs/Meshes/geometry";
  49295. import { Skeleton } from "babylonjs/Bones/skeleton";
  49296. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  49297. import { AssetContainer } from "babylonjs/assetContainer";
  49298. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49299. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49301. import { Material } from "babylonjs/Materials/material";
  49302. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  49303. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  49304. import { Camera } from "babylonjs/Cameras/camera";
  49305. import { Light } from "babylonjs/Lights/light";
  49306. import { Node } from "babylonjs/node";
  49307. import { Animation } from "babylonjs/Animations/animation";
  49308. /**
  49309. * Defines how the parser contract is defined.
  49310. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  49311. */
  49312. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  49313. /**
  49314. * Defines how the individual parser contract is defined.
  49315. * These parser can parse an individual asset
  49316. */
  49317. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  49318. /**
  49319. * Base class of the scene acting as a container for the different elements composing a scene.
  49320. * This class is dynamically extended by the different components of the scene increasing
  49321. * flexibility and reducing coupling
  49322. */
  49323. export abstract class AbstractScene {
  49324. /**
  49325. * Stores the list of available parsers in the application.
  49326. */
  49327. private static _BabylonFileParsers;
  49328. /**
  49329. * Stores the list of available individual parsers in the application.
  49330. */
  49331. private static _IndividualBabylonFileParsers;
  49332. /**
  49333. * Adds a parser in the list of available ones
  49334. * @param name Defines the name of the parser
  49335. * @param parser Defines the parser to add
  49336. */
  49337. static AddParser(name: string, parser: BabylonFileParser): void;
  49338. /**
  49339. * Gets a general parser from the list of avaialble ones
  49340. * @param name Defines the name of the parser
  49341. * @returns the requested parser or null
  49342. */
  49343. static GetParser(name: string): Nullable<BabylonFileParser>;
  49344. /**
  49345. * Adds n individual parser in the list of available ones
  49346. * @param name Defines the name of the parser
  49347. * @param parser Defines the parser to add
  49348. */
  49349. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  49350. /**
  49351. * Gets an individual parser from the list of avaialble ones
  49352. * @param name Defines the name of the parser
  49353. * @returns the requested parser or null
  49354. */
  49355. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  49356. /**
  49357. * Parser json data and populate both a scene and its associated container object
  49358. * @param jsonData Defines the data to parse
  49359. * @param scene Defines the scene to parse the data for
  49360. * @param container Defines the container attached to the parsing sequence
  49361. * @param rootUrl Defines the root url of the data
  49362. */
  49363. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  49364. /**
  49365. * Gets the list of root nodes (ie. nodes with no parent)
  49366. */
  49367. rootNodes: Node[];
  49368. /** All of the cameras added to this scene
  49369. * @see https://doc.babylonjs.com/babylon101/cameras
  49370. */
  49371. cameras: Camera[];
  49372. /**
  49373. * All of the lights added to this scene
  49374. * @see https://doc.babylonjs.com/babylon101/lights
  49375. */
  49376. lights: Light[];
  49377. /**
  49378. * All of the (abstract) meshes added to this scene
  49379. */
  49380. meshes: AbstractMesh[];
  49381. /**
  49382. * The list of skeletons added to the scene
  49383. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  49384. */
  49385. skeletons: Skeleton[];
  49386. /**
  49387. * All of the particle systems added to this scene
  49388. * @see https://doc.babylonjs.com/babylon101/particles
  49389. */
  49390. particleSystems: IParticleSystem[];
  49391. /**
  49392. * Gets a list of Animations associated with the scene
  49393. */
  49394. animations: Animation[];
  49395. /**
  49396. * All of the animation groups added to this scene
  49397. * @see https://doc.babylonjs.com/how_to/group
  49398. */
  49399. animationGroups: AnimationGroup[];
  49400. /**
  49401. * All of the multi-materials added to this scene
  49402. * @see https://doc.babylonjs.com/how_to/multi_materials
  49403. */
  49404. multiMaterials: MultiMaterial[];
  49405. /**
  49406. * All of the materials added to this scene
  49407. * In the context of a Scene, it is not supposed to be modified manually.
  49408. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  49409. * Note also that the order of the Material within the array is not significant and might change.
  49410. * @see https://doc.babylonjs.com/babylon101/materials
  49411. */
  49412. materials: Material[];
  49413. /**
  49414. * The list of morph target managers added to the scene
  49415. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  49416. */
  49417. morphTargetManagers: MorphTargetManager[];
  49418. /**
  49419. * The list of geometries used in the scene.
  49420. */
  49421. geometries: Geometry[];
  49422. /**
  49423. * All of the tranform nodes added to this scene
  49424. * In the context of a Scene, it is not supposed to be modified manually.
  49425. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  49426. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  49427. * @see https://doc.babylonjs.com/how_to/transformnode
  49428. */
  49429. transformNodes: TransformNode[];
  49430. /**
  49431. * ActionManagers available on the scene.
  49432. */
  49433. actionManagers: AbstractActionManager[];
  49434. /**
  49435. * Textures to keep.
  49436. */
  49437. textures: BaseTexture[];
  49438. /** @hidden */
  49439. protected _environmentTexture: Nullable<BaseTexture>;
  49440. /**
  49441. * Texture used in all pbr material as the reflection texture.
  49442. * As in the majority of the scene they are the same (exception for multi room and so on),
  49443. * this is easier to reference from here than from all the materials.
  49444. */
  49445. get environmentTexture(): Nullable<BaseTexture>;
  49446. set environmentTexture(value: Nullable<BaseTexture>);
  49447. /**
  49448. * The list of postprocesses added to the scene
  49449. */
  49450. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  49451. /**
  49452. * @returns all meshes, lights, cameras, transformNodes and bones
  49453. */
  49454. getNodes(): Array<Node>;
  49455. }
  49456. }
  49457. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  49458. /**
  49459. * Interface used to define options for Sound class
  49460. */
  49461. export interface ISoundOptions {
  49462. /**
  49463. * Does the sound autoplay once loaded.
  49464. */
  49465. autoplay?: boolean;
  49466. /**
  49467. * Does the sound loop after it finishes playing once.
  49468. */
  49469. loop?: boolean;
  49470. /**
  49471. * Sound's volume
  49472. */
  49473. volume?: number;
  49474. /**
  49475. * Is it a spatial sound?
  49476. */
  49477. spatialSound?: boolean;
  49478. /**
  49479. * Maximum distance to hear that sound
  49480. */
  49481. maxDistance?: number;
  49482. /**
  49483. * Uses user defined attenuation function
  49484. */
  49485. useCustomAttenuation?: boolean;
  49486. /**
  49487. * Define the roll off factor of spatial sounds.
  49488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49489. */
  49490. rolloffFactor?: number;
  49491. /**
  49492. * Define the reference distance the sound should be heard perfectly.
  49493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49494. */
  49495. refDistance?: number;
  49496. /**
  49497. * Define the distance attenuation model the sound will follow.
  49498. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49499. */
  49500. distanceModel?: string;
  49501. /**
  49502. * Defines the playback speed (1 by default)
  49503. */
  49504. playbackRate?: number;
  49505. /**
  49506. * Defines if the sound is from a streaming source
  49507. */
  49508. streaming?: boolean;
  49509. /**
  49510. * Defines an optional length (in seconds) inside the sound file
  49511. */
  49512. length?: number;
  49513. /**
  49514. * Defines an optional offset (in seconds) inside the sound file
  49515. */
  49516. offset?: number;
  49517. /**
  49518. * If true, URLs will not be required to state the audio file codec to use.
  49519. */
  49520. skipCodecCheck?: boolean;
  49521. }
  49522. }
  49523. declare module "babylonjs/Audio/sound" {
  49524. import { Observable } from "babylonjs/Misc/observable";
  49525. import { Vector3 } from "babylonjs/Maths/math.vector";
  49526. import { Nullable } from "babylonjs/types";
  49527. import { Scene } from "babylonjs/scene";
  49528. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49529. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  49530. /**
  49531. * Defines a sound that can be played in the application.
  49532. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49533. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49534. */
  49535. export class Sound {
  49536. /**
  49537. * The name of the sound in the scene.
  49538. */
  49539. name: string;
  49540. /**
  49541. * Does the sound autoplay once loaded.
  49542. */
  49543. autoplay: boolean;
  49544. private _loop;
  49545. /**
  49546. * Does the sound loop after it finishes playing once.
  49547. */
  49548. get loop(): boolean;
  49549. set loop(value: boolean);
  49550. /**
  49551. * Does the sound use a custom attenuation curve to simulate the falloff
  49552. * happening when the source gets further away from the camera.
  49553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49554. */
  49555. useCustomAttenuation: boolean;
  49556. /**
  49557. * The sound track id this sound belongs to.
  49558. */
  49559. soundTrackId: number;
  49560. /**
  49561. * Is this sound currently played.
  49562. */
  49563. isPlaying: boolean;
  49564. /**
  49565. * Is this sound currently paused.
  49566. */
  49567. isPaused: boolean;
  49568. /**
  49569. * Does this sound enables spatial sound.
  49570. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49571. */
  49572. spatialSound: boolean;
  49573. /**
  49574. * Define the reference distance the sound should be heard perfectly.
  49575. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49576. */
  49577. refDistance: number;
  49578. /**
  49579. * Define the roll off factor of spatial sounds.
  49580. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49581. */
  49582. rolloffFactor: number;
  49583. /**
  49584. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49585. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49586. */
  49587. maxDistance: number;
  49588. /**
  49589. * Define the distance attenuation model the sound will follow.
  49590. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49591. */
  49592. distanceModel: string;
  49593. /**
  49594. * @hidden
  49595. * Back Compat
  49596. **/
  49597. onended: () => any;
  49598. /**
  49599. * Gets or sets an object used to store user defined information for the sound.
  49600. */
  49601. metadata: any;
  49602. /**
  49603. * Observable event when the current playing sound finishes.
  49604. */
  49605. onEndedObservable: Observable<Sound>;
  49606. /**
  49607. * Gets the current time for the sound.
  49608. */
  49609. get currentTime(): number;
  49610. private _panningModel;
  49611. private _playbackRate;
  49612. private _streaming;
  49613. private _startTime;
  49614. private _startOffset;
  49615. private _position;
  49616. /** @hidden */
  49617. _positionInEmitterSpace: boolean;
  49618. private _localDirection;
  49619. private _volume;
  49620. private _isReadyToPlay;
  49621. private _isDirectional;
  49622. private _readyToPlayCallback;
  49623. private _audioBuffer;
  49624. private _soundSource;
  49625. private _streamingSource;
  49626. private _soundPanner;
  49627. private _soundGain;
  49628. private _inputAudioNode;
  49629. private _outputAudioNode;
  49630. private _coneInnerAngle;
  49631. private _coneOuterAngle;
  49632. private _coneOuterGain;
  49633. private _scene;
  49634. private _connectedTransformNode;
  49635. private _customAttenuationFunction;
  49636. private _registerFunc;
  49637. private _isOutputConnected;
  49638. private _htmlAudioElement;
  49639. private _urlType;
  49640. private _length?;
  49641. private _offset?;
  49642. /** @hidden */
  49643. static _SceneComponentInitialization: (scene: Scene) => void;
  49644. /**
  49645. * Create a sound and attach it to a scene
  49646. * @param name Name of your sound
  49647. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49648. * @param scene defines the scene the sound belongs to
  49649. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49650. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49651. */
  49652. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49653. /**
  49654. * Release the sound and its associated resources
  49655. */
  49656. dispose(): void;
  49657. /**
  49658. * Gets if the sounds is ready to be played or not.
  49659. * @returns true if ready, otherwise false
  49660. */
  49661. isReady(): boolean;
  49662. /**
  49663. * Get the current class name.
  49664. * @returns current class name
  49665. */
  49666. getClassName(): string;
  49667. private _soundLoaded;
  49668. /**
  49669. * Sets the data of the sound from an audiobuffer
  49670. * @param audioBuffer The audioBuffer containing the data
  49671. */
  49672. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49673. /**
  49674. * Updates the current sounds options such as maxdistance, loop...
  49675. * @param options A JSON object containing values named as the object properties
  49676. */
  49677. updateOptions(options: ISoundOptions): void;
  49678. private _createSpatialParameters;
  49679. private _updateSpatialParameters;
  49680. /**
  49681. * Switch the panning model to HRTF:
  49682. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49684. */
  49685. switchPanningModelToHRTF(): void;
  49686. /**
  49687. * Switch the panning model to Equal Power:
  49688. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49689. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49690. */
  49691. switchPanningModelToEqualPower(): void;
  49692. private _switchPanningModel;
  49693. /**
  49694. * Connect this sound to a sound track audio node like gain...
  49695. * @param soundTrackAudioNode the sound track audio node to connect to
  49696. */
  49697. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49698. /**
  49699. * Transform this sound into a directional source
  49700. * @param coneInnerAngle Size of the inner cone in degree
  49701. * @param coneOuterAngle Size of the outer cone in degree
  49702. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49703. */
  49704. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49705. /**
  49706. * Gets or sets the inner angle for the directional cone.
  49707. */
  49708. get directionalConeInnerAngle(): number;
  49709. /**
  49710. * Gets or sets the inner angle for the directional cone.
  49711. */
  49712. set directionalConeInnerAngle(value: number);
  49713. /**
  49714. * Gets or sets the outer angle for the directional cone.
  49715. */
  49716. get directionalConeOuterAngle(): number;
  49717. /**
  49718. * Gets or sets the outer angle for the directional cone.
  49719. */
  49720. set directionalConeOuterAngle(value: number);
  49721. /**
  49722. * Sets the position of the emitter if spatial sound is enabled
  49723. * @param newPosition Defines the new posisiton
  49724. */
  49725. setPosition(newPosition: Vector3): void;
  49726. /**
  49727. * Sets the local direction of the emitter if spatial sound is enabled
  49728. * @param newLocalDirection Defines the new local direction
  49729. */
  49730. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  49731. private _updateDirection;
  49732. /** @hidden */
  49733. updateDistanceFromListener(): void;
  49734. /**
  49735. * Sets a new custom attenuation function for the sound.
  49736. * @param callback Defines the function used for the attenuation
  49737. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49738. */
  49739. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  49740. /**
  49741. * Play the sound
  49742. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  49743. * @param offset (optional) Start the sound at a specific time in seconds
  49744. * @param length (optional) Sound duration (in seconds)
  49745. */
  49746. play(time?: number, offset?: number, length?: number): void;
  49747. private _onended;
  49748. /**
  49749. * Stop the sound
  49750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  49751. */
  49752. stop(time?: number): void;
  49753. /**
  49754. * Put the sound in pause
  49755. */
  49756. pause(): void;
  49757. /**
  49758. * Sets a dedicated volume for this sounds
  49759. * @param newVolume Define the new volume of the sound
  49760. * @param time Define time for gradual change to new volume
  49761. */
  49762. setVolume(newVolume: number, time?: number): void;
  49763. /**
  49764. * Set the sound play back rate
  49765. * @param newPlaybackRate Define the playback rate the sound should be played at
  49766. */
  49767. setPlaybackRate(newPlaybackRate: number): void;
  49768. /**
  49769. * Gets the volume of the sound.
  49770. * @returns the volume of the sound
  49771. */
  49772. getVolume(): number;
  49773. /**
  49774. * Attach the sound to a dedicated mesh
  49775. * @param transformNode The transform node to connect the sound with
  49776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49777. */
  49778. attachToMesh(transformNode: TransformNode): void;
  49779. /**
  49780. * Detach the sound from the previously attached mesh
  49781. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49782. */
  49783. detachFromMesh(): void;
  49784. private _onRegisterAfterWorldMatrixUpdate;
  49785. /**
  49786. * Clone the current sound in the scene.
  49787. * @returns the new sound clone
  49788. */
  49789. clone(): Nullable<Sound>;
  49790. /**
  49791. * Gets the current underlying audio buffer containing the data
  49792. * @returns the audio buffer
  49793. */
  49794. getAudioBuffer(): Nullable<AudioBuffer>;
  49795. /**
  49796. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  49797. * @returns the source node
  49798. */
  49799. getSoundSource(): Nullable<AudioBufferSourceNode>;
  49800. /**
  49801. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  49802. * @returns the gain node
  49803. */
  49804. getSoundGain(): Nullable<GainNode>;
  49805. /**
  49806. * Serializes the Sound in a JSON representation
  49807. * @returns the JSON representation of the sound
  49808. */
  49809. serialize(): any;
  49810. /**
  49811. * Parse a JSON representation of a sound to innstantiate in a given scene
  49812. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  49813. * @param scene Define the scene the new parsed sound should be created in
  49814. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  49815. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  49816. * @returns the newly parsed sound
  49817. */
  49818. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  49819. }
  49820. }
  49821. declare module "babylonjs/Actions/directAudioActions" {
  49822. import { Action } from "babylonjs/Actions/action";
  49823. import { Condition } from "babylonjs/Actions/condition";
  49824. import { Sound } from "babylonjs/Audio/sound";
  49825. /**
  49826. * This defines an action helpful to play a defined sound on a triggered action.
  49827. */
  49828. export class PlaySoundAction extends Action {
  49829. private _sound;
  49830. /**
  49831. * Instantiate the action
  49832. * @param triggerOptions defines the trigger options
  49833. * @param sound defines the sound to play
  49834. * @param condition defines the trigger related conditions
  49835. */
  49836. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49837. /** @hidden */
  49838. _prepare(): void;
  49839. /**
  49840. * Execute the action and play the sound.
  49841. */
  49842. execute(): void;
  49843. /**
  49844. * Serializes the actions and its related information.
  49845. * @param parent defines the object to serialize in
  49846. * @returns the serialized object
  49847. */
  49848. serialize(parent: any): any;
  49849. }
  49850. /**
  49851. * This defines an action helpful to stop a defined sound on a triggered action.
  49852. */
  49853. export class StopSoundAction extends Action {
  49854. private _sound;
  49855. /**
  49856. * Instantiate the action
  49857. * @param triggerOptions defines the trigger options
  49858. * @param sound defines the sound to stop
  49859. * @param condition defines the trigger related conditions
  49860. */
  49861. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49862. /** @hidden */
  49863. _prepare(): void;
  49864. /**
  49865. * Execute the action and stop the sound.
  49866. */
  49867. execute(): void;
  49868. /**
  49869. * Serializes the actions and its related information.
  49870. * @param parent defines the object to serialize in
  49871. * @returns the serialized object
  49872. */
  49873. serialize(parent: any): any;
  49874. }
  49875. }
  49876. declare module "babylonjs/Actions/interpolateValueAction" {
  49877. import { Action } from "babylonjs/Actions/action";
  49878. import { Condition } from "babylonjs/Actions/condition";
  49879. import { Observable } from "babylonjs/Misc/observable";
  49880. /**
  49881. * This defines an action responsible to change the value of a property
  49882. * by interpolating between its current value and the newly set one once triggered.
  49883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  49884. */
  49885. export class InterpolateValueAction extends Action {
  49886. /**
  49887. * Defines the path of the property where the value should be interpolated
  49888. */
  49889. propertyPath: string;
  49890. /**
  49891. * Defines the target value at the end of the interpolation.
  49892. */
  49893. value: any;
  49894. /**
  49895. * Defines the time it will take for the property to interpolate to the value.
  49896. */
  49897. duration: number;
  49898. /**
  49899. * Defines if the other scene animations should be stopped when the action has been triggered
  49900. */
  49901. stopOtherAnimations?: boolean;
  49902. /**
  49903. * Defines a callback raised once the interpolation animation has been done.
  49904. */
  49905. onInterpolationDone?: () => void;
  49906. /**
  49907. * Observable triggered once the interpolation animation has been done.
  49908. */
  49909. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  49910. private _target;
  49911. private _effectiveTarget;
  49912. private _property;
  49913. /**
  49914. * Instantiate the action
  49915. * @param triggerOptions defines the trigger options
  49916. * @param target defines the object containing the value to interpolate
  49917. * @param propertyPath defines the path to the property in the target object
  49918. * @param value defines the target value at the end of the interpolation
  49919. * @param duration deines the time it will take for the property to interpolate to the value.
  49920. * @param condition defines the trigger related conditions
  49921. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  49922. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  49923. */
  49924. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  49925. /** @hidden */
  49926. _prepare(): void;
  49927. /**
  49928. * Execute the action starts the value interpolation.
  49929. */
  49930. execute(): void;
  49931. /**
  49932. * Serializes the actions and its related information.
  49933. * @param parent defines the object to serialize in
  49934. * @returns the serialized object
  49935. */
  49936. serialize(parent: any): any;
  49937. }
  49938. }
  49939. declare module "babylonjs/Actions/index" {
  49940. export * from "babylonjs/Actions/abstractActionManager";
  49941. export * from "babylonjs/Actions/action";
  49942. export * from "babylonjs/Actions/actionEvent";
  49943. export * from "babylonjs/Actions/actionManager";
  49944. export * from "babylonjs/Actions/condition";
  49945. export * from "babylonjs/Actions/directActions";
  49946. export * from "babylonjs/Actions/directAudioActions";
  49947. export * from "babylonjs/Actions/interpolateValueAction";
  49948. }
  49949. declare module "babylonjs/Animations/index" {
  49950. export * from "babylonjs/Animations/animatable";
  49951. export * from "babylonjs/Animations/animation";
  49952. export * from "babylonjs/Animations/animationGroup";
  49953. export * from "babylonjs/Animations/animationPropertiesOverride";
  49954. export * from "babylonjs/Animations/easing";
  49955. export * from "babylonjs/Animations/runtimeAnimation";
  49956. export * from "babylonjs/Animations/animationEvent";
  49957. export * from "babylonjs/Animations/animationGroup";
  49958. export * from "babylonjs/Animations/animationKey";
  49959. export * from "babylonjs/Animations/animationRange";
  49960. export * from "babylonjs/Animations/animatable.interface";
  49961. }
  49962. declare module "babylonjs/Audio/audioEngine" {
  49963. import { Analyser } from "babylonjs/Audio/analyser";
  49964. import { Nullable } from "babylonjs/types";
  49965. import { Observable } from "babylonjs/Misc/observable";
  49966. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  49967. /**
  49968. * This represents the default audio engine used in babylon.
  49969. * It is responsible to play, synchronize and analyse sounds throughout the application.
  49970. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49971. */
  49972. export class AudioEngine implements IAudioEngine {
  49973. private _audioContext;
  49974. private _audioContextInitialized;
  49975. private _muteButton;
  49976. private _hostElement;
  49977. /**
  49978. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  49979. */
  49980. canUseWebAudio: boolean;
  49981. /**
  49982. * The master gain node defines the global audio volume of your audio engine.
  49983. */
  49984. masterGain: GainNode;
  49985. /**
  49986. * Defines if Babylon should emit a warning if WebAudio is not supported.
  49987. * @ignoreNaming
  49988. */
  49989. WarnedWebAudioUnsupported: boolean;
  49990. /**
  49991. * Gets whether or not mp3 are supported by your browser.
  49992. */
  49993. isMP3supported: boolean;
  49994. /**
  49995. * Gets whether or not ogg are supported by your browser.
  49996. */
  49997. isOGGsupported: boolean;
  49998. /**
  49999. * Gets whether audio has been unlocked on the device.
  50000. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  50001. * a user interaction has happened.
  50002. */
  50003. unlocked: boolean;
  50004. /**
  50005. * Defines if the audio engine relies on a custom unlocked button.
  50006. * In this case, the embedded button will not be displayed.
  50007. */
  50008. useCustomUnlockedButton: boolean;
  50009. /**
  50010. * Event raised when audio has been unlocked on the browser.
  50011. */
  50012. onAudioUnlockedObservable: Observable<IAudioEngine>;
  50013. /**
  50014. * Event raised when audio has been locked on the browser.
  50015. */
  50016. onAudioLockedObservable: Observable<IAudioEngine>;
  50017. /**
  50018. * Gets the current AudioContext if available.
  50019. */
  50020. get audioContext(): Nullable<AudioContext>;
  50021. private _connectedAnalyser;
  50022. /**
  50023. * Instantiates a new audio engine.
  50024. *
  50025. * There should be only one per page as some browsers restrict the number
  50026. * of audio contexts you can create.
  50027. * @param hostElement defines the host element where to display the mute icon if necessary
  50028. */
  50029. constructor(hostElement?: Nullable<HTMLElement>);
  50030. /**
  50031. * Flags the audio engine in Locked state.
  50032. * This happens due to new browser policies preventing audio to autoplay.
  50033. */
  50034. lock(): void;
  50035. /**
  50036. * Unlocks the audio engine once a user action has been done on the dom.
  50037. * This is helpful to resume play once browser policies have been satisfied.
  50038. */
  50039. unlock(): void;
  50040. private _resumeAudioContext;
  50041. private _initializeAudioContext;
  50042. private _tryToRun;
  50043. private _triggerRunningState;
  50044. private _triggerSuspendedState;
  50045. private _displayMuteButton;
  50046. private _moveButtonToTopLeft;
  50047. private _onResize;
  50048. private _hideMuteButton;
  50049. /**
  50050. * Destroy and release the resources associated with the audio ccontext.
  50051. */
  50052. dispose(): void;
  50053. /**
  50054. * Gets the global volume sets on the master gain.
  50055. * @returns the global volume if set or -1 otherwise
  50056. */
  50057. getGlobalVolume(): number;
  50058. /**
  50059. * Sets the global volume of your experience (sets on the master gain).
  50060. * @param newVolume Defines the new global volume of the application
  50061. */
  50062. setGlobalVolume(newVolume: number): void;
  50063. /**
  50064. * Connect the audio engine to an audio analyser allowing some amazing
  50065. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50067. * @param analyser The analyser to connect to the engine
  50068. */
  50069. connectToAnalyser(analyser: Analyser): void;
  50070. }
  50071. }
  50072. declare module "babylonjs/Audio/soundTrack" {
  50073. import { Sound } from "babylonjs/Audio/sound";
  50074. import { Analyser } from "babylonjs/Audio/analyser";
  50075. import { Scene } from "babylonjs/scene";
  50076. /**
  50077. * Options allowed during the creation of a sound track.
  50078. */
  50079. export interface ISoundTrackOptions {
  50080. /**
  50081. * The volume the sound track should take during creation
  50082. */
  50083. volume?: number;
  50084. /**
  50085. * Define if the sound track is the main sound track of the scene
  50086. */
  50087. mainTrack?: boolean;
  50088. }
  50089. /**
  50090. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  50091. * It will be also used in a future release to apply effects on a specific track.
  50092. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50093. */
  50094. export class SoundTrack {
  50095. /**
  50096. * The unique identifier of the sound track in the scene.
  50097. */
  50098. id: number;
  50099. /**
  50100. * The list of sounds included in the sound track.
  50101. */
  50102. soundCollection: Array<Sound>;
  50103. private _outputAudioNode;
  50104. private _scene;
  50105. private _connectedAnalyser;
  50106. private _options;
  50107. private _isInitialized;
  50108. /**
  50109. * Creates a new sound track.
  50110. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50111. * @param scene Define the scene the sound track belongs to
  50112. * @param options
  50113. */
  50114. constructor(scene: Scene, options?: ISoundTrackOptions);
  50115. private _initializeSoundTrackAudioGraph;
  50116. /**
  50117. * Release the sound track and its associated resources
  50118. */
  50119. dispose(): void;
  50120. /**
  50121. * Adds a sound to this sound track
  50122. * @param sound define the cound to add
  50123. * @ignoreNaming
  50124. */
  50125. addSound(sound: Sound): void;
  50126. /**
  50127. * Removes a sound to this sound track
  50128. * @param sound define the cound to remove
  50129. * @ignoreNaming
  50130. */
  50131. removeSound(sound: Sound): void;
  50132. /**
  50133. * Set a global volume for the full sound track.
  50134. * @param newVolume Define the new volume of the sound track
  50135. */
  50136. setVolume(newVolume: number): void;
  50137. /**
  50138. * Switch the panning model to HRTF:
  50139. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  50140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50141. */
  50142. switchPanningModelToHRTF(): void;
  50143. /**
  50144. * Switch the panning model to Equal Power:
  50145. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  50146. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50147. */
  50148. switchPanningModelToEqualPower(): void;
  50149. /**
  50150. * Connect the sound track to an audio analyser allowing some amazing
  50151. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50153. * @param analyser The analyser to connect to the engine
  50154. */
  50155. connectToAnalyser(analyser: Analyser): void;
  50156. }
  50157. }
  50158. declare module "babylonjs/Audio/audioSceneComponent" {
  50159. import { Sound } from "babylonjs/Audio/sound";
  50160. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  50161. import { Nullable } from "babylonjs/types";
  50162. import { Vector3 } from "babylonjs/Maths/math.vector";
  50163. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50164. import { Scene } from "babylonjs/scene";
  50165. import { AbstractScene } from "babylonjs/abstractScene";
  50166. import "babylonjs/Audio/audioEngine";
  50167. module "babylonjs/abstractScene" {
  50168. interface AbstractScene {
  50169. /**
  50170. * The list of sounds used in the scene.
  50171. */
  50172. sounds: Nullable<Array<Sound>>;
  50173. }
  50174. }
  50175. module "babylonjs/scene" {
  50176. interface Scene {
  50177. /**
  50178. * @hidden
  50179. * Backing field
  50180. */
  50181. _mainSoundTrack: SoundTrack;
  50182. /**
  50183. * The main sound track played by the scene.
  50184. * It cotains your primary collection of sounds.
  50185. */
  50186. mainSoundTrack: SoundTrack;
  50187. /**
  50188. * The list of sound tracks added to the scene
  50189. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50190. */
  50191. soundTracks: Nullable<Array<SoundTrack>>;
  50192. /**
  50193. * Gets a sound using a given name
  50194. * @param name defines the name to search for
  50195. * @return the found sound or null if not found at all.
  50196. */
  50197. getSoundByName(name: string): Nullable<Sound>;
  50198. /**
  50199. * Gets or sets if audio support is enabled
  50200. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50201. */
  50202. audioEnabled: boolean;
  50203. /**
  50204. * Gets or sets if audio will be output to headphones
  50205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50206. */
  50207. headphone: boolean;
  50208. /**
  50209. * Gets or sets custom audio listener position provider
  50210. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50211. */
  50212. audioListenerPositionProvider: Nullable<() => Vector3>;
  50213. /**
  50214. * Gets or sets a refresh rate when using 3D audio positioning
  50215. */
  50216. audioPositioningRefreshRate: number;
  50217. }
  50218. }
  50219. /**
  50220. * Defines the sound scene component responsible to manage any sounds
  50221. * in a given scene.
  50222. */
  50223. export class AudioSceneComponent implements ISceneSerializableComponent {
  50224. private static _CameraDirectionLH;
  50225. private static _CameraDirectionRH;
  50226. /**
  50227. * The component name helpfull to identify the component in the list of scene components.
  50228. */
  50229. readonly name: string;
  50230. /**
  50231. * The scene the component belongs to.
  50232. */
  50233. scene: Scene;
  50234. private _audioEnabled;
  50235. /**
  50236. * Gets whether audio is enabled or not.
  50237. * Please use related enable/disable method to switch state.
  50238. */
  50239. get audioEnabled(): boolean;
  50240. private _headphone;
  50241. /**
  50242. * Gets whether audio is outputing to headphone or not.
  50243. * Please use the according Switch methods to change output.
  50244. */
  50245. get headphone(): boolean;
  50246. /**
  50247. * Gets or sets a refresh rate when using 3D audio positioning
  50248. */
  50249. audioPositioningRefreshRate: number;
  50250. private _audioListenerPositionProvider;
  50251. /**
  50252. * Gets the current audio listener position provider
  50253. */
  50254. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  50255. /**
  50256. * Sets a custom listener position for all sounds in the scene
  50257. * By default, this is the position of the first active camera
  50258. */
  50259. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  50260. /**
  50261. * Creates a new instance of the component for the given scene
  50262. * @param scene Defines the scene to register the component in
  50263. */
  50264. constructor(scene: Scene);
  50265. /**
  50266. * Registers the component in a given scene
  50267. */
  50268. register(): void;
  50269. /**
  50270. * Rebuilds the elements related to this component in case of
  50271. * context lost for instance.
  50272. */
  50273. rebuild(): void;
  50274. /**
  50275. * Serializes the component data to the specified json object
  50276. * @param serializationObject The object to serialize to
  50277. */
  50278. serialize(serializationObject: any): void;
  50279. /**
  50280. * Adds all the elements from the container to the scene
  50281. * @param container the container holding the elements
  50282. */
  50283. addFromContainer(container: AbstractScene): void;
  50284. /**
  50285. * Removes all the elements in the container from the scene
  50286. * @param container contains the elements to remove
  50287. * @param dispose if the removed element should be disposed (default: false)
  50288. */
  50289. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50290. /**
  50291. * Disposes the component and the associated ressources.
  50292. */
  50293. dispose(): void;
  50294. /**
  50295. * Disables audio in the associated scene.
  50296. */
  50297. disableAudio(): void;
  50298. /**
  50299. * Enables audio in the associated scene.
  50300. */
  50301. enableAudio(): void;
  50302. /**
  50303. * Switch audio to headphone output.
  50304. */
  50305. switchAudioModeForHeadphones(): void;
  50306. /**
  50307. * Switch audio to normal speakers.
  50308. */
  50309. switchAudioModeForNormalSpeakers(): void;
  50310. private _cachedCameraDirection;
  50311. private _cachedCameraPosition;
  50312. private _lastCheck;
  50313. private _afterRender;
  50314. }
  50315. }
  50316. declare module "babylonjs/Audio/weightedsound" {
  50317. import { Sound } from "babylonjs/Audio/sound";
  50318. /**
  50319. * Wraps one or more Sound objects and selects one with random weight for playback.
  50320. */
  50321. export class WeightedSound {
  50322. /** When true a Sound will be selected and played when the current playing Sound completes. */
  50323. loop: boolean;
  50324. private _coneInnerAngle;
  50325. private _coneOuterAngle;
  50326. private _volume;
  50327. /** A Sound is currently playing. */
  50328. isPlaying: boolean;
  50329. /** A Sound is currently paused. */
  50330. isPaused: boolean;
  50331. private _sounds;
  50332. private _weights;
  50333. private _currentIndex?;
  50334. /**
  50335. * Creates a new WeightedSound from the list of sounds given.
  50336. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  50337. * @param sounds Array of Sounds that will be selected from.
  50338. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  50339. */
  50340. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  50341. /**
  50342. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  50343. */
  50344. get directionalConeInnerAngle(): number;
  50345. /**
  50346. * The size of cone in degress for a directional sound in which there will be no attenuation.
  50347. */
  50348. set directionalConeInnerAngle(value: number);
  50349. /**
  50350. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50351. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50352. */
  50353. get directionalConeOuterAngle(): number;
  50354. /**
  50355. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50356. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50357. */
  50358. set directionalConeOuterAngle(value: number);
  50359. /**
  50360. * Playback volume.
  50361. */
  50362. get volume(): number;
  50363. /**
  50364. * Playback volume.
  50365. */
  50366. set volume(value: number);
  50367. private _onended;
  50368. /**
  50369. * Suspend playback
  50370. */
  50371. pause(): void;
  50372. /**
  50373. * Stop playback
  50374. */
  50375. stop(): void;
  50376. /**
  50377. * Start playback.
  50378. * @param startOffset Position the clip head at a specific time in seconds.
  50379. */
  50380. play(startOffset?: number): void;
  50381. }
  50382. }
  50383. declare module "babylonjs/Audio/index" {
  50384. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  50385. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  50386. export * from "babylonjs/Audio/analyser";
  50387. export * from "babylonjs/Audio/audioEngine";
  50388. export * from "babylonjs/Audio/audioSceneComponent";
  50389. export * from "babylonjs/Audio/sound";
  50390. export * from "babylonjs/Audio/soundTrack";
  50391. export * from "babylonjs/Audio/weightedsound";
  50392. }
  50393. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  50394. import { Behavior } from "babylonjs/Behaviors/behavior";
  50395. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50396. import { BackEase } from "babylonjs/Animations/easing";
  50397. /**
  50398. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  50399. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50400. */
  50401. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  50402. /**
  50403. * Gets the name of the behavior.
  50404. */
  50405. get name(): string;
  50406. /**
  50407. * The easing function used by animations
  50408. */
  50409. static EasingFunction: BackEase;
  50410. /**
  50411. * The easing mode used by animations
  50412. */
  50413. static EasingMode: number;
  50414. /**
  50415. * The duration of the animation, in milliseconds
  50416. */
  50417. transitionDuration: number;
  50418. /**
  50419. * Length of the distance animated by the transition when lower radius is reached
  50420. */
  50421. lowerRadiusTransitionRange: number;
  50422. /**
  50423. * Length of the distance animated by the transition when upper radius is reached
  50424. */
  50425. upperRadiusTransitionRange: number;
  50426. private _autoTransitionRange;
  50427. /**
  50428. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50429. */
  50430. get autoTransitionRange(): boolean;
  50431. /**
  50432. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50433. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  50434. */
  50435. set autoTransitionRange(value: boolean);
  50436. private _attachedCamera;
  50437. private _onAfterCheckInputsObserver;
  50438. private _onMeshTargetChangedObserver;
  50439. /**
  50440. * Initializes the behavior.
  50441. */
  50442. init(): void;
  50443. /**
  50444. * Attaches the behavior to its arc rotate camera.
  50445. * @param camera Defines the camera to attach the behavior to
  50446. */
  50447. attach(camera: ArcRotateCamera): void;
  50448. /**
  50449. * Detaches the behavior from its current arc rotate camera.
  50450. */
  50451. detach(): void;
  50452. private _radiusIsAnimating;
  50453. private _radiusBounceTransition;
  50454. private _animatables;
  50455. private _cachedWheelPrecision;
  50456. /**
  50457. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  50458. * @param radiusLimit The limit to check against.
  50459. * @return Bool to indicate if at limit.
  50460. */
  50461. private _isRadiusAtLimit;
  50462. /**
  50463. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  50464. * @param radiusDelta The delta by which to animate to. Can be negative.
  50465. */
  50466. private _applyBoundRadiusAnimation;
  50467. /**
  50468. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50469. */
  50470. protected _clearAnimationLocks(): void;
  50471. /**
  50472. * Stops and removes all animations that have been applied to the camera
  50473. */
  50474. stopAllAnimations(): void;
  50475. }
  50476. }
  50477. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  50478. import { Behavior } from "babylonjs/Behaviors/behavior";
  50479. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50480. import { ExponentialEase } from "babylonjs/Animations/easing";
  50481. import { Nullable } from "babylonjs/types";
  50482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50483. import { Vector3 } from "babylonjs/Maths/math.vector";
  50484. /**
  50485. * 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.
  50486. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50487. */
  50488. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50489. /**
  50490. * Gets the name of the behavior.
  50491. */
  50492. get name(): string;
  50493. private _mode;
  50494. private _radiusScale;
  50495. private _positionScale;
  50496. private _defaultElevation;
  50497. private _elevationReturnTime;
  50498. private _elevationReturnWaitTime;
  50499. private _zoomStopsAnimation;
  50500. private _framingTime;
  50501. /**
  50502. * The easing function used by animations
  50503. */
  50504. static EasingFunction: ExponentialEase;
  50505. /**
  50506. * The easing mode used by animations
  50507. */
  50508. static EasingMode: number;
  50509. /**
  50510. * Sets the current mode used by the behavior
  50511. */
  50512. set mode(mode: number);
  50513. /**
  50514. * Gets current mode used by the behavior.
  50515. */
  50516. get mode(): number;
  50517. /**
  50518. * Sets the scale applied to the radius (1 by default)
  50519. */
  50520. set radiusScale(radius: number);
  50521. /**
  50522. * Gets the scale applied to the radius
  50523. */
  50524. get radiusScale(): number;
  50525. /**
  50526. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50527. */
  50528. set positionScale(scale: number);
  50529. /**
  50530. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50531. */
  50532. get positionScale(): number;
  50533. /**
  50534. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50535. * behaviour is triggered, in radians.
  50536. */
  50537. set defaultElevation(elevation: number);
  50538. /**
  50539. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50540. * behaviour is triggered, in radians.
  50541. */
  50542. get defaultElevation(): number;
  50543. /**
  50544. * Sets the time (in milliseconds) taken to return to the default beta position.
  50545. * Negative value indicates camera should not return to default.
  50546. */
  50547. set elevationReturnTime(speed: number);
  50548. /**
  50549. * Gets the time (in milliseconds) taken to return to the default beta position.
  50550. * Negative value indicates camera should not return to default.
  50551. */
  50552. get elevationReturnTime(): number;
  50553. /**
  50554. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50555. */
  50556. set elevationReturnWaitTime(time: number);
  50557. /**
  50558. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50559. */
  50560. get elevationReturnWaitTime(): number;
  50561. /**
  50562. * Sets the flag that indicates if user zooming should stop animation.
  50563. */
  50564. set zoomStopsAnimation(flag: boolean);
  50565. /**
  50566. * Gets the flag that indicates if user zooming should stop animation.
  50567. */
  50568. get zoomStopsAnimation(): boolean;
  50569. /**
  50570. * Sets the transition time when framing the mesh, in milliseconds
  50571. */
  50572. set framingTime(time: number);
  50573. /**
  50574. * Gets the transition time when framing the mesh, in milliseconds
  50575. */
  50576. get framingTime(): number;
  50577. /**
  50578. * Define if the behavior should automatically change the configured
  50579. * camera limits and sensibilities.
  50580. */
  50581. autoCorrectCameraLimitsAndSensibility: boolean;
  50582. private _onPrePointerObservableObserver;
  50583. private _onAfterCheckInputsObserver;
  50584. private _onMeshTargetChangedObserver;
  50585. private _attachedCamera;
  50586. private _isPointerDown;
  50587. private _lastInteractionTime;
  50588. /**
  50589. * Initializes the behavior.
  50590. */
  50591. init(): void;
  50592. /**
  50593. * Attaches the behavior to its arc rotate camera.
  50594. * @param camera Defines the camera to attach the behavior to
  50595. */
  50596. attach(camera: ArcRotateCamera): void;
  50597. /**
  50598. * Detaches the behavior from its current arc rotate camera.
  50599. */
  50600. detach(): void;
  50601. private _animatables;
  50602. private _betaIsAnimating;
  50603. private _betaTransition;
  50604. private _radiusTransition;
  50605. private _vectorTransition;
  50606. /**
  50607. * Targets the given mesh and updates zoom level accordingly.
  50608. * @param mesh The mesh to target.
  50609. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50610. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50611. */
  50612. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50613. /**
  50614. * Targets the given mesh with its children and updates zoom level accordingly.
  50615. * @param mesh The mesh to target.
  50616. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50617. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50618. */
  50619. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50620. /**
  50621. * Targets the given meshes with their children and updates zoom level accordingly.
  50622. * @param meshes The mesh to target.
  50623. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50624. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50625. */
  50626. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50627. /**
  50628. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50629. * @param minimumWorld Determines the smaller position of the bounding box extend
  50630. * @param maximumWorld Determines the bigger position of the bounding box extend
  50631. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50632. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50633. */
  50634. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50635. /**
  50636. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50637. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50638. * frustum width.
  50639. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50640. * to fully enclose the mesh in the viewing frustum.
  50641. */
  50642. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50643. /**
  50644. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50645. * is automatically returned to its default position (expected to be above ground plane).
  50646. */
  50647. private _maintainCameraAboveGround;
  50648. /**
  50649. * Returns the frustum slope based on the canvas ratio and camera FOV
  50650. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50651. */
  50652. private _getFrustumSlope;
  50653. /**
  50654. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50655. */
  50656. private _clearAnimationLocks;
  50657. /**
  50658. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50659. */
  50660. private _applyUserInteraction;
  50661. /**
  50662. * Stops and removes all animations that have been applied to the camera
  50663. */
  50664. stopAllAnimations(): void;
  50665. /**
  50666. * Gets a value indicating if the user is moving the camera
  50667. */
  50668. get isUserIsMoving(): boolean;
  50669. /**
  50670. * The camera can move all the way towards the mesh.
  50671. */
  50672. static IgnoreBoundsSizeMode: number;
  50673. /**
  50674. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50675. */
  50676. static FitFrustumSidesMode: number;
  50677. }
  50678. }
  50679. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  50680. import { Nullable } from "babylonjs/types";
  50681. import { Camera } from "babylonjs/Cameras/camera";
  50682. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50683. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50684. /**
  50685. * Base class for Camera Pointer Inputs.
  50686. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50687. * for example usage.
  50688. */
  50689. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50690. /**
  50691. * Defines the camera the input is attached to.
  50692. */
  50693. abstract camera: Camera;
  50694. /**
  50695. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50696. */
  50697. protected _altKey: boolean;
  50698. protected _ctrlKey: boolean;
  50699. protected _metaKey: boolean;
  50700. protected _shiftKey: boolean;
  50701. /**
  50702. * Which mouse buttons were pressed at time of last mouse event.
  50703. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50704. */
  50705. protected _buttonsPressed: number;
  50706. /**
  50707. * Defines the buttons associated with the input to handle camera move.
  50708. */
  50709. buttons: number[];
  50710. /**
  50711. * Attach the input controls to a specific dom element to get the input from.
  50712. * @param element Defines the element the controls should be listened from
  50713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50714. */
  50715. attachControl(noPreventDefault?: boolean): void;
  50716. /**
  50717. * Detach the current controls from the specified dom element.
  50718. */
  50719. detachControl(): void;
  50720. /**
  50721. * Gets the class name of the current input.
  50722. * @returns the class name
  50723. */
  50724. getClassName(): string;
  50725. /**
  50726. * Get the friendly name associated with the input class.
  50727. * @returns the input friendly name
  50728. */
  50729. getSimpleName(): string;
  50730. /**
  50731. * Called on pointer POINTERDOUBLETAP event.
  50732. * Override this method to provide functionality on POINTERDOUBLETAP event.
  50733. */
  50734. protected onDoubleTap(type: string): void;
  50735. /**
  50736. * Called on pointer POINTERMOVE event if only a single touch is active.
  50737. * Override this method to provide functionality.
  50738. */
  50739. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50740. /**
  50741. * Called on pointer POINTERMOVE event if multiple touches are active.
  50742. * Override this method to provide functionality.
  50743. */
  50744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50745. /**
  50746. * Called on JS contextmenu event.
  50747. * Override this method to provide functionality.
  50748. */
  50749. protected onContextMenu(evt: PointerEvent): void;
  50750. /**
  50751. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50752. * press.
  50753. * Override this method to provide functionality.
  50754. */
  50755. protected onButtonDown(evt: PointerEvent): void;
  50756. /**
  50757. * Called each time a new POINTERUP event occurs. Ie, for each button
  50758. * release.
  50759. * Override this method to provide functionality.
  50760. */
  50761. protected onButtonUp(evt: PointerEvent): void;
  50762. /**
  50763. * Called when window becomes inactive.
  50764. * Override this method to provide functionality.
  50765. */
  50766. protected onLostFocus(): void;
  50767. private _pointerInput;
  50768. private _observer;
  50769. private _onLostFocus;
  50770. private pointA;
  50771. private pointB;
  50772. }
  50773. }
  50774. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  50775. import { Nullable } from "babylonjs/types";
  50776. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50777. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  50778. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50779. /**
  50780. * Manage the pointers inputs to control an arc rotate camera.
  50781. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50782. */
  50783. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  50784. /**
  50785. * Defines the camera the input is attached to.
  50786. */
  50787. camera: ArcRotateCamera;
  50788. /**
  50789. * Gets the class name of the current input.
  50790. * @returns the class name
  50791. */
  50792. getClassName(): string;
  50793. /**
  50794. * Defines the buttons associated with the input to handle camera move.
  50795. */
  50796. buttons: number[];
  50797. /**
  50798. * Defines the pointer angular sensibility along the X axis or how fast is
  50799. * the camera rotating.
  50800. */
  50801. angularSensibilityX: number;
  50802. /**
  50803. * Defines the pointer angular sensibility along the Y axis or how fast is
  50804. * the camera rotating.
  50805. */
  50806. angularSensibilityY: number;
  50807. /**
  50808. * Defines the pointer pinch precision or how fast is the camera zooming.
  50809. */
  50810. pinchPrecision: number;
  50811. /**
  50812. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50813. * from 0.
  50814. * It defines the percentage of current camera.radius to use as delta when
  50815. * pinch zoom is used.
  50816. */
  50817. pinchDeltaPercentage: number;
  50818. /**
  50819. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50820. * that any object in the plane at the camera's target point will scale
  50821. * perfectly with finger motion.
  50822. * Overrides pinchDeltaPercentage and pinchPrecision.
  50823. */
  50824. useNaturalPinchZoom: boolean;
  50825. /**
  50826. * Defines the pointer panning sensibility or how fast is the camera moving.
  50827. */
  50828. panningSensibility: number;
  50829. /**
  50830. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  50831. */
  50832. multiTouchPanning: boolean;
  50833. /**
  50834. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  50835. * zoom (pinch) through multitouch.
  50836. */
  50837. multiTouchPanAndZoom: boolean;
  50838. /**
  50839. * Revers pinch action direction.
  50840. */
  50841. pinchInwards: boolean;
  50842. private _isPanClick;
  50843. private _twoFingerActivityCount;
  50844. private _isPinching;
  50845. /**
  50846. * Called on pointer POINTERMOVE event if only a single touch is active.
  50847. */
  50848. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50849. /**
  50850. * Called on pointer POINTERDOUBLETAP event.
  50851. */
  50852. protected onDoubleTap(type: string): void;
  50853. /**
  50854. * Called on pointer POINTERMOVE event if multiple touches are active.
  50855. */
  50856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50857. /**
  50858. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50859. * press.
  50860. */
  50861. protected onButtonDown(evt: PointerEvent): void;
  50862. /**
  50863. * Called each time a new POINTERUP event occurs. Ie, for each button
  50864. * release.
  50865. */
  50866. protected onButtonUp(evt: PointerEvent): void;
  50867. /**
  50868. * Called when window becomes inactive.
  50869. */
  50870. protected onLostFocus(): void;
  50871. }
  50872. }
  50873. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  50874. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50875. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50876. /**
  50877. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  50878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50879. */
  50880. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  50881. /**
  50882. * Defines the camera the input is attached to.
  50883. */
  50884. camera: ArcRotateCamera;
  50885. /**
  50886. * Defines the list of key codes associated with the up action (increase alpha)
  50887. */
  50888. keysUp: number[];
  50889. /**
  50890. * Defines the list of key codes associated with the down action (decrease alpha)
  50891. */
  50892. keysDown: number[];
  50893. /**
  50894. * Defines the list of key codes associated with the left action (increase beta)
  50895. */
  50896. keysLeft: number[];
  50897. /**
  50898. * Defines the list of key codes associated with the right action (decrease beta)
  50899. */
  50900. keysRight: number[];
  50901. /**
  50902. * Defines the list of key codes associated with the reset action.
  50903. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  50904. */
  50905. keysReset: number[];
  50906. /**
  50907. * Defines the panning sensibility of the inputs.
  50908. * (How fast is the camera panning)
  50909. */
  50910. panningSensibility: number;
  50911. /**
  50912. * Defines the zooming sensibility of the inputs.
  50913. * (How fast is the camera zooming)
  50914. */
  50915. zoomingSensibility: number;
  50916. /**
  50917. * Defines whether maintaining the alt key down switch the movement mode from
  50918. * orientation to zoom.
  50919. */
  50920. useAltToZoom: boolean;
  50921. /**
  50922. * Rotation speed of the camera
  50923. */
  50924. angularSpeed: number;
  50925. private _keys;
  50926. private _ctrlPressed;
  50927. private _altPressed;
  50928. private _onCanvasBlurObserver;
  50929. private _onKeyboardObserver;
  50930. private _engine;
  50931. private _scene;
  50932. /**
  50933. * Attach the input controls to a specific dom element to get the input from.
  50934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50935. */
  50936. attachControl(noPreventDefault?: boolean): void;
  50937. /**
  50938. * Detach the current controls from the specified dom element.
  50939. */
  50940. detachControl(): void;
  50941. /**
  50942. * Update the current camera state depending on the inputs that have been used this frame.
  50943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50944. */
  50945. checkInputs(): void;
  50946. /**
  50947. * Gets the class name of the current intput.
  50948. * @returns the class name
  50949. */
  50950. getClassName(): string;
  50951. /**
  50952. * Get the friendly name associated with the input class.
  50953. * @returns the input friendly name
  50954. */
  50955. getSimpleName(): string;
  50956. }
  50957. }
  50958. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  50959. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50960. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50961. /**
  50962. * Manage the mouse wheel inputs to control an arc rotate camera.
  50963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50964. */
  50965. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  50966. /**
  50967. * Defines the camera the input is attached to.
  50968. */
  50969. camera: ArcRotateCamera;
  50970. /**
  50971. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50972. */
  50973. wheelPrecision: number;
  50974. /**
  50975. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50976. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50977. */
  50978. wheelDeltaPercentage: number;
  50979. private _wheel;
  50980. private _observer;
  50981. private computeDeltaFromMouseWheelLegacyEvent;
  50982. /**
  50983. * Attach the input controls to a specific dom element to get the input from.
  50984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50985. */
  50986. attachControl(noPreventDefault?: boolean): void;
  50987. /**
  50988. * Detach the current controls from the specified dom element.
  50989. */
  50990. detachControl(): void;
  50991. /**
  50992. * Gets the class name of the current intput.
  50993. * @returns the class name
  50994. */
  50995. getClassName(): string;
  50996. /**
  50997. * Get the friendly name associated with the input class.
  50998. * @returns the input friendly name
  50999. */
  51000. getSimpleName(): string;
  51001. }
  51002. }
  51003. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51004. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51005. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  51006. /**
  51007. * Default Inputs manager for the ArcRotateCamera.
  51008. * It groups all the default supported inputs for ease of use.
  51009. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51010. */
  51011. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  51012. /**
  51013. * Instantiates a new ArcRotateCameraInputsManager.
  51014. * @param camera Defines the camera the inputs belong to
  51015. */
  51016. constructor(camera: ArcRotateCamera);
  51017. /**
  51018. * Add mouse wheel input support to the input manager.
  51019. * @returns the current input manager
  51020. */
  51021. addMouseWheel(): ArcRotateCameraInputsManager;
  51022. /**
  51023. * Add pointers input support to the input manager.
  51024. * @returns the current input manager
  51025. */
  51026. addPointers(): ArcRotateCameraInputsManager;
  51027. /**
  51028. * Add keyboard input support to the input manager.
  51029. * @returns the current input manager
  51030. */
  51031. addKeyboard(): ArcRotateCameraInputsManager;
  51032. }
  51033. }
  51034. declare module "babylonjs/Cameras/arcRotateCamera" {
  51035. import { Observable } from "babylonjs/Misc/observable";
  51036. import { Nullable } from "babylonjs/types";
  51037. import { Scene } from "babylonjs/scene";
  51038. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  51039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51040. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51041. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51042. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  51043. import { Camera } from "babylonjs/Cameras/camera";
  51044. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  51045. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51046. import { Collider } from "babylonjs/Collisions/collider";
  51047. /**
  51048. * This represents an orbital type of camera.
  51049. *
  51050. * 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.
  51051. * 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.
  51052. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  51053. */
  51054. export class ArcRotateCamera extends TargetCamera {
  51055. /**
  51056. * Defines the rotation angle of the camera along the longitudinal axis.
  51057. */
  51058. alpha: number;
  51059. /**
  51060. * Defines the rotation angle of the camera along the latitudinal axis.
  51061. */
  51062. beta: number;
  51063. /**
  51064. * Defines the radius of the camera from it s target point.
  51065. */
  51066. radius: number;
  51067. protected _target: Vector3;
  51068. protected _targetHost: Nullable<AbstractMesh>;
  51069. /**
  51070. * Defines the target point of the camera.
  51071. * The camera looks towards it form the radius distance.
  51072. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  51073. */
  51074. get target(): Vector3;
  51075. set target(value: Vector3);
  51076. /**
  51077. * Define the current local position of the camera in the scene
  51078. */
  51079. get position(): Vector3;
  51080. set position(newPosition: Vector3);
  51081. protected _upToYMatrix: Matrix;
  51082. protected _YToUpMatrix: Matrix;
  51083. /**
  51084. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  51085. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  51086. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  51087. */
  51088. set upVector(vec: Vector3);
  51089. get upVector(): Vector3;
  51090. /**
  51091. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  51092. */
  51093. setMatUp(): void;
  51094. /**
  51095. * Current inertia value on the longitudinal axis.
  51096. * The bigger this number the longer it will take for the camera to stop.
  51097. */
  51098. inertialAlphaOffset: number;
  51099. /**
  51100. * Current inertia value on the latitudinal axis.
  51101. * The bigger this number the longer it will take for the camera to stop.
  51102. */
  51103. inertialBetaOffset: number;
  51104. /**
  51105. * Current inertia value on the radius axis.
  51106. * The bigger this number the longer it will take for the camera to stop.
  51107. */
  51108. inertialRadiusOffset: number;
  51109. /**
  51110. * Minimum allowed angle on the longitudinal axis.
  51111. * This can help limiting how the Camera is able to move in the scene.
  51112. */
  51113. lowerAlphaLimit: Nullable<number>;
  51114. /**
  51115. * Maximum allowed angle on the longitudinal axis.
  51116. * This can help limiting how the Camera is able to move in the scene.
  51117. */
  51118. upperAlphaLimit: Nullable<number>;
  51119. /**
  51120. * Minimum allowed angle on the latitudinal axis.
  51121. * This can help limiting how the Camera is able to move in the scene.
  51122. */
  51123. lowerBetaLimit: number;
  51124. /**
  51125. * Maximum allowed angle on the latitudinal axis.
  51126. * This can help limiting how the Camera is able to move in the scene.
  51127. */
  51128. upperBetaLimit: number;
  51129. /**
  51130. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  51131. * This can help limiting how the Camera is able to move in the scene.
  51132. */
  51133. lowerRadiusLimit: Nullable<number>;
  51134. /**
  51135. * Maximum allowed distance of the camera to the target (The camera can not get further).
  51136. * This can help limiting how the Camera is able to move in the scene.
  51137. */
  51138. upperRadiusLimit: Nullable<number>;
  51139. /**
  51140. * Defines the current inertia value used during panning of the camera along the X axis.
  51141. */
  51142. inertialPanningX: number;
  51143. /**
  51144. * Defines the current inertia value used during panning of the camera along the Y axis.
  51145. */
  51146. inertialPanningY: number;
  51147. /**
  51148. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  51149. * Basically if your fingers moves away from more than this distance you will be considered
  51150. * in pinch mode.
  51151. */
  51152. pinchToPanMaxDistance: number;
  51153. /**
  51154. * Defines the maximum distance the camera can pan.
  51155. * This could help keeping the cammera always in your scene.
  51156. */
  51157. panningDistanceLimit: Nullable<number>;
  51158. /**
  51159. * Defines the target of the camera before paning.
  51160. */
  51161. panningOriginTarget: Vector3;
  51162. /**
  51163. * Defines the value of the inertia used during panning.
  51164. * 0 would mean stop inertia and one would mean no decelleration at all.
  51165. */
  51166. panningInertia: number;
  51167. /**
  51168. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  51169. */
  51170. get angularSensibilityX(): number;
  51171. set angularSensibilityX(value: number);
  51172. /**
  51173. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  51174. */
  51175. get angularSensibilityY(): number;
  51176. set angularSensibilityY(value: number);
  51177. /**
  51178. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  51179. */
  51180. get pinchPrecision(): number;
  51181. set pinchPrecision(value: number);
  51182. /**
  51183. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  51184. * It will be used instead of pinchDeltaPrecision if different from 0.
  51185. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51186. */
  51187. get pinchDeltaPercentage(): number;
  51188. set pinchDeltaPercentage(value: number);
  51189. /**
  51190. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  51191. * and pinch delta percentage.
  51192. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51193. * that any object in the plane at the camera's target point will scale
  51194. * perfectly with finger motion.
  51195. */
  51196. get useNaturalPinchZoom(): boolean;
  51197. set useNaturalPinchZoom(value: boolean);
  51198. /**
  51199. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  51200. */
  51201. get panningSensibility(): number;
  51202. set panningSensibility(value: number);
  51203. /**
  51204. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  51205. */
  51206. get keysUp(): number[];
  51207. set keysUp(value: number[]);
  51208. /**
  51209. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  51210. */
  51211. get keysDown(): number[];
  51212. set keysDown(value: number[]);
  51213. /**
  51214. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  51215. */
  51216. get keysLeft(): number[];
  51217. set keysLeft(value: number[]);
  51218. /**
  51219. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  51220. */
  51221. get keysRight(): number[];
  51222. set keysRight(value: number[]);
  51223. /**
  51224. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51225. */
  51226. get wheelPrecision(): number;
  51227. set wheelPrecision(value: number);
  51228. /**
  51229. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  51230. * It will be used instead of pinchDeltaPrecision if different from 0.
  51231. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51232. */
  51233. get wheelDeltaPercentage(): number;
  51234. set wheelDeltaPercentage(value: number);
  51235. /**
  51236. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  51237. */
  51238. zoomOnFactor: number;
  51239. /**
  51240. * Defines a screen offset for the camera position.
  51241. */
  51242. targetScreenOffset: Vector2;
  51243. /**
  51244. * Allows the camera to be completely reversed.
  51245. * If false the camera can not arrive upside down.
  51246. */
  51247. allowUpsideDown: boolean;
  51248. /**
  51249. * Define if double tap/click is used to restore the previously saved state of the camera.
  51250. */
  51251. useInputToRestoreState: boolean;
  51252. /** @hidden */
  51253. _viewMatrix: Matrix;
  51254. /** @hidden */
  51255. _useCtrlForPanning: boolean;
  51256. /** @hidden */
  51257. _panningMouseButton: number;
  51258. /**
  51259. * Defines the input associated to the camera.
  51260. */
  51261. inputs: ArcRotateCameraInputsManager;
  51262. /** @hidden */
  51263. _reset: () => void;
  51264. /**
  51265. * Defines the allowed panning axis.
  51266. */
  51267. panningAxis: Vector3;
  51268. protected _transformedDirection: Vector3;
  51269. private _bouncingBehavior;
  51270. /**
  51271. * Gets the bouncing behavior of the camera if it has been enabled.
  51272. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51273. */
  51274. get bouncingBehavior(): Nullable<BouncingBehavior>;
  51275. /**
  51276. * Defines if the bouncing behavior of the camera is enabled on the camera.
  51277. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51278. */
  51279. get useBouncingBehavior(): boolean;
  51280. set useBouncingBehavior(value: boolean);
  51281. private _framingBehavior;
  51282. /**
  51283. * Gets the framing behavior of the camera if it has been enabled.
  51284. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51285. */
  51286. get framingBehavior(): Nullable<FramingBehavior>;
  51287. /**
  51288. * Defines if the framing behavior of the camera is enabled on the camera.
  51289. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51290. */
  51291. get useFramingBehavior(): boolean;
  51292. set useFramingBehavior(value: boolean);
  51293. private _autoRotationBehavior;
  51294. /**
  51295. * Gets the auto rotation behavior of the camera if it has been enabled.
  51296. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51297. */
  51298. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  51299. /**
  51300. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  51301. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51302. */
  51303. get useAutoRotationBehavior(): boolean;
  51304. set useAutoRotationBehavior(value: boolean);
  51305. /**
  51306. * Observable triggered when the mesh target has been changed on the camera.
  51307. */
  51308. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  51309. /**
  51310. * Event raised when the camera is colliding with a mesh.
  51311. */
  51312. onCollide: (collidedMesh: AbstractMesh) => void;
  51313. /**
  51314. * Defines whether the camera should check collision with the objects oh the scene.
  51315. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  51316. */
  51317. checkCollisions: boolean;
  51318. /**
  51319. * Defines the collision radius of the camera.
  51320. * This simulates a sphere around the camera.
  51321. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51322. */
  51323. collisionRadius: Vector3;
  51324. protected _collider: Collider;
  51325. protected _previousPosition: Vector3;
  51326. protected _collisionVelocity: Vector3;
  51327. protected _newPosition: Vector3;
  51328. protected _previousAlpha: number;
  51329. protected _previousBeta: number;
  51330. protected _previousRadius: number;
  51331. protected _collisionTriggered: boolean;
  51332. protected _targetBoundingCenter: Nullable<Vector3>;
  51333. private _computationVector;
  51334. /**
  51335. * Instantiates a new ArcRotateCamera in a given scene
  51336. * @param name Defines the name of the camera
  51337. * @param alpha Defines the camera rotation along the logitudinal axis
  51338. * @param beta Defines the camera rotation along the latitudinal axis
  51339. * @param radius Defines the camera distance from its target
  51340. * @param target Defines the camera target
  51341. * @param scene Defines the scene the camera belongs to
  51342. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  51343. */
  51344. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51345. /** @hidden */
  51346. _initCache(): void;
  51347. /** @hidden */
  51348. _updateCache(ignoreParentClass?: boolean): void;
  51349. protected _getTargetPosition(): Vector3;
  51350. private _storedAlpha;
  51351. private _storedBeta;
  51352. private _storedRadius;
  51353. private _storedTarget;
  51354. private _storedTargetScreenOffset;
  51355. /**
  51356. * Stores the current state of the camera (alpha, beta, radius and target)
  51357. * @returns the camera itself
  51358. */
  51359. storeState(): Camera;
  51360. /**
  51361. * @hidden
  51362. * Restored camera state. You must call storeState() first
  51363. */
  51364. _restoreStateValues(): boolean;
  51365. /** @hidden */
  51366. _isSynchronizedViewMatrix(): boolean;
  51367. /**
  51368. * Attach the input controls to a specific dom element to get the input from.
  51369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51370. */
  51371. attachControl(noPreventDefault?: boolean): void;
  51372. /**
  51373. * Attach the input controls to a specific dom element to get the input from.
  51374. * @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
  51375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51376. */
  51377. attachControl(ignored: any, noPreventDefault?: boolean): void;
  51378. /**
  51379. * Attached controls to the current camera.
  51380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51381. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51382. */
  51383. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51384. /**
  51385. * Attached controls to the current camera.
  51386. * @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
  51387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51388. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51389. */
  51390. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51391. /**
  51392. * Attached controls to the current camera.
  51393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51394. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51395. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  51396. */
  51397. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  51398. /**
  51399. * Detach the current controls from the specified dom element.
  51400. */
  51401. detachControl(): void;
  51402. /**
  51403. * Detach the current controls from the specified dom element.
  51404. * @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
  51405. */
  51406. detachControl(ignored: any): void;
  51407. /** @hidden */
  51408. _checkInputs(): void;
  51409. protected _checkLimits(): void;
  51410. /**
  51411. * Rebuilds angles (alpha, beta) and radius from the give position and target
  51412. */
  51413. rebuildAnglesAndRadius(): void;
  51414. /**
  51415. * Use a position to define the current camera related information like alpha, beta and radius
  51416. * @param position Defines the position to set the camera at
  51417. */
  51418. setPosition(position: Vector3): void;
  51419. /**
  51420. * Defines the target the camera should look at.
  51421. * This will automatically adapt alpha beta and radius to fit within the new target.
  51422. * @param target Defines the new target as a Vector or a mesh
  51423. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  51424. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  51425. */
  51426. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  51427. /** @hidden */
  51428. _getViewMatrix(): Matrix;
  51429. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  51430. /**
  51431. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  51432. * @param meshes Defines the mesh to zoom on
  51433. * @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)
  51434. */
  51435. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  51436. /**
  51437. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  51438. * The target will be changed but the radius
  51439. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  51440. * @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)
  51441. */
  51442. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  51443. min: Vector3;
  51444. max: Vector3;
  51445. distance: number;
  51446. }, doNotUpdateMaxZ?: boolean): void;
  51447. /**
  51448. * @override
  51449. * Override Camera.createRigCamera
  51450. */
  51451. createRigCamera(name: string, cameraIndex: number): Camera;
  51452. /**
  51453. * @hidden
  51454. * @override
  51455. * Override Camera._updateRigCameras
  51456. */
  51457. _updateRigCameras(): void;
  51458. /**
  51459. * Destroy the camera and release the current resources hold by it.
  51460. */
  51461. dispose(): void;
  51462. /**
  51463. * Gets the current object class name.
  51464. * @return the class name
  51465. */
  51466. getClassName(): string;
  51467. }
  51468. }
  51469. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  51470. import { Behavior } from "babylonjs/Behaviors/behavior";
  51471. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51472. /**
  51473. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  51474. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51475. */
  51476. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  51477. /**
  51478. * Gets the name of the behavior.
  51479. */
  51480. get name(): string;
  51481. private _zoomStopsAnimation;
  51482. private _idleRotationSpeed;
  51483. private _idleRotationWaitTime;
  51484. private _idleRotationSpinupTime;
  51485. /**
  51486. * Sets the flag that indicates if user zooming should stop animation.
  51487. */
  51488. set zoomStopsAnimation(flag: boolean);
  51489. /**
  51490. * Gets the flag that indicates if user zooming should stop animation.
  51491. */
  51492. get zoomStopsAnimation(): boolean;
  51493. /**
  51494. * Sets the default speed at which the camera rotates around the model.
  51495. */
  51496. set idleRotationSpeed(speed: number);
  51497. /**
  51498. * Gets the default speed at which the camera rotates around the model.
  51499. */
  51500. get idleRotationSpeed(): number;
  51501. /**
  51502. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51503. */
  51504. set idleRotationWaitTime(time: number);
  51505. /**
  51506. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51507. */
  51508. get idleRotationWaitTime(): number;
  51509. /**
  51510. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51511. */
  51512. set idleRotationSpinupTime(time: number);
  51513. /**
  51514. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51515. */
  51516. get idleRotationSpinupTime(): number;
  51517. /**
  51518. * Gets a value indicating if the camera is currently rotating because of this behavior
  51519. */
  51520. get rotationInProgress(): boolean;
  51521. private _onPrePointerObservableObserver;
  51522. private _onAfterCheckInputsObserver;
  51523. private _attachedCamera;
  51524. private _isPointerDown;
  51525. private _lastFrameTime;
  51526. private _lastInteractionTime;
  51527. private _cameraRotationSpeed;
  51528. /**
  51529. * Initializes the behavior.
  51530. */
  51531. init(): void;
  51532. /**
  51533. * Attaches the behavior to its arc rotate camera.
  51534. * @param camera Defines the camera to attach the behavior to
  51535. */
  51536. attach(camera: ArcRotateCamera): void;
  51537. /**
  51538. * Detaches the behavior from its current arc rotate camera.
  51539. */
  51540. detach(): void;
  51541. /**
  51542. * Returns true if user is scrolling.
  51543. * @return true if user is scrolling.
  51544. */
  51545. private _userIsZooming;
  51546. private _lastFrameRadius;
  51547. private _shouldAnimationStopForInteraction;
  51548. /**
  51549. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51550. */
  51551. private _applyUserInteraction;
  51552. private _userIsMoving;
  51553. }
  51554. }
  51555. declare module "babylonjs/Behaviors/Cameras/index" {
  51556. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51557. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51558. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  51559. }
  51560. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  51561. import { Mesh } from "babylonjs/Meshes/mesh";
  51562. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51563. import { Behavior } from "babylonjs/Behaviors/behavior";
  51564. /**
  51565. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51566. */
  51567. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51568. private ui;
  51569. /**
  51570. * The name of the behavior
  51571. */
  51572. name: string;
  51573. /**
  51574. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51575. */
  51576. distanceAwayFromFace: number;
  51577. /**
  51578. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51579. */
  51580. distanceAwayFromBottomOfFace: number;
  51581. private _faceVectors;
  51582. private _target;
  51583. private _scene;
  51584. private _onRenderObserver;
  51585. private _tmpMatrix;
  51586. private _tmpVector;
  51587. /**
  51588. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51589. * @param ui The transform node that should be attched to the mesh
  51590. */
  51591. constructor(ui: TransformNode);
  51592. /**
  51593. * Initializes the behavior
  51594. */
  51595. init(): void;
  51596. private _closestFace;
  51597. private _zeroVector;
  51598. private _lookAtTmpMatrix;
  51599. private _lookAtToRef;
  51600. /**
  51601. * Attaches the AttachToBoxBehavior to the passed in mesh
  51602. * @param target The mesh that the specified node will be attached to
  51603. */
  51604. attach(target: Mesh): void;
  51605. /**
  51606. * Detaches the behavior from the mesh
  51607. */
  51608. detach(): void;
  51609. }
  51610. }
  51611. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  51612. import { Behavior } from "babylonjs/Behaviors/behavior";
  51613. import { Mesh } from "babylonjs/Meshes/mesh";
  51614. /**
  51615. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51616. */
  51617. export class FadeInOutBehavior implements Behavior<Mesh> {
  51618. /**
  51619. * Time in milliseconds to delay before fading in (Default: 0)
  51620. */
  51621. delay: number;
  51622. /**
  51623. * Time in milliseconds for the mesh to fade in (Default: 300)
  51624. */
  51625. fadeInTime: number;
  51626. private _millisecondsPerFrame;
  51627. private _hovered;
  51628. private _hoverValue;
  51629. private _ownerNode;
  51630. /**
  51631. * Instatiates the FadeInOutBehavior
  51632. */
  51633. constructor();
  51634. /**
  51635. * The name of the behavior
  51636. */
  51637. get name(): string;
  51638. /**
  51639. * Initializes the behavior
  51640. */
  51641. init(): void;
  51642. /**
  51643. * Attaches the fade behavior on the passed in mesh
  51644. * @param ownerNode The mesh that will be faded in/out once attached
  51645. */
  51646. attach(ownerNode: Mesh): void;
  51647. /**
  51648. * Detaches the behavior from the mesh
  51649. */
  51650. detach(): void;
  51651. /**
  51652. * Triggers the mesh to begin fading in or out
  51653. * @param value if the object should fade in or out (true to fade in)
  51654. */
  51655. fadeIn(value: boolean): void;
  51656. private _update;
  51657. private _setAllVisibility;
  51658. }
  51659. }
  51660. declare module "babylonjs/Misc/pivotTools" {
  51661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51662. /**
  51663. * Class containing a set of static utilities functions for managing Pivots
  51664. * @hidden
  51665. */
  51666. export class PivotTools {
  51667. private static _PivotCached;
  51668. private static _OldPivotPoint;
  51669. private static _PivotTranslation;
  51670. private static _PivotTmpVector;
  51671. private static _PivotPostMultiplyPivotMatrix;
  51672. /** @hidden */
  51673. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51674. /** @hidden */
  51675. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51676. }
  51677. }
  51678. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  51679. import { Scene } from "babylonjs/scene";
  51680. import { Vector4 } from "babylonjs/Maths/math.vector";
  51681. import { Mesh } from "babylonjs/Meshes/mesh";
  51682. import { Nullable } from "babylonjs/types";
  51683. import { Plane } from "babylonjs/Maths/math.plane";
  51684. /**
  51685. * Class containing static functions to help procedurally build meshes
  51686. */
  51687. export class PlaneBuilder {
  51688. /**
  51689. * Creates a plane mesh
  51690. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51691. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51692. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51694. * * 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
  51695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51696. * @param name defines the name of the mesh
  51697. * @param options defines the options used to create the mesh
  51698. * @param scene defines the hosting scene
  51699. * @returns the plane mesh
  51700. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51701. */
  51702. static CreatePlane(name: string, options: {
  51703. size?: number;
  51704. width?: number;
  51705. height?: number;
  51706. sideOrientation?: number;
  51707. frontUVs?: Vector4;
  51708. backUVs?: Vector4;
  51709. updatable?: boolean;
  51710. sourcePlane?: Plane;
  51711. }, scene?: Nullable<Scene>): Mesh;
  51712. }
  51713. }
  51714. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  51715. import { Behavior } from "babylonjs/Behaviors/behavior";
  51716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51717. import { Observable } from "babylonjs/Misc/observable";
  51718. import { Vector3 } from "babylonjs/Maths/math.vector";
  51719. import { Ray } from "babylonjs/Culling/ray";
  51720. import "babylonjs/Meshes/Builders/planeBuilder";
  51721. /**
  51722. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  51723. */
  51724. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  51725. private static _AnyMouseID;
  51726. /**
  51727. * Abstract mesh the behavior is set on
  51728. */
  51729. attachedNode: AbstractMesh;
  51730. private _dragPlane;
  51731. private _scene;
  51732. private _pointerObserver;
  51733. private _beforeRenderObserver;
  51734. private static _planeScene;
  51735. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  51736. /**
  51737. * 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)
  51738. */
  51739. maxDragAngle: number;
  51740. /**
  51741. * @hidden
  51742. */
  51743. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  51744. /**
  51745. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51746. */
  51747. currentDraggingPointerID: number;
  51748. /**
  51749. * The last position where the pointer hit the drag plane in world space
  51750. */
  51751. lastDragPosition: Vector3;
  51752. /**
  51753. * If the behavior is currently in a dragging state
  51754. */
  51755. dragging: boolean;
  51756. /**
  51757. * 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)
  51758. */
  51759. dragDeltaRatio: number;
  51760. /**
  51761. * If the drag plane orientation should be updated during the dragging (Default: true)
  51762. */
  51763. updateDragPlane: boolean;
  51764. private _debugMode;
  51765. private _moving;
  51766. /**
  51767. * Fires each time the attached mesh is dragged with the pointer
  51768. * * delta between last drag position and current drag position in world space
  51769. * * dragDistance along the drag axis
  51770. * * dragPlaneNormal normal of the current drag plane used during the drag
  51771. * * dragPlanePoint in world space where the drag intersects the drag plane
  51772. */
  51773. onDragObservable: Observable<{
  51774. delta: Vector3;
  51775. dragPlanePoint: Vector3;
  51776. dragPlaneNormal: Vector3;
  51777. dragDistance: number;
  51778. pointerId: number;
  51779. }>;
  51780. /**
  51781. * Fires each time a drag begins (eg. mouse down on mesh)
  51782. */
  51783. onDragStartObservable: Observable<{
  51784. dragPlanePoint: Vector3;
  51785. pointerId: number;
  51786. }>;
  51787. /**
  51788. * Fires each time a drag ends (eg. mouse release after drag)
  51789. */
  51790. onDragEndObservable: Observable<{
  51791. dragPlanePoint: Vector3;
  51792. pointerId: number;
  51793. }>;
  51794. /**
  51795. * If the attached mesh should be moved when dragged
  51796. */
  51797. moveAttached: boolean;
  51798. /**
  51799. * If the drag behavior will react to drag events (Default: true)
  51800. */
  51801. enabled: boolean;
  51802. /**
  51803. * If pointer events should start and release the drag (Default: true)
  51804. */
  51805. startAndReleaseDragOnPointerEvents: boolean;
  51806. /**
  51807. * If camera controls should be detached during the drag
  51808. */
  51809. detachCameraControls: boolean;
  51810. /**
  51811. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  51812. */
  51813. useObjectOrientationForDragging: boolean;
  51814. private _options;
  51815. /**
  51816. * Gets the options used by the behavior
  51817. */
  51818. get options(): {
  51819. dragAxis?: Vector3;
  51820. dragPlaneNormal?: Vector3;
  51821. };
  51822. /**
  51823. * Sets the options used by the behavior
  51824. */
  51825. set options(options: {
  51826. dragAxis?: Vector3;
  51827. dragPlaneNormal?: Vector3;
  51828. });
  51829. /**
  51830. * Creates a pointer drag behavior that can be attached to a mesh
  51831. * @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)
  51832. */
  51833. constructor(options?: {
  51834. dragAxis?: Vector3;
  51835. dragPlaneNormal?: Vector3;
  51836. });
  51837. /**
  51838. * Predicate to determine if it is valid to move the object to a new position when it is moved
  51839. */
  51840. validateDrag: (targetPosition: Vector3) => boolean;
  51841. /**
  51842. * The name of the behavior
  51843. */
  51844. get name(): string;
  51845. /**
  51846. * Initializes the behavior
  51847. */
  51848. init(): void;
  51849. private _tmpVector;
  51850. private _alternatePickedPoint;
  51851. private _worldDragAxis;
  51852. private _targetPosition;
  51853. private _attachedToElement;
  51854. /**
  51855. * Attaches the drag behavior the passed in mesh
  51856. * @param ownerNode The mesh that will be dragged around once attached
  51857. * @param predicate Predicate to use for pick filtering
  51858. */
  51859. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  51860. /**
  51861. * Force relase the drag action by code.
  51862. */
  51863. releaseDrag(): void;
  51864. private _startDragRay;
  51865. private _lastPointerRay;
  51866. /**
  51867. * Simulates the start of a pointer drag event on the behavior
  51868. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  51869. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  51870. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  51871. */
  51872. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51873. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51874. private _dragDelta;
  51875. protected _moveDrag(ray: Ray): void;
  51876. private _pickWithRayOnDragPlane;
  51877. private _pointA;
  51878. private _pointC;
  51879. private _localAxis;
  51880. private _lookAt;
  51881. private _updateDragPlanePosition;
  51882. /**
  51883. * Detaches the behavior from the mesh
  51884. */
  51885. detach(): void;
  51886. }
  51887. }
  51888. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  51889. import { Mesh } from "babylonjs/Meshes/mesh";
  51890. import { Behavior } from "babylonjs/Behaviors/behavior";
  51891. /**
  51892. * A behavior that when attached to a mesh will allow the mesh to be scaled
  51893. */
  51894. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  51895. private _dragBehaviorA;
  51896. private _dragBehaviorB;
  51897. private _startDistance;
  51898. private _initialScale;
  51899. private _targetScale;
  51900. private _ownerNode;
  51901. private _sceneRenderObserver;
  51902. /**
  51903. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  51904. */
  51905. constructor();
  51906. /**
  51907. * The name of the behavior
  51908. */
  51909. get name(): string;
  51910. /**
  51911. * Initializes the behavior
  51912. */
  51913. init(): void;
  51914. private _getCurrentDistance;
  51915. /**
  51916. * Attaches the scale behavior the passed in mesh
  51917. * @param ownerNode The mesh that will be scaled around once attached
  51918. */
  51919. attach(ownerNode: Mesh): void;
  51920. /**
  51921. * Detaches the behavior from the mesh
  51922. */
  51923. detach(): void;
  51924. }
  51925. }
  51926. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  51927. import { Behavior } from "babylonjs/Behaviors/behavior";
  51928. import { Mesh } from "babylonjs/Meshes/mesh";
  51929. import { Observable } from "babylonjs/Misc/observable";
  51930. /**
  51931. * 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
  51932. */
  51933. export class SixDofDragBehavior implements Behavior<Mesh> {
  51934. private static _virtualScene;
  51935. private _ownerNode;
  51936. private _sceneRenderObserver;
  51937. private _scene;
  51938. private _targetPosition;
  51939. private _virtualOriginMesh;
  51940. private _virtualDragMesh;
  51941. private _pointerObserver;
  51942. private _moving;
  51943. private _startingOrientation;
  51944. private _attachedToElement;
  51945. /**
  51946. * 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)
  51947. */
  51948. private zDragFactor;
  51949. /**
  51950. * If the object should rotate to face the drag origin
  51951. */
  51952. rotateDraggedObject: boolean;
  51953. /**
  51954. * If the behavior is currently in a dragging state
  51955. */
  51956. dragging: boolean;
  51957. /**
  51958. * 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)
  51959. */
  51960. dragDeltaRatio: number;
  51961. /**
  51962. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51963. */
  51964. currentDraggingPointerID: number;
  51965. /**
  51966. * If camera controls should be detached during the drag
  51967. */
  51968. detachCameraControls: boolean;
  51969. /**
  51970. * Fires each time a drag starts
  51971. */
  51972. onDragStartObservable: Observable<{}>;
  51973. /**
  51974. * Fires each time a drag happens
  51975. */
  51976. onDragObservable: Observable<void>;
  51977. /**
  51978. * Fires each time a drag ends (eg. mouse release after drag)
  51979. */
  51980. onDragEndObservable: Observable<{}>;
  51981. /**
  51982. * 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
  51983. */
  51984. constructor();
  51985. /**
  51986. * The name of the behavior
  51987. */
  51988. get name(): string;
  51989. /**
  51990. * Initializes the behavior
  51991. */
  51992. init(): void;
  51993. /**
  51994. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  51995. */
  51996. private get _pointerCamera();
  51997. /**
  51998. * Attaches the scale behavior the passed in mesh
  51999. * @param ownerNode The mesh that will be scaled around once attached
  52000. */
  52001. attach(ownerNode: Mesh): void;
  52002. /**
  52003. * Detaches the behavior from the mesh
  52004. */
  52005. detach(): void;
  52006. }
  52007. }
  52008. declare module "babylonjs/Behaviors/Meshes/index" {
  52009. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  52010. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  52011. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  52012. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52013. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  52014. }
  52015. declare module "babylonjs/Behaviors/index" {
  52016. export * from "babylonjs/Behaviors/behavior";
  52017. export * from "babylonjs/Behaviors/Cameras/index";
  52018. export * from "babylonjs/Behaviors/Meshes/index";
  52019. }
  52020. declare module "babylonjs/Bones/boneIKController" {
  52021. import { Bone } from "babylonjs/Bones/bone";
  52022. import { Vector3 } from "babylonjs/Maths/math.vector";
  52023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52024. import { Nullable } from "babylonjs/types";
  52025. /**
  52026. * Class used to apply inverse kinematics to bones
  52027. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  52028. */
  52029. export class BoneIKController {
  52030. private static _tmpVecs;
  52031. private static _tmpQuat;
  52032. private static _tmpMats;
  52033. /**
  52034. * Gets or sets the target mesh
  52035. */
  52036. targetMesh: AbstractMesh;
  52037. /** Gets or sets the mesh used as pole */
  52038. poleTargetMesh: AbstractMesh;
  52039. /**
  52040. * Gets or sets the bone used as pole
  52041. */
  52042. poleTargetBone: Nullable<Bone>;
  52043. /**
  52044. * Gets or sets the target position
  52045. */
  52046. targetPosition: Vector3;
  52047. /**
  52048. * Gets or sets the pole target position
  52049. */
  52050. poleTargetPosition: Vector3;
  52051. /**
  52052. * Gets or sets the pole target local offset
  52053. */
  52054. poleTargetLocalOffset: Vector3;
  52055. /**
  52056. * Gets or sets the pole angle
  52057. */
  52058. poleAngle: number;
  52059. /**
  52060. * Gets or sets the mesh associated with the controller
  52061. */
  52062. mesh: AbstractMesh;
  52063. /**
  52064. * 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)
  52065. */
  52066. slerpAmount: number;
  52067. private _bone1Quat;
  52068. private _bone1Mat;
  52069. private _bone2Ang;
  52070. private _bone1;
  52071. private _bone2;
  52072. private _bone1Length;
  52073. private _bone2Length;
  52074. private _maxAngle;
  52075. private _maxReach;
  52076. private _rightHandedSystem;
  52077. private _bendAxis;
  52078. private _slerping;
  52079. private _adjustRoll;
  52080. /**
  52081. * Gets or sets maximum allowed angle
  52082. */
  52083. get maxAngle(): number;
  52084. set maxAngle(value: number);
  52085. /**
  52086. * Creates a new BoneIKController
  52087. * @param mesh defines the mesh to control
  52088. * @param bone defines the bone to control
  52089. * @param options defines options to set up the controller
  52090. */
  52091. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  52092. targetMesh?: AbstractMesh;
  52093. poleTargetMesh?: AbstractMesh;
  52094. poleTargetBone?: Bone;
  52095. poleTargetLocalOffset?: Vector3;
  52096. poleAngle?: number;
  52097. bendAxis?: Vector3;
  52098. maxAngle?: number;
  52099. slerpAmount?: number;
  52100. });
  52101. private _setMaxAngle;
  52102. /**
  52103. * Force the controller to update the bones
  52104. */
  52105. update(): void;
  52106. }
  52107. }
  52108. declare module "babylonjs/Bones/boneLookController" {
  52109. import { Vector3 } from "babylonjs/Maths/math.vector";
  52110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52111. import { Bone } from "babylonjs/Bones/bone";
  52112. import { Space } from "babylonjs/Maths/math.axis";
  52113. /**
  52114. * Class used to make a bone look toward a point in space
  52115. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  52116. */
  52117. export class BoneLookController {
  52118. private static _tmpVecs;
  52119. private static _tmpQuat;
  52120. private static _tmpMats;
  52121. /**
  52122. * The target Vector3 that the bone will look at
  52123. */
  52124. target: Vector3;
  52125. /**
  52126. * The mesh that the bone is attached to
  52127. */
  52128. mesh: AbstractMesh;
  52129. /**
  52130. * The bone that will be looking to the target
  52131. */
  52132. bone: Bone;
  52133. /**
  52134. * The up axis of the coordinate system that is used when the bone is rotated
  52135. */
  52136. upAxis: Vector3;
  52137. /**
  52138. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  52139. */
  52140. upAxisSpace: Space;
  52141. /**
  52142. * Used to make an adjustment to the yaw of the bone
  52143. */
  52144. adjustYaw: number;
  52145. /**
  52146. * Used to make an adjustment to the pitch of the bone
  52147. */
  52148. adjustPitch: number;
  52149. /**
  52150. * Used to make an adjustment to the roll of the bone
  52151. */
  52152. adjustRoll: number;
  52153. /**
  52154. * 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)
  52155. */
  52156. slerpAmount: number;
  52157. private _minYaw;
  52158. private _maxYaw;
  52159. private _minPitch;
  52160. private _maxPitch;
  52161. private _minYawSin;
  52162. private _minYawCos;
  52163. private _maxYawSin;
  52164. private _maxYawCos;
  52165. private _midYawConstraint;
  52166. private _minPitchTan;
  52167. private _maxPitchTan;
  52168. private _boneQuat;
  52169. private _slerping;
  52170. private _transformYawPitch;
  52171. private _transformYawPitchInv;
  52172. private _firstFrameSkipped;
  52173. private _yawRange;
  52174. private _fowardAxis;
  52175. /**
  52176. * Gets or sets the minimum yaw angle that the bone can look to
  52177. */
  52178. get minYaw(): number;
  52179. set minYaw(value: number);
  52180. /**
  52181. * Gets or sets the maximum yaw angle that the bone can look to
  52182. */
  52183. get maxYaw(): number;
  52184. set maxYaw(value: number);
  52185. /**
  52186. * Gets or sets the minimum pitch angle that the bone can look to
  52187. */
  52188. get minPitch(): number;
  52189. set minPitch(value: number);
  52190. /**
  52191. * Gets or sets the maximum pitch angle that the bone can look to
  52192. */
  52193. get maxPitch(): number;
  52194. set maxPitch(value: number);
  52195. /**
  52196. * Create a BoneLookController
  52197. * @param mesh the mesh that the bone belongs to
  52198. * @param bone the bone that will be looking to the target
  52199. * @param target the target Vector3 to look at
  52200. * @param options optional settings:
  52201. * * maxYaw: the maximum angle the bone will yaw to
  52202. * * minYaw: the minimum angle the bone will yaw to
  52203. * * maxPitch: the maximum angle the bone will pitch to
  52204. * * minPitch: the minimum angle the bone will yaw to
  52205. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  52206. * * upAxis: the up axis of the coordinate system
  52207. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  52208. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  52209. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  52210. * * adjustYaw: used to make an adjustment to the yaw of the bone
  52211. * * adjustPitch: used to make an adjustment to the pitch of the bone
  52212. * * adjustRoll: used to make an adjustment to the roll of the bone
  52213. **/
  52214. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  52215. maxYaw?: number;
  52216. minYaw?: number;
  52217. maxPitch?: number;
  52218. minPitch?: number;
  52219. slerpAmount?: number;
  52220. upAxis?: Vector3;
  52221. upAxisSpace?: Space;
  52222. yawAxis?: Vector3;
  52223. pitchAxis?: Vector3;
  52224. adjustYaw?: number;
  52225. adjustPitch?: number;
  52226. adjustRoll?: number;
  52227. });
  52228. /**
  52229. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  52230. */
  52231. update(): void;
  52232. private _getAngleDiff;
  52233. private _getAngleBetween;
  52234. private _isAngleBetween;
  52235. }
  52236. }
  52237. declare module "babylonjs/Bones/index" {
  52238. export * from "babylonjs/Bones/bone";
  52239. export * from "babylonjs/Bones/boneIKController";
  52240. export * from "babylonjs/Bones/boneLookController";
  52241. export * from "babylonjs/Bones/skeleton";
  52242. }
  52243. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  52244. import { Nullable } from "babylonjs/types";
  52245. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52247. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  52248. /**
  52249. * Manage the gamepad inputs to control an arc rotate camera.
  52250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52251. */
  52252. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  52253. /**
  52254. * Defines the camera the input is attached to.
  52255. */
  52256. camera: ArcRotateCamera;
  52257. /**
  52258. * Defines the gamepad the input is gathering event from.
  52259. */
  52260. gamepad: Nullable<Gamepad>;
  52261. /**
  52262. * Defines the gamepad rotation sensiblity.
  52263. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52264. */
  52265. gamepadRotationSensibility: number;
  52266. /**
  52267. * Defines the gamepad move sensiblity.
  52268. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52269. */
  52270. gamepadMoveSensibility: number;
  52271. private _yAxisScale;
  52272. /**
  52273. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52274. */
  52275. get invertYAxis(): boolean;
  52276. set invertYAxis(value: boolean);
  52277. private _onGamepadConnectedObserver;
  52278. private _onGamepadDisconnectedObserver;
  52279. /**
  52280. * Attach the input controls to a specific dom element to get the input from.
  52281. */
  52282. attachControl(): void;
  52283. /**
  52284. * Detach the current controls from the specified dom element.
  52285. */
  52286. detachControl(): void;
  52287. /**
  52288. * Update the current camera state depending on the inputs that have been used this frame.
  52289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52290. */
  52291. checkInputs(): void;
  52292. /**
  52293. * Gets the class name of the current intput.
  52294. * @returns the class name
  52295. */
  52296. getClassName(): string;
  52297. /**
  52298. * Get the friendly name associated with the input class.
  52299. * @returns the input friendly name
  52300. */
  52301. getSimpleName(): string;
  52302. }
  52303. }
  52304. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  52305. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52306. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52307. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  52308. interface ArcRotateCameraInputsManager {
  52309. /**
  52310. * Add orientation input support to the input manager.
  52311. * @returns the current input manager
  52312. */
  52313. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  52314. }
  52315. }
  52316. /**
  52317. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  52318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52319. */
  52320. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  52321. /**
  52322. * Defines the camera the input is attached to.
  52323. */
  52324. camera: ArcRotateCamera;
  52325. /**
  52326. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  52327. */
  52328. alphaCorrection: number;
  52329. /**
  52330. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  52331. */
  52332. gammaCorrection: number;
  52333. private _alpha;
  52334. private _gamma;
  52335. private _dirty;
  52336. private _deviceOrientationHandler;
  52337. /**
  52338. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  52339. */
  52340. constructor();
  52341. /**
  52342. * Attach the input controls to a specific dom element to get the input from.
  52343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52344. */
  52345. attachControl(noPreventDefault?: boolean): void;
  52346. /** @hidden */
  52347. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  52348. /**
  52349. * Update the current camera state depending on the inputs that have been used this frame.
  52350. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52351. */
  52352. checkInputs(): void;
  52353. /**
  52354. * Detach the current controls from the specified dom element.
  52355. */
  52356. detachControl(): void;
  52357. /**
  52358. * Gets the class name of the current intput.
  52359. * @returns the class name
  52360. */
  52361. getClassName(): string;
  52362. /**
  52363. * Get the friendly name associated with the input class.
  52364. * @returns the input friendly name
  52365. */
  52366. getSimpleName(): string;
  52367. }
  52368. }
  52369. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  52370. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52371. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52372. /**
  52373. * Listen to mouse events to control the camera.
  52374. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52375. */
  52376. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  52377. /**
  52378. * Defines the camera the input is attached to.
  52379. */
  52380. camera: FlyCamera;
  52381. /**
  52382. * Defines if touch is enabled. (Default is true.)
  52383. */
  52384. touchEnabled: boolean;
  52385. /**
  52386. * Defines the buttons associated with the input to handle camera rotation.
  52387. */
  52388. buttons: number[];
  52389. /**
  52390. * Assign buttons for Yaw control.
  52391. */
  52392. buttonsYaw: number[];
  52393. /**
  52394. * Assign buttons for Pitch control.
  52395. */
  52396. buttonsPitch: number[];
  52397. /**
  52398. * Assign buttons for Roll control.
  52399. */
  52400. buttonsRoll: number[];
  52401. /**
  52402. * Detect if any button is being pressed while mouse is moved.
  52403. * -1 = Mouse locked.
  52404. * 0 = Left button.
  52405. * 1 = Middle Button.
  52406. * 2 = Right Button.
  52407. */
  52408. activeButton: number;
  52409. /**
  52410. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  52411. * Higher values reduce its sensitivity.
  52412. */
  52413. angularSensibility: number;
  52414. private _observer;
  52415. private _rollObserver;
  52416. private previousPosition;
  52417. private noPreventDefault;
  52418. private element;
  52419. /**
  52420. * Listen to mouse events to control the camera.
  52421. * @param touchEnabled Define if touch is enabled. (Default is true.)
  52422. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52423. */
  52424. constructor(touchEnabled?: boolean);
  52425. /**
  52426. * Attach the mouse control to the HTML DOM element.
  52427. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  52428. */
  52429. attachControl(noPreventDefault?: boolean): void;
  52430. /**
  52431. * Detach the current controls from the specified dom element.
  52432. */
  52433. detachControl(): void;
  52434. /**
  52435. * Gets the class name of the current input.
  52436. * @returns the class name.
  52437. */
  52438. getClassName(): string;
  52439. /**
  52440. * Get the friendly name associated with the input class.
  52441. * @returns the input's friendly name.
  52442. */
  52443. getSimpleName(): string;
  52444. private _pointerInput;
  52445. private _onMouseMove;
  52446. /**
  52447. * Rotate camera by mouse offset.
  52448. */
  52449. private rotateCamera;
  52450. }
  52451. }
  52452. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  52453. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52454. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  52455. /**
  52456. * Default Inputs manager for the FlyCamera.
  52457. * It groups all the default supported inputs for ease of use.
  52458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52459. */
  52460. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  52461. /**
  52462. * Instantiates a new FlyCameraInputsManager.
  52463. * @param camera Defines the camera the inputs belong to.
  52464. */
  52465. constructor(camera: FlyCamera);
  52466. /**
  52467. * Add keyboard input support to the input manager.
  52468. * @returns the new FlyCameraKeyboardMoveInput().
  52469. */
  52470. addKeyboard(): FlyCameraInputsManager;
  52471. /**
  52472. * Add mouse input support to the input manager.
  52473. * @param touchEnabled Enable touch screen support.
  52474. * @returns the new FlyCameraMouseInput().
  52475. */
  52476. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  52477. }
  52478. }
  52479. declare module "babylonjs/Cameras/flyCamera" {
  52480. import { Scene } from "babylonjs/scene";
  52481. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52483. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  52484. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  52485. /**
  52486. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52487. * such as in a 3D Space Shooter or a Flight Simulator.
  52488. */
  52489. export class FlyCamera extends TargetCamera {
  52490. /**
  52491. * Define the collision ellipsoid of the camera.
  52492. * This is helpful for simulating a camera body, like a player's body.
  52493. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  52494. */
  52495. ellipsoid: Vector3;
  52496. /**
  52497. * Define an offset for the position of the ellipsoid around the camera.
  52498. * This can be helpful if the camera is attached away from the player's body center,
  52499. * such as at its head.
  52500. */
  52501. ellipsoidOffset: Vector3;
  52502. /**
  52503. * Enable or disable collisions of the camera with the rest of the scene objects.
  52504. */
  52505. checkCollisions: boolean;
  52506. /**
  52507. * Enable or disable gravity on the camera.
  52508. */
  52509. applyGravity: boolean;
  52510. /**
  52511. * Define the current direction the camera is moving to.
  52512. */
  52513. cameraDirection: Vector3;
  52514. /**
  52515. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  52516. * This overrides and empties cameraRotation.
  52517. */
  52518. rotationQuaternion: Quaternion;
  52519. /**
  52520. * Track Roll to maintain the wanted Rolling when looking around.
  52521. */
  52522. _trackRoll: number;
  52523. /**
  52524. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  52525. */
  52526. rollCorrect: number;
  52527. /**
  52528. * Mimic a banked turn, Rolling the camera when Yawing.
  52529. * It's recommended to use rollCorrect = 10 for faster banking correction.
  52530. */
  52531. bankedTurn: boolean;
  52532. /**
  52533. * Limit in radians for how much Roll banking will add. (Default: 90°)
  52534. */
  52535. bankedTurnLimit: number;
  52536. /**
  52537. * Value of 0 disables the banked Roll.
  52538. * Value of 1 is equal to the Yaw angle in radians.
  52539. */
  52540. bankedTurnMultiplier: number;
  52541. /**
  52542. * The inputs manager loads all the input sources, such as keyboard and mouse.
  52543. */
  52544. inputs: FlyCameraInputsManager;
  52545. /**
  52546. * Gets the input sensibility for mouse input.
  52547. * Higher values reduce sensitivity.
  52548. */
  52549. get angularSensibility(): number;
  52550. /**
  52551. * Sets the input sensibility for a mouse input.
  52552. * Higher values reduce sensitivity.
  52553. */
  52554. set angularSensibility(value: number);
  52555. /**
  52556. * Get the keys for camera movement forward.
  52557. */
  52558. get keysForward(): number[];
  52559. /**
  52560. * Set the keys for camera movement forward.
  52561. */
  52562. set keysForward(value: number[]);
  52563. /**
  52564. * Get the keys for camera movement backward.
  52565. */
  52566. get keysBackward(): number[];
  52567. set keysBackward(value: number[]);
  52568. /**
  52569. * Get the keys for camera movement up.
  52570. */
  52571. get keysUp(): number[];
  52572. /**
  52573. * Set the keys for camera movement up.
  52574. */
  52575. set keysUp(value: number[]);
  52576. /**
  52577. * Get the keys for camera movement down.
  52578. */
  52579. get keysDown(): number[];
  52580. /**
  52581. * Set the keys for camera movement down.
  52582. */
  52583. set keysDown(value: number[]);
  52584. /**
  52585. * Get the keys for camera movement left.
  52586. */
  52587. get keysLeft(): number[];
  52588. /**
  52589. * Set the keys for camera movement left.
  52590. */
  52591. set keysLeft(value: number[]);
  52592. /**
  52593. * Set the keys for camera movement right.
  52594. */
  52595. get keysRight(): number[];
  52596. /**
  52597. * Set the keys for camera movement right.
  52598. */
  52599. set keysRight(value: number[]);
  52600. /**
  52601. * Event raised when the camera collides with a mesh in the scene.
  52602. */
  52603. onCollide: (collidedMesh: AbstractMesh) => void;
  52604. private _collider;
  52605. private _needMoveForGravity;
  52606. private _oldPosition;
  52607. private _diffPosition;
  52608. private _newPosition;
  52609. /** @hidden */
  52610. _localDirection: Vector3;
  52611. /** @hidden */
  52612. _transformedDirection: Vector3;
  52613. /**
  52614. * Instantiates a FlyCamera.
  52615. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52616. * such as in a 3D Space Shooter or a Flight Simulator.
  52617. * @param name Define the name of the camera in the scene.
  52618. * @param position Define the starting position of the camera in the scene.
  52619. * @param scene Define the scene the camera belongs to.
  52620. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  52621. */
  52622. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52623. /**
  52624. * Attach the input controls to a specific dom element to get the input from.
  52625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52626. */
  52627. attachControl(noPreventDefault?: boolean): void;
  52628. /**
  52629. * Detach a control from the HTML DOM element.
  52630. * The camera will stop reacting to that input.
  52631. */
  52632. detachControl(): void;
  52633. private _collisionMask;
  52634. /**
  52635. * Get the mask that the camera ignores in collision events.
  52636. */
  52637. get collisionMask(): number;
  52638. /**
  52639. * Set the mask that the camera ignores in collision events.
  52640. */
  52641. set collisionMask(mask: number);
  52642. /** @hidden */
  52643. _collideWithWorld(displacement: Vector3): void;
  52644. /** @hidden */
  52645. private _onCollisionPositionChange;
  52646. /** @hidden */
  52647. _checkInputs(): void;
  52648. /** @hidden */
  52649. _decideIfNeedsToMove(): boolean;
  52650. /** @hidden */
  52651. _updatePosition(): void;
  52652. /**
  52653. * Restore the Roll to its target value at the rate specified.
  52654. * @param rate - Higher means slower restoring.
  52655. * @hidden
  52656. */
  52657. restoreRoll(rate: number): void;
  52658. /**
  52659. * Destroy the camera and release the current resources held by it.
  52660. */
  52661. dispose(): void;
  52662. /**
  52663. * Get the current object class name.
  52664. * @returns the class name.
  52665. */
  52666. getClassName(): string;
  52667. }
  52668. }
  52669. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  52670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52671. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52672. /**
  52673. * Listen to keyboard events to control the camera.
  52674. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52675. */
  52676. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52677. /**
  52678. * Defines the camera the input is attached to.
  52679. */
  52680. camera: FlyCamera;
  52681. /**
  52682. * The list of keyboard keys used to control the forward move of the camera.
  52683. */
  52684. keysForward: number[];
  52685. /**
  52686. * The list of keyboard keys used to control the backward move of the camera.
  52687. */
  52688. keysBackward: number[];
  52689. /**
  52690. * The list of keyboard keys used to control the forward move of the camera.
  52691. */
  52692. keysUp: number[];
  52693. /**
  52694. * The list of keyboard keys used to control the backward move of the camera.
  52695. */
  52696. keysDown: number[];
  52697. /**
  52698. * The list of keyboard keys used to control the right strafe move of the camera.
  52699. */
  52700. keysRight: number[];
  52701. /**
  52702. * The list of keyboard keys used to control the left strafe move of the camera.
  52703. */
  52704. keysLeft: number[];
  52705. private _keys;
  52706. private _onCanvasBlurObserver;
  52707. private _onKeyboardObserver;
  52708. private _engine;
  52709. private _scene;
  52710. /**
  52711. * Attach the input controls to a specific dom element to get the input from.
  52712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52713. */
  52714. attachControl(noPreventDefault?: boolean): void;
  52715. /**
  52716. * Detach the current controls from the specified dom element.
  52717. */
  52718. detachControl(): void;
  52719. /**
  52720. * Gets the class name of the current intput.
  52721. * @returns the class name
  52722. */
  52723. getClassName(): string;
  52724. /** @hidden */
  52725. _onLostFocus(e: FocusEvent): void;
  52726. /**
  52727. * Get the friendly name associated with the input class.
  52728. * @returns the input friendly name
  52729. */
  52730. getSimpleName(): string;
  52731. /**
  52732. * Update the current camera state depending on the inputs that have been used this frame.
  52733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52734. */
  52735. checkInputs(): void;
  52736. }
  52737. }
  52738. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  52739. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52740. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52741. /**
  52742. * Manage the mouse wheel inputs to control a follow camera.
  52743. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52744. */
  52745. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  52746. /**
  52747. * Defines the camera the input is attached to.
  52748. */
  52749. camera: FollowCamera;
  52750. /**
  52751. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  52752. */
  52753. axisControlRadius: boolean;
  52754. /**
  52755. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  52756. */
  52757. axisControlHeight: boolean;
  52758. /**
  52759. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  52760. */
  52761. axisControlRotation: boolean;
  52762. /**
  52763. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  52764. * relation to mouseWheel events.
  52765. */
  52766. wheelPrecision: number;
  52767. /**
  52768. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  52769. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  52770. */
  52771. wheelDeltaPercentage: number;
  52772. private _wheel;
  52773. private _observer;
  52774. /**
  52775. * Attach the input controls to a specific dom element to get the input from.
  52776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52777. */
  52778. attachControl(noPreventDefault?: boolean): void;
  52779. /**
  52780. * Detach the current controls from the specified dom element.
  52781. */
  52782. detachControl(): void;
  52783. /**
  52784. * Gets the class name of the current intput.
  52785. * @returns the class name
  52786. */
  52787. getClassName(): string;
  52788. /**
  52789. * Get the friendly name associated with the input class.
  52790. * @returns the input friendly name
  52791. */
  52792. getSimpleName(): string;
  52793. }
  52794. }
  52795. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  52796. import { Nullable } from "babylonjs/types";
  52797. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52798. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  52799. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  52800. /**
  52801. * Manage the pointers inputs to control an follow camera.
  52802. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52803. */
  52804. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  52805. /**
  52806. * Defines the camera the input is attached to.
  52807. */
  52808. camera: FollowCamera;
  52809. /**
  52810. * Gets the class name of the current input.
  52811. * @returns the class name
  52812. */
  52813. getClassName(): string;
  52814. /**
  52815. * Defines the pointer angular sensibility along the X axis or how fast is
  52816. * the camera rotating.
  52817. * A negative number will reverse the axis direction.
  52818. */
  52819. angularSensibilityX: number;
  52820. /**
  52821. * Defines the pointer angular sensibility along the Y axis or how fast is
  52822. * the camera rotating.
  52823. * A negative number will reverse the axis direction.
  52824. */
  52825. angularSensibilityY: number;
  52826. /**
  52827. * Defines the pointer pinch precision or how fast is the camera zooming.
  52828. * A negative number will reverse the axis direction.
  52829. */
  52830. pinchPrecision: number;
  52831. /**
  52832. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  52833. * from 0.
  52834. * It defines the percentage of current camera.radius to use as delta when
  52835. * pinch zoom is used.
  52836. */
  52837. pinchDeltaPercentage: number;
  52838. /**
  52839. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  52840. */
  52841. axisXControlRadius: boolean;
  52842. /**
  52843. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  52844. */
  52845. axisXControlHeight: boolean;
  52846. /**
  52847. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  52848. */
  52849. axisXControlRotation: boolean;
  52850. /**
  52851. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  52852. */
  52853. axisYControlRadius: boolean;
  52854. /**
  52855. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  52856. */
  52857. axisYControlHeight: boolean;
  52858. /**
  52859. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  52860. */
  52861. axisYControlRotation: boolean;
  52862. /**
  52863. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  52864. */
  52865. axisPinchControlRadius: boolean;
  52866. /**
  52867. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  52868. */
  52869. axisPinchControlHeight: boolean;
  52870. /**
  52871. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  52872. */
  52873. axisPinchControlRotation: boolean;
  52874. /**
  52875. * Log error messages if basic misconfiguration has occurred.
  52876. */
  52877. warningEnable: boolean;
  52878. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  52879. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  52880. private _warningCounter;
  52881. private _warning;
  52882. }
  52883. }
  52884. declare module "babylonjs/Cameras/followCameraInputsManager" {
  52885. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  52886. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52887. /**
  52888. * Default Inputs manager for the FollowCamera.
  52889. * It groups all the default supported inputs for ease of use.
  52890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52891. */
  52892. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  52893. /**
  52894. * Instantiates a new FollowCameraInputsManager.
  52895. * @param camera Defines the camera the inputs belong to
  52896. */
  52897. constructor(camera: FollowCamera);
  52898. /**
  52899. * Add keyboard input support to the input manager.
  52900. * @returns the current input manager
  52901. */
  52902. addKeyboard(): FollowCameraInputsManager;
  52903. /**
  52904. * Add mouse wheel input support to the input manager.
  52905. * @returns the current input manager
  52906. */
  52907. addMouseWheel(): FollowCameraInputsManager;
  52908. /**
  52909. * Add pointers input support to the input manager.
  52910. * @returns the current input manager
  52911. */
  52912. addPointers(): FollowCameraInputsManager;
  52913. /**
  52914. * Add orientation input support to the input manager.
  52915. * @returns the current input manager
  52916. */
  52917. addVRDeviceOrientation(): FollowCameraInputsManager;
  52918. }
  52919. }
  52920. declare module "babylonjs/Cameras/followCamera" {
  52921. import { Nullable } from "babylonjs/types";
  52922. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  52923. import { Scene } from "babylonjs/scene";
  52924. import { Vector3 } from "babylonjs/Maths/math.vector";
  52925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52926. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  52927. /**
  52928. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  52929. * an arc rotate version arcFollowCamera are available.
  52930. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52931. */
  52932. export class FollowCamera extends TargetCamera {
  52933. /**
  52934. * Distance the follow camera should follow an object at
  52935. */
  52936. radius: number;
  52937. /**
  52938. * Minimum allowed distance of the camera to the axis of rotation
  52939. * (The camera can not get closer).
  52940. * This can help limiting how the Camera is able to move in the scene.
  52941. */
  52942. lowerRadiusLimit: Nullable<number>;
  52943. /**
  52944. * Maximum allowed distance of the camera to the axis of rotation
  52945. * (The camera can not get further).
  52946. * This can help limiting how the Camera is able to move in the scene.
  52947. */
  52948. upperRadiusLimit: Nullable<number>;
  52949. /**
  52950. * Define a rotation offset between the camera and the object it follows
  52951. */
  52952. rotationOffset: number;
  52953. /**
  52954. * Minimum allowed angle to camera position relative to target object.
  52955. * This can help limiting how the Camera is able to move in the scene.
  52956. */
  52957. lowerRotationOffsetLimit: Nullable<number>;
  52958. /**
  52959. * Maximum allowed angle to camera position relative to target object.
  52960. * This can help limiting how the Camera is able to move in the scene.
  52961. */
  52962. upperRotationOffsetLimit: Nullable<number>;
  52963. /**
  52964. * Define a height offset between the camera and the object it follows.
  52965. * It can help following an object from the top (like a car chaing a plane)
  52966. */
  52967. heightOffset: number;
  52968. /**
  52969. * Minimum allowed height of camera position relative to target object.
  52970. * This can help limiting how the Camera is able to move in the scene.
  52971. */
  52972. lowerHeightOffsetLimit: Nullable<number>;
  52973. /**
  52974. * Maximum allowed height of camera position relative to target object.
  52975. * This can help limiting how the Camera is able to move in the scene.
  52976. */
  52977. upperHeightOffsetLimit: Nullable<number>;
  52978. /**
  52979. * Define how fast the camera can accelerate to follow it s target.
  52980. */
  52981. cameraAcceleration: number;
  52982. /**
  52983. * Define the speed limit of the camera following an object.
  52984. */
  52985. maxCameraSpeed: number;
  52986. /**
  52987. * Define the target of the camera.
  52988. */
  52989. lockedTarget: Nullable<AbstractMesh>;
  52990. /**
  52991. * Defines the input associated with the camera.
  52992. */
  52993. inputs: FollowCameraInputsManager;
  52994. /**
  52995. * Instantiates the follow camera.
  52996. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52997. * @param name Define the name of the camera in the scene
  52998. * @param position Define the position of the camera
  52999. * @param scene Define the scene the camera belong to
  53000. * @param lockedTarget Define the target of the camera
  53001. */
  53002. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  53003. private _follow;
  53004. /**
  53005. * Attach the input controls to a specific dom element to get the input from.
  53006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53007. */
  53008. attachControl(noPreventDefault?: boolean): void;
  53009. /**
  53010. * Detach the current controls from the specified dom element.
  53011. */
  53012. detachControl(): void;
  53013. /** @hidden */
  53014. _checkInputs(): void;
  53015. private _checkLimits;
  53016. /**
  53017. * Gets the camera class name.
  53018. * @returns the class name
  53019. */
  53020. getClassName(): string;
  53021. }
  53022. /**
  53023. * Arc Rotate version of the follow camera.
  53024. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  53025. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53026. */
  53027. export class ArcFollowCamera extends TargetCamera {
  53028. /** The longitudinal angle of the camera */
  53029. alpha: number;
  53030. /** The latitudinal angle of the camera */
  53031. beta: number;
  53032. /** The radius of the camera from its target */
  53033. radius: number;
  53034. private _cartesianCoordinates;
  53035. /** Define the camera target (the mesh it should follow) */
  53036. private _meshTarget;
  53037. /**
  53038. * Instantiates a new ArcFollowCamera
  53039. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53040. * @param name Define the name of the camera
  53041. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  53042. * @param beta Define the rotation angle of the camera around the elevation axis
  53043. * @param radius Define the radius of the camera from its target point
  53044. * @param target Define the target of the camera
  53045. * @param scene Define the scene the camera belongs to
  53046. */
  53047. constructor(name: string,
  53048. /** The longitudinal angle of the camera */
  53049. alpha: number,
  53050. /** The latitudinal angle of the camera */
  53051. beta: number,
  53052. /** The radius of the camera from its target */
  53053. radius: number,
  53054. /** Define the camera target (the mesh it should follow) */
  53055. target: Nullable<AbstractMesh>, scene: Scene);
  53056. private _follow;
  53057. /** @hidden */
  53058. _checkInputs(): void;
  53059. /**
  53060. * Returns the class name of the object.
  53061. * It is mostly used internally for serialization purposes.
  53062. */
  53063. getClassName(): string;
  53064. }
  53065. }
  53066. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  53067. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53068. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53069. /**
  53070. * Manage the keyboard inputs to control the movement of a follow camera.
  53071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53072. */
  53073. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  53074. /**
  53075. * Defines the camera the input is attached to.
  53076. */
  53077. camera: FollowCamera;
  53078. /**
  53079. * Defines the list of key codes associated with the up action (increase heightOffset)
  53080. */
  53081. keysHeightOffsetIncr: number[];
  53082. /**
  53083. * Defines the list of key codes associated with the down action (decrease heightOffset)
  53084. */
  53085. keysHeightOffsetDecr: number[];
  53086. /**
  53087. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  53088. */
  53089. keysHeightOffsetModifierAlt: boolean;
  53090. /**
  53091. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  53092. */
  53093. keysHeightOffsetModifierCtrl: boolean;
  53094. /**
  53095. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  53096. */
  53097. keysHeightOffsetModifierShift: boolean;
  53098. /**
  53099. * Defines the list of key codes associated with the left action (increase rotationOffset)
  53100. */
  53101. keysRotationOffsetIncr: number[];
  53102. /**
  53103. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  53104. */
  53105. keysRotationOffsetDecr: number[];
  53106. /**
  53107. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  53108. */
  53109. keysRotationOffsetModifierAlt: boolean;
  53110. /**
  53111. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  53112. */
  53113. keysRotationOffsetModifierCtrl: boolean;
  53114. /**
  53115. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  53116. */
  53117. keysRotationOffsetModifierShift: boolean;
  53118. /**
  53119. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  53120. */
  53121. keysRadiusIncr: number[];
  53122. /**
  53123. * Defines the list of key codes associated with the zoom-out action (increase radius)
  53124. */
  53125. keysRadiusDecr: number[];
  53126. /**
  53127. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  53128. */
  53129. keysRadiusModifierAlt: boolean;
  53130. /**
  53131. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  53132. */
  53133. keysRadiusModifierCtrl: boolean;
  53134. /**
  53135. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  53136. */
  53137. keysRadiusModifierShift: boolean;
  53138. /**
  53139. * Defines the rate of change of heightOffset.
  53140. */
  53141. heightSensibility: number;
  53142. /**
  53143. * Defines the rate of change of rotationOffset.
  53144. */
  53145. rotationSensibility: number;
  53146. /**
  53147. * Defines the rate of change of radius.
  53148. */
  53149. radiusSensibility: number;
  53150. private _keys;
  53151. private _ctrlPressed;
  53152. private _altPressed;
  53153. private _shiftPressed;
  53154. private _onCanvasBlurObserver;
  53155. private _onKeyboardObserver;
  53156. private _engine;
  53157. private _scene;
  53158. /**
  53159. * Attach the input controls to a specific dom element to get the input from.
  53160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53161. */
  53162. attachControl(noPreventDefault?: boolean): void;
  53163. /**
  53164. * Detach the current controls from the specified dom element.
  53165. */
  53166. detachControl(): void;
  53167. /**
  53168. * Update the current camera state depending on the inputs that have been used this frame.
  53169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53170. */
  53171. checkInputs(): void;
  53172. /**
  53173. * Gets the class name of the current input.
  53174. * @returns the class name
  53175. */
  53176. getClassName(): string;
  53177. /**
  53178. * Get the friendly name associated with the input class.
  53179. * @returns the input friendly name
  53180. */
  53181. getSimpleName(): string;
  53182. /**
  53183. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53184. * allow modification of the heightOffset value.
  53185. */
  53186. private _modifierHeightOffset;
  53187. /**
  53188. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53189. * allow modification of the rotationOffset value.
  53190. */
  53191. private _modifierRotationOffset;
  53192. /**
  53193. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53194. * allow modification of the radius value.
  53195. */
  53196. private _modifierRadius;
  53197. }
  53198. }
  53199. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  53200. import { Nullable } from "babylonjs/types";
  53201. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53203. import { Observable } from "babylonjs/Misc/observable";
  53204. module "babylonjs/Cameras/freeCameraInputsManager" {
  53205. interface FreeCameraInputsManager {
  53206. /**
  53207. * @hidden
  53208. */
  53209. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  53210. /**
  53211. * Add orientation input support to the input manager.
  53212. * @returns the current input manager
  53213. */
  53214. addDeviceOrientation(): FreeCameraInputsManager;
  53215. }
  53216. }
  53217. /**
  53218. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  53219. * Screen rotation is taken into account.
  53220. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53221. */
  53222. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  53223. private _camera;
  53224. private _screenOrientationAngle;
  53225. private _constantTranform;
  53226. private _screenQuaternion;
  53227. private _alpha;
  53228. private _beta;
  53229. private _gamma;
  53230. /**
  53231. * Can be used to detect if a device orientation sensor is available on a device
  53232. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  53233. * @returns a promise that will resolve on orientation change
  53234. */
  53235. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  53236. /**
  53237. * @hidden
  53238. */
  53239. _onDeviceOrientationChangedObservable: Observable<void>;
  53240. /**
  53241. * Instantiates a new input
  53242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53243. */
  53244. constructor();
  53245. /**
  53246. * Define the camera controlled by the input.
  53247. */
  53248. get camera(): FreeCamera;
  53249. set camera(camera: FreeCamera);
  53250. /**
  53251. * Attach the input controls to a specific dom element to get the input from.
  53252. */
  53253. attachControl(): void;
  53254. private _orientationChanged;
  53255. private _deviceOrientation;
  53256. /**
  53257. * Detach the current controls from the specified dom element.
  53258. */
  53259. detachControl(): void;
  53260. /**
  53261. * Update the current camera state depending on the inputs that have been used this frame.
  53262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53263. */
  53264. checkInputs(): void;
  53265. /**
  53266. * Gets the class name of the current intput.
  53267. * @returns the class name
  53268. */
  53269. getClassName(): string;
  53270. /**
  53271. * Get the friendly name associated with the input class.
  53272. * @returns the input friendly name
  53273. */
  53274. getSimpleName(): string;
  53275. }
  53276. }
  53277. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  53278. import { Nullable } from "babylonjs/types";
  53279. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53280. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53281. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53282. /**
  53283. * Manage the gamepad inputs to control a free camera.
  53284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53285. */
  53286. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  53287. /**
  53288. * Define the camera the input is attached to.
  53289. */
  53290. camera: FreeCamera;
  53291. /**
  53292. * Define the Gamepad controlling the input
  53293. */
  53294. gamepad: Nullable<Gamepad>;
  53295. /**
  53296. * Defines the gamepad rotation sensiblity.
  53297. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53298. */
  53299. gamepadAngularSensibility: number;
  53300. /**
  53301. * Defines the gamepad move sensiblity.
  53302. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53303. */
  53304. gamepadMoveSensibility: number;
  53305. private _yAxisScale;
  53306. /**
  53307. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  53308. */
  53309. get invertYAxis(): boolean;
  53310. set invertYAxis(value: boolean);
  53311. private _onGamepadConnectedObserver;
  53312. private _onGamepadDisconnectedObserver;
  53313. private _cameraTransform;
  53314. private _deltaTransform;
  53315. private _vector3;
  53316. private _vector2;
  53317. /**
  53318. * Attach the input controls to a specific dom element to get the input from.
  53319. */
  53320. attachControl(): void;
  53321. /**
  53322. * Detach the current controls from the specified dom element.
  53323. */
  53324. detachControl(): void;
  53325. /**
  53326. * Update the current camera state depending on the inputs that have been used this frame.
  53327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53328. */
  53329. checkInputs(): void;
  53330. /**
  53331. * Gets the class name of the current intput.
  53332. * @returns the class name
  53333. */
  53334. getClassName(): string;
  53335. /**
  53336. * Get the friendly name associated with the input class.
  53337. * @returns the input friendly name
  53338. */
  53339. getSimpleName(): string;
  53340. }
  53341. }
  53342. declare module "babylonjs/Misc/virtualJoystick" {
  53343. import { Nullable } from "babylonjs/types";
  53344. import { Vector3 } from "babylonjs/Maths/math.vector";
  53345. /**
  53346. * Defines the potential axis of a Joystick
  53347. */
  53348. export enum JoystickAxis {
  53349. /** X axis */
  53350. X = 0,
  53351. /** Y axis */
  53352. Y = 1,
  53353. /** Z axis */
  53354. Z = 2
  53355. }
  53356. /**
  53357. * Represents the different customization options available
  53358. * for VirtualJoystick
  53359. */
  53360. interface VirtualJoystickCustomizations {
  53361. /**
  53362. * Size of the joystick's puck
  53363. */
  53364. puckSize: number;
  53365. /**
  53366. * Size of the joystick's container
  53367. */
  53368. containerSize: number;
  53369. /**
  53370. * Color of the joystick && puck
  53371. */
  53372. color: string;
  53373. /**
  53374. * Image URL for the joystick's puck
  53375. */
  53376. puckImage?: string;
  53377. /**
  53378. * Image URL for the joystick's container
  53379. */
  53380. containerImage?: string;
  53381. /**
  53382. * Defines the unmoving position of the joystick container
  53383. */
  53384. position?: {
  53385. x: number;
  53386. y: number;
  53387. };
  53388. /**
  53389. * Defines whether or not the joystick container is always visible
  53390. */
  53391. alwaysVisible: boolean;
  53392. /**
  53393. * Defines whether or not to limit the movement of the puck to the joystick's container
  53394. */
  53395. limitToContainer: boolean;
  53396. }
  53397. /**
  53398. * Class used to define virtual joystick (used in touch mode)
  53399. */
  53400. export class VirtualJoystick {
  53401. /**
  53402. * Gets or sets a boolean indicating that left and right values must be inverted
  53403. */
  53404. reverseLeftRight: boolean;
  53405. /**
  53406. * Gets or sets a boolean indicating that up and down values must be inverted
  53407. */
  53408. reverseUpDown: boolean;
  53409. /**
  53410. * Gets the offset value for the position (ie. the change of the position value)
  53411. */
  53412. deltaPosition: Vector3;
  53413. /**
  53414. * Gets a boolean indicating if the virtual joystick was pressed
  53415. */
  53416. pressed: boolean;
  53417. /**
  53418. * Canvas the virtual joystick will render onto, default z-index of this is 5
  53419. */
  53420. static Canvas: Nullable<HTMLCanvasElement>;
  53421. /**
  53422. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  53423. */
  53424. limitToContainer: boolean;
  53425. private static _globalJoystickIndex;
  53426. private static _alwaysVisibleSticks;
  53427. private static vjCanvasContext;
  53428. private static vjCanvasWidth;
  53429. private static vjCanvasHeight;
  53430. private static halfWidth;
  53431. private static _GetDefaultOptions;
  53432. private _action;
  53433. private _axisTargetedByLeftAndRight;
  53434. private _axisTargetedByUpAndDown;
  53435. private _joystickSensibility;
  53436. private _inversedSensibility;
  53437. private _joystickPointerID;
  53438. private _joystickColor;
  53439. private _joystickPointerPos;
  53440. private _joystickPreviousPointerPos;
  53441. private _joystickPointerStartPos;
  53442. private _deltaJoystickVector;
  53443. private _leftJoystick;
  53444. private _touches;
  53445. private _joystickPosition;
  53446. private _alwaysVisible;
  53447. private _puckImage;
  53448. private _containerImage;
  53449. private _joystickPuckSize;
  53450. private _joystickContainerSize;
  53451. private _clearPuckSize;
  53452. private _clearContainerSize;
  53453. private _clearPuckSizeOffset;
  53454. private _clearContainerSizeOffset;
  53455. private _onPointerDownHandlerRef;
  53456. private _onPointerMoveHandlerRef;
  53457. private _onPointerUpHandlerRef;
  53458. private _onResize;
  53459. /**
  53460. * Creates a new virtual joystick
  53461. * @param leftJoystick defines that the joystick is for left hand (false by default)
  53462. * @param customizations Defines the options we want to customize the VirtualJoystick
  53463. */
  53464. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  53465. /**
  53466. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  53467. * @param newJoystickSensibility defines the new sensibility
  53468. */
  53469. setJoystickSensibility(newJoystickSensibility: number): void;
  53470. private _onPointerDown;
  53471. private _onPointerMove;
  53472. private _onPointerUp;
  53473. /**
  53474. * Change the color of the virtual joystick
  53475. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  53476. */
  53477. setJoystickColor(newColor: string): void;
  53478. /**
  53479. * Size of the joystick's container
  53480. */
  53481. set containerSize(newSize: number);
  53482. get containerSize(): number;
  53483. /**
  53484. * Size of the joystick's puck
  53485. */
  53486. set puckSize(newSize: number);
  53487. get puckSize(): number;
  53488. /**
  53489. * Clears the set position of the joystick
  53490. */
  53491. clearPosition(): void;
  53492. /**
  53493. * Defines whether or not the joystick container is always visible
  53494. */
  53495. set alwaysVisible(value: boolean);
  53496. get alwaysVisible(): boolean;
  53497. /**
  53498. * Sets the constant position of the Joystick container
  53499. * @param x X axis coordinate
  53500. * @param y Y axis coordinate
  53501. */
  53502. setPosition(x: number, y: number): void;
  53503. /**
  53504. * Defines a callback to call when the joystick is touched
  53505. * @param action defines the callback
  53506. */
  53507. setActionOnTouch(action: () => any): void;
  53508. /**
  53509. * Defines which axis you'd like to control for left & right
  53510. * @param axis defines the axis to use
  53511. */
  53512. setAxisForLeftRight(axis: JoystickAxis): void;
  53513. /**
  53514. * Defines which axis you'd like to control for up & down
  53515. * @param axis defines the axis to use
  53516. */
  53517. setAxisForUpDown(axis: JoystickAxis): void;
  53518. /**
  53519. * Clears the canvas from the previous puck / container draw
  53520. */
  53521. private _clearPreviousDraw;
  53522. /**
  53523. * Loads `urlPath` to be used for the container's image
  53524. * @param urlPath defines the urlPath of an image to use
  53525. */
  53526. setContainerImage(urlPath: string): void;
  53527. /**
  53528. * Loads `urlPath` to be used for the puck's image
  53529. * @param urlPath defines the urlPath of an image to use
  53530. */
  53531. setPuckImage(urlPath: string): void;
  53532. /**
  53533. * Draws the Virtual Joystick's container
  53534. */
  53535. private _drawContainer;
  53536. /**
  53537. * Draws the Virtual Joystick's puck
  53538. */
  53539. private _drawPuck;
  53540. private _drawVirtualJoystick;
  53541. /**
  53542. * Release internal HTML canvas
  53543. */
  53544. releaseCanvas(): void;
  53545. }
  53546. }
  53547. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  53548. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  53549. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53550. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53551. module "babylonjs/Cameras/freeCameraInputsManager" {
  53552. interface FreeCameraInputsManager {
  53553. /**
  53554. * Add virtual joystick input support to the input manager.
  53555. * @returns the current input manager
  53556. */
  53557. addVirtualJoystick(): FreeCameraInputsManager;
  53558. }
  53559. }
  53560. /**
  53561. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  53562. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53563. */
  53564. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  53565. /**
  53566. * Defines the camera the input is attached to.
  53567. */
  53568. camera: FreeCamera;
  53569. private _leftjoystick;
  53570. private _rightjoystick;
  53571. /**
  53572. * Gets the left stick of the virtual joystick.
  53573. * @returns The virtual Joystick
  53574. */
  53575. getLeftJoystick(): VirtualJoystick;
  53576. /**
  53577. * Gets the right stick of the virtual joystick.
  53578. * @returns The virtual Joystick
  53579. */
  53580. getRightJoystick(): VirtualJoystick;
  53581. /**
  53582. * Update the current camera state depending on the inputs that have been used this frame.
  53583. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53584. */
  53585. checkInputs(): void;
  53586. /**
  53587. * Attach the input controls to a specific dom element to get the input from.
  53588. */
  53589. attachControl(): void;
  53590. /**
  53591. * Detach the current controls from the specified dom element.
  53592. */
  53593. detachControl(): void;
  53594. /**
  53595. * Gets the class name of the current intput.
  53596. * @returns the class name
  53597. */
  53598. getClassName(): string;
  53599. /**
  53600. * Get the friendly name associated with the input class.
  53601. * @returns the input friendly name
  53602. */
  53603. getSimpleName(): string;
  53604. }
  53605. }
  53606. declare module "babylonjs/Cameras/Inputs/index" {
  53607. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  53608. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  53609. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  53610. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  53611. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  53612. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  53613. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  53614. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  53615. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  53616. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  53617. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53618. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  53619. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  53620. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  53621. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  53622. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  53623. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  53624. }
  53625. declare module "babylonjs/Cameras/touchCamera" {
  53626. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53627. import { Scene } from "babylonjs/scene";
  53628. import { Vector3 } from "babylonjs/Maths/math.vector";
  53629. /**
  53630. * This represents a FPS type of camera controlled by touch.
  53631. * This is like a universal camera minus the Gamepad controls.
  53632. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53633. */
  53634. export class TouchCamera extends FreeCamera {
  53635. /**
  53636. * Defines the touch sensibility for rotation.
  53637. * The higher the faster.
  53638. */
  53639. get touchAngularSensibility(): number;
  53640. set touchAngularSensibility(value: number);
  53641. /**
  53642. * Defines the touch sensibility for move.
  53643. * The higher the faster.
  53644. */
  53645. get touchMoveSensibility(): number;
  53646. set touchMoveSensibility(value: number);
  53647. /**
  53648. * Instantiates a new touch camera.
  53649. * This represents a FPS type of camera controlled by touch.
  53650. * This is like a universal camera minus the Gamepad controls.
  53651. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53652. * @param name Define the name of the camera in the scene
  53653. * @param position Define the start position of the camera in the scene
  53654. * @param scene Define the scene the camera belongs to
  53655. */
  53656. constructor(name: string, position: Vector3, scene: Scene);
  53657. /**
  53658. * Gets the current object class name.
  53659. * @return the class name
  53660. */
  53661. getClassName(): string;
  53662. /** @hidden */
  53663. _setupInputs(): void;
  53664. }
  53665. }
  53666. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  53667. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53668. import { Scene } from "babylonjs/scene";
  53669. import { Vector3 } from "babylonjs/Maths/math.vector";
  53670. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53671. import { Axis } from "babylonjs/Maths/math.axis";
  53672. /**
  53673. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53674. * being tilted forward or back and left or right.
  53675. */
  53676. export class DeviceOrientationCamera extends FreeCamera {
  53677. private _initialQuaternion;
  53678. private _quaternionCache;
  53679. private _tmpDragQuaternion;
  53680. private _disablePointerInputWhenUsingDeviceOrientation;
  53681. /**
  53682. * Creates a new device orientation camera
  53683. * @param name The name of the camera
  53684. * @param position The start position camera
  53685. * @param scene The scene the camera belongs to
  53686. */
  53687. constructor(name: string, position: Vector3, scene: Scene);
  53688. /**
  53689. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53690. */
  53691. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53692. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53693. private _dragFactor;
  53694. /**
  53695. * Enabled turning on the y axis when the orientation sensor is active
  53696. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53697. */
  53698. enableHorizontalDragging(dragFactor?: number): void;
  53699. /**
  53700. * Gets the current instance class name ("DeviceOrientationCamera").
  53701. * This helps avoiding instanceof at run time.
  53702. * @returns the class name
  53703. */
  53704. getClassName(): string;
  53705. /**
  53706. * @hidden
  53707. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  53708. */
  53709. _checkInputs(): void;
  53710. /**
  53711. * Reset the camera to its default orientation on the specified axis only.
  53712. * @param axis The axis to reset
  53713. */
  53714. resetToCurrentRotation(axis?: Axis): void;
  53715. }
  53716. }
  53717. declare module "babylonjs/Gamepads/xboxGamepad" {
  53718. import { Observable } from "babylonjs/Misc/observable";
  53719. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53720. /**
  53721. * Defines supported buttons for XBox360 compatible gamepads
  53722. */
  53723. export enum Xbox360Button {
  53724. /** A */
  53725. A = 0,
  53726. /** B */
  53727. B = 1,
  53728. /** X */
  53729. X = 2,
  53730. /** Y */
  53731. Y = 3,
  53732. /** Left button */
  53733. LB = 4,
  53734. /** Right button */
  53735. RB = 5,
  53736. /** Back */
  53737. Back = 8,
  53738. /** Start */
  53739. Start = 9,
  53740. /** Left stick */
  53741. LeftStick = 10,
  53742. /** Right stick */
  53743. RightStick = 11
  53744. }
  53745. /** Defines values for XBox360 DPad */
  53746. export enum Xbox360Dpad {
  53747. /** Up */
  53748. Up = 12,
  53749. /** Down */
  53750. Down = 13,
  53751. /** Left */
  53752. Left = 14,
  53753. /** Right */
  53754. Right = 15
  53755. }
  53756. /**
  53757. * Defines a XBox360 gamepad
  53758. */
  53759. export class Xbox360Pad extends Gamepad {
  53760. private _leftTrigger;
  53761. private _rightTrigger;
  53762. private _onlefttriggerchanged;
  53763. private _onrighttriggerchanged;
  53764. private _onbuttondown;
  53765. private _onbuttonup;
  53766. private _ondpaddown;
  53767. private _ondpadup;
  53768. /** Observable raised when a button is pressed */
  53769. onButtonDownObservable: Observable<Xbox360Button>;
  53770. /** Observable raised when a button is released */
  53771. onButtonUpObservable: Observable<Xbox360Button>;
  53772. /** Observable raised when a pad is pressed */
  53773. onPadDownObservable: Observable<Xbox360Dpad>;
  53774. /** Observable raised when a pad is released */
  53775. onPadUpObservable: Observable<Xbox360Dpad>;
  53776. private _buttonA;
  53777. private _buttonB;
  53778. private _buttonX;
  53779. private _buttonY;
  53780. private _buttonBack;
  53781. private _buttonStart;
  53782. private _buttonLB;
  53783. private _buttonRB;
  53784. private _buttonLeftStick;
  53785. private _buttonRightStick;
  53786. private _dPadUp;
  53787. private _dPadDown;
  53788. private _dPadLeft;
  53789. private _dPadRight;
  53790. private _isXboxOnePad;
  53791. /**
  53792. * Creates a new XBox360 gamepad object
  53793. * @param id defines the id of this gamepad
  53794. * @param index defines its index
  53795. * @param gamepad defines the internal HTML gamepad object
  53796. * @param xboxOne defines if it is a XBox One gamepad
  53797. */
  53798. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  53799. /**
  53800. * Defines the callback to call when left trigger is pressed
  53801. * @param callback defines the callback to use
  53802. */
  53803. onlefttriggerchanged(callback: (value: number) => void): void;
  53804. /**
  53805. * Defines the callback to call when right trigger is pressed
  53806. * @param callback defines the callback to use
  53807. */
  53808. onrighttriggerchanged(callback: (value: number) => void): void;
  53809. /**
  53810. * Gets the left trigger value
  53811. */
  53812. get leftTrigger(): number;
  53813. /**
  53814. * Sets the left trigger value
  53815. */
  53816. set leftTrigger(newValue: number);
  53817. /**
  53818. * Gets the right trigger value
  53819. */
  53820. get rightTrigger(): number;
  53821. /**
  53822. * Sets the right trigger value
  53823. */
  53824. set rightTrigger(newValue: number);
  53825. /**
  53826. * Defines the callback to call when a button is pressed
  53827. * @param callback defines the callback to use
  53828. */
  53829. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  53830. /**
  53831. * Defines the callback to call when a button is released
  53832. * @param callback defines the callback to use
  53833. */
  53834. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  53835. /**
  53836. * Defines the callback to call when a pad is pressed
  53837. * @param callback defines the callback to use
  53838. */
  53839. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  53840. /**
  53841. * Defines the callback to call when a pad is released
  53842. * @param callback defines the callback to use
  53843. */
  53844. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  53845. private _setButtonValue;
  53846. private _setDPadValue;
  53847. /**
  53848. * Gets the value of the `A` button
  53849. */
  53850. get buttonA(): number;
  53851. /**
  53852. * Sets the value of the `A` button
  53853. */
  53854. set buttonA(value: number);
  53855. /**
  53856. * Gets the value of the `B` button
  53857. */
  53858. get buttonB(): number;
  53859. /**
  53860. * Sets the value of the `B` button
  53861. */
  53862. set buttonB(value: number);
  53863. /**
  53864. * Gets the value of the `X` button
  53865. */
  53866. get buttonX(): number;
  53867. /**
  53868. * Sets the value of the `X` button
  53869. */
  53870. set buttonX(value: number);
  53871. /**
  53872. * Gets the value of the `Y` button
  53873. */
  53874. get buttonY(): number;
  53875. /**
  53876. * Sets the value of the `Y` button
  53877. */
  53878. set buttonY(value: number);
  53879. /**
  53880. * Gets the value of the `Start` button
  53881. */
  53882. get buttonStart(): number;
  53883. /**
  53884. * Sets the value of the `Start` button
  53885. */
  53886. set buttonStart(value: number);
  53887. /**
  53888. * Gets the value of the `Back` button
  53889. */
  53890. get buttonBack(): number;
  53891. /**
  53892. * Sets the value of the `Back` button
  53893. */
  53894. set buttonBack(value: number);
  53895. /**
  53896. * Gets the value of the `Left` button
  53897. */
  53898. get buttonLB(): number;
  53899. /**
  53900. * Sets the value of the `Left` button
  53901. */
  53902. set buttonLB(value: number);
  53903. /**
  53904. * Gets the value of the `Right` button
  53905. */
  53906. get buttonRB(): number;
  53907. /**
  53908. * Sets the value of the `Right` button
  53909. */
  53910. set buttonRB(value: number);
  53911. /**
  53912. * Gets the value of the Left joystick
  53913. */
  53914. get buttonLeftStick(): number;
  53915. /**
  53916. * Sets the value of the Left joystick
  53917. */
  53918. set buttonLeftStick(value: number);
  53919. /**
  53920. * Gets the value of the Right joystick
  53921. */
  53922. get buttonRightStick(): number;
  53923. /**
  53924. * Sets the value of the Right joystick
  53925. */
  53926. set buttonRightStick(value: number);
  53927. /**
  53928. * Gets the value of D-pad up
  53929. */
  53930. get dPadUp(): number;
  53931. /**
  53932. * Sets the value of D-pad up
  53933. */
  53934. set dPadUp(value: number);
  53935. /**
  53936. * Gets the value of D-pad down
  53937. */
  53938. get dPadDown(): number;
  53939. /**
  53940. * Sets the value of D-pad down
  53941. */
  53942. set dPadDown(value: number);
  53943. /**
  53944. * Gets the value of D-pad left
  53945. */
  53946. get dPadLeft(): number;
  53947. /**
  53948. * Sets the value of D-pad left
  53949. */
  53950. set dPadLeft(value: number);
  53951. /**
  53952. * Gets the value of D-pad right
  53953. */
  53954. get dPadRight(): number;
  53955. /**
  53956. * Sets the value of D-pad right
  53957. */
  53958. set dPadRight(value: number);
  53959. /**
  53960. * Force the gamepad to synchronize with device values
  53961. */
  53962. update(): void;
  53963. /**
  53964. * Disposes the gamepad
  53965. */
  53966. dispose(): void;
  53967. }
  53968. }
  53969. declare module "babylonjs/Gamepads/dualShockGamepad" {
  53970. import { Observable } from "babylonjs/Misc/observable";
  53971. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53972. /**
  53973. * Defines supported buttons for DualShock compatible gamepads
  53974. */
  53975. export enum DualShockButton {
  53976. /** Cross */
  53977. Cross = 0,
  53978. /** Circle */
  53979. Circle = 1,
  53980. /** Square */
  53981. Square = 2,
  53982. /** Triangle */
  53983. Triangle = 3,
  53984. /** L1 */
  53985. L1 = 4,
  53986. /** R1 */
  53987. R1 = 5,
  53988. /** Share */
  53989. Share = 8,
  53990. /** Options */
  53991. Options = 9,
  53992. /** Left stick */
  53993. LeftStick = 10,
  53994. /** Right stick */
  53995. RightStick = 11
  53996. }
  53997. /** Defines values for DualShock DPad */
  53998. export enum DualShockDpad {
  53999. /** Up */
  54000. Up = 12,
  54001. /** Down */
  54002. Down = 13,
  54003. /** Left */
  54004. Left = 14,
  54005. /** Right */
  54006. Right = 15
  54007. }
  54008. /**
  54009. * Defines a DualShock gamepad
  54010. */
  54011. export class DualShockPad extends Gamepad {
  54012. private _leftTrigger;
  54013. private _rightTrigger;
  54014. private _onlefttriggerchanged;
  54015. private _onrighttriggerchanged;
  54016. private _onbuttondown;
  54017. private _onbuttonup;
  54018. private _ondpaddown;
  54019. private _ondpadup;
  54020. /** Observable raised when a button is pressed */
  54021. onButtonDownObservable: Observable<DualShockButton>;
  54022. /** Observable raised when a button is released */
  54023. onButtonUpObservable: Observable<DualShockButton>;
  54024. /** Observable raised when a pad is pressed */
  54025. onPadDownObservable: Observable<DualShockDpad>;
  54026. /** Observable raised when a pad is released */
  54027. onPadUpObservable: Observable<DualShockDpad>;
  54028. private _buttonCross;
  54029. private _buttonCircle;
  54030. private _buttonSquare;
  54031. private _buttonTriangle;
  54032. private _buttonShare;
  54033. private _buttonOptions;
  54034. private _buttonL1;
  54035. private _buttonR1;
  54036. private _buttonLeftStick;
  54037. private _buttonRightStick;
  54038. private _dPadUp;
  54039. private _dPadDown;
  54040. private _dPadLeft;
  54041. private _dPadRight;
  54042. /**
  54043. * Creates a new DualShock gamepad object
  54044. * @param id defines the id of this gamepad
  54045. * @param index defines its index
  54046. * @param gamepad defines the internal HTML gamepad object
  54047. */
  54048. constructor(id: string, index: number, gamepad: any);
  54049. /**
  54050. * Defines the callback to call when left trigger is pressed
  54051. * @param callback defines the callback to use
  54052. */
  54053. onlefttriggerchanged(callback: (value: number) => void): void;
  54054. /**
  54055. * Defines the callback to call when right trigger is pressed
  54056. * @param callback defines the callback to use
  54057. */
  54058. onrighttriggerchanged(callback: (value: number) => void): void;
  54059. /**
  54060. * Gets the left trigger value
  54061. */
  54062. get leftTrigger(): number;
  54063. /**
  54064. * Sets the left trigger value
  54065. */
  54066. set leftTrigger(newValue: number);
  54067. /**
  54068. * Gets the right trigger value
  54069. */
  54070. get rightTrigger(): number;
  54071. /**
  54072. * Sets the right trigger value
  54073. */
  54074. set rightTrigger(newValue: number);
  54075. /**
  54076. * Defines the callback to call when a button is pressed
  54077. * @param callback defines the callback to use
  54078. */
  54079. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  54080. /**
  54081. * Defines the callback to call when a button is released
  54082. * @param callback defines the callback to use
  54083. */
  54084. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  54085. /**
  54086. * Defines the callback to call when a pad is pressed
  54087. * @param callback defines the callback to use
  54088. */
  54089. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  54090. /**
  54091. * Defines the callback to call when a pad is released
  54092. * @param callback defines the callback to use
  54093. */
  54094. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  54095. private _setButtonValue;
  54096. private _setDPadValue;
  54097. /**
  54098. * Gets the value of the `Cross` button
  54099. */
  54100. get buttonCross(): number;
  54101. /**
  54102. * Sets the value of the `Cross` button
  54103. */
  54104. set buttonCross(value: number);
  54105. /**
  54106. * Gets the value of the `Circle` button
  54107. */
  54108. get buttonCircle(): number;
  54109. /**
  54110. * Sets the value of the `Circle` button
  54111. */
  54112. set buttonCircle(value: number);
  54113. /**
  54114. * Gets the value of the `Square` button
  54115. */
  54116. get buttonSquare(): number;
  54117. /**
  54118. * Sets the value of the `Square` button
  54119. */
  54120. set buttonSquare(value: number);
  54121. /**
  54122. * Gets the value of the `Triangle` button
  54123. */
  54124. get buttonTriangle(): number;
  54125. /**
  54126. * Sets the value of the `Triangle` button
  54127. */
  54128. set buttonTriangle(value: number);
  54129. /**
  54130. * Gets the value of the `Options` button
  54131. */
  54132. get buttonOptions(): number;
  54133. /**
  54134. * Sets the value of the `Options` button
  54135. */
  54136. set buttonOptions(value: number);
  54137. /**
  54138. * Gets the value of the `Share` button
  54139. */
  54140. get buttonShare(): number;
  54141. /**
  54142. * Sets the value of the `Share` button
  54143. */
  54144. set buttonShare(value: number);
  54145. /**
  54146. * Gets the value of the `L1` button
  54147. */
  54148. get buttonL1(): number;
  54149. /**
  54150. * Sets the value of the `L1` button
  54151. */
  54152. set buttonL1(value: number);
  54153. /**
  54154. * Gets the value of the `R1` button
  54155. */
  54156. get buttonR1(): number;
  54157. /**
  54158. * Sets the value of the `R1` button
  54159. */
  54160. set buttonR1(value: number);
  54161. /**
  54162. * Gets the value of the Left joystick
  54163. */
  54164. get buttonLeftStick(): number;
  54165. /**
  54166. * Sets the value of the Left joystick
  54167. */
  54168. set buttonLeftStick(value: number);
  54169. /**
  54170. * Gets the value of the Right joystick
  54171. */
  54172. get buttonRightStick(): number;
  54173. /**
  54174. * Sets the value of the Right joystick
  54175. */
  54176. set buttonRightStick(value: number);
  54177. /**
  54178. * Gets the value of D-pad up
  54179. */
  54180. get dPadUp(): number;
  54181. /**
  54182. * Sets the value of D-pad up
  54183. */
  54184. set dPadUp(value: number);
  54185. /**
  54186. * Gets the value of D-pad down
  54187. */
  54188. get dPadDown(): number;
  54189. /**
  54190. * Sets the value of D-pad down
  54191. */
  54192. set dPadDown(value: number);
  54193. /**
  54194. * Gets the value of D-pad left
  54195. */
  54196. get dPadLeft(): number;
  54197. /**
  54198. * Sets the value of D-pad left
  54199. */
  54200. set dPadLeft(value: number);
  54201. /**
  54202. * Gets the value of D-pad right
  54203. */
  54204. get dPadRight(): number;
  54205. /**
  54206. * Sets the value of D-pad right
  54207. */
  54208. set dPadRight(value: number);
  54209. /**
  54210. * Force the gamepad to synchronize with device values
  54211. */
  54212. update(): void;
  54213. /**
  54214. * Disposes the gamepad
  54215. */
  54216. dispose(): void;
  54217. }
  54218. }
  54219. declare module "babylonjs/Gamepads/gamepadManager" {
  54220. import { Observable } from "babylonjs/Misc/observable";
  54221. import { Nullable } from "babylonjs/types";
  54222. import { Scene } from "babylonjs/scene";
  54223. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54224. /**
  54225. * Manager for handling gamepads
  54226. */
  54227. export class GamepadManager {
  54228. private _scene?;
  54229. private _babylonGamepads;
  54230. private _oneGamepadConnected;
  54231. /** @hidden */
  54232. _isMonitoring: boolean;
  54233. private _gamepadEventSupported;
  54234. private _gamepadSupport?;
  54235. /**
  54236. * observable to be triggered when the gamepad controller has been connected
  54237. */
  54238. onGamepadConnectedObservable: Observable<Gamepad>;
  54239. /**
  54240. * observable to be triggered when the gamepad controller has been disconnected
  54241. */
  54242. onGamepadDisconnectedObservable: Observable<Gamepad>;
  54243. private _onGamepadConnectedEvent;
  54244. private _onGamepadDisconnectedEvent;
  54245. /**
  54246. * Initializes the gamepad manager
  54247. * @param _scene BabylonJS scene
  54248. */
  54249. constructor(_scene?: Scene | undefined);
  54250. /**
  54251. * The gamepads in the game pad manager
  54252. */
  54253. get gamepads(): Gamepad[];
  54254. /**
  54255. * Get the gamepad controllers based on type
  54256. * @param type The type of gamepad controller
  54257. * @returns Nullable gamepad
  54258. */
  54259. getGamepadByType(type?: number): Nullable<Gamepad>;
  54260. /**
  54261. * Disposes the gamepad manager
  54262. */
  54263. dispose(): void;
  54264. private _addNewGamepad;
  54265. private _startMonitoringGamepads;
  54266. private _stopMonitoringGamepads;
  54267. /** @hidden */
  54268. _checkGamepadsStatus(): void;
  54269. private _updateGamepadObjects;
  54270. }
  54271. }
  54272. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  54273. import { Nullable } from "babylonjs/types";
  54274. import { Scene } from "babylonjs/scene";
  54275. import { ISceneComponent } from "babylonjs/sceneComponent";
  54276. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  54277. module "babylonjs/scene" {
  54278. interface Scene {
  54279. /** @hidden */
  54280. _gamepadManager: Nullable<GamepadManager>;
  54281. /**
  54282. * Gets the gamepad manager associated with the scene
  54283. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  54284. */
  54285. gamepadManager: GamepadManager;
  54286. }
  54287. }
  54288. module "babylonjs/Cameras/freeCameraInputsManager" {
  54289. /**
  54290. * Interface representing a free camera inputs manager
  54291. */
  54292. interface FreeCameraInputsManager {
  54293. /**
  54294. * Adds gamepad input support to the FreeCameraInputsManager.
  54295. * @returns the FreeCameraInputsManager
  54296. */
  54297. addGamepad(): FreeCameraInputsManager;
  54298. }
  54299. }
  54300. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  54301. /**
  54302. * Interface representing an arc rotate camera inputs manager
  54303. */
  54304. interface ArcRotateCameraInputsManager {
  54305. /**
  54306. * Adds gamepad input support to the ArcRotateCamera InputManager.
  54307. * @returns the camera inputs manager
  54308. */
  54309. addGamepad(): ArcRotateCameraInputsManager;
  54310. }
  54311. }
  54312. /**
  54313. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  54314. */
  54315. export class GamepadSystemSceneComponent implements ISceneComponent {
  54316. /**
  54317. * The component name helpfull to identify the component in the list of scene components.
  54318. */
  54319. readonly name: string;
  54320. /**
  54321. * The scene the component belongs to.
  54322. */
  54323. scene: Scene;
  54324. /**
  54325. * Creates a new instance of the component for the given scene
  54326. * @param scene Defines the scene to register the component in
  54327. */
  54328. constructor(scene: Scene);
  54329. /**
  54330. * Registers the component in a given scene
  54331. */
  54332. register(): void;
  54333. /**
  54334. * Rebuilds the elements related to this component in case of
  54335. * context lost for instance.
  54336. */
  54337. rebuild(): void;
  54338. /**
  54339. * Disposes the component and the associated ressources
  54340. */
  54341. dispose(): void;
  54342. private _beforeCameraUpdate;
  54343. }
  54344. }
  54345. declare module "babylonjs/Cameras/universalCamera" {
  54346. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  54347. import { Scene } from "babylonjs/scene";
  54348. import { Vector3 } from "babylonjs/Maths/math.vector";
  54349. import "babylonjs/Gamepads/gamepadSceneComponent";
  54350. /**
  54351. * 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,
  54352. * which still works and will still be found in many Playgrounds.
  54353. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54354. */
  54355. export class UniversalCamera extends TouchCamera {
  54356. /**
  54357. * Defines the gamepad rotation sensiblity.
  54358. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  54359. */
  54360. get gamepadAngularSensibility(): number;
  54361. set gamepadAngularSensibility(value: number);
  54362. /**
  54363. * Defines the gamepad move sensiblity.
  54364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  54365. */
  54366. get gamepadMoveSensibility(): number;
  54367. set gamepadMoveSensibility(value: number);
  54368. /**
  54369. * 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,
  54370. * which still works and will still be found in many Playgrounds.
  54371. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54372. * @param name Define the name of the camera in the scene
  54373. * @param position Define the start position of the camera in the scene
  54374. * @param scene Define the scene the camera belongs to
  54375. */
  54376. constructor(name: string, position: Vector3, scene: Scene);
  54377. /**
  54378. * Gets the current object class name.
  54379. * @return the class name
  54380. */
  54381. getClassName(): string;
  54382. }
  54383. }
  54384. declare module "babylonjs/Cameras/gamepadCamera" {
  54385. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54386. import { Scene } from "babylonjs/scene";
  54387. import { Vector3 } from "babylonjs/Maths/math.vector";
  54388. /**
  54389. * This represents a FPS type of camera. This is only here for back compat purpose.
  54390. * Please use the UniversalCamera instead as both are identical.
  54391. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54392. */
  54393. export class GamepadCamera extends UniversalCamera {
  54394. /**
  54395. * Instantiates a new Gamepad Camera
  54396. * This represents a FPS type of camera. This is only here for back compat purpose.
  54397. * Please use the UniversalCamera instead as both are identical.
  54398. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54399. * @param name Define the name of the camera in the scene
  54400. * @param position Define the start position of the camera in the scene
  54401. * @param scene Define the scene the camera belongs to
  54402. */
  54403. constructor(name: string, position: Vector3, scene: Scene);
  54404. /**
  54405. * Gets the current object class name.
  54406. * @return the class name
  54407. */
  54408. getClassName(): string;
  54409. }
  54410. }
  54411. declare module "babylonjs/Shaders/anaglyph.fragment" {
  54412. /** @hidden */
  54413. export var anaglyphPixelShader: {
  54414. name: string;
  54415. shader: string;
  54416. };
  54417. }
  54418. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  54419. import { Engine } from "babylonjs/Engines/engine";
  54420. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54421. import { Camera } from "babylonjs/Cameras/camera";
  54422. import "babylonjs/Shaders/anaglyph.fragment";
  54423. /**
  54424. * Postprocess used to generate anaglyphic rendering
  54425. */
  54426. export class AnaglyphPostProcess extends PostProcess {
  54427. private _passedProcess;
  54428. /**
  54429. * Gets a string identifying the name of the class
  54430. * @returns "AnaglyphPostProcess" string
  54431. */
  54432. getClassName(): string;
  54433. /**
  54434. * Creates a new AnaglyphPostProcess
  54435. * @param name defines postprocess name
  54436. * @param options defines creation options or target ratio scale
  54437. * @param rigCameras defines cameras using this postprocess
  54438. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  54439. * @param engine defines hosting engine
  54440. * @param reusable defines if the postprocess will be reused multiple times per frame
  54441. */
  54442. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  54443. }
  54444. }
  54445. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  54446. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  54447. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54448. import { Scene } from "babylonjs/scene";
  54449. import { Vector3 } from "babylonjs/Maths/math.vector";
  54450. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54451. /**
  54452. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  54453. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54454. */
  54455. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  54456. /**
  54457. * Creates a new AnaglyphArcRotateCamera
  54458. * @param name defines camera name
  54459. * @param alpha defines alpha angle (in radians)
  54460. * @param beta defines beta angle (in radians)
  54461. * @param radius defines radius
  54462. * @param target defines camera target
  54463. * @param interaxialDistance defines distance between each color axis
  54464. * @param scene defines the hosting scene
  54465. */
  54466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  54467. /**
  54468. * Gets camera class name
  54469. * @returns AnaglyphArcRotateCamera
  54470. */
  54471. getClassName(): string;
  54472. }
  54473. }
  54474. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  54475. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54476. import { Scene } from "babylonjs/scene";
  54477. import { Vector3 } from "babylonjs/Maths/math.vector";
  54478. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54479. /**
  54480. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  54481. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54482. */
  54483. export class AnaglyphFreeCamera extends FreeCamera {
  54484. /**
  54485. * Creates a new AnaglyphFreeCamera
  54486. * @param name defines camera name
  54487. * @param position defines initial position
  54488. * @param interaxialDistance defines distance between each color axis
  54489. * @param scene defines the hosting scene
  54490. */
  54491. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54492. /**
  54493. * Gets camera class name
  54494. * @returns AnaglyphFreeCamera
  54495. */
  54496. getClassName(): string;
  54497. }
  54498. }
  54499. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  54500. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54501. import { Scene } from "babylonjs/scene";
  54502. import { Vector3 } from "babylonjs/Maths/math.vector";
  54503. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54504. /**
  54505. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  54506. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54507. */
  54508. export class AnaglyphGamepadCamera extends GamepadCamera {
  54509. /**
  54510. * Creates a new AnaglyphGamepadCamera
  54511. * @param name defines camera name
  54512. * @param position defines initial position
  54513. * @param interaxialDistance defines distance between each color axis
  54514. * @param scene defines the hosting scene
  54515. */
  54516. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54517. /**
  54518. * Gets camera class name
  54519. * @returns AnaglyphGamepadCamera
  54520. */
  54521. getClassName(): string;
  54522. }
  54523. }
  54524. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  54525. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54526. import { Scene } from "babylonjs/scene";
  54527. import { Vector3 } from "babylonjs/Maths/math.vector";
  54528. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54529. /**
  54530. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  54531. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54532. */
  54533. export class AnaglyphUniversalCamera extends UniversalCamera {
  54534. /**
  54535. * Creates a new AnaglyphUniversalCamera
  54536. * @param name defines camera name
  54537. * @param position defines initial position
  54538. * @param interaxialDistance defines distance between each color axis
  54539. * @param scene defines the hosting scene
  54540. */
  54541. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54542. /**
  54543. * Gets camera class name
  54544. * @returns AnaglyphUniversalCamera
  54545. */
  54546. getClassName(): string;
  54547. }
  54548. }
  54549. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  54550. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  54551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54552. import { Scene } from "babylonjs/scene";
  54553. import { Vector3 } from "babylonjs/Maths/math.vector";
  54554. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54555. /**
  54556. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  54557. * @see https://doc.babylonjs.com/features/cameras
  54558. */
  54559. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  54560. /**
  54561. * Creates a new StereoscopicArcRotateCamera
  54562. * @param name defines camera name
  54563. * @param alpha defines alpha angle (in radians)
  54564. * @param beta defines beta angle (in radians)
  54565. * @param radius defines radius
  54566. * @param target defines camera target
  54567. * @param interaxialDistance defines distance between each color axis
  54568. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54569. * @param scene defines the hosting scene
  54570. */
  54571. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54572. /**
  54573. * Gets camera class name
  54574. * @returns StereoscopicArcRotateCamera
  54575. */
  54576. getClassName(): string;
  54577. }
  54578. }
  54579. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  54580. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54581. import { Scene } from "babylonjs/scene";
  54582. import { Vector3 } from "babylonjs/Maths/math.vector";
  54583. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54584. /**
  54585. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  54586. * @see https://doc.babylonjs.com/features/cameras
  54587. */
  54588. export class StereoscopicFreeCamera extends FreeCamera {
  54589. /**
  54590. * Creates a new StereoscopicFreeCamera
  54591. * @param name defines camera name
  54592. * @param position defines initial position
  54593. * @param interaxialDistance defines distance between each color axis
  54594. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54595. * @param scene defines the hosting scene
  54596. */
  54597. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54598. /**
  54599. * Gets camera class name
  54600. * @returns StereoscopicFreeCamera
  54601. */
  54602. getClassName(): string;
  54603. }
  54604. }
  54605. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  54606. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54607. import { Scene } from "babylonjs/scene";
  54608. import { Vector3 } from "babylonjs/Maths/math.vector";
  54609. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54610. /**
  54611. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  54612. * @see https://doc.babylonjs.com/features/cameras
  54613. */
  54614. export class StereoscopicGamepadCamera extends GamepadCamera {
  54615. /**
  54616. * Creates a new StereoscopicGamepadCamera
  54617. * @param name defines camera name
  54618. * @param position defines initial position
  54619. * @param interaxialDistance defines distance between each color axis
  54620. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54621. * @param scene defines the hosting scene
  54622. */
  54623. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54624. /**
  54625. * Gets camera class name
  54626. * @returns StereoscopicGamepadCamera
  54627. */
  54628. getClassName(): string;
  54629. }
  54630. }
  54631. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  54632. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54633. import { Scene } from "babylonjs/scene";
  54634. import { Vector3 } from "babylonjs/Maths/math.vector";
  54635. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54636. /**
  54637. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54638. * @see https://doc.babylonjs.com/features/cameras
  54639. */
  54640. export class StereoscopicUniversalCamera extends UniversalCamera {
  54641. /**
  54642. * Creates a new StereoscopicUniversalCamera
  54643. * @param name defines camera name
  54644. * @param position defines initial position
  54645. * @param interaxialDistance defines distance between each color axis
  54646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54647. * @param scene defines the hosting scene
  54648. */
  54649. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54650. /**
  54651. * Gets camera class name
  54652. * @returns StereoscopicUniversalCamera
  54653. */
  54654. getClassName(): string;
  54655. }
  54656. }
  54657. declare module "babylonjs/Cameras/Stereoscopic/index" {
  54658. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  54659. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  54660. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  54661. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  54662. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  54663. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  54664. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  54665. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  54666. }
  54667. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  54668. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54669. import { Scene } from "babylonjs/scene";
  54670. import { Vector3 } from "babylonjs/Maths/math.vector";
  54671. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  54672. /**
  54673. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  54674. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54675. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54676. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54677. */
  54678. export class VirtualJoysticksCamera extends FreeCamera {
  54679. /**
  54680. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  54681. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54682. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54683. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54684. * @param name Define the name of the camera in the scene
  54685. * @param position Define the start position of the camera in the scene
  54686. * @param scene Define the scene the camera belongs to
  54687. */
  54688. constructor(name: string, position: Vector3, scene: Scene);
  54689. /**
  54690. * Gets the current object class name.
  54691. * @return the class name
  54692. */
  54693. getClassName(): string;
  54694. }
  54695. }
  54696. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  54697. import { Matrix } from "babylonjs/Maths/math.vector";
  54698. /**
  54699. * This represents all the required metrics to create a VR camera.
  54700. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  54701. */
  54702. export class VRCameraMetrics {
  54703. /**
  54704. * Define the horizontal resolution off the screen.
  54705. */
  54706. hResolution: number;
  54707. /**
  54708. * Define the vertical resolution off the screen.
  54709. */
  54710. vResolution: number;
  54711. /**
  54712. * Define the horizontal screen size.
  54713. */
  54714. hScreenSize: number;
  54715. /**
  54716. * Define the vertical screen size.
  54717. */
  54718. vScreenSize: number;
  54719. /**
  54720. * Define the vertical screen center position.
  54721. */
  54722. vScreenCenter: number;
  54723. /**
  54724. * Define the distance of the eyes to the screen.
  54725. */
  54726. eyeToScreenDistance: number;
  54727. /**
  54728. * Define the distance between both lenses
  54729. */
  54730. lensSeparationDistance: number;
  54731. /**
  54732. * Define the distance between both viewer's eyes.
  54733. */
  54734. interpupillaryDistance: number;
  54735. /**
  54736. * Define the distortion factor of the VR postprocess.
  54737. * Please, touch with care.
  54738. */
  54739. distortionK: number[];
  54740. /**
  54741. * Define the chromatic aberration correction factors for the VR post process.
  54742. */
  54743. chromaAbCorrection: number[];
  54744. /**
  54745. * Define the scale factor of the post process.
  54746. * The smaller the better but the slower.
  54747. */
  54748. postProcessScaleFactor: number;
  54749. /**
  54750. * Define an offset for the lens center.
  54751. */
  54752. lensCenterOffset: number;
  54753. /**
  54754. * Define if the current vr camera should compensate the distortion of the lense or not.
  54755. */
  54756. compensateDistortion: boolean;
  54757. /**
  54758. * Defines if multiview should be enabled when rendering (Default: false)
  54759. */
  54760. multiviewEnabled: boolean;
  54761. /**
  54762. * Gets the rendering aspect ratio based on the provided resolutions.
  54763. */
  54764. get aspectRatio(): number;
  54765. /**
  54766. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  54767. */
  54768. get aspectRatioFov(): number;
  54769. /**
  54770. * @hidden
  54771. */
  54772. get leftHMatrix(): Matrix;
  54773. /**
  54774. * @hidden
  54775. */
  54776. get rightHMatrix(): Matrix;
  54777. /**
  54778. * @hidden
  54779. */
  54780. get leftPreViewMatrix(): Matrix;
  54781. /**
  54782. * @hidden
  54783. */
  54784. get rightPreViewMatrix(): Matrix;
  54785. /**
  54786. * Get the default VRMetrics based on the most generic setup.
  54787. * @returns the default vr metrics
  54788. */
  54789. static GetDefault(): VRCameraMetrics;
  54790. }
  54791. }
  54792. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  54793. /** @hidden */
  54794. export var vrDistortionCorrectionPixelShader: {
  54795. name: string;
  54796. shader: string;
  54797. };
  54798. }
  54799. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  54800. import { Camera } from "babylonjs/Cameras/camera";
  54801. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54802. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54803. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  54804. /**
  54805. * VRDistortionCorrectionPostProcess used for mobile VR
  54806. */
  54807. export class VRDistortionCorrectionPostProcess extends PostProcess {
  54808. private _isRightEye;
  54809. private _distortionFactors;
  54810. private _postProcessScaleFactor;
  54811. private _lensCenterOffset;
  54812. private _scaleIn;
  54813. private _scaleFactor;
  54814. private _lensCenter;
  54815. /**
  54816. * Gets a string identifying the name of the class
  54817. * @returns "VRDistortionCorrectionPostProcess" string
  54818. */
  54819. getClassName(): string;
  54820. /**
  54821. * Initializes the VRDistortionCorrectionPostProcess
  54822. * @param name The name of the effect.
  54823. * @param camera The camera to apply the render pass to.
  54824. * @param isRightEye If this is for the right eye distortion
  54825. * @param vrMetrics All the required metrics for the VR camera
  54826. */
  54827. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  54828. }
  54829. }
  54830. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  54831. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  54832. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54834. import { Scene } from "babylonjs/scene";
  54835. import { Vector3 } from "babylonjs/Maths/math.vector";
  54836. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  54837. import "babylonjs/Cameras/RigModes/vrRigMode";
  54838. /**
  54839. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  54840. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54841. */
  54842. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  54843. /**
  54844. * Creates a new VRDeviceOrientationArcRotateCamera
  54845. * @param name defines camera name
  54846. * @param alpha defines the camera rotation along the logitudinal axis
  54847. * @param beta defines the camera rotation along the latitudinal axis
  54848. * @param radius defines the camera distance from its target
  54849. * @param target defines the camera target
  54850. * @param scene defines the scene the camera belongs to
  54851. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  54852. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54853. */
  54854. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54855. /**
  54856. * Gets camera class name
  54857. * @returns VRDeviceOrientationArcRotateCamera
  54858. */
  54859. getClassName(): string;
  54860. }
  54861. }
  54862. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  54863. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54864. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54865. import { Scene } from "babylonjs/scene";
  54866. import { Vector3 } from "babylonjs/Maths/math.vector";
  54867. import "babylonjs/Cameras/RigModes/vrRigMode";
  54868. /**
  54869. * Camera used to simulate VR rendering (based on FreeCamera)
  54870. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54871. */
  54872. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  54873. /**
  54874. * Creates a new VRDeviceOrientationFreeCamera
  54875. * @param name defines camera name
  54876. * @param position defines the start position of the camera
  54877. * @param scene defines the scene the camera belongs to
  54878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  54879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54880. */
  54881. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54882. /**
  54883. * Gets camera class name
  54884. * @returns VRDeviceOrientationFreeCamera
  54885. */
  54886. getClassName(): string;
  54887. }
  54888. }
  54889. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  54890. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54891. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54892. import { Scene } from "babylonjs/scene";
  54893. import { Vector3 } from "babylonjs/Maths/math.vector";
  54894. import "babylonjs/Gamepads/gamepadSceneComponent";
  54895. /**
  54896. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  54897. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54898. */
  54899. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  54900. /**
  54901. * Creates a new VRDeviceOrientationGamepadCamera
  54902. * @param name defines camera name
  54903. * @param position defines the start position of the camera
  54904. * @param scene defines the scene the camera belongs to
  54905. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  54906. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54907. */
  54908. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54909. /**
  54910. * Gets camera class name
  54911. * @returns VRDeviceOrientationGamepadCamera
  54912. */
  54913. getClassName(): string;
  54914. }
  54915. }
  54916. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  54917. import { Scene } from "babylonjs/scene";
  54918. import { Texture } from "babylonjs/Materials/Textures/texture";
  54919. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54920. /**
  54921. * A class extending Texture allowing drawing on a texture
  54922. * @see https://doc.babylonjs.com/how_to/dynamictexture
  54923. */
  54924. export class DynamicTexture extends Texture {
  54925. private _generateMipMaps;
  54926. private _canvas;
  54927. private _context;
  54928. /**
  54929. * Creates a DynamicTexture
  54930. * @param name defines the name of the texture
  54931. * @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
  54932. * @param scene defines the scene where you want the texture
  54933. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  54934. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54935. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  54936. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  54937. */
  54938. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  54939. /**
  54940. * Get the current class name of the texture useful for serialization or dynamic coding.
  54941. * @returns "DynamicTexture"
  54942. */
  54943. getClassName(): string;
  54944. /**
  54945. * Gets the current state of canRescale
  54946. */
  54947. get canRescale(): boolean;
  54948. private _recreate;
  54949. /**
  54950. * Scales the texture
  54951. * @param ratio the scale factor to apply to both width and height
  54952. */
  54953. scale(ratio: number): void;
  54954. /**
  54955. * Resizes the texture
  54956. * @param width the new width
  54957. * @param height the new height
  54958. */
  54959. scaleTo(width: number, height: number): void;
  54960. /**
  54961. * Gets the context of the canvas used by the texture
  54962. * @returns the canvas context of the dynamic texture
  54963. */
  54964. getContext(): CanvasRenderingContext2D;
  54965. /**
  54966. * Clears the texture
  54967. */
  54968. clear(): void;
  54969. /**
  54970. * Updates the texture
  54971. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54972. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  54973. */
  54974. update(invertY?: boolean, premulAlpha?: boolean): void;
  54975. /**
  54976. * Draws text onto the texture
  54977. * @param text defines the text to be drawn
  54978. * @param x defines the placement of the text from the left
  54979. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  54980. * @param font defines the font to be used with font-style, font-size, font-name
  54981. * @param color defines the color used for the text
  54982. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  54983. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54984. * @param update defines whether texture is immediately update (default is true)
  54985. */
  54986. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  54987. /**
  54988. * Clones the texture
  54989. * @returns the clone of the texture.
  54990. */
  54991. clone(): DynamicTexture;
  54992. /**
  54993. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  54994. * @returns a serialized dynamic texture object
  54995. */
  54996. serialize(): any;
  54997. private _IsCanvasElement;
  54998. /** @hidden */
  54999. _rebuild(): void;
  55000. }
  55001. }
  55002. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  55003. import { Scene } from "babylonjs/scene";
  55004. import { Color3 } from "babylonjs/Maths/math.color";
  55005. import { Mesh } from "babylonjs/Meshes/mesh";
  55006. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55007. import { Nullable } from "babylonjs/types";
  55008. /**
  55009. * Class containing static functions to help procedurally build meshes
  55010. */
  55011. export class GroundBuilder {
  55012. /**
  55013. * Creates a ground mesh
  55014. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55015. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55017. * @param name defines the name of the mesh
  55018. * @param options defines the options used to create the mesh
  55019. * @param scene defines the hosting scene
  55020. * @returns the ground mesh
  55021. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55022. */
  55023. static CreateGround(name: string, options: {
  55024. width?: number;
  55025. height?: number;
  55026. subdivisions?: number;
  55027. subdivisionsX?: number;
  55028. subdivisionsY?: number;
  55029. updatable?: boolean;
  55030. }, scene: any): Mesh;
  55031. /**
  55032. * Creates a tiled ground mesh
  55033. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55034. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55035. * * 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
  55036. * * 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
  55037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55038. * @param name defines the name of the mesh
  55039. * @param options defines the options used to create the mesh
  55040. * @param scene defines the hosting scene
  55041. * @returns the tiled ground mesh
  55042. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55043. */
  55044. static CreateTiledGround(name: string, options: {
  55045. xmin: number;
  55046. zmin: number;
  55047. xmax: number;
  55048. zmax: number;
  55049. subdivisions?: {
  55050. w: number;
  55051. h: number;
  55052. };
  55053. precision?: {
  55054. w: number;
  55055. h: number;
  55056. };
  55057. updatable?: boolean;
  55058. }, scene?: Nullable<Scene>): Mesh;
  55059. /**
  55060. * Creates a ground mesh from a height map
  55061. * * The parameter `url` sets the URL of the height map image resource.
  55062. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55063. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55064. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55065. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55066. * * 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.
  55067. * * 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).
  55068. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55070. * @param name defines the name of the mesh
  55071. * @param url defines the url to the height map
  55072. * @param options defines the options used to create the mesh
  55073. * @param scene defines the hosting scene
  55074. * @returns the ground mesh
  55075. * @see https://doc.babylonjs.com/babylon101/height_map
  55076. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55077. */
  55078. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55079. width?: number;
  55080. height?: number;
  55081. subdivisions?: number;
  55082. minHeight?: number;
  55083. maxHeight?: number;
  55084. colorFilter?: Color3;
  55085. alphaFilter?: number;
  55086. updatable?: boolean;
  55087. onReady?: (mesh: GroundMesh) => void;
  55088. }, scene?: Nullable<Scene>): GroundMesh;
  55089. }
  55090. }
  55091. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  55092. import { Vector4 } from "babylonjs/Maths/math.vector";
  55093. import { Mesh } from "babylonjs/Meshes/mesh";
  55094. /**
  55095. * Class containing static functions to help procedurally build meshes
  55096. */
  55097. export class TorusBuilder {
  55098. /**
  55099. * Creates a torus mesh
  55100. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55101. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55102. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55104. * * 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
  55105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55106. * @param name defines the name of the mesh
  55107. * @param options defines the options used to create the mesh
  55108. * @param scene defines the hosting scene
  55109. * @returns the torus mesh
  55110. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55111. */
  55112. static CreateTorus(name: string, options: {
  55113. diameter?: number;
  55114. thickness?: number;
  55115. tessellation?: number;
  55116. updatable?: boolean;
  55117. sideOrientation?: number;
  55118. frontUVs?: Vector4;
  55119. backUVs?: Vector4;
  55120. }, scene: any): Mesh;
  55121. }
  55122. }
  55123. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  55124. import { Vector4 } from "babylonjs/Maths/math.vector";
  55125. import { Color4 } from "babylonjs/Maths/math.color";
  55126. import { Mesh } from "babylonjs/Meshes/mesh";
  55127. /**
  55128. * Class containing static functions to help procedurally build meshes
  55129. */
  55130. export class CylinderBuilder {
  55131. /**
  55132. * Creates a cylinder or a cone mesh
  55133. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55134. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55135. * * 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.
  55136. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55137. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55138. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55139. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55140. * * 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).
  55141. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55142. * * 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).
  55143. * * 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
  55144. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55145. * * 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
  55146. * * 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.
  55147. * * If `enclose` is false, a ring surface is one element.
  55148. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55149. * * 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
  55150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55151. * * 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
  55152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55153. * @param name defines the name of the mesh
  55154. * @param options defines the options used to create the mesh
  55155. * @param scene defines the hosting scene
  55156. * @returns the cylinder mesh
  55157. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55158. */
  55159. static CreateCylinder(name: string, options: {
  55160. height?: number;
  55161. diameterTop?: number;
  55162. diameterBottom?: number;
  55163. diameter?: number;
  55164. tessellation?: number;
  55165. subdivisions?: number;
  55166. arc?: number;
  55167. faceColors?: Color4[];
  55168. faceUV?: Vector4[];
  55169. updatable?: boolean;
  55170. hasRings?: boolean;
  55171. enclose?: boolean;
  55172. cap?: number;
  55173. sideOrientation?: number;
  55174. frontUVs?: Vector4;
  55175. backUVs?: Vector4;
  55176. }, scene: any): Mesh;
  55177. }
  55178. }
  55179. declare module "babylonjs/XR/webXRTypes" {
  55180. import { Nullable } from "babylonjs/types";
  55181. import { IDisposable } from "babylonjs/scene";
  55182. /**
  55183. * States of the webXR experience
  55184. */
  55185. export enum WebXRState {
  55186. /**
  55187. * Transitioning to being in XR mode
  55188. */
  55189. ENTERING_XR = 0,
  55190. /**
  55191. * Transitioning to non XR mode
  55192. */
  55193. EXITING_XR = 1,
  55194. /**
  55195. * In XR mode and presenting
  55196. */
  55197. IN_XR = 2,
  55198. /**
  55199. * Not entered XR mode
  55200. */
  55201. NOT_IN_XR = 3
  55202. }
  55203. /**
  55204. * The state of the XR camera's tracking
  55205. */
  55206. export enum WebXRTrackingState {
  55207. /**
  55208. * No transformation received, device is not being tracked
  55209. */
  55210. NOT_TRACKING = 0,
  55211. /**
  55212. * Tracking lost - using emulated position
  55213. */
  55214. TRACKING_LOST = 1,
  55215. /**
  55216. * Transformation tracking works normally
  55217. */
  55218. TRACKING = 2
  55219. }
  55220. /**
  55221. * Abstraction of the XR render target
  55222. */
  55223. export interface WebXRRenderTarget extends IDisposable {
  55224. /**
  55225. * xrpresent context of the canvas which can be used to display/mirror xr content
  55226. */
  55227. canvasContext: WebGLRenderingContext;
  55228. /**
  55229. * xr layer for the canvas
  55230. */
  55231. xrLayer: Nullable<XRWebGLLayer>;
  55232. /**
  55233. * Initializes the xr layer for the session
  55234. * @param xrSession xr session
  55235. * @returns a promise that will resolve once the XR Layer has been created
  55236. */
  55237. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55238. }
  55239. }
  55240. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  55241. import { Nullable } from "babylonjs/types";
  55242. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55243. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55244. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55245. import { Observable } from "babylonjs/Misc/observable";
  55246. /**
  55247. * COnfiguration object for WebXR output canvas
  55248. */
  55249. export class WebXRManagedOutputCanvasOptions {
  55250. /**
  55251. * An optional canvas in case you wish to create it yourself and provide it here.
  55252. * If not provided, a new canvas will be created
  55253. */
  55254. canvasElement?: HTMLCanvasElement;
  55255. /**
  55256. * Options for this XR Layer output
  55257. */
  55258. canvasOptions?: XRWebGLLayerInit;
  55259. /**
  55260. * CSS styling for a newly created canvas (if not provided)
  55261. */
  55262. newCanvasCssStyle?: string;
  55263. /**
  55264. * Get the default values of the configuration object
  55265. * @param engine defines the engine to use (can be null)
  55266. * @returns default values of this configuration object
  55267. */
  55268. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  55269. }
  55270. /**
  55271. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  55272. */
  55273. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  55274. private _options;
  55275. private _canvas;
  55276. private _engine;
  55277. private _originalCanvasSize;
  55278. /**
  55279. * Rendering context of the canvas which can be used to display/mirror xr content
  55280. */
  55281. canvasContext: WebGLRenderingContext;
  55282. /**
  55283. * xr layer for the canvas
  55284. */
  55285. xrLayer: Nullable<XRWebGLLayer>;
  55286. /**
  55287. * Obseervers registered here will be triggered when the xr layer was initialized
  55288. */
  55289. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  55290. /**
  55291. * Initializes the canvas to be added/removed upon entering/exiting xr
  55292. * @param _xrSessionManager The XR Session manager
  55293. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  55294. */
  55295. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  55296. /**
  55297. * Disposes of the object
  55298. */
  55299. dispose(): void;
  55300. /**
  55301. * Initializes the xr layer for the session
  55302. * @param xrSession xr session
  55303. * @returns a promise that will resolve once the XR Layer has been created
  55304. */
  55305. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55306. private _addCanvas;
  55307. private _removeCanvas;
  55308. private _setCanvasSize;
  55309. private _setManagedOutputCanvas;
  55310. }
  55311. }
  55312. declare module "babylonjs/XR/webXRSessionManager" {
  55313. import { Observable } from "babylonjs/Misc/observable";
  55314. import { Nullable } from "babylonjs/types";
  55315. import { IDisposable, Scene } from "babylonjs/scene";
  55316. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55317. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55318. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55319. /**
  55320. * Manages an XRSession to work with Babylon's engine
  55321. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  55322. */
  55323. export class WebXRSessionManager implements IDisposable {
  55324. /** The scene which the session should be created for */
  55325. scene: Scene;
  55326. private _referenceSpace;
  55327. private _rttProvider;
  55328. private _sessionEnded;
  55329. private _xrNavigator;
  55330. private baseLayer;
  55331. /**
  55332. * The base reference space from which the session started. good if you want to reset your
  55333. * reference space
  55334. */
  55335. baseReferenceSpace: XRReferenceSpace;
  55336. /**
  55337. * Current XR frame
  55338. */
  55339. currentFrame: Nullable<XRFrame>;
  55340. /** WebXR timestamp updated every frame */
  55341. currentTimestamp: number;
  55342. /**
  55343. * Used just in case of a failure to initialize an immersive session.
  55344. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  55345. */
  55346. defaultHeightCompensation: number;
  55347. /**
  55348. * Fires every time a new xrFrame arrives which can be used to update the camera
  55349. */
  55350. onXRFrameObservable: Observable<XRFrame>;
  55351. /**
  55352. * Fires when the reference space changed
  55353. */
  55354. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  55355. /**
  55356. * Fires when the xr session is ended either by the device or manually done
  55357. */
  55358. onXRSessionEnded: Observable<any>;
  55359. /**
  55360. * Fires when the xr session is ended either by the device or manually done
  55361. */
  55362. onXRSessionInit: Observable<XRSession>;
  55363. /**
  55364. * Underlying xr session
  55365. */
  55366. session: XRSession;
  55367. /**
  55368. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  55369. * or get the offset the player is currently at.
  55370. */
  55371. viewerReferenceSpace: XRReferenceSpace;
  55372. /**
  55373. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  55374. * @param scene The scene which the session should be created for
  55375. */
  55376. constructor(
  55377. /** The scene which the session should be created for */
  55378. scene: Scene);
  55379. /**
  55380. * The current reference space used in this session. This reference space can constantly change!
  55381. * It is mainly used to offset the camera's position.
  55382. */
  55383. get referenceSpace(): XRReferenceSpace;
  55384. /**
  55385. * Set a new reference space and triggers the observable
  55386. */
  55387. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  55388. /**
  55389. * Disposes of the session manager
  55390. */
  55391. dispose(): void;
  55392. /**
  55393. * Stops the xrSession and restores the render loop
  55394. * @returns Promise which resolves after it exits XR
  55395. */
  55396. exitXRAsync(): Promise<void>;
  55397. /**
  55398. * Gets the correct render target texture to be rendered this frame for this eye
  55399. * @param eye the eye for which to get the render target
  55400. * @returns the render target for the specified eye
  55401. */
  55402. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  55403. /**
  55404. * Creates a WebXRRenderTarget object for the XR session
  55405. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  55406. * @param options optional options to provide when creating a new render target
  55407. * @returns a WebXR render target to which the session can render
  55408. */
  55409. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  55410. /**
  55411. * Initializes the manager
  55412. * After initialization enterXR can be called to start an XR session
  55413. * @returns Promise which resolves after it is initialized
  55414. */
  55415. initializeAsync(): Promise<void>;
  55416. /**
  55417. * Initializes an xr session
  55418. * @param xrSessionMode mode to initialize
  55419. * @param xrSessionInit defines optional and required values to pass to the session builder
  55420. * @returns a promise which will resolve once the session has been initialized
  55421. */
  55422. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  55423. /**
  55424. * Checks if a session would be supported for the creation options specified
  55425. * @param sessionMode session mode to check if supported eg. immersive-vr
  55426. * @returns A Promise that resolves to true if supported and false if not
  55427. */
  55428. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55429. /**
  55430. * Resets the reference space to the one started the session
  55431. */
  55432. resetReferenceSpace(): void;
  55433. /**
  55434. * Starts rendering to the xr layer
  55435. */
  55436. runXRRenderLoop(): void;
  55437. /**
  55438. * Sets the reference space on the xr session
  55439. * @param referenceSpaceType space to set
  55440. * @returns a promise that will resolve once the reference space has been set
  55441. */
  55442. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  55443. /**
  55444. * Updates the render state of the session
  55445. * @param state state to set
  55446. * @returns a promise that resolves once the render state has been updated
  55447. */
  55448. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  55449. /**
  55450. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  55451. * @param sessionMode defines the session to test
  55452. * @returns a promise with boolean as final value
  55453. */
  55454. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55455. /**
  55456. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  55457. */
  55458. get isNative(): boolean;
  55459. private _createRenderTargetTexture;
  55460. }
  55461. }
  55462. declare module "babylonjs/XR/webXRCamera" {
  55463. import { Vector3 } from "babylonjs/Maths/math.vector";
  55464. import { Scene } from "babylonjs/scene";
  55465. import { Camera } from "babylonjs/Cameras/camera";
  55466. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55467. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55468. import { Observable } from "babylonjs/Misc/observable";
  55469. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  55470. /**
  55471. * WebXR Camera which holds the views for the xrSession
  55472. * @see https://doc.babylonjs.com/how_to/webxr_camera
  55473. */
  55474. export class WebXRCamera extends FreeCamera {
  55475. private _xrSessionManager;
  55476. private _firstFrame;
  55477. private _referenceQuaternion;
  55478. private _referencedPosition;
  55479. private _xrInvPositionCache;
  55480. private _xrInvQuaternionCache;
  55481. private _trackingState;
  55482. /**
  55483. * Observable raised before camera teleportation
  55484. */
  55485. onBeforeCameraTeleport: Observable<Vector3>;
  55486. /**
  55487. * Observable raised after camera teleportation
  55488. */
  55489. onAfterCameraTeleport: Observable<Vector3>;
  55490. /**
  55491. * Notifies when the camera's tracking state has changed.
  55492. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  55493. */
  55494. onTrackingStateChanged: Observable<WebXRTrackingState>;
  55495. /**
  55496. * Should position compensation execute on first frame.
  55497. * This is used when copying the position from a native (non XR) camera
  55498. */
  55499. compensateOnFirstFrame: boolean;
  55500. /**
  55501. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  55502. * @param name the name of the camera
  55503. * @param scene the scene to add the camera to
  55504. * @param _xrSessionManager a constructed xr session manager
  55505. */
  55506. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  55507. /**
  55508. * Get the current XR tracking state of the camera
  55509. */
  55510. get trackingState(): WebXRTrackingState;
  55511. private _setTrackingState;
  55512. /**
  55513. * Return the user's height, unrelated to the current ground.
  55514. * This will be the y position of this camera, when ground level is 0.
  55515. */
  55516. get realWorldHeight(): number;
  55517. /** @hidden */
  55518. _updateForDualEyeDebugging(): void;
  55519. /**
  55520. * Sets this camera's transformation based on a non-vr camera
  55521. * @param otherCamera the non-vr camera to copy the transformation from
  55522. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  55523. */
  55524. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  55525. /**
  55526. * Gets the current instance class name ("WebXRCamera").
  55527. * @returns the class name
  55528. */
  55529. getClassName(): string;
  55530. private _rotate180;
  55531. private _updateFromXRSession;
  55532. private _updateNumberOfRigCameras;
  55533. private _updateReferenceSpace;
  55534. private _updateReferenceSpaceOffset;
  55535. }
  55536. }
  55537. declare module "babylonjs/XR/webXRFeaturesManager" {
  55538. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55539. import { IDisposable } from "babylonjs/scene";
  55540. /**
  55541. * Defining the interface required for a (webxr) feature
  55542. */
  55543. export interface IWebXRFeature extends IDisposable {
  55544. /**
  55545. * Is this feature attached
  55546. */
  55547. attached: boolean;
  55548. /**
  55549. * Should auto-attach be disabled?
  55550. */
  55551. disableAutoAttach: boolean;
  55552. /**
  55553. * Attach the feature to the session
  55554. * Will usually be called by the features manager
  55555. *
  55556. * @param force should attachment be forced (even when already attached)
  55557. * @returns true if successful.
  55558. */
  55559. attach(force?: boolean): boolean;
  55560. /**
  55561. * Detach the feature from the session
  55562. * Will usually be called by the features manager
  55563. *
  55564. * @returns true if successful.
  55565. */
  55566. detach(): boolean;
  55567. /**
  55568. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55569. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55570. *
  55571. * @returns whether or not the feature is compatible in this environment
  55572. */
  55573. isCompatible(): boolean;
  55574. /**
  55575. * Was this feature disposed;
  55576. */
  55577. isDisposed: boolean;
  55578. /**
  55579. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  55580. */
  55581. xrNativeFeatureName?: string;
  55582. /**
  55583. * A list of (Babylon WebXR) features this feature depends on
  55584. */
  55585. dependsOn?: string[];
  55586. }
  55587. /**
  55588. * A list of the currently available features without referencing them
  55589. */
  55590. export class WebXRFeatureName {
  55591. /**
  55592. * The name of the anchor system feature
  55593. */
  55594. static readonly ANCHOR_SYSTEM: string;
  55595. /**
  55596. * The name of the background remover feature
  55597. */
  55598. static readonly BACKGROUND_REMOVER: string;
  55599. /**
  55600. * The name of the hit test feature
  55601. */
  55602. static readonly HIT_TEST: string;
  55603. /**
  55604. * The name of the mesh detection feature
  55605. */
  55606. static readonly MESH_DETECTION: string;
  55607. /**
  55608. * physics impostors for xr controllers feature
  55609. */
  55610. static readonly PHYSICS_CONTROLLERS: string;
  55611. /**
  55612. * The name of the plane detection feature
  55613. */
  55614. static readonly PLANE_DETECTION: string;
  55615. /**
  55616. * The name of the pointer selection feature
  55617. */
  55618. static readonly POINTER_SELECTION: string;
  55619. /**
  55620. * The name of the teleportation feature
  55621. */
  55622. static readonly TELEPORTATION: string;
  55623. /**
  55624. * The name of the feature points feature.
  55625. */
  55626. static readonly FEATURE_POINTS: string;
  55627. /**
  55628. * The name of the hand tracking feature.
  55629. */
  55630. static readonly HAND_TRACKING: string;
  55631. }
  55632. /**
  55633. * Defining the constructor of a feature. Used to register the modules.
  55634. */
  55635. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  55636. /**
  55637. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  55638. * It is mainly used in AR sessions.
  55639. *
  55640. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  55641. */
  55642. export class WebXRFeaturesManager implements IDisposable {
  55643. private _xrSessionManager;
  55644. private static readonly _AvailableFeatures;
  55645. private _features;
  55646. /**
  55647. * constructs a new features manages.
  55648. *
  55649. * @param _xrSessionManager an instance of WebXRSessionManager
  55650. */
  55651. constructor(_xrSessionManager: WebXRSessionManager);
  55652. /**
  55653. * Used to register a module. After calling this function a developer can use this feature in the scene.
  55654. * Mainly used internally.
  55655. *
  55656. * @param featureName the name of the feature to register
  55657. * @param constructorFunction the function used to construct the module
  55658. * @param version the (babylon) version of the module
  55659. * @param stable is that a stable version of this module
  55660. */
  55661. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  55662. /**
  55663. * Returns a constructor of a specific feature.
  55664. *
  55665. * @param featureName the name of the feature to construct
  55666. * @param version the version of the feature to load
  55667. * @param xrSessionManager the xrSessionManager. Used to construct the module
  55668. * @param options optional options provided to the module.
  55669. * @returns a function that, when called, will return a new instance of this feature
  55670. */
  55671. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  55672. /**
  55673. * Can be used to return the list of features currently registered
  55674. *
  55675. * @returns an Array of available features
  55676. */
  55677. static GetAvailableFeatures(): string[];
  55678. /**
  55679. * Gets the versions available for a specific feature
  55680. * @param featureName the name of the feature
  55681. * @returns an array with the available versions
  55682. */
  55683. static GetAvailableVersions(featureName: string): string[];
  55684. /**
  55685. * Return the latest unstable version of this feature
  55686. * @param featureName the name of the feature to search
  55687. * @returns the version number. if not found will return -1
  55688. */
  55689. static GetLatestVersionOfFeature(featureName: string): number;
  55690. /**
  55691. * Return the latest stable version of this feature
  55692. * @param featureName the name of the feature to search
  55693. * @returns the version number. if not found will return -1
  55694. */
  55695. static GetStableVersionOfFeature(featureName: string): number;
  55696. /**
  55697. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  55698. * Can be used during a session to start a feature
  55699. * @param featureName the name of feature to attach
  55700. */
  55701. attachFeature(featureName: string): void;
  55702. /**
  55703. * Can be used inside a session or when the session ends to detach a specific feature
  55704. * @param featureName the name of the feature to detach
  55705. */
  55706. detachFeature(featureName: string): void;
  55707. /**
  55708. * Used to disable an already-enabled feature
  55709. * The feature will be disposed and will be recreated once enabled.
  55710. * @param featureName the feature to disable
  55711. * @returns true if disable was successful
  55712. */
  55713. disableFeature(featureName: string | {
  55714. Name: string;
  55715. }): boolean;
  55716. /**
  55717. * dispose this features manager
  55718. */
  55719. dispose(): void;
  55720. /**
  55721. * 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.
  55722. * 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.
  55723. *
  55724. * @param featureName the name of the feature to load or the class of the feature
  55725. * @param version optional version to load. if not provided the latest version will be enabled
  55726. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  55727. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  55728. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  55729. * @returns a new constructed feature or throws an error if feature not found.
  55730. */
  55731. enableFeature(featureName: string | {
  55732. Name: string;
  55733. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  55734. /**
  55735. * get the implementation of an enabled feature.
  55736. * @param featureName the name of the feature to load
  55737. * @returns the feature class, if found
  55738. */
  55739. getEnabledFeature(featureName: string): IWebXRFeature;
  55740. /**
  55741. * Get the list of enabled features
  55742. * @returns an array of enabled features
  55743. */
  55744. getEnabledFeatures(): string[];
  55745. /**
  55746. * This function will exten the session creation configuration object with enabled features.
  55747. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  55748. * according to the defined "required" variable, provided during enableFeature call
  55749. * @param xrSessionInit the xr Session init object to extend
  55750. *
  55751. * @returns an extended XRSessionInit object
  55752. */
  55753. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  55754. }
  55755. }
  55756. declare module "babylonjs/XR/webXRExperienceHelper" {
  55757. import { Observable } from "babylonjs/Misc/observable";
  55758. import { IDisposable, Scene } from "babylonjs/scene";
  55759. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55760. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  55761. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55762. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  55763. /**
  55764. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  55765. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  55766. */
  55767. export class WebXRExperienceHelper implements IDisposable {
  55768. private scene;
  55769. private _nonVRCamera;
  55770. private _originalSceneAutoClear;
  55771. private _supported;
  55772. /**
  55773. * Camera used to render xr content
  55774. */
  55775. camera: WebXRCamera;
  55776. /** A features manager for this xr session */
  55777. featuresManager: WebXRFeaturesManager;
  55778. /**
  55779. * Observers registered here will be triggered after the camera's initial transformation is set
  55780. * This can be used to set a different ground level or an extra rotation.
  55781. *
  55782. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  55783. * to the position set after this observable is done executing.
  55784. */
  55785. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  55786. /**
  55787. * Fires when the state of the experience helper has changed
  55788. */
  55789. onStateChangedObservable: Observable<WebXRState>;
  55790. /** Session manager used to keep track of xr session */
  55791. sessionManager: WebXRSessionManager;
  55792. /**
  55793. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  55794. */
  55795. state: WebXRState;
  55796. /**
  55797. * Creates a WebXRExperienceHelper
  55798. * @param scene The scene the helper should be created in
  55799. */
  55800. private constructor();
  55801. /**
  55802. * Creates the experience helper
  55803. * @param scene the scene to attach the experience helper to
  55804. * @returns a promise for the experience helper
  55805. */
  55806. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  55807. /**
  55808. * Disposes of the experience helper
  55809. */
  55810. dispose(): void;
  55811. /**
  55812. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  55813. * @param sessionMode options for the XR session
  55814. * @param referenceSpaceType frame of reference of the XR session
  55815. * @param renderTarget the output canvas that will be used to enter XR mode
  55816. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  55817. * @returns promise that resolves after xr mode has entered
  55818. */
  55819. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  55820. /**
  55821. * Exits XR mode and returns the scene to its original state
  55822. * @returns promise that resolves after xr mode has exited
  55823. */
  55824. exitXRAsync(): Promise<void>;
  55825. private _nonXRToXRCamera;
  55826. private _setState;
  55827. }
  55828. }
  55829. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  55830. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  55831. import { Observable } from "babylonjs/Misc/observable";
  55832. import { IDisposable } from "babylonjs/scene";
  55833. /**
  55834. * X-Y values for axes in WebXR
  55835. */
  55836. export interface IWebXRMotionControllerAxesValue {
  55837. /**
  55838. * The value of the x axis
  55839. */
  55840. x: number;
  55841. /**
  55842. * The value of the y-axis
  55843. */
  55844. y: number;
  55845. }
  55846. /**
  55847. * changed / previous values for the values of this component
  55848. */
  55849. export interface IWebXRMotionControllerComponentChangesValues<T> {
  55850. /**
  55851. * current (this frame) value
  55852. */
  55853. current: T;
  55854. /**
  55855. * previous (last change) value
  55856. */
  55857. previous: T;
  55858. }
  55859. /**
  55860. * Represents changes in the component between current frame and last values recorded
  55861. */
  55862. export interface IWebXRMotionControllerComponentChanges {
  55863. /**
  55864. * will be populated with previous and current values if axes changed
  55865. */
  55866. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  55867. /**
  55868. * will be populated with previous and current values if pressed changed
  55869. */
  55870. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55871. /**
  55872. * will be populated with previous and current values if touched changed
  55873. */
  55874. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55875. /**
  55876. * will be populated with previous and current values if value changed
  55877. */
  55878. value?: IWebXRMotionControllerComponentChangesValues<number>;
  55879. }
  55880. /**
  55881. * This class represents a single component (for example button or thumbstick) of a motion controller
  55882. */
  55883. export class WebXRControllerComponent implements IDisposable {
  55884. /**
  55885. * the id of this component
  55886. */
  55887. id: string;
  55888. /**
  55889. * the type of the component
  55890. */
  55891. type: MotionControllerComponentType;
  55892. private _buttonIndex;
  55893. private _axesIndices;
  55894. private _axes;
  55895. private _changes;
  55896. private _currentValue;
  55897. private _hasChanges;
  55898. private _pressed;
  55899. private _touched;
  55900. /**
  55901. * button component type
  55902. */
  55903. static BUTTON_TYPE: MotionControllerComponentType;
  55904. /**
  55905. * squeeze component type
  55906. */
  55907. static SQUEEZE_TYPE: MotionControllerComponentType;
  55908. /**
  55909. * Thumbstick component type
  55910. */
  55911. static THUMBSTICK_TYPE: MotionControllerComponentType;
  55912. /**
  55913. * Touchpad component type
  55914. */
  55915. static TOUCHPAD_TYPE: MotionControllerComponentType;
  55916. /**
  55917. * trigger component type
  55918. */
  55919. static TRIGGER_TYPE: MotionControllerComponentType;
  55920. /**
  55921. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  55922. * the axes data changes
  55923. */
  55924. onAxisValueChangedObservable: Observable<{
  55925. x: number;
  55926. y: number;
  55927. }>;
  55928. /**
  55929. * Observers registered here will be triggered when the state of a button changes
  55930. * State change is either pressed / touched / value
  55931. */
  55932. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  55933. /**
  55934. * Creates a new component for a motion controller.
  55935. * It is created by the motion controller itself
  55936. *
  55937. * @param id the id of this component
  55938. * @param type the type of the component
  55939. * @param _buttonIndex index in the buttons array of the gamepad
  55940. * @param _axesIndices indices of the values in the axes array of the gamepad
  55941. */
  55942. constructor(
  55943. /**
  55944. * the id of this component
  55945. */
  55946. id: string,
  55947. /**
  55948. * the type of the component
  55949. */
  55950. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  55951. /**
  55952. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  55953. */
  55954. get axes(): IWebXRMotionControllerAxesValue;
  55955. /**
  55956. * Get the changes. Elements will be populated only if they changed with their previous and current value
  55957. */
  55958. get changes(): IWebXRMotionControllerComponentChanges;
  55959. /**
  55960. * Return whether or not the component changed the last frame
  55961. */
  55962. get hasChanges(): boolean;
  55963. /**
  55964. * is the button currently pressed
  55965. */
  55966. get pressed(): boolean;
  55967. /**
  55968. * is the button currently touched
  55969. */
  55970. get touched(): boolean;
  55971. /**
  55972. * Get the current value of this component
  55973. */
  55974. get value(): number;
  55975. /**
  55976. * Dispose this component
  55977. */
  55978. dispose(): void;
  55979. /**
  55980. * Are there axes correlating to this component
  55981. * @return true is axes data is available
  55982. */
  55983. isAxes(): boolean;
  55984. /**
  55985. * Is this component a button (hence - pressable)
  55986. * @returns true if can be pressed
  55987. */
  55988. isButton(): boolean;
  55989. /**
  55990. * update this component using the gamepad object it is in. Called on every frame
  55991. * @param nativeController the native gamepad controller object
  55992. */
  55993. update(nativeController: IMinimalMotionControllerObject): void;
  55994. }
  55995. }
  55996. declare module "babylonjs/Loading/sceneLoader" {
  55997. import { Observable } from "babylonjs/Misc/observable";
  55998. import { Nullable } from "babylonjs/types";
  55999. import { Scene } from "babylonjs/scene";
  56000. import { Engine } from "babylonjs/Engines/engine";
  56001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56002. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56003. import { AssetContainer } from "babylonjs/assetContainer";
  56004. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56005. import { Skeleton } from "babylonjs/Bones/skeleton";
  56006. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  56007. import { WebRequest } from "babylonjs/Misc/webRequest";
  56008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56009. import { Geometry } from "babylonjs/Meshes/geometry";
  56010. import { Light } from "babylonjs/Lights/light";
  56011. /**
  56012. * Type used for the success callback of ImportMesh
  56013. */
  56014. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  56015. /**
  56016. * Interface used for the result of ImportMeshAsync
  56017. */
  56018. export interface ISceneLoaderAsyncResult {
  56019. /**
  56020. * The array of loaded meshes
  56021. */
  56022. readonly meshes: AbstractMesh[];
  56023. /**
  56024. * The array of loaded particle systems
  56025. */
  56026. readonly particleSystems: IParticleSystem[];
  56027. /**
  56028. * The array of loaded skeletons
  56029. */
  56030. readonly skeletons: Skeleton[];
  56031. /**
  56032. * The array of loaded animation groups
  56033. */
  56034. readonly animationGroups: AnimationGroup[];
  56035. /**
  56036. * The array of loaded transform nodes
  56037. */
  56038. readonly transformNodes: TransformNode[];
  56039. /**
  56040. * The array of loaded geometries
  56041. */
  56042. readonly geometries: Geometry[];
  56043. /**
  56044. * The array of loaded lights
  56045. */
  56046. readonly lights: Light[];
  56047. }
  56048. /**
  56049. * Interface used to represent data loading progression
  56050. */
  56051. export interface ISceneLoaderProgressEvent {
  56052. /**
  56053. * Defines if data length to load can be evaluated
  56054. */
  56055. readonly lengthComputable: boolean;
  56056. /**
  56057. * Defines the loaded data length
  56058. */
  56059. readonly loaded: number;
  56060. /**
  56061. * Defines the data length to load
  56062. */
  56063. readonly total: number;
  56064. }
  56065. /**
  56066. * Interface used by SceneLoader plugins to define supported file extensions
  56067. */
  56068. export interface ISceneLoaderPluginExtensions {
  56069. /**
  56070. * Defines the list of supported extensions
  56071. */
  56072. [extension: string]: {
  56073. isBinary: boolean;
  56074. };
  56075. }
  56076. /**
  56077. * Interface used by SceneLoader plugin factory
  56078. */
  56079. export interface ISceneLoaderPluginFactory {
  56080. /**
  56081. * Defines the name of the factory
  56082. */
  56083. name: string;
  56084. /**
  56085. * Function called to create a new plugin
  56086. * @return the new plugin
  56087. */
  56088. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56089. /**
  56090. * The callback that returns true if the data can be directly loaded.
  56091. * @param data string containing the file data
  56092. * @returns if the data can be loaded directly
  56093. */
  56094. canDirectLoad?(data: string): boolean;
  56095. }
  56096. /**
  56097. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  56098. */
  56099. export interface ISceneLoaderPluginBase {
  56100. /**
  56101. * The friendly name of this plugin.
  56102. */
  56103. name: string;
  56104. /**
  56105. * The file extensions supported by this plugin.
  56106. */
  56107. extensions: string | ISceneLoaderPluginExtensions;
  56108. /**
  56109. * The callback called when loading from a url.
  56110. * @param scene scene loading this url
  56111. * @param url url to load
  56112. * @param onSuccess callback called when the file successfully loads
  56113. * @param onProgress callback called while file is loading (if the server supports this mode)
  56114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  56115. * @param onError callback called when the file fails to load
  56116. * @returns a file request object
  56117. */
  56118. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56119. /**
  56120. * The callback called when loading from a file object.
  56121. * @param scene scene loading this file
  56122. * @param file defines the file to load
  56123. * @param onSuccess defines the callback to call when data is loaded
  56124. * @param onProgress defines the callback to call during loading process
  56125. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  56126. * @param onError defines the callback to call when an error occurs
  56127. * @returns a file request object
  56128. */
  56129. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56130. /**
  56131. * The callback that returns true if the data can be directly loaded.
  56132. * @param data string containing the file data
  56133. * @returns if the data can be loaded directly
  56134. */
  56135. canDirectLoad?(data: string): boolean;
  56136. /**
  56137. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  56138. * @param scene scene loading this data
  56139. * @param data string containing the data
  56140. * @returns data to pass to the plugin
  56141. */
  56142. directLoad?(scene: Scene, data: string): any;
  56143. /**
  56144. * The callback that allows custom handling of the root url based on the response url.
  56145. * @param rootUrl the original root url
  56146. * @param responseURL the response url if available
  56147. * @returns the new root url
  56148. */
  56149. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  56150. }
  56151. /**
  56152. * Interface used to define a SceneLoader plugin
  56153. */
  56154. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  56155. /**
  56156. * Import meshes into a scene.
  56157. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56158. * @param scene The scene to import into
  56159. * @param data The data to import
  56160. * @param rootUrl The root url for scene and resources
  56161. * @param meshes The meshes array to import into
  56162. * @param particleSystems The particle systems array to import into
  56163. * @param skeletons The skeletons array to import into
  56164. * @param onError The callback when import fails
  56165. * @returns True if successful or false otherwise
  56166. */
  56167. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  56168. /**
  56169. * Load into a scene.
  56170. * @param scene The scene to load into
  56171. * @param data The data to import
  56172. * @param rootUrl The root url for scene and resources
  56173. * @param onError The callback when import fails
  56174. * @returns True if successful or false otherwise
  56175. */
  56176. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  56177. /**
  56178. * Load into an asset container.
  56179. * @param scene The scene to load into
  56180. * @param data The data to import
  56181. * @param rootUrl The root url for scene and resources
  56182. * @param onError The callback when import fails
  56183. * @returns The loaded asset container
  56184. */
  56185. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  56186. }
  56187. /**
  56188. * Interface used to define an async SceneLoader plugin
  56189. */
  56190. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  56191. /**
  56192. * Import meshes into a scene.
  56193. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56194. * @param scene The scene to import into
  56195. * @param data The data to import
  56196. * @param rootUrl The root url for scene and resources
  56197. * @param onProgress The callback when the load progresses
  56198. * @param fileName Defines the name of the file to load
  56199. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  56200. */
  56201. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  56202. /**
  56203. * Load into a scene.
  56204. * @param scene The scene to load into
  56205. * @param data The data to import
  56206. * @param rootUrl The root url for scene and resources
  56207. * @param onProgress The callback when the load progresses
  56208. * @param fileName Defines the name of the file to load
  56209. * @returns Nothing
  56210. */
  56211. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56212. /**
  56213. * Load into an asset container.
  56214. * @param scene The scene to load into
  56215. * @param data The data to import
  56216. * @param rootUrl The root url for scene and resources
  56217. * @param onProgress The callback when the load progresses
  56218. * @param fileName Defines the name of the file to load
  56219. * @returns The loaded asset container
  56220. */
  56221. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56222. }
  56223. /**
  56224. * Mode that determines how to handle old animation groups before loading new ones.
  56225. */
  56226. export enum SceneLoaderAnimationGroupLoadingMode {
  56227. /**
  56228. * Reset all old animations to initial state then dispose them.
  56229. */
  56230. Clean = 0,
  56231. /**
  56232. * Stop all old animations.
  56233. */
  56234. Stop = 1,
  56235. /**
  56236. * Restart old animations from first frame.
  56237. */
  56238. Sync = 2,
  56239. /**
  56240. * Old animations remains untouched.
  56241. */
  56242. NoSync = 3
  56243. }
  56244. /**
  56245. * Defines a plugin registered by the SceneLoader
  56246. */
  56247. interface IRegisteredPlugin {
  56248. /**
  56249. * Defines the plugin to use
  56250. */
  56251. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56252. /**
  56253. * Defines if the plugin supports binary data
  56254. */
  56255. isBinary: boolean;
  56256. }
  56257. /**
  56258. * Class used to load scene from various file formats using registered plugins
  56259. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  56260. */
  56261. export class SceneLoader {
  56262. /**
  56263. * No logging while loading
  56264. */
  56265. static readonly NO_LOGGING: number;
  56266. /**
  56267. * Minimal logging while loading
  56268. */
  56269. static readonly MINIMAL_LOGGING: number;
  56270. /**
  56271. * Summary logging while loading
  56272. */
  56273. static readonly SUMMARY_LOGGING: number;
  56274. /**
  56275. * Detailled logging while loading
  56276. */
  56277. static readonly DETAILED_LOGGING: number;
  56278. /**
  56279. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  56280. */
  56281. static get ForceFullSceneLoadingForIncremental(): boolean;
  56282. static set ForceFullSceneLoadingForIncremental(value: boolean);
  56283. /**
  56284. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  56285. */
  56286. static get ShowLoadingScreen(): boolean;
  56287. static set ShowLoadingScreen(value: boolean);
  56288. /**
  56289. * Defines the current logging level (while loading the scene)
  56290. * @ignorenaming
  56291. */
  56292. static get loggingLevel(): number;
  56293. static set loggingLevel(value: number);
  56294. /**
  56295. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  56296. */
  56297. static get CleanBoneMatrixWeights(): boolean;
  56298. static set CleanBoneMatrixWeights(value: boolean);
  56299. /**
  56300. * Event raised when a plugin is used to load a scene
  56301. */
  56302. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56303. private static _registeredPlugins;
  56304. private static _showingLoadingScreen;
  56305. /**
  56306. * Gets the default plugin (used to load Babylon files)
  56307. * @returns the .babylon plugin
  56308. */
  56309. static GetDefaultPlugin(): IRegisteredPlugin;
  56310. private static _GetPluginForExtension;
  56311. private static _GetPluginForDirectLoad;
  56312. private static _GetPluginForFilename;
  56313. private static _GetDirectLoad;
  56314. private static _LoadData;
  56315. private static _GetFileInfo;
  56316. /**
  56317. * Gets a plugin that can load the given extension
  56318. * @param extension defines the extension to load
  56319. * @returns a plugin or null if none works
  56320. */
  56321. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56322. /**
  56323. * Gets a boolean indicating that the given extension can be loaded
  56324. * @param extension defines the extension to load
  56325. * @returns true if the extension is supported
  56326. */
  56327. static IsPluginForExtensionAvailable(extension: string): boolean;
  56328. /**
  56329. * Adds a new plugin to the list of registered plugins
  56330. * @param plugin defines the plugin to add
  56331. */
  56332. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  56333. /**
  56334. * Import meshes into a scene
  56335. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56336. * @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)
  56337. * @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)
  56338. * @param scene the instance of BABYLON.Scene to append to
  56339. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  56340. * @param onProgress a callback with a progress event for each file being loaded
  56341. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56342. * @param pluginExtension the extension used to determine the plugin
  56343. * @returns The loaded plugin
  56344. */
  56345. 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>;
  56346. /**
  56347. * Import meshes into a scene
  56348. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56349. * @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)
  56350. * @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)
  56351. * @param scene the instance of BABYLON.Scene to append to
  56352. * @param onProgress a callback with a progress event for each file being loaded
  56353. * @param pluginExtension the extension used to determine the plugin
  56354. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  56355. */
  56356. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  56357. /**
  56358. * Load a scene
  56359. * @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)
  56360. * @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)
  56361. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56362. * @param onSuccess a callback with the scene when import succeeds
  56363. * @param onProgress a callback with a progress event for each file being loaded
  56364. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56365. * @param pluginExtension the extension used to determine the plugin
  56366. * @returns The loaded plugin
  56367. */
  56368. 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>;
  56369. /**
  56370. * Load a scene
  56371. * @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)
  56372. * @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)
  56373. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56374. * @param onProgress a callback with a progress event for each file being loaded
  56375. * @param pluginExtension the extension used to determine the plugin
  56376. * @returns The loaded scene
  56377. */
  56378. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56379. /**
  56380. * Append a scene
  56381. * @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)
  56382. * @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)
  56383. * @param scene is the instance of BABYLON.Scene to append to
  56384. * @param onSuccess a callback with the scene when import succeeds
  56385. * @param onProgress a callback with a progress event for each file being loaded
  56386. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56387. * @param pluginExtension the extension used to determine the plugin
  56388. * @returns The loaded plugin
  56389. */
  56390. 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>;
  56391. /**
  56392. * Append a scene
  56393. * @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)
  56394. * @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)
  56395. * @param scene is the instance of BABYLON.Scene to append to
  56396. * @param onProgress a callback with a progress event for each file being loaded
  56397. * @param pluginExtension the extension used to determine the plugin
  56398. * @returns The given scene
  56399. */
  56400. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56401. /**
  56402. * Load a scene into an asset container
  56403. * @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)
  56404. * @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)
  56405. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56406. * @param onSuccess a callback with the scene when import succeeds
  56407. * @param onProgress a callback with a progress event for each file being loaded
  56408. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56409. * @param pluginExtension the extension used to determine the plugin
  56410. * @returns The loaded plugin
  56411. */
  56412. 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>;
  56413. /**
  56414. * Load a scene into an asset container
  56415. * @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)
  56416. * @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)
  56417. * @param scene is the instance of Scene to append to
  56418. * @param onProgress a callback with a progress event for each file being loaded
  56419. * @param pluginExtension the extension used to determine the plugin
  56420. * @returns The loaded asset container
  56421. */
  56422. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  56423. /**
  56424. * Import animations from a file into a scene
  56425. * @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)
  56426. * @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)
  56427. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56428. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56429. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56430. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56431. * @param onSuccess a callback with the scene when import succeeds
  56432. * @param onProgress a callback with a progress event for each file being loaded
  56433. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56434. * @param pluginExtension the extension used to determine the plugin
  56435. */
  56436. 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;
  56437. /**
  56438. * Import animations from a file into a scene
  56439. * @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)
  56440. * @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)
  56441. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56442. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56443. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56444. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56445. * @param onSuccess a callback with the scene when import succeeds
  56446. * @param onProgress a callback with a progress event for each file being loaded
  56447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56448. * @param pluginExtension the extension used to determine the plugin
  56449. * @returns the updated scene with imported animations
  56450. */
  56451. 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>;
  56452. }
  56453. }
  56454. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  56455. import { IDisposable, Scene } from "babylonjs/scene";
  56456. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  56457. import { Observable } from "babylonjs/Misc/observable";
  56458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56459. import { Nullable } from "babylonjs/types";
  56460. /**
  56461. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  56462. */
  56463. export type MotionControllerHandedness = "none" | "left" | "right";
  56464. /**
  56465. * The type of components available in motion controllers.
  56466. * This is not the name of the component.
  56467. */
  56468. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  56469. /**
  56470. * The state of a controller component
  56471. */
  56472. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  56473. /**
  56474. * The schema of motion controller layout.
  56475. * No object will be initialized using this interface
  56476. * This is used just to define the profile.
  56477. */
  56478. export interface IMotionControllerLayout {
  56479. /**
  56480. * Path to load the assets. Usually relative to the base path
  56481. */
  56482. assetPath: string;
  56483. /**
  56484. * Available components (unsorted)
  56485. */
  56486. components: {
  56487. /**
  56488. * A map of component Ids
  56489. */
  56490. [componentId: string]: {
  56491. /**
  56492. * The type of input the component outputs
  56493. */
  56494. type: MotionControllerComponentType;
  56495. /**
  56496. * The indices of this component in the gamepad object
  56497. */
  56498. gamepadIndices: {
  56499. /**
  56500. * Index of button
  56501. */
  56502. button?: number;
  56503. /**
  56504. * If available, index of x-axis
  56505. */
  56506. xAxis?: number;
  56507. /**
  56508. * If available, index of y-axis
  56509. */
  56510. yAxis?: number;
  56511. };
  56512. /**
  56513. * The mesh's root node name
  56514. */
  56515. rootNodeName: string;
  56516. /**
  56517. * Animation definitions for this model
  56518. */
  56519. visualResponses: {
  56520. [stateKey: string]: {
  56521. /**
  56522. * What property will be animated
  56523. */
  56524. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  56525. /**
  56526. * What states influence this visual response
  56527. */
  56528. states: MotionControllerComponentStateType[];
  56529. /**
  56530. * Type of animation - movement or visibility
  56531. */
  56532. valueNodeProperty: "transform" | "visibility";
  56533. /**
  56534. * Base node name to move. Its position will be calculated according to the min and max nodes
  56535. */
  56536. valueNodeName?: string;
  56537. /**
  56538. * Minimum movement node
  56539. */
  56540. minNodeName?: string;
  56541. /**
  56542. * Max movement node
  56543. */
  56544. maxNodeName?: string;
  56545. };
  56546. };
  56547. /**
  56548. * If touch enabled, what is the name of node to display user feedback
  56549. */
  56550. touchPointNodeName?: string;
  56551. };
  56552. };
  56553. /**
  56554. * Is it xr standard mapping or not
  56555. */
  56556. gamepadMapping: "" | "xr-standard";
  56557. /**
  56558. * Base root node of this entire model
  56559. */
  56560. rootNodeName: string;
  56561. /**
  56562. * Defines the main button component id
  56563. */
  56564. selectComponentId: string;
  56565. }
  56566. /**
  56567. * A definition for the layout map in the input profile
  56568. */
  56569. export interface IMotionControllerLayoutMap {
  56570. /**
  56571. * Layouts with handedness type as a key
  56572. */
  56573. [handedness: string]: IMotionControllerLayout;
  56574. }
  56575. /**
  56576. * The XR Input profile schema
  56577. * Profiles can be found here:
  56578. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  56579. */
  56580. export interface IMotionControllerProfile {
  56581. /**
  56582. * fallback profiles for this profileId
  56583. */
  56584. fallbackProfileIds: string[];
  56585. /**
  56586. * The layout map, with handedness as key
  56587. */
  56588. layouts: IMotionControllerLayoutMap;
  56589. /**
  56590. * The id of this profile
  56591. * correlates to the profile(s) in the xrInput.profiles array
  56592. */
  56593. profileId: string;
  56594. }
  56595. /**
  56596. * A helper-interface for the 3 meshes needed for controller button animation
  56597. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  56598. */
  56599. export interface IMotionControllerButtonMeshMap {
  56600. /**
  56601. * the mesh that defines the pressed value mesh position.
  56602. * This is used to find the max-position of this button
  56603. */
  56604. pressedMesh: AbstractMesh;
  56605. /**
  56606. * the mesh that defines the unpressed value mesh position.
  56607. * This is used to find the min (or initial) position of this button
  56608. */
  56609. unpressedMesh: AbstractMesh;
  56610. /**
  56611. * The mesh that will be changed when value changes
  56612. */
  56613. valueMesh: AbstractMesh;
  56614. }
  56615. /**
  56616. * A helper-interface for the 3 meshes needed for controller axis animation.
  56617. * This will be expanded when touchpad animations are fully supported
  56618. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  56619. */
  56620. export interface IMotionControllerMeshMap {
  56621. /**
  56622. * the mesh that defines the maximum value mesh position.
  56623. */
  56624. maxMesh?: AbstractMesh;
  56625. /**
  56626. * the mesh that defines the minimum value mesh position.
  56627. */
  56628. minMesh?: AbstractMesh;
  56629. /**
  56630. * The mesh that will be changed when axis value changes
  56631. */
  56632. valueMesh?: AbstractMesh;
  56633. }
  56634. /**
  56635. * The elements needed for change-detection of the gamepad objects in motion controllers
  56636. */
  56637. export interface IMinimalMotionControllerObject {
  56638. /**
  56639. * Available axes of this controller
  56640. */
  56641. axes: number[];
  56642. /**
  56643. * An array of available buttons
  56644. */
  56645. buttons: Array<{
  56646. /**
  56647. * Value of the button/trigger
  56648. */
  56649. value: number;
  56650. /**
  56651. * If the button/trigger is currently touched
  56652. */
  56653. touched: boolean;
  56654. /**
  56655. * If the button/trigger is currently pressed
  56656. */
  56657. pressed: boolean;
  56658. }>;
  56659. /**
  56660. * EXPERIMENTAL haptic support.
  56661. */
  56662. hapticActuators?: Array<{
  56663. pulse: (value: number, duration: number) => Promise<boolean>;
  56664. }>;
  56665. }
  56666. /**
  56667. * An Abstract Motion controller
  56668. * This class receives an xrInput and a profile layout and uses those to initialize the components
  56669. * Each component has an observable to check for changes in value and state
  56670. */
  56671. export abstract class WebXRAbstractMotionController implements IDisposable {
  56672. protected scene: Scene;
  56673. protected layout: IMotionControllerLayout;
  56674. /**
  56675. * The gamepad object correlating to this controller
  56676. */
  56677. gamepadObject: IMinimalMotionControllerObject;
  56678. /**
  56679. * handedness (left/right/none) of this controller
  56680. */
  56681. handedness: MotionControllerHandedness;
  56682. private _initComponent;
  56683. private _modelReady;
  56684. /**
  56685. * A map of components (WebXRControllerComponent) in this motion controller
  56686. * Components have a ComponentType and can also have both button and axis definitions
  56687. */
  56688. readonly components: {
  56689. [id: string]: WebXRControllerComponent;
  56690. };
  56691. /**
  56692. * Disable the model's animation. Can be set at any time.
  56693. */
  56694. disableAnimation: boolean;
  56695. /**
  56696. * Observers registered here will be triggered when the model of this controller is done loading
  56697. */
  56698. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  56699. /**
  56700. * The profile id of this motion controller
  56701. */
  56702. abstract profileId: string;
  56703. /**
  56704. * The root mesh of the model. It is null if the model was not yet initialized
  56705. */
  56706. rootMesh: Nullable<AbstractMesh>;
  56707. /**
  56708. * constructs a new abstract motion controller
  56709. * @param scene the scene to which the model of the controller will be added
  56710. * @param layout The profile layout to load
  56711. * @param gamepadObject The gamepad object correlating to this controller
  56712. * @param handedness handedness (left/right/none) of this controller
  56713. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  56714. */
  56715. constructor(scene: Scene, layout: IMotionControllerLayout,
  56716. /**
  56717. * The gamepad object correlating to this controller
  56718. */
  56719. gamepadObject: IMinimalMotionControllerObject,
  56720. /**
  56721. * handedness (left/right/none) of this controller
  56722. */
  56723. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  56724. /**
  56725. * Dispose this controller, the model mesh and all its components
  56726. */
  56727. dispose(): void;
  56728. /**
  56729. * Returns all components of specific type
  56730. * @param type the type to search for
  56731. * @return an array of components with this type
  56732. */
  56733. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  56734. /**
  56735. * get a component based an its component id as defined in layout.components
  56736. * @param id the id of the component
  56737. * @returns the component correlates to the id or undefined if not found
  56738. */
  56739. getComponent(id: string): WebXRControllerComponent;
  56740. /**
  56741. * Get the list of components available in this motion controller
  56742. * @returns an array of strings correlating to available components
  56743. */
  56744. getComponentIds(): string[];
  56745. /**
  56746. * Get the first component of specific type
  56747. * @param type type of component to find
  56748. * @return a controller component or null if not found
  56749. */
  56750. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  56751. /**
  56752. * Get the main (Select) component of this controller as defined in the layout
  56753. * @returns the main component of this controller
  56754. */
  56755. getMainComponent(): WebXRControllerComponent;
  56756. /**
  56757. * Loads the model correlating to this controller
  56758. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  56759. * @returns A promise fulfilled with the result of the model loading
  56760. */
  56761. loadModel(): Promise<boolean>;
  56762. /**
  56763. * Update this model using the current XRFrame
  56764. * @param xrFrame the current xr frame to use and update the model
  56765. */
  56766. updateFromXRFrame(xrFrame: XRFrame): void;
  56767. /**
  56768. * Backwards compatibility due to a deeply-integrated typo
  56769. */
  56770. get handness(): XREye;
  56771. /**
  56772. * Pulse (vibrate) this controller
  56773. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  56774. * Consecutive calls to this function will cancel the last pulse call
  56775. *
  56776. * @param value the strength of the pulse in 0.0...1.0 range
  56777. * @param duration Duration of the pulse in milliseconds
  56778. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  56779. * @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
  56780. */
  56781. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  56782. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56783. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56784. /**
  56785. * Moves the axis on the controller mesh based on its current state
  56786. * @param axis the index of the axis
  56787. * @param axisValue the value of the axis which determines the meshes new position
  56788. * @hidden
  56789. */
  56790. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  56791. /**
  56792. * Update the model itself with the current frame data
  56793. * @param xrFrame the frame to use for updating the model mesh
  56794. */
  56795. protected updateModel(xrFrame: XRFrame): void;
  56796. /**
  56797. * Get the filename and path for this controller's model
  56798. * @returns a map of filename and path
  56799. */
  56800. protected abstract _getFilenameAndPath(): {
  56801. filename: string;
  56802. path: string;
  56803. };
  56804. /**
  56805. * This function is called before the mesh is loaded. It checks for loading constraints.
  56806. * For example, this function can check if the GLB loader is available
  56807. * If this function returns false, the generic controller will be loaded instead
  56808. * @returns Is the client ready to load the mesh
  56809. */
  56810. protected abstract _getModelLoadingConstraints(): boolean;
  56811. /**
  56812. * This function will be called after the model was successfully loaded and can be used
  56813. * for mesh transformations before it is available for the user
  56814. * @param meshes the loaded meshes
  56815. */
  56816. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  56817. /**
  56818. * Set the root mesh for this controller. Important for the WebXR controller class
  56819. * @param meshes the loaded meshes
  56820. */
  56821. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  56822. /**
  56823. * A function executed each frame that updates the mesh (if needed)
  56824. * @param xrFrame the current xrFrame
  56825. */
  56826. protected abstract _updateModel(xrFrame: XRFrame): void;
  56827. private _getGenericFilenameAndPath;
  56828. private _getGenericParentMesh;
  56829. }
  56830. }
  56831. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  56832. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56834. import { Scene } from "babylonjs/scene";
  56835. /**
  56836. * A generic trigger-only motion controller for WebXR
  56837. */
  56838. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  56839. /**
  56840. * Static version of the profile id of this controller
  56841. */
  56842. static ProfileId: string;
  56843. profileId: string;
  56844. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  56845. protected _getFilenameAndPath(): {
  56846. filename: string;
  56847. path: string;
  56848. };
  56849. protected _getModelLoadingConstraints(): boolean;
  56850. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  56851. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56852. protected _updateModel(): void;
  56853. }
  56854. }
  56855. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  56856. import { Vector4 } from "babylonjs/Maths/math.vector";
  56857. import { Mesh } from "babylonjs/Meshes/mesh";
  56858. import { Scene } from "babylonjs/scene";
  56859. import { Nullable } from "babylonjs/types";
  56860. /**
  56861. * Class containing static functions to help procedurally build meshes
  56862. */
  56863. export class SphereBuilder {
  56864. /**
  56865. * Creates a sphere mesh
  56866. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56867. * * 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`)
  56868. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56869. * * 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
  56870. * * 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)
  56871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56872. * * 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
  56873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56874. * @param name defines the name of the mesh
  56875. * @param options defines the options used to create the mesh
  56876. * @param scene defines the hosting scene
  56877. * @returns the sphere mesh
  56878. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56879. */
  56880. static CreateSphere(name: string, options: {
  56881. segments?: number;
  56882. diameter?: number;
  56883. diameterX?: number;
  56884. diameterY?: number;
  56885. diameterZ?: number;
  56886. arc?: number;
  56887. slice?: number;
  56888. sideOrientation?: number;
  56889. frontUVs?: Vector4;
  56890. backUVs?: Vector4;
  56891. updatable?: boolean;
  56892. }, scene?: Nullable<Scene>): Mesh;
  56893. }
  56894. }
  56895. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  56896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56897. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56898. import { Scene } from "babylonjs/scene";
  56899. /**
  56900. * A profiled motion controller has its profile loaded from an online repository.
  56901. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  56902. */
  56903. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  56904. private _repositoryUrl;
  56905. private _buttonMeshMapping;
  56906. private _touchDots;
  56907. /**
  56908. * The profile ID of this controller. Will be populated when the controller initializes.
  56909. */
  56910. profileId: string;
  56911. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  56912. dispose(): void;
  56913. protected _getFilenameAndPath(): {
  56914. filename: string;
  56915. path: string;
  56916. };
  56917. protected _getModelLoadingConstraints(): boolean;
  56918. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  56919. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56920. protected _updateModel(_xrFrame: XRFrame): void;
  56921. }
  56922. }
  56923. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  56924. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56925. import { Scene } from "babylonjs/scene";
  56926. /**
  56927. * A construction function type to create a new controller based on an xrInput object
  56928. */
  56929. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  56930. /**
  56931. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  56932. *
  56933. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  56934. * it should be replaced with auto-loaded controllers.
  56935. *
  56936. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  56937. */
  56938. export class WebXRMotionControllerManager {
  56939. private static _AvailableControllers;
  56940. private static _Fallbacks;
  56941. private static _ProfileLoadingPromises;
  56942. private static _ProfilesList;
  56943. /**
  56944. * The base URL of the online controller repository. Can be changed at any time.
  56945. */
  56946. static BaseRepositoryUrl: string;
  56947. /**
  56948. * Which repository gets priority - local or online
  56949. */
  56950. static PrioritizeOnlineRepository: boolean;
  56951. /**
  56952. * Use the online repository, or use only locally-defined controllers
  56953. */
  56954. static UseOnlineRepository: boolean;
  56955. /**
  56956. * Clear the cache used for profile loading and reload when requested again
  56957. */
  56958. static ClearProfilesCache(): void;
  56959. /**
  56960. * Register the default fallbacks.
  56961. * This function is called automatically when this file is imported.
  56962. */
  56963. static DefaultFallbacks(): void;
  56964. /**
  56965. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  56966. * @param profileId the profile to which a fallback needs to be found
  56967. * @return an array with corresponding fallback profiles
  56968. */
  56969. static FindFallbackWithProfileId(profileId: string): string[];
  56970. /**
  56971. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  56972. * The order of search:
  56973. *
  56974. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  56975. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  56976. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  56977. * 4) return the generic trigger controller if none were found
  56978. *
  56979. * @param xrInput the xrInput to which a new controller is initialized
  56980. * @param scene the scene to which the model will be added
  56981. * @param forceProfile force a certain profile for this controller
  56982. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  56983. */
  56984. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  56985. /**
  56986. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  56987. *
  56988. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  56989. *
  56990. * @param type the profile type to register
  56991. * @param constructFunction the function to be called when loading this profile
  56992. */
  56993. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  56994. /**
  56995. * Register a fallback to a specific profile.
  56996. * @param profileId the profileId that will receive the fallbacks
  56997. * @param fallbacks A list of fallback profiles
  56998. */
  56999. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  57000. /**
  57001. * Will update the list of profiles available in the repository
  57002. * @return a promise that resolves to a map of profiles available online
  57003. */
  57004. static UpdateProfilesList(): Promise<{
  57005. [profile: string]: string;
  57006. }>;
  57007. private static _LoadProfileFromRepository;
  57008. private static _LoadProfilesFromAvailableControllers;
  57009. }
  57010. }
  57011. declare module "babylonjs/XR/webXRInputSource" {
  57012. import { Observable } from "babylonjs/Misc/observable";
  57013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57014. import { Ray } from "babylonjs/Culling/ray";
  57015. import { Scene } from "babylonjs/scene";
  57016. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57017. /**
  57018. * Configuration options for the WebXR controller creation
  57019. */
  57020. export interface IWebXRControllerOptions {
  57021. /**
  57022. * Should the controller mesh be animated when a user interacts with it
  57023. * The pressed buttons / thumbstick and touchpad animations will be disabled
  57024. */
  57025. disableMotionControllerAnimation?: boolean;
  57026. /**
  57027. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  57028. */
  57029. doNotLoadControllerMesh?: boolean;
  57030. /**
  57031. * Force a specific controller type for this controller.
  57032. * This can be used when creating your own profile or when testing different controllers
  57033. */
  57034. forceControllerProfile?: string;
  57035. /**
  57036. * Defines a rendering group ID for meshes that will be loaded.
  57037. * This is for the default controllers only.
  57038. */
  57039. renderingGroupId?: number;
  57040. }
  57041. /**
  57042. * Represents an XR controller
  57043. */
  57044. export class WebXRInputSource {
  57045. private _scene;
  57046. /** The underlying input source for the controller */
  57047. inputSource: XRInputSource;
  57048. private _options;
  57049. private _tmpVector;
  57050. private _uniqueId;
  57051. private _disposed;
  57052. /**
  57053. * 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
  57054. */
  57055. grip?: AbstractMesh;
  57056. /**
  57057. * If available, this is the gamepad object related to this controller.
  57058. * Using this object it is possible to get click events and trackpad changes of the
  57059. * webxr controller that is currently being used.
  57060. */
  57061. motionController?: WebXRAbstractMotionController;
  57062. /**
  57063. * Event that fires when the controller is removed/disposed.
  57064. * The object provided as event data is this controller, after associated assets were disposed.
  57065. * uniqueId is still available.
  57066. */
  57067. onDisposeObservable: Observable<WebXRInputSource>;
  57068. /**
  57069. * Will be triggered when the mesh associated with the motion controller is done loading.
  57070. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  57071. * A shortened version of controller -> motion controller -> on mesh loaded.
  57072. */
  57073. onMeshLoadedObservable: Observable<AbstractMesh>;
  57074. /**
  57075. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  57076. */
  57077. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  57078. /**
  57079. * Pointer which can be used to select objects or attach a visible laser to
  57080. */
  57081. pointer: AbstractMesh;
  57082. /**
  57083. * Creates the input source object
  57084. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  57085. * @param _scene the scene which the controller should be associated to
  57086. * @param inputSource the underlying input source for the controller
  57087. * @param _options options for this controller creation
  57088. */
  57089. constructor(_scene: Scene,
  57090. /** The underlying input source for the controller */
  57091. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  57092. /**
  57093. * Get this controllers unique id
  57094. */
  57095. get uniqueId(): string;
  57096. /**
  57097. * Disposes of the object
  57098. */
  57099. dispose(): void;
  57100. /**
  57101. * Gets a world space ray coming from the pointer or grip
  57102. * @param result the resulting ray
  57103. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  57104. */
  57105. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  57106. /**
  57107. * Updates the controller pose based on the given XRFrame
  57108. * @param xrFrame xr frame to update the pose with
  57109. * @param referenceSpace reference space to use
  57110. */
  57111. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  57112. }
  57113. }
  57114. declare module "babylonjs/XR/webXRInput" {
  57115. import { Observable } from "babylonjs/Misc/observable";
  57116. import { IDisposable } from "babylonjs/scene";
  57117. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  57118. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57119. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57120. /**
  57121. * The schema for initialization options of the XR Input class
  57122. */
  57123. export interface IWebXRInputOptions {
  57124. /**
  57125. * If set to true no model will be automatically loaded
  57126. */
  57127. doNotLoadControllerMeshes?: boolean;
  57128. /**
  57129. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  57130. * If not found, the xr input profile data will be used.
  57131. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  57132. */
  57133. forceInputProfile?: string;
  57134. /**
  57135. * Do not send a request to the controller repository to load the profile.
  57136. *
  57137. * Instead, use the controllers available in babylon itself.
  57138. */
  57139. disableOnlineControllerRepository?: boolean;
  57140. /**
  57141. * A custom URL for the controllers repository
  57142. */
  57143. customControllersRepositoryURL?: string;
  57144. /**
  57145. * Should the controller model's components not move according to the user input
  57146. */
  57147. disableControllerAnimation?: boolean;
  57148. /**
  57149. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  57150. */
  57151. controllerOptions?: IWebXRControllerOptions;
  57152. }
  57153. /**
  57154. * XR input used to track XR inputs such as controllers/rays
  57155. */
  57156. export class WebXRInput implements IDisposable {
  57157. /**
  57158. * the xr session manager for this session
  57159. */
  57160. xrSessionManager: WebXRSessionManager;
  57161. /**
  57162. * the WebXR camera for this session. Mainly used for teleportation
  57163. */
  57164. xrCamera: WebXRCamera;
  57165. private readonly options;
  57166. /**
  57167. * XR controllers being tracked
  57168. */
  57169. controllers: Array<WebXRInputSource>;
  57170. private _frameObserver;
  57171. private _sessionEndedObserver;
  57172. private _sessionInitObserver;
  57173. /**
  57174. * Event when a controller has been connected/added
  57175. */
  57176. onControllerAddedObservable: Observable<WebXRInputSource>;
  57177. /**
  57178. * Event when a controller has been removed/disconnected
  57179. */
  57180. onControllerRemovedObservable: Observable<WebXRInputSource>;
  57181. /**
  57182. * Initializes the WebXRInput
  57183. * @param xrSessionManager the xr session manager for this session
  57184. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  57185. * @param options = initialization options for this xr input
  57186. */
  57187. constructor(
  57188. /**
  57189. * the xr session manager for this session
  57190. */
  57191. xrSessionManager: WebXRSessionManager,
  57192. /**
  57193. * the WebXR camera for this session. Mainly used for teleportation
  57194. */
  57195. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  57196. private _onInputSourcesChange;
  57197. private _addAndRemoveControllers;
  57198. /**
  57199. * Disposes of the object
  57200. */
  57201. dispose(): void;
  57202. }
  57203. }
  57204. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  57205. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  57206. import { Observable, EventState } from "babylonjs/Misc/observable";
  57207. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57208. /**
  57209. * This is the base class for all WebXR features.
  57210. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  57211. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  57212. */
  57213. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  57214. protected _xrSessionManager: WebXRSessionManager;
  57215. private _attached;
  57216. private _removeOnDetach;
  57217. /**
  57218. * Is this feature disposed?
  57219. */
  57220. isDisposed: boolean;
  57221. /**
  57222. * Should auto-attach be disabled?
  57223. */
  57224. disableAutoAttach: boolean;
  57225. /**
  57226. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  57227. */
  57228. xrNativeFeatureName: string;
  57229. /**
  57230. * Construct a new (abstract) WebXR feature
  57231. * @param _xrSessionManager the xr session manager for this feature
  57232. */
  57233. constructor(_xrSessionManager: WebXRSessionManager);
  57234. /**
  57235. * Is this feature attached
  57236. */
  57237. get attached(): boolean;
  57238. /**
  57239. * attach this feature
  57240. *
  57241. * @param force should attachment be forced (even when already attached)
  57242. * @returns true if successful, false is failed or already attached
  57243. */
  57244. attach(force?: boolean): boolean;
  57245. /**
  57246. * detach this feature.
  57247. *
  57248. * @returns true if successful, false if failed or already detached
  57249. */
  57250. detach(): boolean;
  57251. /**
  57252. * Dispose this feature and all of the resources attached
  57253. */
  57254. dispose(): void;
  57255. /**
  57256. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  57257. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  57258. *
  57259. * @returns whether or not the feature is compatible in this environment
  57260. */
  57261. isCompatible(): boolean;
  57262. /**
  57263. * This is used to register callbacks that will automatically be removed when detach is called.
  57264. * @param observable the observable to which the observer will be attached
  57265. * @param callback the callback to register
  57266. */
  57267. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  57268. /**
  57269. * Code in this function will be executed on each xrFrame received from the browser.
  57270. * This function will not execute after the feature is detached.
  57271. * @param _xrFrame the current frame
  57272. */
  57273. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  57274. }
  57275. }
  57276. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  57277. import { IDisposable, Scene } from "babylonjs/scene";
  57278. import { Nullable } from "babylonjs/types";
  57279. import { Observable } from "babylonjs/Misc/observable";
  57280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57281. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  57282. import { Camera } from "babylonjs/Cameras/camera";
  57283. /**
  57284. * Renders a layer on top of an existing scene
  57285. */
  57286. export class UtilityLayerRenderer implements IDisposable {
  57287. /** the original scene that will be rendered on top of */
  57288. originalScene: Scene;
  57289. private _pointerCaptures;
  57290. private _lastPointerEvents;
  57291. private static _DefaultUtilityLayer;
  57292. private static _DefaultKeepDepthUtilityLayer;
  57293. private _sharedGizmoLight;
  57294. private _renderCamera;
  57295. /**
  57296. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  57297. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  57298. * @returns the camera that is used when rendering the utility layer
  57299. */
  57300. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  57301. /**
  57302. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  57303. * @param cam the camera that should be used when rendering the utility layer
  57304. */
  57305. setRenderCamera(cam: Nullable<Camera>): void;
  57306. /**
  57307. * @hidden
  57308. * Light which used by gizmos to get light shading
  57309. */
  57310. _getSharedGizmoLight(): HemisphericLight;
  57311. /**
  57312. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  57313. */
  57314. pickUtilitySceneFirst: boolean;
  57315. /**
  57316. * 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)
  57317. */
  57318. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  57319. /**
  57320. * 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)
  57321. */
  57322. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  57323. /**
  57324. * The scene that is rendered on top of the original scene
  57325. */
  57326. utilityLayerScene: Scene;
  57327. /**
  57328. * If the utility layer should automatically be rendered on top of existing scene
  57329. */
  57330. shouldRender: boolean;
  57331. /**
  57332. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  57333. */
  57334. onlyCheckPointerDownEvents: boolean;
  57335. /**
  57336. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  57337. */
  57338. processAllEvents: boolean;
  57339. /**
  57340. * Observable raised when the pointer move from the utility layer scene to the main scene
  57341. */
  57342. onPointerOutObservable: Observable<number>;
  57343. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  57344. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  57345. private _afterRenderObserver;
  57346. private _sceneDisposeObserver;
  57347. private _originalPointerObserver;
  57348. /**
  57349. * Instantiates a UtilityLayerRenderer
  57350. * @param originalScene the original scene that will be rendered on top of
  57351. * @param handleEvents boolean indicating if the utility layer should handle events
  57352. */
  57353. constructor(
  57354. /** the original scene that will be rendered on top of */
  57355. originalScene: Scene, handleEvents?: boolean);
  57356. private _notifyObservers;
  57357. /**
  57358. * Renders the utility layers scene on top of the original scene
  57359. */
  57360. render(): void;
  57361. /**
  57362. * Disposes of the renderer
  57363. */
  57364. dispose(): void;
  57365. private _updateCamera;
  57366. }
  57367. }
  57368. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  57369. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57371. import { WebXRInput } from "babylonjs/XR/webXRInput";
  57372. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  57373. import { Scene } from "babylonjs/scene";
  57374. import { Nullable } from "babylonjs/types";
  57375. import { Color3 } from "babylonjs/Maths/math.color";
  57376. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  57377. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57378. /**
  57379. * Options interface for the pointer selection module
  57380. */
  57381. export interface IWebXRControllerPointerSelectionOptions {
  57382. /**
  57383. * if provided, this scene will be used to render meshes.
  57384. */
  57385. customUtilityLayerScene?: Scene;
  57386. /**
  57387. * 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)
  57388. * If not disabled, the last picked point will be used to execute a pointer up event
  57389. * If disabled, pointer up event will be triggered right after the pointer down event.
  57390. * Used in screen and gaze target ray mode only
  57391. */
  57392. disablePointerUpOnTouchOut: boolean;
  57393. /**
  57394. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  57395. */
  57396. forceGazeMode: boolean;
  57397. /**
  57398. * 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
  57399. * to start a new countdown to the pointer down event.
  57400. * Defaults to 1.
  57401. */
  57402. gazeModePointerMovedFactor?: number;
  57403. /**
  57404. * Different button type to use instead of the main component
  57405. */
  57406. overrideButtonId?: string;
  57407. /**
  57408. * use this rendering group id for the meshes (optional)
  57409. */
  57410. renderingGroupId?: number;
  57411. /**
  57412. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  57413. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  57414. * 3000 means 3 seconds between pointing at something and selecting it
  57415. */
  57416. timeToSelect?: number;
  57417. /**
  57418. * Should meshes created here be added to a utility layer or the main scene
  57419. */
  57420. useUtilityLayer?: boolean;
  57421. /**
  57422. * Optional WebXR camera to be used for gaze selection
  57423. */
  57424. gazeCamera?: WebXRCamera;
  57425. /**
  57426. * the xr input to use with this pointer selection
  57427. */
  57428. xrInput: WebXRInput;
  57429. /**
  57430. * Should the scene pointerX and pointerY update be disabled
  57431. * This is required for fullscreen AR GUI, but might slow down other experiences.
  57432. * Disable in VR, if not needed.
  57433. * The first rig camera (left eye) will be used to calculate the projection
  57434. */
  57435. disableScenePointerVectorUpdate: boolean;
  57436. /**
  57437. * Enable pointer selection on all controllers instead of switching between them
  57438. */
  57439. enablePointerSelectionOnAllControllers?: boolean;
  57440. /**
  57441. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  57442. * If switch is enabled, it will still allow the user to switch between the different controllers
  57443. */
  57444. preferredHandedness?: XRHandedness;
  57445. /**
  57446. * Disable switching the pointer selection from one controller to the other.
  57447. * 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
  57448. */
  57449. disableSwitchOnClick?: boolean;
  57450. /**
  57451. * The maximum distance of the pointer selection feature. Defaults to 100.
  57452. */
  57453. maxPointerDistance?: number;
  57454. }
  57455. /**
  57456. * A module that will enable pointer selection for motion controllers of XR Input Sources
  57457. */
  57458. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  57459. private readonly _options;
  57460. private static _idCounter;
  57461. private _attachController;
  57462. private _controllers;
  57463. private _scene;
  57464. private _tmpVectorForPickCompare;
  57465. private _attachedController;
  57466. /**
  57467. * The module's name
  57468. */
  57469. static readonly Name: string;
  57470. /**
  57471. * The (Babylon) version of this module.
  57472. * This is an integer representing the implementation version.
  57473. * This number does not correspond to the WebXR specs version
  57474. */
  57475. static readonly Version: number;
  57476. /**
  57477. * Disable lighting on the laser pointer (so it will always be visible)
  57478. */
  57479. disablePointerLighting: boolean;
  57480. /**
  57481. * Disable lighting on the selection mesh (so it will always be visible)
  57482. */
  57483. disableSelectionMeshLighting: boolean;
  57484. /**
  57485. * Should the laser pointer be displayed
  57486. */
  57487. displayLaserPointer: boolean;
  57488. /**
  57489. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  57490. */
  57491. displaySelectionMesh: boolean;
  57492. /**
  57493. * This color will be set to the laser pointer when selection is triggered
  57494. */
  57495. laserPointerPickedColor: Color3;
  57496. /**
  57497. * Default color of the laser pointer
  57498. */
  57499. laserPointerDefaultColor: Color3;
  57500. /**
  57501. * default color of the selection ring
  57502. */
  57503. selectionMeshDefaultColor: Color3;
  57504. /**
  57505. * This color will be applied to the selection ring when selection is triggered
  57506. */
  57507. selectionMeshPickedColor: Color3;
  57508. /**
  57509. * Optional filter to be used for ray selection. This predicate shares behavior with
  57510. * scene.pointerMovePredicate which takes priority if it is also assigned.
  57511. */
  57512. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57513. /**
  57514. * constructs a new background remover module
  57515. * @param _xrSessionManager the session manager for this module
  57516. * @param _options read-only options to be used in this module
  57517. */
  57518. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  57519. /**
  57520. * attach this feature
  57521. * Will usually be called by the features manager
  57522. *
  57523. * @returns true if successful.
  57524. */
  57525. attach(): boolean;
  57526. /**
  57527. * detach this feature.
  57528. * Will usually be called by the features manager
  57529. *
  57530. * @returns true if successful.
  57531. */
  57532. detach(): boolean;
  57533. /**
  57534. * Will get the mesh under a specific pointer.
  57535. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  57536. * @param controllerId the controllerId to check
  57537. * @returns The mesh under pointer or null if no mesh is under the pointer
  57538. */
  57539. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  57540. /**
  57541. * Get the xr controller that correlates to the pointer id in the pointer event
  57542. *
  57543. * @param id the pointer id to search for
  57544. * @returns the controller that correlates to this id or null if not found
  57545. */
  57546. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  57547. private _identityMatrix;
  57548. private _screenCoordinatesRef;
  57549. private _viewportRef;
  57550. protected _onXRFrame(_xrFrame: XRFrame): void;
  57551. private _attachGazeMode;
  57552. private _attachScreenRayMode;
  57553. private _attachTrackedPointerRayMode;
  57554. private _convertNormalToDirectionOfRay;
  57555. private _detachController;
  57556. private _generateNewMeshPair;
  57557. private _pickingMoved;
  57558. private _updatePointerDistance;
  57559. /** @hidden */
  57560. get lasterPointerDefaultColor(): Color3;
  57561. }
  57562. }
  57563. declare module "babylonjs/XR/webXREnterExitUI" {
  57564. import { Nullable } from "babylonjs/types";
  57565. import { Observable } from "babylonjs/Misc/observable";
  57566. import { IDisposable, Scene } from "babylonjs/scene";
  57567. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  57568. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  57569. /**
  57570. * Button which can be used to enter a different mode of XR
  57571. */
  57572. export class WebXREnterExitUIButton {
  57573. /** button element */
  57574. element: HTMLElement;
  57575. /** XR initialization options for the button */
  57576. sessionMode: XRSessionMode;
  57577. /** Reference space type */
  57578. referenceSpaceType: XRReferenceSpaceType;
  57579. /**
  57580. * Creates a WebXREnterExitUIButton
  57581. * @param element button element
  57582. * @param sessionMode XR initialization session mode
  57583. * @param referenceSpaceType the type of reference space to be used
  57584. */
  57585. constructor(
  57586. /** button element */
  57587. element: HTMLElement,
  57588. /** XR initialization options for the button */
  57589. sessionMode: XRSessionMode,
  57590. /** Reference space type */
  57591. referenceSpaceType: XRReferenceSpaceType);
  57592. /**
  57593. * Extendable function which can be used to update the button's visuals when the state changes
  57594. * @param activeButton the current active button in the UI
  57595. */
  57596. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  57597. }
  57598. /**
  57599. * Options to create the webXR UI
  57600. */
  57601. export class WebXREnterExitUIOptions {
  57602. /**
  57603. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  57604. */
  57605. customButtons?: Array<WebXREnterExitUIButton>;
  57606. /**
  57607. * A reference space type to use when creating the default button.
  57608. * Default is local-floor
  57609. */
  57610. referenceSpaceType?: XRReferenceSpaceType;
  57611. /**
  57612. * Context to enter xr with
  57613. */
  57614. renderTarget?: Nullable<WebXRRenderTarget>;
  57615. /**
  57616. * A session mode to use when creating the default button.
  57617. * Default is immersive-vr
  57618. */
  57619. sessionMode?: XRSessionMode;
  57620. /**
  57621. * A list of optional features to init the session with
  57622. */
  57623. optionalFeatures?: string[];
  57624. /**
  57625. * A list of optional features to init the session with
  57626. */
  57627. requiredFeatures?: string[];
  57628. /**
  57629. * If defined, this function will be executed if the UI encounters an error when entering XR
  57630. */
  57631. onError?: (error: any) => void;
  57632. }
  57633. /**
  57634. * UI to allow the user to enter/exit XR mode
  57635. */
  57636. export class WebXREnterExitUI implements IDisposable {
  57637. private scene;
  57638. /** version of the options passed to this UI */
  57639. options: WebXREnterExitUIOptions;
  57640. private _activeButton;
  57641. private _buttons;
  57642. /**
  57643. * The HTML Div Element to which buttons are added.
  57644. */
  57645. readonly overlay: HTMLDivElement;
  57646. /**
  57647. * Fired every time the active button is changed.
  57648. *
  57649. * When xr is entered via a button that launches xr that button will be the callback parameter
  57650. *
  57651. * When exiting xr the callback parameter will be null)
  57652. */
  57653. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  57654. /**
  57655. *
  57656. * @param scene babylon scene object to use
  57657. * @param options (read-only) version of the options passed to this UI
  57658. */
  57659. private constructor();
  57660. /**
  57661. * Creates UI to allow the user to enter/exit XR mode
  57662. * @param scene the scene to add the ui to
  57663. * @param helper the xr experience helper to enter/exit xr with
  57664. * @param options options to configure the UI
  57665. * @returns the created ui
  57666. */
  57667. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  57668. /**
  57669. * Disposes of the XR UI component
  57670. */
  57671. dispose(): void;
  57672. private _updateButtons;
  57673. }
  57674. }
  57675. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  57676. import { Vector3 } from "babylonjs/Maths/math.vector";
  57677. import { Color4 } from "babylonjs/Maths/math.color";
  57678. import { Nullable } from "babylonjs/types";
  57679. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57680. import { Scene } from "babylonjs/scene";
  57681. /**
  57682. * Class containing static functions to help procedurally build meshes
  57683. */
  57684. export class LinesBuilder {
  57685. /**
  57686. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57687. * * 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
  57688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57689. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57690. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57691. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57693. * * 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
  57694. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57697. * @param name defines the name of the new line system
  57698. * @param options defines the options used to create the line system
  57699. * @param scene defines the hosting scene
  57700. * @returns a new line system mesh
  57701. */
  57702. static CreateLineSystem(name: string, options: {
  57703. lines: Vector3[][];
  57704. updatable?: boolean;
  57705. instance?: Nullable<LinesMesh>;
  57706. colors?: Nullable<Color4[][]>;
  57707. useVertexAlpha?: boolean;
  57708. }, scene: Nullable<Scene>): LinesMesh;
  57709. /**
  57710. * Creates a line mesh
  57711. * 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
  57712. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57713. * * The parameter `points` is an array successive Vector3
  57714. * * 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
  57715. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57716. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57717. * * When updating an instance, remember that only point positions can change, not the number of points
  57718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57720. * @param name defines the name of the new line system
  57721. * @param options defines the options used to create the line system
  57722. * @param scene defines the hosting scene
  57723. * @returns a new line mesh
  57724. */
  57725. static CreateLines(name: string, options: {
  57726. points: Vector3[];
  57727. updatable?: boolean;
  57728. instance?: Nullable<LinesMesh>;
  57729. colors?: Color4[];
  57730. useVertexAlpha?: boolean;
  57731. }, scene?: Nullable<Scene>): LinesMesh;
  57732. /**
  57733. * Creates a dashed line mesh
  57734. * * 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
  57735. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57736. * * The parameter `points` is an array successive Vector3
  57737. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57738. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57739. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57740. * * 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
  57741. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57742. * * When updating an instance, remember that only point positions can change, not the number of points
  57743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57744. * @param name defines the name of the mesh
  57745. * @param options defines the options used to create the mesh
  57746. * @param scene defines the hosting scene
  57747. * @returns the dashed line mesh
  57748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57749. */
  57750. static CreateDashedLines(name: string, options: {
  57751. points: Vector3[];
  57752. dashSize?: number;
  57753. gapSize?: number;
  57754. dashNb?: number;
  57755. updatable?: boolean;
  57756. instance?: LinesMesh;
  57757. useVertexAlpha?: boolean;
  57758. }, scene?: Nullable<Scene>): LinesMesh;
  57759. }
  57760. }
  57761. declare module "babylonjs/Misc/timer" {
  57762. import { Observable, Observer } from "babylonjs/Misc/observable";
  57763. import { Nullable } from "babylonjs/types";
  57764. import { IDisposable } from "babylonjs/scene";
  57765. /**
  57766. * Construction options for a timer
  57767. */
  57768. export interface ITimerOptions<T> {
  57769. /**
  57770. * Time-to-end
  57771. */
  57772. timeout: number;
  57773. /**
  57774. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  57775. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  57776. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  57777. */
  57778. contextObservable: Observable<T>;
  57779. /**
  57780. * Optional parameters when adding an observer to the observable
  57781. */
  57782. observableParameters?: {
  57783. mask?: number;
  57784. insertFirst?: boolean;
  57785. scope?: any;
  57786. };
  57787. /**
  57788. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  57789. */
  57790. breakCondition?: (data?: ITimerData<T>) => boolean;
  57791. /**
  57792. * Will be triggered when the time condition has met
  57793. */
  57794. onEnded?: (data: ITimerData<any>) => void;
  57795. /**
  57796. * Will be triggered when the break condition has met (prematurely ended)
  57797. */
  57798. onAborted?: (data: ITimerData<any>) => void;
  57799. /**
  57800. * Optional function to execute on each tick (or count)
  57801. */
  57802. onTick?: (data: ITimerData<any>) => void;
  57803. }
  57804. /**
  57805. * An interface defining the data sent by the timer
  57806. */
  57807. export interface ITimerData<T> {
  57808. /**
  57809. * When did it start
  57810. */
  57811. startTime: number;
  57812. /**
  57813. * Time now
  57814. */
  57815. currentTime: number;
  57816. /**
  57817. * Time passed since started
  57818. */
  57819. deltaTime: number;
  57820. /**
  57821. * How much is completed, in [0.0...1.0].
  57822. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  57823. */
  57824. completeRate: number;
  57825. /**
  57826. * What the registered observable sent in the last count
  57827. */
  57828. payload: T;
  57829. }
  57830. /**
  57831. * The current state of the timer
  57832. */
  57833. export enum TimerState {
  57834. /**
  57835. * Timer initialized, not yet started
  57836. */
  57837. INIT = 0,
  57838. /**
  57839. * Timer started and counting
  57840. */
  57841. STARTED = 1,
  57842. /**
  57843. * Timer ended (whether aborted or time reached)
  57844. */
  57845. ENDED = 2
  57846. }
  57847. /**
  57848. * A simple version of the timer. Will take options and start the timer immediately after calling it
  57849. *
  57850. * @param options options with which to initialize this timer
  57851. */
  57852. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  57853. /**
  57854. * An advanced implementation of a timer class
  57855. */
  57856. export class AdvancedTimer<T = any> implements IDisposable {
  57857. /**
  57858. * Will notify each time the timer calculates the remaining time
  57859. */
  57860. onEachCountObservable: Observable<ITimerData<T>>;
  57861. /**
  57862. * Will trigger when the timer was aborted due to the break condition
  57863. */
  57864. onTimerAbortedObservable: Observable<ITimerData<T>>;
  57865. /**
  57866. * Will trigger when the timer ended successfully
  57867. */
  57868. onTimerEndedObservable: Observable<ITimerData<T>>;
  57869. /**
  57870. * Will trigger when the timer state has changed
  57871. */
  57872. onStateChangedObservable: Observable<TimerState>;
  57873. private _observer;
  57874. private _contextObservable;
  57875. private _observableParameters;
  57876. private _startTime;
  57877. private _timer;
  57878. private _state;
  57879. private _breakCondition;
  57880. private _timeToEnd;
  57881. private _breakOnNextTick;
  57882. /**
  57883. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  57884. * @param options construction options for this advanced timer
  57885. */
  57886. constructor(options: ITimerOptions<T>);
  57887. /**
  57888. * set a breaking condition for this timer. Default is to never break during count
  57889. * @param predicate the new break condition. Returns true to break, false otherwise
  57890. */
  57891. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  57892. /**
  57893. * Reset ALL associated observables in this advanced timer
  57894. */
  57895. clearObservables(): void;
  57896. /**
  57897. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  57898. *
  57899. * @param timeToEnd how much time to measure until timer ended
  57900. */
  57901. start(timeToEnd?: number): void;
  57902. /**
  57903. * Will force a stop on the next tick.
  57904. */
  57905. stop(): void;
  57906. /**
  57907. * Dispose this timer, clearing all resources
  57908. */
  57909. dispose(): void;
  57910. private _setState;
  57911. private _tick;
  57912. private _stop;
  57913. }
  57914. }
  57915. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  57916. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  57917. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57918. import { Nullable } from "babylonjs/types";
  57919. import { WebXRInput } from "babylonjs/XR/webXRInput";
  57920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57921. import { Vector3 } from "babylonjs/Maths/math.vector";
  57922. import { Material } from "babylonjs/Materials/material";
  57923. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  57924. import { Scene } from "babylonjs/scene";
  57925. /**
  57926. * The options container for the teleportation module
  57927. */
  57928. export interface IWebXRTeleportationOptions {
  57929. /**
  57930. * if provided, this scene will be used to render meshes.
  57931. */
  57932. customUtilityLayerScene?: Scene;
  57933. /**
  57934. * Values to configure the default target mesh
  57935. */
  57936. defaultTargetMeshOptions?: {
  57937. /**
  57938. * Fill color of the teleportation area
  57939. */
  57940. teleportationFillColor?: string;
  57941. /**
  57942. * Border color for the teleportation area
  57943. */
  57944. teleportationBorderColor?: string;
  57945. /**
  57946. * Disable the mesh's animation sequence
  57947. */
  57948. disableAnimation?: boolean;
  57949. /**
  57950. * Disable lighting on the material or the ring and arrow
  57951. */
  57952. disableLighting?: boolean;
  57953. /**
  57954. * Override the default material of the torus and arrow
  57955. */
  57956. torusArrowMaterial?: Material;
  57957. };
  57958. /**
  57959. * A list of meshes to use as floor meshes.
  57960. * Meshes can be added and removed after initializing the feature using the
  57961. * addFloorMesh and removeFloorMesh functions
  57962. * If empty, rotation will still work
  57963. */
  57964. floorMeshes?: AbstractMesh[];
  57965. /**
  57966. * use this rendering group id for the meshes (optional)
  57967. */
  57968. renderingGroupId?: number;
  57969. /**
  57970. * Should teleportation move only to snap points
  57971. */
  57972. snapPointsOnly?: boolean;
  57973. /**
  57974. * An array of points to which the teleportation will snap to.
  57975. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  57976. */
  57977. snapPositions?: Vector3[];
  57978. /**
  57979. * How close should the teleportation ray be in order to snap to position.
  57980. * Default to 0.8 units (meters)
  57981. */
  57982. snapToPositionRadius?: number;
  57983. /**
  57984. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  57985. * If you want to support rotation, make sure your mesh has a direction indicator.
  57986. *
  57987. * When left untouched, the default mesh will be initialized.
  57988. */
  57989. teleportationTargetMesh?: AbstractMesh;
  57990. /**
  57991. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  57992. */
  57993. timeToTeleport?: number;
  57994. /**
  57995. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  57996. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  57997. */
  57998. useMainComponentOnly?: boolean;
  57999. /**
  58000. * Should meshes created here be added to a utility layer or the main scene
  58001. */
  58002. useUtilityLayer?: boolean;
  58003. /**
  58004. * Babylon XR Input class for controller
  58005. */
  58006. xrInput: WebXRInput;
  58007. /**
  58008. * Meshes that the teleportation ray cannot go through
  58009. */
  58010. pickBlockerMeshes?: AbstractMesh[];
  58011. /**
  58012. * Should teleport work only on a specific hand?
  58013. */
  58014. forceHandedness?: XRHandedness;
  58015. /**
  58016. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  58017. */
  58018. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  58019. }
  58020. /**
  58021. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  58022. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  58023. * the input of the attached controllers.
  58024. */
  58025. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  58026. private _options;
  58027. private _controllers;
  58028. private _currentTeleportationControllerId;
  58029. private _floorMeshes;
  58030. private _quadraticBezierCurve;
  58031. private _selectionFeature;
  58032. private _snapToPositions;
  58033. private _snappedToPoint;
  58034. private _teleportationRingMaterial?;
  58035. private _tmpRay;
  58036. private _tmpVector;
  58037. private _tmpQuaternion;
  58038. /**
  58039. * The module's name
  58040. */
  58041. static readonly Name: string;
  58042. /**
  58043. * The (Babylon) version of this module.
  58044. * This is an integer representing the implementation version.
  58045. * This number does not correspond to the webxr specs version
  58046. */
  58047. static readonly Version: number;
  58048. /**
  58049. * Is movement backwards enabled
  58050. */
  58051. backwardsMovementEnabled: boolean;
  58052. /**
  58053. * Distance to travel when moving backwards
  58054. */
  58055. backwardsTeleportationDistance: number;
  58056. /**
  58057. * The distance from the user to the inspection point in the direction of the controller
  58058. * A higher number will allow the user to move further
  58059. * defaults to 5 (meters, in xr units)
  58060. */
  58061. parabolicCheckRadius: number;
  58062. /**
  58063. * Should the module support parabolic ray on top of direct ray
  58064. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  58065. * Very helpful when moving between floors / different heights
  58066. */
  58067. parabolicRayEnabled: boolean;
  58068. /**
  58069. * The second type of ray - straight line.
  58070. * Should it be enabled or should the parabolic line be the only one.
  58071. */
  58072. straightRayEnabled: boolean;
  58073. /**
  58074. * How much rotation should be applied when rotating right and left
  58075. */
  58076. rotationAngle: number;
  58077. private _rotationEnabled;
  58078. /**
  58079. * Is rotation enabled when moving forward?
  58080. * Disabling this feature will prevent the user from deciding the direction when teleporting
  58081. */
  58082. get rotationEnabled(): boolean;
  58083. /**
  58084. * Sets wether rotation is enabled or not
  58085. * @param enabled is rotation enabled when teleportation is shown
  58086. */
  58087. set rotationEnabled(enabled: boolean);
  58088. /**
  58089. * Exposes the currently set teleportation target mesh.
  58090. */
  58091. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  58092. /**
  58093. * constructs a new anchor system
  58094. * @param _xrSessionManager an instance of WebXRSessionManager
  58095. * @param _options configuration object for this feature
  58096. */
  58097. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  58098. /**
  58099. * Get the snapPointsOnly flag
  58100. */
  58101. get snapPointsOnly(): boolean;
  58102. /**
  58103. * Sets the snapPointsOnly flag
  58104. * @param snapToPoints should teleportation be exclusively to snap points
  58105. */
  58106. set snapPointsOnly(snapToPoints: boolean);
  58107. /**
  58108. * Add a new mesh to the floor meshes array
  58109. * @param mesh the mesh to use as floor mesh
  58110. */
  58111. addFloorMesh(mesh: AbstractMesh): void;
  58112. /**
  58113. * Add a new snap-to point to fix teleportation to this position
  58114. * @param newSnapPoint The new Snap-To point
  58115. */
  58116. addSnapPoint(newSnapPoint: Vector3): void;
  58117. attach(): boolean;
  58118. detach(): boolean;
  58119. dispose(): void;
  58120. /**
  58121. * Remove a mesh from the floor meshes array
  58122. * @param mesh the mesh to remove
  58123. */
  58124. removeFloorMesh(mesh: AbstractMesh): void;
  58125. /**
  58126. * Remove a mesh from the floor meshes array using its name
  58127. * @param name the mesh name to remove
  58128. */
  58129. removeFloorMeshByName(name: string): void;
  58130. /**
  58131. * 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
  58132. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  58133. * @returns was the point found and removed or not
  58134. */
  58135. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  58136. /**
  58137. * This function sets a selection feature that will be disabled when
  58138. * the forward ray is shown and will be reattached when hidden.
  58139. * This is used to remove the selection rays when moving.
  58140. * @param selectionFeature the feature to disable when forward movement is enabled
  58141. */
  58142. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  58143. protected _onXRFrame(_xrFrame: XRFrame): void;
  58144. private _attachController;
  58145. private _createDefaultTargetMesh;
  58146. private _detachController;
  58147. private _findClosestSnapPointWithRadius;
  58148. private _setTargetMeshPosition;
  58149. private _setTargetMeshVisibility;
  58150. private _showParabolicPath;
  58151. private _teleportForward;
  58152. }
  58153. }
  58154. declare module "babylonjs/XR/webXRDefaultExperience" {
  58155. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  58156. import { Scene } from "babylonjs/scene";
  58157. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  58158. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  58159. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  58160. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  58161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58162. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  58163. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  58164. /**
  58165. * Options for the default xr helper
  58166. */
  58167. export class WebXRDefaultExperienceOptions {
  58168. /**
  58169. * Enable or disable default UI to enter XR
  58170. */
  58171. disableDefaultUI?: boolean;
  58172. /**
  58173. * Should teleportation not initialize. defaults to false.
  58174. */
  58175. disableTeleportation?: boolean;
  58176. /**
  58177. * Floor meshes that will be used for teleport
  58178. */
  58179. floorMeshes?: Array<AbstractMesh>;
  58180. /**
  58181. * If set to true, the first frame will not be used to reset position
  58182. * The first frame is mainly used when copying transformation from the old camera
  58183. * Mainly used in AR
  58184. */
  58185. ignoreNativeCameraTransformation?: boolean;
  58186. /**
  58187. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  58188. */
  58189. inputOptions?: IWebXRInputOptions;
  58190. /**
  58191. * optional configuration for the output canvas
  58192. */
  58193. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  58194. /**
  58195. * optional UI options. This can be used among other to change session mode and reference space type
  58196. */
  58197. uiOptions?: WebXREnterExitUIOptions;
  58198. /**
  58199. * When loading teleportation and pointer select, use stable versions instead of latest.
  58200. */
  58201. useStablePlugins?: boolean;
  58202. /**
  58203. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  58204. */
  58205. renderingGroupId?: number;
  58206. /**
  58207. * A list of optional features to init the session with
  58208. * If set to true, all features we support will be added
  58209. */
  58210. optionalFeatures?: boolean | string[];
  58211. }
  58212. /**
  58213. * Default experience which provides a similar setup to the previous webVRExperience
  58214. */
  58215. export class WebXRDefaultExperience {
  58216. /**
  58217. * Base experience
  58218. */
  58219. baseExperience: WebXRExperienceHelper;
  58220. /**
  58221. * Enables ui for entering/exiting xr
  58222. */
  58223. enterExitUI: WebXREnterExitUI;
  58224. /**
  58225. * Input experience extension
  58226. */
  58227. input: WebXRInput;
  58228. /**
  58229. * Enables laser pointer and selection
  58230. */
  58231. pointerSelection: WebXRControllerPointerSelection;
  58232. /**
  58233. * Default target xr should render to
  58234. */
  58235. renderTarget: WebXRRenderTarget;
  58236. /**
  58237. * Enables teleportation
  58238. */
  58239. teleportation: WebXRMotionControllerTeleportation;
  58240. private constructor();
  58241. /**
  58242. * Creates the default xr experience
  58243. * @param scene scene
  58244. * @param options options for basic configuration
  58245. * @returns resulting WebXRDefaultExperience
  58246. */
  58247. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58248. /**
  58249. * DIsposes of the experience helper
  58250. */
  58251. dispose(): void;
  58252. }
  58253. }
  58254. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  58255. import { Observable } from "babylonjs/Misc/observable";
  58256. import { Nullable } from "babylonjs/types";
  58257. import { Camera } from "babylonjs/Cameras/camera";
  58258. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  58259. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58260. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  58261. import { Scene } from "babylonjs/scene";
  58262. import { Vector3 } from "babylonjs/Maths/math.vector";
  58263. import { Color3 } from "babylonjs/Maths/math.color";
  58264. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58266. import { Mesh } from "babylonjs/Meshes/mesh";
  58267. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  58268. import { EasingFunction } from "babylonjs/Animations/easing";
  58269. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  58270. import "babylonjs/Meshes/Builders/groundBuilder";
  58271. import "babylonjs/Meshes/Builders/torusBuilder";
  58272. import "babylonjs/Meshes/Builders/cylinderBuilder";
  58273. import "babylonjs/Gamepads/gamepadSceneComponent";
  58274. import "babylonjs/Animations/animatable";
  58275. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  58276. /**
  58277. * Options to modify the vr teleportation behavior.
  58278. */
  58279. export interface VRTeleportationOptions {
  58280. /**
  58281. * The name of the mesh which should be used as the teleportation floor. (default: null)
  58282. */
  58283. floorMeshName?: string;
  58284. /**
  58285. * A list of meshes to be used as the teleportation floor. (default: empty)
  58286. */
  58287. floorMeshes?: Mesh[];
  58288. /**
  58289. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  58290. */
  58291. teleportationMode?: number;
  58292. /**
  58293. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  58294. */
  58295. teleportationTime?: number;
  58296. /**
  58297. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  58298. */
  58299. teleportationSpeed?: number;
  58300. /**
  58301. * The easing function used in the animation or null for Linear. (default CircleEase)
  58302. */
  58303. easingFunction?: EasingFunction;
  58304. }
  58305. /**
  58306. * Options to modify the vr experience helper's behavior.
  58307. */
  58308. export interface VRExperienceHelperOptions extends WebVROptions {
  58309. /**
  58310. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  58311. */
  58312. createDeviceOrientationCamera?: boolean;
  58313. /**
  58314. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  58315. */
  58316. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  58317. /**
  58318. * Uses the main button on the controller to toggle the laser casted. (default: true)
  58319. */
  58320. laserToggle?: boolean;
  58321. /**
  58322. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  58323. */
  58324. floorMeshes?: Mesh[];
  58325. /**
  58326. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  58327. */
  58328. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  58329. /**
  58330. * Defines if WebXR should be used instead of WebVR (if available)
  58331. */
  58332. useXR?: boolean;
  58333. }
  58334. /**
  58335. * Event containing information after VR has been entered
  58336. */
  58337. export class OnAfterEnteringVRObservableEvent {
  58338. /**
  58339. * If entering vr was successful
  58340. */
  58341. success: boolean;
  58342. }
  58343. /**
  58344. * Helps to quickly add VR support to an existing scene.
  58345. * See https://doc.babylonjs.com/how_to/webvr_helper
  58346. */
  58347. export class VRExperienceHelper {
  58348. /** Options to modify the vr experience helper's behavior. */
  58349. webVROptions: VRExperienceHelperOptions;
  58350. private _scene;
  58351. private _position;
  58352. private _btnVR;
  58353. private _btnVRDisplayed;
  58354. private _webVRsupported;
  58355. private _webVRready;
  58356. private _webVRrequesting;
  58357. private _webVRpresenting;
  58358. private _hasEnteredVR;
  58359. private _fullscreenVRpresenting;
  58360. private _inputElement;
  58361. private _webVRCamera;
  58362. private _vrDeviceOrientationCamera;
  58363. private _deviceOrientationCamera;
  58364. private _existingCamera;
  58365. private _onKeyDown;
  58366. private _onVrDisplayPresentChange;
  58367. private _onVRDisplayChanged;
  58368. private _onVRRequestPresentStart;
  58369. private _onVRRequestPresentComplete;
  58370. /**
  58371. * 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)
  58372. */
  58373. enableGazeEvenWhenNoPointerLock: boolean;
  58374. /**
  58375. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  58376. */
  58377. exitVROnDoubleTap: boolean;
  58378. /**
  58379. * Observable raised right before entering VR.
  58380. */
  58381. onEnteringVRObservable: Observable<VRExperienceHelper>;
  58382. /**
  58383. * Observable raised when entering VR has completed.
  58384. */
  58385. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  58386. /**
  58387. * Observable raised when exiting VR.
  58388. */
  58389. onExitingVRObservable: Observable<VRExperienceHelper>;
  58390. /**
  58391. * Observable raised when controller mesh is loaded.
  58392. */
  58393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  58394. /** Return this.onEnteringVRObservable
  58395. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  58396. */
  58397. get onEnteringVR(): Observable<VRExperienceHelper>;
  58398. /** Return this.onExitingVRObservable
  58399. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  58400. */
  58401. get onExitingVR(): Observable<VRExperienceHelper>;
  58402. /** Return this.onControllerMeshLoadedObservable
  58403. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  58404. */
  58405. get onControllerMeshLoaded(): Observable<WebVRController>;
  58406. private _rayLength;
  58407. private _useCustomVRButton;
  58408. private _teleportationRequested;
  58409. private _teleportActive;
  58410. private _floorMeshName;
  58411. private _floorMeshesCollection;
  58412. private _teleportationMode;
  58413. private _teleportationTime;
  58414. private _teleportationSpeed;
  58415. private _teleportationEasing;
  58416. private _rotationAllowed;
  58417. private _teleportBackwardsVector;
  58418. private _teleportationTarget;
  58419. private _isDefaultTeleportationTarget;
  58420. private _postProcessMove;
  58421. private _teleportationFillColor;
  58422. private _teleportationBorderColor;
  58423. private _rotationAngle;
  58424. private _haloCenter;
  58425. private _cameraGazer;
  58426. private _padSensibilityUp;
  58427. private _padSensibilityDown;
  58428. private _leftController;
  58429. private _rightController;
  58430. private _gazeColor;
  58431. private _laserColor;
  58432. private _pickedLaserColor;
  58433. private _pickedGazeColor;
  58434. /**
  58435. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  58436. */
  58437. onNewMeshSelected: Observable<AbstractMesh>;
  58438. /**
  58439. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  58440. * This observable will provide the mesh and the controller used to select the mesh
  58441. */
  58442. onMeshSelectedWithController: Observable<{
  58443. mesh: AbstractMesh;
  58444. controller: WebVRController;
  58445. }>;
  58446. /**
  58447. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  58448. */
  58449. onNewMeshPicked: Observable<PickingInfo>;
  58450. private _circleEase;
  58451. /**
  58452. * Observable raised before camera teleportation
  58453. */
  58454. onBeforeCameraTeleport: Observable<Vector3>;
  58455. /**
  58456. * Observable raised after camera teleportation
  58457. */
  58458. onAfterCameraTeleport: Observable<Vector3>;
  58459. /**
  58460. * Observable raised when current selected mesh gets unselected
  58461. */
  58462. onSelectedMeshUnselected: Observable<AbstractMesh>;
  58463. private _raySelectionPredicate;
  58464. /**
  58465. * To be optionaly changed by user to define custom ray selection
  58466. */
  58467. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  58468. /**
  58469. * To be optionaly changed by user to define custom selection logic (after ray selection)
  58470. */
  58471. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58472. /**
  58473. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  58474. */
  58475. teleportationEnabled: boolean;
  58476. private _defaultHeight;
  58477. private _teleportationInitialized;
  58478. private _interactionsEnabled;
  58479. private _interactionsRequested;
  58480. private _displayGaze;
  58481. private _displayLaserPointer;
  58482. /**
  58483. * The mesh used to display where the user is going to teleport.
  58484. */
  58485. get teleportationTarget(): Mesh;
  58486. /**
  58487. * Sets the mesh to be used to display where the user is going to teleport.
  58488. */
  58489. set teleportationTarget(value: Mesh);
  58490. /**
  58491. * 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
  58492. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  58493. * See https://doc.babylonjs.com/resources/baking_transformations
  58494. */
  58495. get gazeTrackerMesh(): Mesh;
  58496. set gazeTrackerMesh(value: Mesh);
  58497. /**
  58498. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  58499. */
  58500. updateGazeTrackerScale: boolean;
  58501. /**
  58502. * If the gaze trackers color should be updated when selecting meshes
  58503. */
  58504. updateGazeTrackerColor: boolean;
  58505. /**
  58506. * If the controller laser color should be updated when selecting meshes
  58507. */
  58508. updateControllerLaserColor: boolean;
  58509. /**
  58510. * The gaze tracking mesh corresponding to the left controller
  58511. */
  58512. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  58513. /**
  58514. * The gaze tracking mesh corresponding to the right controller
  58515. */
  58516. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  58517. /**
  58518. * If the ray of the gaze should be displayed.
  58519. */
  58520. get displayGaze(): boolean;
  58521. /**
  58522. * Sets if the ray of the gaze should be displayed.
  58523. */
  58524. set displayGaze(value: boolean);
  58525. /**
  58526. * If the ray of the LaserPointer should be displayed.
  58527. */
  58528. get displayLaserPointer(): boolean;
  58529. /**
  58530. * Sets if the ray of the LaserPointer should be displayed.
  58531. */
  58532. set displayLaserPointer(value: boolean);
  58533. /**
  58534. * The deviceOrientationCamera used as the camera when not in VR.
  58535. */
  58536. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  58537. /**
  58538. * Based on the current WebVR support, returns the current VR camera used.
  58539. */
  58540. get currentVRCamera(): Nullable<Camera>;
  58541. /**
  58542. * The webVRCamera which is used when in VR.
  58543. */
  58544. get webVRCamera(): WebVRFreeCamera;
  58545. /**
  58546. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  58547. */
  58548. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  58549. /**
  58550. * The html button that is used to trigger entering into VR.
  58551. */
  58552. get vrButton(): Nullable<HTMLButtonElement>;
  58553. private get _teleportationRequestInitiated();
  58554. /**
  58555. * Defines whether or not Pointer lock should be requested when switching to
  58556. * full screen.
  58557. */
  58558. requestPointerLockOnFullScreen: boolean;
  58559. /**
  58560. * If asking to force XR, this will be populated with the default xr experience
  58561. */
  58562. xr: WebXRDefaultExperience;
  58563. /**
  58564. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  58565. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  58566. */
  58567. xrTestDone: boolean;
  58568. /**
  58569. * Instantiates a VRExperienceHelper.
  58570. * Helps to quickly add VR support to an existing scene.
  58571. * @param scene The scene the VRExperienceHelper belongs to.
  58572. * @param webVROptions Options to modify the vr experience helper's behavior.
  58573. */
  58574. constructor(scene: Scene,
  58575. /** Options to modify the vr experience helper's behavior. */
  58576. webVROptions?: VRExperienceHelperOptions);
  58577. private completeVRInit;
  58578. private _onDefaultMeshLoaded;
  58579. private _onResize;
  58580. private _onFullscreenChange;
  58581. /**
  58582. * Gets a value indicating if we are currently in VR mode.
  58583. */
  58584. get isInVRMode(): boolean;
  58585. private onVrDisplayPresentChange;
  58586. private onVRDisplayChanged;
  58587. private moveButtonToBottomRight;
  58588. private displayVRButton;
  58589. private updateButtonVisibility;
  58590. private _cachedAngularSensibility;
  58591. /**
  58592. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  58593. * Otherwise, will use the fullscreen API.
  58594. */
  58595. enterVR(): void;
  58596. /**
  58597. * Attempt to exit VR, or fullscreen.
  58598. */
  58599. exitVR(): void;
  58600. /**
  58601. * The position of the vr experience helper.
  58602. */
  58603. get position(): Vector3;
  58604. /**
  58605. * Sets the position of the vr experience helper.
  58606. */
  58607. set position(value: Vector3);
  58608. /**
  58609. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  58610. */
  58611. enableInteractions(): void;
  58612. private get _noControllerIsActive();
  58613. private beforeRender;
  58614. private _isTeleportationFloor;
  58615. /**
  58616. * Adds a floor mesh to be used for teleportation.
  58617. * @param floorMesh the mesh to be used for teleportation.
  58618. */
  58619. addFloorMesh(floorMesh: Mesh): void;
  58620. /**
  58621. * Removes a floor mesh from being used for teleportation.
  58622. * @param floorMesh the mesh to be removed.
  58623. */
  58624. removeFloorMesh(floorMesh: Mesh): void;
  58625. /**
  58626. * Enables interactions and teleportation using the VR controllers and gaze.
  58627. * @param vrTeleportationOptions options to modify teleportation behavior.
  58628. */
  58629. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  58630. private _onNewGamepadConnected;
  58631. private _tryEnableInteractionOnController;
  58632. private _onNewGamepadDisconnected;
  58633. private _enableInteractionOnController;
  58634. private _checkTeleportWithRay;
  58635. private _checkRotate;
  58636. private _checkTeleportBackwards;
  58637. private _enableTeleportationOnController;
  58638. private _createTeleportationCircles;
  58639. private _displayTeleportationTarget;
  58640. private _hideTeleportationTarget;
  58641. private _rotateCamera;
  58642. private _moveTeleportationSelectorTo;
  58643. private _workingVector;
  58644. private _workingQuaternion;
  58645. private _workingMatrix;
  58646. /**
  58647. * Time Constant Teleportation Mode
  58648. */
  58649. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  58650. /**
  58651. * Speed Constant Teleportation Mode
  58652. */
  58653. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  58654. /**
  58655. * Teleports the users feet to the desired location
  58656. * @param location The location where the user's feet should be placed
  58657. */
  58658. teleportCamera(location: Vector3): void;
  58659. private _convertNormalToDirectionOfRay;
  58660. private _castRayAndSelectObject;
  58661. private _notifySelectedMeshUnselected;
  58662. /**
  58663. * Permanently set new colors for the laser pointer
  58664. * @param color the new laser color
  58665. * @param pickedColor the new laser color when picked mesh detected
  58666. */
  58667. setLaserColor(color: Color3, pickedColor?: Color3): void;
  58668. /**
  58669. * Set lighting enabled / disabled on the laser pointer of both controllers
  58670. * @param enabled should the lighting be enabled on the laser pointer
  58671. */
  58672. setLaserLightingState(enabled?: boolean): void;
  58673. /**
  58674. * Permanently set new colors for the gaze pointer
  58675. * @param color the new gaze color
  58676. * @param pickedColor the new gaze color when picked mesh detected
  58677. */
  58678. setGazeColor(color: Color3, pickedColor?: Color3): void;
  58679. /**
  58680. * Sets the color of the laser ray from the vr controllers.
  58681. * @param color new color for the ray.
  58682. */
  58683. changeLaserColor(color: Color3): void;
  58684. /**
  58685. * Sets the color of the ray from the vr headsets gaze.
  58686. * @param color new color for the ray.
  58687. */
  58688. changeGazeColor(color: Color3): void;
  58689. /**
  58690. * Exits VR and disposes of the vr experience helper
  58691. */
  58692. dispose(): void;
  58693. /**
  58694. * Gets the name of the VRExperienceHelper class
  58695. * @returns "VRExperienceHelper"
  58696. */
  58697. getClassName(): string;
  58698. }
  58699. }
  58700. declare module "babylonjs/Cameras/VR/index" {
  58701. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  58702. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  58703. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58704. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  58705. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  58706. export * from "babylonjs/Cameras/VR/webVRCamera";
  58707. }
  58708. declare module "babylonjs/Cameras/RigModes/index" {
  58709. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  58710. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  58711. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  58712. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  58713. }
  58714. declare module "babylonjs/Cameras/index" {
  58715. export * from "babylonjs/Cameras/Inputs/index";
  58716. export * from "babylonjs/Cameras/cameraInputsManager";
  58717. export * from "babylonjs/Cameras/camera";
  58718. export * from "babylonjs/Cameras/targetCamera";
  58719. export * from "babylonjs/Cameras/freeCamera";
  58720. export * from "babylonjs/Cameras/freeCameraInputsManager";
  58721. export * from "babylonjs/Cameras/touchCamera";
  58722. export * from "babylonjs/Cameras/arcRotateCamera";
  58723. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  58724. export * from "babylonjs/Cameras/deviceOrientationCamera";
  58725. export * from "babylonjs/Cameras/flyCamera";
  58726. export * from "babylonjs/Cameras/flyCameraInputsManager";
  58727. export * from "babylonjs/Cameras/followCamera";
  58728. export * from "babylonjs/Cameras/followCameraInputsManager";
  58729. export * from "babylonjs/Cameras/gamepadCamera";
  58730. export * from "babylonjs/Cameras/Stereoscopic/index";
  58731. export * from "babylonjs/Cameras/universalCamera";
  58732. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  58733. export * from "babylonjs/Cameras/VR/index";
  58734. export * from "babylonjs/Cameras/RigModes/index";
  58735. }
  58736. declare module "babylonjs/Collisions/index" {
  58737. export * from "babylonjs/Collisions/collider";
  58738. export * from "babylonjs/Collisions/collisionCoordinator";
  58739. export * from "babylonjs/Collisions/pickingInfo";
  58740. export * from "babylonjs/Collisions/intersectionInfo";
  58741. export * from "babylonjs/Collisions/meshCollisionData";
  58742. }
  58743. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  58744. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  58745. import { Vector3 } from "babylonjs/Maths/math.vector";
  58746. import { Ray } from "babylonjs/Culling/ray";
  58747. import { Plane } from "babylonjs/Maths/math.plane";
  58748. /**
  58749. * Contains an array of blocks representing the octree
  58750. */
  58751. export interface IOctreeContainer<T> {
  58752. /**
  58753. * Blocks within the octree
  58754. */
  58755. blocks: Array<OctreeBlock<T>>;
  58756. }
  58757. /**
  58758. * Class used to store a cell in an octree
  58759. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58760. */
  58761. export class OctreeBlock<T> {
  58762. /**
  58763. * Gets the content of the current block
  58764. */
  58765. entries: T[];
  58766. /**
  58767. * Gets the list of block children
  58768. */
  58769. blocks: Array<OctreeBlock<T>>;
  58770. private _depth;
  58771. private _maxDepth;
  58772. private _capacity;
  58773. private _minPoint;
  58774. private _maxPoint;
  58775. private _boundingVectors;
  58776. private _creationFunc;
  58777. /**
  58778. * Creates a new block
  58779. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  58780. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  58781. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  58782. * @param depth defines the current depth of this block in the octree
  58783. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  58784. * @param creationFunc defines a callback to call when an element is added to the block
  58785. */
  58786. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  58787. /**
  58788. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  58789. */
  58790. get capacity(): number;
  58791. /**
  58792. * Gets the minimum vector (in world space) of the block's bounding box
  58793. */
  58794. get minPoint(): Vector3;
  58795. /**
  58796. * Gets the maximum vector (in world space) of the block's bounding box
  58797. */
  58798. get maxPoint(): Vector3;
  58799. /**
  58800. * Add a new element to this block
  58801. * @param entry defines the element to add
  58802. */
  58803. addEntry(entry: T): void;
  58804. /**
  58805. * Remove an element from this block
  58806. * @param entry defines the element to remove
  58807. */
  58808. removeEntry(entry: T): void;
  58809. /**
  58810. * Add an array of elements to this block
  58811. * @param entries defines the array of elements to add
  58812. */
  58813. addEntries(entries: T[]): void;
  58814. /**
  58815. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  58816. * @param frustumPlanes defines the frustum planes to test
  58817. * @param selection defines the array to store current content if selection is positive
  58818. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58819. */
  58820. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  58821. /**
  58822. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  58823. * @param sphereCenter defines the bounding sphere center
  58824. * @param sphereRadius defines the bounding sphere radius
  58825. * @param selection defines the array to store current content if selection is positive
  58826. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58827. */
  58828. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  58829. /**
  58830. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  58831. * @param ray defines the ray to test with
  58832. * @param selection defines the array to store current content if selection is positive
  58833. */
  58834. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  58835. /**
  58836. * Subdivide the content into child blocks (this block will then be empty)
  58837. */
  58838. createInnerBlocks(): void;
  58839. /**
  58840. * @hidden
  58841. */
  58842. 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;
  58843. }
  58844. }
  58845. declare module "babylonjs/Culling/Octrees/octree" {
  58846. import { SmartArray } from "babylonjs/Misc/smartArray";
  58847. import { Vector3 } from "babylonjs/Maths/math.vector";
  58848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58850. import { Ray } from "babylonjs/Culling/ray";
  58851. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  58852. import { Plane } from "babylonjs/Maths/math.plane";
  58853. /**
  58854. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  58855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58856. */
  58857. export class Octree<T> {
  58858. /** 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.) */
  58859. maxDepth: number;
  58860. /**
  58861. * Blocks within the octree containing objects
  58862. */
  58863. blocks: Array<OctreeBlock<T>>;
  58864. /**
  58865. * Content stored in the octree
  58866. */
  58867. dynamicContent: T[];
  58868. private _maxBlockCapacity;
  58869. private _selectionContent;
  58870. private _creationFunc;
  58871. /**
  58872. * Creates a octree
  58873. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58874. * @param creationFunc function to be used to instatiate the octree
  58875. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  58876. * @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.)
  58877. */
  58878. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  58879. /** 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.) */
  58880. maxDepth?: number);
  58881. /**
  58882. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  58883. * @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);
  58884. * @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);
  58885. * @param entries meshes to be added to the octree blocks
  58886. */
  58887. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  58888. /**
  58889. * Adds a mesh to the octree
  58890. * @param entry Mesh to add to the octree
  58891. */
  58892. addMesh(entry: T): void;
  58893. /**
  58894. * Remove an element from the octree
  58895. * @param entry defines the element to remove
  58896. */
  58897. removeMesh(entry: T): void;
  58898. /**
  58899. * Selects an array of meshes within the frustum
  58900. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  58901. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  58902. * @returns array of meshes within the frustum
  58903. */
  58904. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  58905. /**
  58906. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  58907. * @param sphereCenter defines the bounding sphere center
  58908. * @param sphereRadius defines the bounding sphere radius
  58909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58910. * @returns an array of objects that intersect the sphere
  58911. */
  58912. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  58913. /**
  58914. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  58915. * @param ray defines the ray to test with
  58916. * @returns array of intersected objects
  58917. */
  58918. intersectsRay(ray: Ray): SmartArray<T>;
  58919. /**
  58920. * Adds a mesh into the octree block if it intersects the block
  58921. */
  58922. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  58923. /**
  58924. * Adds a submesh into the octree block if it intersects the block
  58925. */
  58926. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  58927. }
  58928. }
  58929. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  58930. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  58931. import { Scene } from "babylonjs/scene";
  58932. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58934. import { Ray } from "babylonjs/Culling/ray";
  58935. import { Octree } from "babylonjs/Culling/Octrees/octree";
  58936. import { Collider } from "babylonjs/Collisions/collider";
  58937. module "babylonjs/scene" {
  58938. interface Scene {
  58939. /**
  58940. * @hidden
  58941. * Backing Filed
  58942. */
  58943. _selectionOctree: Octree<AbstractMesh>;
  58944. /**
  58945. * Gets the octree used to boost mesh selection (picking)
  58946. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58947. */
  58948. selectionOctree: Octree<AbstractMesh>;
  58949. /**
  58950. * Creates or updates the octree used to boost selection (picking)
  58951. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58952. * @param maxCapacity defines the maximum capacity per leaf
  58953. * @param maxDepth defines the maximum depth of the octree
  58954. * @returns an octree of AbstractMesh
  58955. */
  58956. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  58957. }
  58958. }
  58959. module "babylonjs/Meshes/abstractMesh" {
  58960. interface AbstractMesh {
  58961. /**
  58962. * @hidden
  58963. * Backing Field
  58964. */
  58965. _submeshesOctree: Octree<SubMesh>;
  58966. /**
  58967. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  58968. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  58969. * @param maxCapacity defines the maximum size of each block (64 by default)
  58970. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  58971. * @returns the new octree
  58972. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  58973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58974. */
  58975. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  58976. }
  58977. }
  58978. /**
  58979. * Defines the octree scene component responsible to manage any octrees
  58980. * in a given scene.
  58981. */
  58982. export class OctreeSceneComponent {
  58983. /**
  58984. * The component name help to identify the component in the list of scene components.
  58985. */
  58986. readonly name: string;
  58987. /**
  58988. * The scene the component belongs to.
  58989. */
  58990. scene: Scene;
  58991. /**
  58992. * Indicates if the meshes have been checked to make sure they are isEnabled()
  58993. */
  58994. readonly checksIsEnabled: boolean;
  58995. /**
  58996. * Creates a new instance of the component for the given scene
  58997. * @param scene Defines the scene to register the component in
  58998. */
  58999. constructor(scene: Scene);
  59000. /**
  59001. * Registers the component in a given scene
  59002. */
  59003. register(): void;
  59004. /**
  59005. * Return the list of active meshes
  59006. * @returns the list of active meshes
  59007. */
  59008. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  59009. /**
  59010. * Return the list of active sub meshes
  59011. * @param mesh The mesh to get the candidates sub meshes from
  59012. * @returns the list of active sub meshes
  59013. */
  59014. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  59015. private _tempRay;
  59016. /**
  59017. * Return the list of sub meshes intersecting with a given local ray
  59018. * @param mesh defines the mesh to find the submesh for
  59019. * @param localRay defines the ray in local space
  59020. * @returns the list of intersecting sub meshes
  59021. */
  59022. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  59023. /**
  59024. * Return the list of sub meshes colliding with a collider
  59025. * @param mesh defines the mesh to find the submesh for
  59026. * @param collider defines the collider to evaluate the collision against
  59027. * @returns the list of colliding sub meshes
  59028. */
  59029. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  59030. /**
  59031. * Rebuilds the elements related to this component in case of
  59032. * context lost for instance.
  59033. */
  59034. rebuild(): void;
  59035. /**
  59036. * Disposes the component and the associated ressources.
  59037. */
  59038. dispose(): void;
  59039. }
  59040. }
  59041. declare module "babylonjs/Culling/Octrees/index" {
  59042. export * from "babylonjs/Culling/Octrees/octree";
  59043. export * from "babylonjs/Culling/Octrees/octreeBlock";
  59044. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  59045. }
  59046. declare module "babylonjs/Culling/index" {
  59047. export * from "babylonjs/Culling/boundingBox";
  59048. export * from "babylonjs/Culling/boundingInfo";
  59049. export * from "babylonjs/Culling/boundingSphere";
  59050. export * from "babylonjs/Culling/Octrees/index";
  59051. export * from "babylonjs/Culling/ray";
  59052. }
  59053. declare module "babylonjs/Gizmos/gizmo" {
  59054. import { Observer } from "babylonjs/Misc/observable";
  59055. import { Nullable } from "babylonjs/types";
  59056. import { IDisposable } from "babylonjs/scene";
  59057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59058. import { Mesh } from "babylonjs/Meshes/mesh";
  59059. import { Node } from "babylonjs/node";
  59060. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59061. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59062. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  59063. /**
  59064. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  59065. */
  59066. export interface GizmoAxisCache {
  59067. /** Mesh used to runder the Gizmo */
  59068. gizmoMeshes: Mesh[];
  59069. /** Mesh used to detect user interaction with Gizmo */
  59070. colliderMeshes: Mesh[];
  59071. /** Material used to inicate color of gizmo mesh */
  59072. material: StandardMaterial;
  59073. /** Material used to inicate hover state of the Gizmo */
  59074. hoverMaterial: StandardMaterial;
  59075. /** Material used to inicate disabled state of the Gizmo */
  59076. disableMaterial: StandardMaterial;
  59077. /** Used to indicate Active state of the Gizmo */
  59078. active: boolean;
  59079. }
  59080. /**
  59081. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  59082. */
  59083. export class Gizmo implements IDisposable {
  59084. /** The utility layer the gizmo will be added to */
  59085. gizmoLayer: UtilityLayerRenderer;
  59086. /**
  59087. * The root mesh of the gizmo
  59088. */
  59089. _rootMesh: Mesh;
  59090. private _attachedMesh;
  59091. private _attachedNode;
  59092. /**
  59093. * Ratio for the scale of the gizmo (Default: 1)
  59094. */
  59095. protected _scaleRatio: number;
  59096. /**
  59097. * boolean updated by pointermove when a gizmo mesh is hovered
  59098. */
  59099. protected _isHovered: boolean;
  59100. /**
  59101. * Ratio for the scale of the gizmo (Default: 1)
  59102. */
  59103. set scaleRatio(value: number);
  59104. get scaleRatio(): number;
  59105. /**
  59106. * True when the mouse pointer is hovered a gizmo mesh
  59107. */
  59108. get isHovered(): boolean;
  59109. /**
  59110. * If a custom mesh has been set (Default: false)
  59111. */
  59112. protected _customMeshSet: boolean;
  59113. /**
  59114. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  59115. * * When set, interactions will be enabled
  59116. */
  59117. get attachedMesh(): Nullable<AbstractMesh>;
  59118. set attachedMesh(value: Nullable<AbstractMesh>);
  59119. /**
  59120. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  59121. * * When set, interactions will be enabled
  59122. */
  59123. get attachedNode(): Nullable<Node>;
  59124. set attachedNode(value: Nullable<Node>);
  59125. /**
  59126. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59127. * @param mesh The mesh to replace the default mesh of the gizmo
  59128. */
  59129. setCustomMesh(mesh: Mesh): void;
  59130. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  59131. /**
  59132. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  59133. */
  59134. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59135. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59136. /**
  59137. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  59138. */
  59139. updateGizmoPositionToMatchAttachedMesh: boolean;
  59140. /**
  59141. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  59142. */
  59143. updateScale: boolean;
  59144. protected _interactionsEnabled: boolean;
  59145. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59146. private _beforeRenderObserver;
  59147. private _tempQuaternion;
  59148. private _tempVector;
  59149. private _tempVector2;
  59150. private _tempMatrix1;
  59151. private _tempMatrix2;
  59152. private _rightHandtoLeftHandMatrix;
  59153. /**
  59154. * Creates a gizmo
  59155. * @param gizmoLayer The utility layer the gizmo will be added to
  59156. */
  59157. constructor(
  59158. /** The utility layer the gizmo will be added to */
  59159. gizmoLayer?: UtilityLayerRenderer);
  59160. /**
  59161. * Updates the gizmo to match the attached mesh's position/rotation
  59162. */
  59163. protected _update(): void;
  59164. /**
  59165. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  59166. * @param value Node, TransformNode or mesh
  59167. */
  59168. protected _matrixChanged(): void;
  59169. /**
  59170. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  59171. * @param gizmoLayer The utility layer the gizmo will be added to
  59172. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  59173. * @returns {Observer<PointerInfo>} pointerObserver
  59174. */
  59175. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  59176. /**
  59177. * Disposes of the gizmo
  59178. */
  59179. dispose(): void;
  59180. }
  59181. }
  59182. declare module "babylonjs/Gizmos/planeDragGizmo" {
  59183. import { Observable } from "babylonjs/Misc/observable";
  59184. import { Nullable } from "babylonjs/types";
  59185. import { Vector3 } from "babylonjs/Maths/math.vector";
  59186. import { Color3 } from "babylonjs/Maths/math.color";
  59187. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59188. import { Node } from "babylonjs/node";
  59189. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59190. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59191. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59192. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59193. import { Scene } from "babylonjs/scene";
  59194. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59195. /**
  59196. * Single plane drag gizmo
  59197. */
  59198. export class PlaneDragGizmo extends Gizmo {
  59199. /**
  59200. * Drag behavior responsible for the gizmos dragging interactions
  59201. */
  59202. dragBehavior: PointerDragBehavior;
  59203. private _pointerObserver;
  59204. /**
  59205. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59206. */
  59207. snapDistance: number;
  59208. /**
  59209. * Event that fires each time the gizmo snaps to a new location.
  59210. * * snapDistance is the the change in distance
  59211. */
  59212. onSnapObservable: Observable<{
  59213. snapDistance: number;
  59214. }>;
  59215. private _gizmoMesh;
  59216. private _coloredMaterial;
  59217. private _hoverMaterial;
  59218. private _disableMaterial;
  59219. private _isEnabled;
  59220. private _parent;
  59221. private _dragging;
  59222. /** @hidden */
  59223. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  59224. /**
  59225. * Creates a PlaneDragGizmo
  59226. * @param gizmoLayer The utility layer the gizmo will be added to
  59227. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  59228. * @param color The color of the gizmo
  59229. */
  59230. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  59231. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59232. /**
  59233. * If the gizmo is enabled
  59234. */
  59235. set isEnabled(value: boolean);
  59236. get isEnabled(): boolean;
  59237. /**
  59238. * Disposes of the gizmo
  59239. */
  59240. dispose(): void;
  59241. }
  59242. }
  59243. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59244. import { Observable } from "babylonjs/Misc/observable";
  59245. import { Nullable } from "babylonjs/types";
  59246. import { Vector3 } from "babylonjs/Maths/math.vector";
  59247. import { Color3 } from "babylonjs/Maths/math.color";
  59248. import "babylonjs/Meshes/Builders/linesBuilder";
  59249. import { Node } from "babylonjs/node";
  59250. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59251. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59252. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59253. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59254. /**
  59255. * Single plane rotation gizmo
  59256. */
  59257. export class PlaneRotationGizmo extends Gizmo {
  59258. /**
  59259. * Drag behavior responsible for the gizmos dragging interactions
  59260. */
  59261. dragBehavior: PointerDragBehavior;
  59262. private _pointerObserver;
  59263. /**
  59264. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59265. */
  59266. snapDistance: number;
  59267. /**
  59268. * Event that fires each time the gizmo snaps to a new location.
  59269. * * snapDistance is the the change in distance
  59270. */
  59271. onSnapObservable: Observable<{
  59272. snapDistance: number;
  59273. }>;
  59274. private _isEnabled;
  59275. private _parent;
  59276. private _coloredMaterial;
  59277. private _hoverMaterial;
  59278. private _disableMaterial;
  59279. private _gizmoMesh;
  59280. private _rotationCircle;
  59281. private _dragging;
  59282. private static _CircleConstants;
  59283. /**
  59284. * Creates a PlaneRotationGizmo
  59285. * @param gizmoLayer The utility layer the gizmo will be added to
  59286. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59287. * @param color The color of the gizmo
  59288. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59289. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59290. * @param thickness display gizmo axis thickness
  59291. */
  59292. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59293. /** Create Geometry for Gizmo */
  59294. private _createGizmoMesh;
  59295. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59296. private setupRotationCircle;
  59297. private updateRotationPath;
  59298. private updateRotationCircle;
  59299. /**
  59300. * If the gizmo is enabled
  59301. */
  59302. set isEnabled(value: boolean);
  59303. get isEnabled(): boolean;
  59304. /**
  59305. * Disposes of the gizmo
  59306. */
  59307. dispose(): void;
  59308. }
  59309. }
  59310. declare module "babylonjs/Gizmos/rotationGizmo" {
  59311. import { Observable } from "babylonjs/Misc/observable";
  59312. import { Nullable } from "babylonjs/types";
  59313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59314. import { Mesh } from "babylonjs/Meshes/mesh";
  59315. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59316. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59317. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59318. import { Node } from "babylonjs/node";
  59319. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59320. /**
  59321. * Gizmo that enables rotating a mesh along 3 axis
  59322. */
  59323. export class RotationGizmo extends Gizmo {
  59324. /**
  59325. * Internal gizmo used for interactions on the x axis
  59326. */
  59327. xGizmo: PlaneRotationGizmo;
  59328. /**
  59329. * Internal gizmo used for interactions on the y axis
  59330. */
  59331. yGizmo: PlaneRotationGizmo;
  59332. /**
  59333. * Internal gizmo used for interactions on the z axis
  59334. */
  59335. zGizmo: PlaneRotationGizmo;
  59336. /** Fires an event when any of it's sub gizmos are dragged */
  59337. onDragStartObservable: Observable<unknown>;
  59338. /** Fires an event when any of it's sub gizmos are released from dragging */
  59339. onDragEndObservable: Observable<unknown>;
  59340. private _meshAttached;
  59341. private _nodeAttached;
  59342. private _observables;
  59343. /** Node Caching for quick lookup */
  59344. private _gizmoAxisCache;
  59345. get attachedMesh(): Nullable<AbstractMesh>;
  59346. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59347. get attachedNode(): Nullable<Node>;
  59348. set attachedNode(node: Nullable<Node>);
  59349. protected _checkBillboardTransform(): void;
  59350. /**
  59351. * True when the mouse pointer is hovering a gizmo mesh
  59352. */
  59353. get isHovered(): boolean;
  59354. /**
  59355. * Creates a RotationGizmo
  59356. * @param gizmoLayer The utility layer the gizmo will be added to
  59357. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59358. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59359. * @param thickness display gizmo axis thickness
  59360. */
  59361. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  59362. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59363. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59364. /**
  59365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59366. */
  59367. set snapDistance(value: number);
  59368. get snapDistance(): number;
  59369. /**
  59370. * Ratio for the scale of the gizmo (Default: 1)
  59371. */
  59372. set scaleRatio(value: number);
  59373. get scaleRatio(): number;
  59374. /**
  59375. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59376. * @param mesh Axis gizmo mesh
  59377. * @param cache Gizmo axis definition used for reactive gizmo UI
  59378. */
  59379. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59380. /**
  59381. * Disposes of the gizmo
  59382. */
  59383. dispose(): void;
  59384. /**
  59385. * CustomMeshes are not supported by this gizmo
  59386. * @param mesh The mesh to replace the default mesh of the gizmo
  59387. */
  59388. setCustomMesh(mesh: Mesh): void;
  59389. }
  59390. }
  59391. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59392. import { Scene } from "babylonjs/scene";
  59393. import { Vector4 } from "babylonjs/Maths/math.vector";
  59394. import { Color4 } from "babylonjs/Maths/math.color";
  59395. import { Mesh } from "babylonjs/Meshes/mesh";
  59396. import { Nullable } from "babylonjs/types";
  59397. /**
  59398. * Class containing static functions to help procedurally build meshes
  59399. */
  59400. export class PolyhedronBuilder {
  59401. /**
  59402. * Creates a polyhedron mesh
  59403. * * 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
  59404. * * The parameter `size` (positive float, default 1) sets the polygon size
  59405. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59406. * * 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`
  59407. * * 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
  59408. * * 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)`)
  59409. * * 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
  59410. * * 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
  59411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59412. * * 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
  59413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59414. * @param name defines the name of the mesh
  59415. * @param options defines the options used to create the mesh
  59416. * @param scene defines the hosting scene
  59417. * @returns the polyhedron mesh
  59418. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59419. */
  59420. static CreatePolyhedron(name: string, options: {
  59421. type?: number;
  59422. size?: number;
  59423. sizeX?: number;
  59424. sizeY?: number;
  59425. sizeZ?: number;
  59426. custom?: any;
  59427. faceUV?: Vector4[];
  59428. faceColors?: Color4[];
  59429. flat?: boolean;
  59430. updatable?: boolean;
  59431. sideOrientation?: number;
  59432. frontUVs?: Vector4;
  59433. backUVs?: Vector4;
  59434. }, scene?: Nullable<Scene>): Mesh;
  59435. }
  59436. }
  59437. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  59438. import { Nullable } from "babylonjs/types";
  59439. import { Scene } from "babylonjs/scene";
  59440. import { Vector4 } from "babylonjs/Maths/math.vector";
  59441. import { Color4 } from "babylonjs/Maths/math.color";
  59442. import { Mesh } from "babylonjs/Meshes/mesh";
  59443. /**
  59444. * Class containing static functions to help procedurally build meshes
  59445. */
  59446. export class BoxBuilder {
  59447. /**
  59448. * Creates a box mesh
  59449. * * The parameter `size` sets the size (float) of each box side (default 1)
  59450. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59451. * * 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)
  59452. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59454. * * 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
  59455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59456. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59457. * @param name defines the name of the mesh
  59458. * @param options defines the options used to create the mesh
  59459. * @param scene defines the hosting scene
  59460. * @returns the box mesh
  59461. */
  59462. static CreateBox(name: string, options: {
  59463. size?: number;
  59464. width?: number;
  59465. height?: number;
  59466. depth?: number;
  59467. faceUV?: Vector4[];
  59468. faceColors?: Color4[];
  59469. sideOrientation?: number;
  59470. frontUVs?: Vector4;
  59471. backUVs?: Vector4;
  59472. wrap?: boolean;
  59473. topBaseAt?: number;
  59474. bottomBaseAt?: number;
  59475. updatable?: boolean;
  59476. }, scene?: Nullable<Scene>): Mesh;
  59477. }
  59478. }
  59479. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59480. import { Observable } from "babylonjs/Misc/observable";
  59481. import { Nullable } from "babylonjs/types";
  59482. import { Vector3 } from "babylonjs/Maths/math.vector";
  59483. import { Node } from "babylonjs/node";
  59484. import { Mesh } from "babylonjs/Meshes/mesh";
  59485. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59486. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59487. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59488. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59489. import { Color3 } from "babylonjs/Maths/math.color";
  59490. /**
  59491. * Single axis scale gizmo
  59492. */
  59493. export class AxisScaleGizmo extends Gizmo {
  59494. /**
  59495. * Drag behavior responsible for the gizmos dragging interactions
  59496. */
  59497. dragBehavior: PointerDragBehavior;
  59498. private _pointerObserver;
  59499. /**
  59500. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59501. */
  59502. snapDistance: number;
  59503. /**
  59504. * Event that fires each time the gizmo snaps to a new location.
  59505. * * snapDistance is the the change in distance
  59506. */
  59507. onSnapObservable: Observable<{
  59508. snapDistance: number;
  59509. }>;
  59510. /**
  59511. * If the scaling operation should be done on all axis (default: false)
  59512. */
  59513. uniformScaling: boolean;
  59514. /**
  59515. * Custom sensitivity value for the drag strength
  59516. */
  59517. sensitivity: number;
  59518. private _isEnabled;
  59519. private _parent;
  59520. private _gizmoMesh;
  59521. private _coloredMaterial;
  59522. private _hoverMaterial;
  59523. private _disableMaterial;
  59524. private _dragging;
  59525. private _tmpVector;
  59526. private _tmpMatrix;
  59527. private _tmpMatrix2;
  59528. /**
  59529. * Creates an AxisScaleGizmo
  59530. * @param gizmoLayer The utility layer the gizmo will be added to
  59531. * @param dragAxis The axis which the gizmo will be able to scale on
  59532. * @param color The color of the gizmo
  59533. * @param thickness display gizmo axis thickness
  59534. */
  59535. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59536. /** Create Geometry for Gizmo */
  59537. private _createGizmoMesh;
  59538. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59539. /**
  59540. * If the gizmo is enabled
  59541. */
  59542. set isEnabled(value: boolean);
  59543. get isEnabled(): boolean;
  59544. /**
  59545. * Disposes of the gizmo
  59546. */
  59547. dispose(): void;
  59548. /**
  59549. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59550. * @param mesh The mesh to replace the default mesh of the gizmo
  59551. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59552. */
  59553. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59554. }
  59555. }
  59556. declare module "babylonjs/Gizmos/scaleGizmo" {
  59557. import { Observable } from "babylonjs/Misc/observable";
  59558. import { Nullable } from "babylonjs/types";
  59559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59560. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59561. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59562. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59563. import { Mesh } from "babylonjs/Meshes/mesh";
  59564. import { Node } from "babylonjs/node";
  59565. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59566. /**
  59567. * Gizmo that enables scaling a mesh along 3 axis
  59568. */
  59569. export class ScaleGizmo extends Gizmo {
  59570. /**
  59571. * Internal gizmo used for interactions on the x axis
  59572. */
  59573. xGizmo: AxisScaleGizmo;
  59574. /**
  59575. * Internal gizmo used for interactions on the y axis
  59576. */
  59577. yGizmo: AxisScaleGizmo;
  59578. /**
  59579. * Internal gizmo used for interactions on the z axis
  59580. */
  59581. zGizmo: AxisScaleGizmo;
  59582. /**
  59583. * Internal gizmo used to scale all axis equally
  59584. */
  59585. uniformScaleGizmo: AxisScaleGizmo;
  59586. private _meshAttached;
  59587. private _nodeAttached;
  59588. private _snapDistance;
  59589. private _uniformScalingMesh;
  59590. private _octahedron;
  59591. private _sensitivity;
  59592. private _coloredMaterial;
  59593. private _hoverMaterial;
  59594. private _disableMaterial;
  59595. private _observables;
  59596. /** Node Caching for quick lookup */
  59597. private _gizmoAxisCache;
  59598. /** Fires an event when any of it's sub gizmos are dragged */
  59599. onDragStartObservable: Observable<unknown>;
  59600. /** Fires an event when any of it's sub gizmos are released from dragging */
  59601. onDragEndObservable: Observable<unknown>;
  59602. get attachedMesh(): Nullable<AbstractMesh>;
  59603. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59604. get attachedNode(): Nullable<Node>;
  59605. set attachedNode(node: Nullable<Node>);
  59606. /**
  59607. * True when the mouse pointer is hovering a gizmo mesh
  59608. */
  59609. get isHovered(): boolean;
  59610. /**
  59611. * Creates a ScaleGizmo
  59612. * @param gizmoLayer The utility layer the gizmo will be added to
  59613. * @param thickness display gizmo axis thickness
  59614. */
  59615. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59616. /** Create Geometry for Gizmo */
  59617. private _createUniformScaleMesh;
  59618. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59619. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59620. /**
  59621. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59622. */
  59623. set snapDistance(value: number);
  59624. get snapDistance(): number;
  59625. /**
  59626. * Ratio for the scale of the gizmo (Default: 1)
  59627. */
  59628. set scaleRatio(value: number);
  59629. get scaleRatio(): number;
  59630. /**
  59631. * Sensitivity factor for dragging (Default: 1)
  59632. */
  59633. set sensitivity(value: number);
  59634. get sensitivity(): number;
  59635. /**
  59636. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59637. * @param mesh Axis gizmo mesh
  59638. * @param cache Gizmo axis definition used for reactive gizmo UI
  59639. */
  59640. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59641. /**
  59642. * Disposes of the gizmo
  59643. */
  59644. dispose(): void;
  59645. }
  59646. }
  59647. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59648. import { Observable } from "babylonjs/Misc/observable";
  59649. import { Nullable } from "babylonjs/types";
  59650. import { Vector3 } from "babylonjs/Maths/math.vector";
  59651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59652. import { Mesh } from "babylonjs/Meshes/mesh";
  59653. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59654. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59655. import { Color3 } from "babylonjs/Maths/math.color";
  59656. import "babylonjs/Meshes/Builders/boxBuilder";
  59657. /**
  59658. * Bounding box gizmo
  59659. */
  59660. export class BoundingBoxGizmo extends Gizmo {
  59661. private _lineBoundingBox;
  59662. private _rotateSpheresParent;
  59663. private _scaleBoxesParent;
  59664. private _boundingDimensions;
  59665. private _renderObserver;
  59666. private _pointerObserver;
  59667. private _scaleDragSpeed;
  59668. private _tmpQuaternion;
  59669. private _tmpVector;
  59670. private _tmpRotationMatrix;
  59671. /**
  59672. * 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)
  59673. */
  59674. ignoreChildren: boolean;
  59675. /**
  59676. * 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)
  59677. */
  59678. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59679. /**
  59680. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59681. */
  59682. rotationSphereSize: number;
  59683. /**
  59684. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59685. */
  59686. scaleBoxSize: number;
  59687. /**
  59688. * 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)
  59689. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  59690. */
  59691. fixedDragMeshScreenSize: boolean;
  59692. /**
  59693. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  59694. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  59695. */
  59696. fixedDragMeshBoundsSize: boolean;
  59697. /**
  59698. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59699. */
  59700. fixedDragMeshScreenSizeDistanceFactor: number;
  59701. /**
  59702. * Fired when a rotation sphere or scale box is dragged
  59703. */
  59704. onDragStartObservable: Observable<{}>;
  59705. /**
  59706. * Fired when a scale box is dragged
  59707. */
  59708. onScaleBoxDragObservable: Observable<{}>;
  59709. /**
  59710. * Fired when a scale box drag is ended
  59711. */
  59712. onScaleBoxDragEndObservable: Observable<{}>;
  59713. /**
  59714. * Fired when a rotation sphere is dragged
  59715. */
  59716. onRotationSphereDragObservable: Observable<{}>;
  59717. /**
  59718. * Fired when a rotation sphere drag is ended
  59719. */
  59720. onRotationSphereDragEndObservable: Observable<{}>;
  59721. /**
  59722. * 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)
  59723. */
  59724. scalePivot: Nullable<Vector3>;
  59725. /**
  59726. * Mesh used as a pivot to rotate the attached node
  59727. */
  59728. private _anchorMesh;
  59729. private _existingMeshScale;
  59730. private _dragMesh;
  59731. private pointerDragBehavior;
  59732. private coloredMaterial;
  59733. private hoverColoredMaterial;
  59734. /**
  59735. * Sets the color of the bounding box gizmo
  59736. * @param color the color to set
  59737. */
  59738. setColor(color: Color3): void;
  59739. /**
  59740. * Creates an BoundingBoxGizmo
  59741. * @param gizmoLayer The utility layer the gizmo will be added to
  59742. * @param color The color of the gizmo
  59743. */
  59744. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59745. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59746. private _selectNode;
  59747. /**
  59748. * Updates the bounding box information for the Gizmo
  59749. */
  59750. updateBoundingBox(): void;
  59751. private _updateRotationSpheres;
  59752. private _updateScaleBoxes;
  59753. /**
  59754. * Enables rotation on the specified axis and disables rotation on the others
  59755. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59756. */
  59757. setEnabledRotationAxis(axis: string): void;
  59758. /**
  59759. * Enables/disables scaling
  59760. * @param enable if scaling should be enabled
  59761. * @param homogeneousScaling defines if scaling should only be homogeneous
  59762. */
  59763. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59764. private _updateDummy;
  59765. /**
  59766. * Enables a pointer drag behavior on the bounding box of the gizmo
  59767. */
  59768. enableDragBehavior(): void;
  59769. /**
  59770. * Disposes of the gizmo
  59771. */
  59772. dispose(): void;
  59773. /**
  59774. * 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)
  59775. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59776. * @returns the bounding box mesh with the passed in mesh as a child
  59777. */
  59778. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59779. /**
  59780. * CustomMeshes are not supported by this gizmo
  59781. * @param mesh The mesh to replace the default mesh of the gizmo
  59782. */
  59783. setCustomMesh(mesh: Mesh): void;
  59784. }
  59785. }
  59786. declare module "babylonjs/Gizmos/gizmoManager" {
  59787. import { Observable } from "babylonjs/Misc/observable";
  59788. import { Nullable } from "babylonjs/types";
  59789. import { Scene, IDisposable } from "babylonjs/scene";
  59790. import { Node } from "babylonjs/node";
  59791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59792. import { Mesh } from "babylonjs/Meshes/mesh";
  59793. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59794. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59795. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59796. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59797. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59798. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59799. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59800. /**
  59801. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59802. */
  59803. export class GizmoManager implements IDisposable {
  59804. private scene;
  59805. /**
  59806. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59807. */
  59808. gizmos: {
  59809. positionGizmo: Nullable<PositionGizmo>;
  59810. rotationGizmo: Nullable<RotationGizmo>;
  59811. scaleGizmo: Nullable<ScaleGizmo>;
  59812. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59813. };
  59814. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59815. clearGizmoOnEmptyPointerEvent: boolean;
  59816. /** Fires an event when the manager is attached to a mesh */
  59817. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59818. /** Fires an event when the manager is attached to a node */
  59819. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59820. private _gizmosEnabled;
  59821. private _pointerObservers;
  59822. private _attachedMesh;
  59823. private _attachedNode;
  59824. private _boundingBoxColor;
  59825. private _defaultUtilityLayer;
  59826. private _defaultKeepDepthUtilityLayer;
  59827. private _thickness;
  59828. /** Node Caching for quick lookup */
  59829. private _gizmoAxisCache;
  59830. /**
  59831. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59832. */
  59833. boundingBoxDragBehavior: SixDofDragBehavior;
  59834. /**
  59835. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59836. */
  59837. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59838. /**
  59839. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59840. */
  59841. attachableNodes: Nullable<Array<Node>>;
  59842. /**
  59843. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59844. */
  59845. usePointerToAttachGizmos: boolean;
  59846. /**
  59847. * Utility layer that the bounding box gizmo belongs to
  59848. */
  59849. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59850. /**
  59851. * Utility layer that all gizmos besides bounding box belong to
  59852. */
  59853. get utilityLayer(): UtilityLayerRenderer;
  59854. /**
  59855. * True when the mouse pointer is hovering a gizmo mesh
  59856. */
  59857. get isHovered(): boolean;
  59858. /**
  59859. * Instatiates a gizmo manager
  59860. * @param scene the scene to overlay the gizmos on top of
  59861. * @param thickness display gizmo axis thickness
  59862. * @param utilityLayer the layer where gizmos are rendered
  59863. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  59864. */
  59865. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  59866. /**
  59867. * Subscribes to pointer down events, for attaching and detaching mesh
  59868. * @param scene The sceme layer the observer will be added to
  59869. */
  59870. private _attachToMeshPointerObserver;
  59871. /**
  59872. * Attaches a set of gizmos to the specified mesh
  59873. * @param mesh The mesh the gizmo's should be attached to
  59874. */
  59875. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59876. /**
  59877. * Attaches a set of gizmos to the specified node
  59878. * @param node The node the gizmo's should be attached to
  59879. */
  59880. attachToNode(node: Nullable<Node>): void;
  59881. /**
  59882. * If the position gizmo is enabled
  59883. */
  59884. set positionGizmoEnabled(value: boolean);
  59885. get positionGizmoEnabled(): boolean;
  59886. /**
  59887. * If the rotation gizmo is enabled
  59888. */
  59889. set rotationGizmoEnabled(value: boolean);
  59890. get rotationGizmoEnabled(): boolean;
  59891. /**
  59892. * If the scale gizmo is enabled
  59893. */
  59894. set scaleGizmoEnabled(value: boolean);
  59895. get scaleGizmoEnabled(): boolean;
  59896. /**
  59897. * If the boundingBox gizmo is enabled
  59898. */
  59899. set boundingBoxGizmoEnabled(value: boolean);
  59900. get boundingBoxGizmoEnabled(): boolean;
  59901. /**
  59902. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59903. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  59904. */
  59905. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  59906. /**
  59907. * Disposes of the gizmo manager
  59908. */
  59909. dispose(): void;
  59910. }
  59911. }
  59912. declare module "babylonjs/Gizmos/positionGizmo" {
  59913. import { Observable } from "babylonjs/Misc/observable";
  59914. import { Nullable } from "babylonjs/types";
  59915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59916. import { Node } from "babylonjs/node";
  59917. import { Mesh } from "babylonjs/Meshes/mesh";
  59918. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59919. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  59920. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  59921. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59922. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59923. /**
  59924. * Gizmo that enables dragging a mesh along 3 axis
  59925. */
  59926. export class PositionGizmo extends Gizmo {
  59927. /**
  59928. * Internal gizmo used for interactions on the x axis
  59929. */
  59930. xGizmo: AxisDragGizmo;
  59931. /**
  59932. * Internal gizmo used for interactions on the y axis
  59933. */
  59934. yGizmo: AxisDragGizmo;
  59935. /**
  59936. * Internal gizmo used for interactions on the z axis
  59937. */
  59938. zGizmo: AxisDragGizmo;
  59939. /**
  59940. * Internal gizmo used for interactions on the yz plane
  59941. */
  59942. xPlaneGizmo: PlaneDragGizmo;
  59943. /**
  59944. * Internal gizmo used for interactions on the xz plane
  59945. */
  59946. yPlaneGizmo: PlaneDragGizmo;
  59947. /**
  59948. * Internal gizmo used for interactions on the xy plane
  59949. */
  59950. zPlaneGizmo: PlaneDragGizmo;
  59951. /**
  59952. * private variables
  59953. */
  59954. private _meshAttached;
  59955. private _nodeAttached;
  59956. private _snapDistance;
  59957. private _observables;
  59958. /** Node Caching for quick lookup */
  59959. private _gizmoAxisCache;
  59960. /** Fires an event when any of it's sub gizmos are dragged */
  59961. onDragStartObservable: Observable<unknown>;
  59962. /** Fires an event when any of it's sub gizmos are released from dragging */
  59963. onDragEndObservable: Observable<unknown>;
  59964. /**
  59965. * If set to true, planar drag is enabled
  59966. */
  59967. private _planarGizmoEnabled;
  59968. get attachedMesh(): Nullable<AbstractMesh>;
  59969. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59970. get attachedNode(): Nullable<Node>;
  59971. set attachedNode(node: Nullable<Node>);
  59972. /**
  59973. * True when the mouse pointer is hovering a gizmo mesh
  59974. */
  59975. get isHovered(): boolean;
  59976. /**
  59977. * Creates a PositionGizmo
  59978. * @param gizmoLayer The utility layer the gizmo will be added to
  59979. @param thickness display gizmo axis thickness
  59980. */
  59981. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59982. /**
  59983. * If the planar drag gizmo is enabled
  59984. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  59985. */
  59986. set planarGizmoEnabled(value: boolean);
  59987. get planarGizmoEnabled(): boolean;
  59988. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59989. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59990. /**
  59991. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59992. */
  59993. set snapDistance(value: number);
  59994. get snapDistance(): number;
  59995. /**
  59996. * Ratio for the scale of the gizmo (Default: 1)
  59997. */
  59998. set scaleRatio(value: number);
  59999. get scaleRatio(): number;
  60000. /**
  60001. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60002. * @param mesh Axis gizmo mesh
  60003. * @param cache Gizmo axis definition used for reactive gizmo UI
  60004. */
  60005. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60006. /**
  60007. * Disposes of the gizmo
  60008. */
  60009. dispose(): void;
  60010. /**
  60011. * CustomMeshes are not supported by this gizmo
  60012. * @param mesh The mesh to replace the default mesh of the gizmo
  60013. */
  60014. setCustomMesh(mesh: Mesh): void;
  60015. }
  60016. }
  60017. declare module "babylonjs/Gizmos/axisDragGizmo" {
  60018. import { Observable } from "babylonjs/Misc/observable";
  60019. import { Nullable } from "babylonjs/types";
  60020. import { Vector3 } from "babylonjs/Maths/math.vector";
  60021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60022. import { Node } from "babylonjs/node";
  60023. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60024. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60025. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60026. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60027. import { Scene } from "babylonjs/scene";
  60028. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60029. import { Color3 } from "babylonjs/Maths/math.color";
  60030. /**
  60031. * Single axis drag gizmo
  60032. */
  60033. export class AxisDragGizmo extends Gizmo {
  60034. /**
  60035. * Drag behavior responsible for the gizmos dragging interactions
  60036. */
  60037. dragBehavior: PointerDragBehavior;
  60038. private _pointerObserver;
  60039. /**
  60040. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60041. */
  60042. snapDistance: number;
  60043. /**
  60044. * Event that fires each time the gizmo snaps to a new location.
  60045. * * snapDistance is the the change in distance
  60046. */
  60047. onSnapObservable: Observable<{
  60048. snapDistance: number;
  60049. }>;
  60050. private _isEnabled;
  60051. private _parent;
  60052. private _gizmoMesh;
  60053. private _coloredMaterial;
  60054. private _hoverMaterial;
  60055. private _disableMaterial;
  60056. private _dragging;
  60057. /** @hidden */
  60058. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  60059. /** @hidden */
  60060. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  60061. /**
  60062. * Creates an AxisDragGizmo
  60063. * @param gizmoLayer The utility layer the gizmo will be added to
  60064. * @param dragAxis The axis which the gizmo will be able to drag on
  60065. * @param color The color of the gizmo
  60066. * @param thickness display gizmo axis thickness
  60067. */
  60068. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  60069. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60070. /**
  60071. * If the gizmo is enabled
  60072. */
  60073. set isEnabled(value: boolean);
  60074. get isEnabled(): boolean;
  60075. /**
  60076. * Disposes of the gizmo
  60077. */
  60078. dispose(): void;
  60079. }
  60080. }
  60081. declare module "babylonjs/Debug/axesViewer" {
  60082. import { Vector3 } from "babylonjs/Maths/math.vector";
  60083. import { Nullable } from "babylonjs/types";
  60084. import { Scene } from "babylonjs/scene";
  60085. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60086. /**
  60087. * The Axes viewer will show 3 axes in a specific point in space
  60088. */
  60089. export class AxesViewer {
  60090. private _xAxis;
  60091. private _yAxis;
  60092. private _zAxis;
  60093. private _scaleLinesFactor;
  60094. private _instanced;
  60095. /**
  60096. * Gets the hosting scene
  60097. */
  60098. scene: Nullable<Scene>;
  60099. /**
  60100. * Gets or sets a number used to scale line length
  60101. */
  60102. scaleLines: number;
  60103. /** Gets the node hierarchy used to render x-axis */
  60104. get xAxis(): TransformNode;
  60105. /** Gets the node hierarchy used to render y-axis */
  60106. get yAxis(): TransformNode;
  60107. /** Gets the node hierarchy used to render z-axis */
  60108. get zAxis(): TransformNode;
  60109. /**
  60110. * Creates a new AxesViewer
  60111. * @param scene defines the hosting scene
  60112. * @param scaleLines defines a number used to scale line length (1 by default)
  60113. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  60114. * @param xAxis defines the node hierarchy used to render the x-axis
  60115. * @param yAxis defines the node hierarchy used to render the y-axis
  60116. * @param zAxis defines the node hierarchy used to render the z-axis
  60117. */
  60118. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  60119. /**
  60120. * Force the viewer to update
  60121. * @param position defines the position of the viewer
  60122. * @param xaxis defines the x axis of the viewer
  60123. * @param yaxis defines the y axis of the viewer
  60124. * @param zaxis defines the z axis of the viewer
  60125. */
  60126. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  60127. /**
  60128. * Creates an instance of this axes viewer.
  60129. * @returns a new axes viewer with instanced meshes
  60130. */
  60131. createInstance(): AxesViewer;
  60132. /** Releases resources */
  60133. dispose(): void;
  60134. private static _SetRenderingGroupId;
  60135. }
  60136. }
  60137. declare module "babylonjs/Debug/boneAxesViewer" {
  60138. import { Nullable } from "babylonjs/types";
  60139. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  60140. import { Vector3 } from "babylonjs/Maths/math.vector";
  60141. import { Mesh } from "babylonjs/Meshes/mesh";
  60142. import { Bone } from "babylonjs/Bones/bone";
  60143. import { Scene } from "babylonjs/scene";
  60144. /**
  60145. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  60146. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  60147. */
  60148. export class BoneAxesViewer extends AxesViewer {
  60149. /**
  60150. * Gets or sets the target mesh where to display the axes viewer
  60151. */
  60152. mesh: Nullable<Mesh>;
  60153. /**
  60154. * Gets or sets the target bone where to display the axes viewer
  60155. */
  60156. bone: Nullable<Bone>;
  60157. /** Gets current position */
  60158. pos: Vector3;
  60159. /** Gets direction of X axis */
  60160. xaxis: Vector3;
  60161. /** Gets direction of Y axis */
  60162. yaxis: Vector3;
  60163. /** Gets direction of Z axis */
  60164. zaxis: Vector3;
  60165. /**
  60166. * Creates a new BoneAxesViewer
  60167. * @param scene defines the hosting scene
  60168. * @param bone defines the target bone
  60169. * @param mesh defines the target mesh
  60170. * @param scaleLines defines a scaling factor for line length (1 by default)
  60171. */
  60172. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  60173. /**
  60174. * Force the viewer to update
  60175. */
  60176. update(): void;
  60177. /** Releases resources */
  60178. dispose(): void;
  60179. }
  60180. }
  60181. declare module "babylonjs/Debug/debugLayer" {
  60182. import { Scene } from "babylonjs/scene";
  60183. /**
  60184. * Interface used to define scene explorer extensibility option
  60185. */
  60186. export interface IExplorerExtensibilityOption {
  60187. /**
  60188. * Define the option label
  60189. */
  60190. label: string;
  60191. /**
  60192. * Defines the action to execute on click
  60193. */
  60194. action: (entity: any) => void;
  60195. }
  60196. /**
  60197. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  60198. */
  60199. export interface IExplorerExtensibilityGroup {
  60200. /**
  60201. * Defines a predicate to test if a given type mut be extended
  60202. */
  60203. predicate: (entity: any) => boolean;
  60204. /**
  60205. * Gets the list of options added to a type
  60206. */
  60207. entries: IExplorerExtensibilityOption[];
  60208. }
  60209. /**
  60210. * Interface used to define the options to use to create the Inspector
  60211. */
  60212. export interface IInspectorOptions {
  60213. /**
  60214. * Display in overlay mode (default: false)
  60215. */
  60216. overlay?: boolean;
  60217. /**
  60218. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  60219. */
  60220. globalRoot?: HTMLElement;
  60221. /**
  60222. * Display the Scene explorer
  60223. */
  60224. showExplorer?: boolean;
  60225. /**
  60226. * Display the property inspector
  60227. */
  60228. showInspector?: boolean;
  60229. /**
  60230. * Display in embed mode (both panes on the right)
  60231. */
  60232. embedMode?: boolean;
  60233. /**
  60234. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  60235. */
  60236. handleResize?: boolean;
  60237. /**
  60238. * Allow the panes to popup (default: true)
  60239. */
  60240. enablePopup?: boolean;
  60241. /**
  60242. * Allow the panes to be closed by users (default: true)
  60243. */
  60244. enableClose?: boolean;
  60245. /**
  60246. * Optional list of extensibility entries
  60247. */
  60248. explorerExtensibility?: IExplorerExtensibilityGroup[];
  60249. /**
  60250. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  60251. */
  60252. inspectorURL?: string;
  60253. /**
  60254. * Optional initial tab (default to DebugLayerTab.Properties)
  60255. */
  60256. initialTab?: DebugLayerTab;
  60257. }
  60258. module "babylonjs/scene" {
  60259. interface Scene {
  60260. /**
  60261. * @hidden
  60262. * Backing field
  60263. */
  60264. _debugLayer: DebugLayer;
  60265. /**
  60266. * Gets the debug layer (aka Inspector) associated with the scene
  60267. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60268. */
  60269. debugLayer: DebugLayer;
  60270. }
  60271. }
  60272. /**
  60273. * Enum of inspector action tab
  60274. */
  60275. export enum DebugLayerTab {
  60276. /**
  60277. * Properties tag (default)
  60278. */
  60279. Properties = 0,
  60280. /**
  60281. * Debug tab
  60282. */
  60283. Debug = 1,
  60284. /**
  60285. * Statistics tab
  60286. */
  60287. Statistics = 2,
  60288. /**
  60289. * Tools tab
  60290. */
  60291. Tools = 3,
  60292. /**
  60293. * Settings tab
  60294. */
  60295. Settings = 4
  60296. }
  60297. /**
  60298. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60299. * what is happening in your scene
  60300. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60301. */
  60302. export class DebugLayer {
  60303. /**
  60304. * Define the url to get the inspector script from.
  60305. * By default it uses the babylonjs CDN.
  60306. * @ignoreNaming
  60307. */
  60308. static InspectorURL: string;
  60309. private _scene;
  60310. private BJSINSPECTOR;
  60311. private _onPropertyChangedObservable?;
  60312. /**
  60313. * Observable triggered when a property is changed through the inspector.
  60314. */
  60315. get onPropertyChangedObservable(): any;
  60316. /**
  60317. * Instantiates a new debug layer.
  60318. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60319. * what is happening in your scene
  60320. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60321. * @param scene Defines the scene to inspect
  60322. */
  60323. constructor(scene: Scene);
  60324. /** Creates the inspector window. */
  60325. private _createInspector;
  60326. /**
  60327. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  60328. * @param entity defines the entity to select
  60329. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  60330. */
  60331. select(entity: any, lineContainerTitles?: string | string[]): void;
  60332. /** Get the inspector from bundle or global */
  60333. private _getGlobalInspector;
  60334. /**
  60335. * Get if the inspector is visible or not.
  60336. * @returns true if visible otherwise, false
  60337. */
  60338. isVisible(): boolean;
  60339. /**
  60340. * Hide the inspector and close its window.
  60341. */
  60342. hide(): void;
  60343. /**
  60344. * Update the scene in the inspector
  60345. */
  60346. setAsActiveScene(): void;
  60347. /**
  60348. * Launch the debugLayer.
  60349. * @param config Define the configuration of the inspector
  60350. * @return a promise fulfilled when the debug layer is visible
  60351. */
  60352. show(config?: IInspectorOptions): Promise<DebugLayer>;
  60353. }
  60354. }
  60355. declare module "babylonjs/Debug/physicsViewer" {
  60356. import { Nullable } from "babylonjs/types";
  60357. import { Scene } from "babylonjs/scene";
  60358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60359. import { Mesh } from "babylonjs/Meshes/mesh";
  60360. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60361. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60362. /**
  60363. * Used to show the physics impostor around the specific mesh
  60364. */
  60365. export class PhysicsViewer {
  60366. /** @hidden */
  60367. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  60368. /** @hidden */
  60369. protected _meshes: Array<Nullable<AbstractMesh>>;
  60370. /** @hidden */
  60371. protected _scene: Nullable<Scene>;
  60372. /** @hidden */
  60373. protected _numMeshes: number;
  60374. /** @hidden */
  60375. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  60376. private _renderFunction;
  60377. private _utilityLayer;
  60378. private _debugBoxMesh;
  60379. private _debugSphereMesh;
  60380. private _debugCylinderMesh;
  60381. private _debugMaterial;
  60382. private _debugMeshMeshes;
  60383. /**
  60384. * Creates a new PhysicsViewer
  60385. * @param scene defines the hosting scene
  60386. */
  60387. constructor(scene: Scene);
  60388. /** @hidden */
  60389. protected _updateDebugMeshes(): void;
  60390. /**
  60391. * Renders a specified physic impostor
  60392. * @param impostor defines the impostor to render
  60393. * @param targetMesh defines the mesh represented by the impostor
  60394. * @returns the new debug mesh used to render the impostor
  60395. */
  60396. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  60397. /**
  60398. * Hides a specified physic impostor
  60399. * @param impostor defines the impostor to hide
  60400. */
  60401. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  60402. private _getDebugMaterial;
  60403. private _getDebugBoxMesh;
  60404. private _getDebugSphereMesh;
  60405. private _getDebugCylinderMesh;
  60406. private _getDebugMeshMesh;
  60407. private _getDebugMesh;
  60408. /** Releases all resources */
  60409. dispose(): void;
  60410. }
  60411. }
  60412. declare module "babylonjs/Debug/rayHelper" {
  60413. import { Nullable } from "babylonjs/types";
  60414. import { Ray } from "babylonjs/Culling/ray";
  60415. import { Vector3 } from "babylonjs/Maths/math.vector";
  60416. import { Color3 } from "babylonjs/Maths/math.color";
  60417. import { Scene } from "babylonjs/scene";
  60418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60419. import "babylonjs/Meshes/Builders/linesBuilder";
  60420. /**
  60421. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60422. * in order to better appreciate the issue one might have.
  60423. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60424. */
  60425. export class RayHelper {
  60426. /**
  60427. * Defines the ray we are currently tryin to visualize.
  60428. */
  60429. ray: Nullable<Ray>;
  60430. private _renderPoints;
  60431. private _renderLine;
  60432. private _renderFunction;
  60433. private _scene;
  60434. private _onAfterRenderObserver;
  60435. private _onAfterStepObserver;
  60436. private _attachedToMesh;
  60437. private _meshSpaceDirection;
  60438. private _meshSpaceOrigin;
  60439. /**
  60440. * Helper function to create a colored helper in a scene in one line.
  60441. * @param ray Defines the ray we are currently tryin to visualize
  60442. * @param scene Defines the scene the ray is used in
  60443. * @param color Defines the color we want to see the ray in
  60444. * @returns The newly created ray helper.
  60445. */
  60446. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  60447. /**
  60448. * Instantiate a new ray helper.
  60449. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60450. * in order to better appreciate the issue one might have.
  60451. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60452. * @param ray Defines the ray we are currently tryin to visualize
  60453. */
  60454. constructor(ray: Ray);
  60455. /**
  60456. * Shows the ray we are willing to debug.
  60457. * @param scene Defines the scene the ray needs to be rendered in
  60458. * @param color Defines the color the ray needs to be rendered in
  60459. */
  60460. show(scene: Scene, color?: Color3): void;
  60461. /**
  60462. * Hides the ray we are debugging.
  60463. */
  60464. hide(): void;
  60465. private _render;
  60466. /**
  60467. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  60468. * @param mesh Defines the mesh we want the helper attached to
  60469. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  60470. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  60471. * @param length Defines the length of the ray
  60472. */
  60473. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  60474. /**
  60475. * Detach the ray helper from the mesh it has previously been attached to.
  60476. */
  60477. detachFromMesh(): void;
  60478. private _updateToMesh;
  60479. /**
  60480. * Dispose the helper and release its associated resources.
  60481. */
  60482. dispose(): void;
  60483. }
  60484. }
  60485. declare module "babylonjs/Debug/ISkeletonViewer" {
  60486. import { Skeleton } from "babylonjs/Bones/skeleton";
  60487. import { Color3 } from "babylonjs/Maths/math.color";
  60488. /**
  60489. * Defines the options associated with the creation of a SkeletonViewer.
  60490. */
  60491. export interface ISkeletonViewerOptions {
  60492. /** Should the system pause animations before building the Viewer? */
  60493. pauseAnimations: boolean;
  60494. /** Should the system return the skeleton to rest before building? */
  60495. returnToRest: boolean;
  60496. /** public Display Mode of the Viewer */
  60497. displayMode: number;
  60498. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60499. displayOptions: ISkeletonViewerDisplayOptions;
  60500. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60501. computeBonesUsingShaders: boolean;
  60502. /** Flag ignore non weighted bones */
  60503. useAllBones: boolean;
  60504. }
  60505. /**
  60506. * Defines how to display the various bone meshes for the viewer.
  60507. */
  60508. export interface ISkeletonViewerDisplayOptions {
  60509. /** How far down to start tapering the bone spurs */
  60510. midStep?: number;
  60511. /** How big is the midStep? */
  60512. midStepFactor?: number;
  60513. /** Base for the Sphere Size */
  60514. sphereBaseSize?: number;
  60515. /** The ratio of the sphere to the longest bone in units */
  60516. sphereScaleUnit?: number;
  60517. /** Ratio for the Sphere Size */
  60518. sphereFactor?: number;
  60519. /** Whether a spur should attach its far end to the child bone position */
  60520. spurFollowsChild?: boolean;
  60521. /** Whether to show local axes or not */
  60522. showLocalAxes?: boolean;
  60523. /** Length of each local axis */
  60524. localAxesSize?: number;
  60525. }
  60526. /**
  60527. * Defines the constructor options for the BoneWeight Shader.
  60528. */
  60529. export interface IBoneWeightShaderOptions {
  60530. /** Skeleton to Map */
  60531. skeleton: Skeleton;
  60532. /** Colors for Uninfluenced bones */
  60533. colorBase?: Color3;
  60534. /** Colors for 0.0-0.25 Weight bones */
  60535. colorZero?: Color3;
  60536. /** Color for 0.25-0.5 Weight Influence */
  60537. colorQuarter?: Color3;
  60538. /** Color for 0.5-0.75 Weight Influence */
  60539. colorHalf?: Color3;
  60540. /** Color for 0.75-1 Weight Influence */
  60541. colorFull?: Color3;
  60542. /** Color for Zero Weight Influence */
  60543. targetBoneIndex?: number;
  60544. }
  60545. /**
  60546. * Simple structure of the gradient steps for the Color Map.
  60547. */
  60548. export interface ISkeletonMapShaderColorMapKnot {
  60549. /** Color of the Knot */
  60550. color: Color3;
  60551. /** Location of the Knot */
  60552. location: number;
  60553. }
  60554. /**
  60555. * Defines the constructor options for the SkeletonMap Shader.
  60556. */
  60557. export interface ISkeletonMapShaderOptions {
  60558. /** Skeleton to Map */
  60559. skeleton: Skeleton;
  60560. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  60561. colorMap?: ISkeletonMapShaderColorMapKnot[];
  60562. }
  60563. }
  60564. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  60565. import { Nullable } from "babylonjs/types";
  60566. import { Scene } from "babylonjs/scene";
  60567. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  60568. import { Color4 } from "babylonjs/Maths/math.color";
  60569. import { Mesh } from "babylonjs/Meshes/mesh";
  60570. /**
  60571. * Class containing static functions to help procedurally build meshes
  60572. */
  60573. export class RibbonBuilder {
  60574. /**
  60575. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60576. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60577. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60578. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60579. * * 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
  60580. * * 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
  60581. * * 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
  60582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60583. * * 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
  60584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60585. * * 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
  60586. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60587. * * 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
  60588. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60590. * @param name defines the name of the mesh
  60591. * @param options defines the options used to create the mesh
  60592. * @param scene defines the hosting scene
  60593. * @returns the ribbon mesh
  60594. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60596. */
  60597. static CreateRibbon(name: string, options: {
  60598. pathArray: Vector3[][];
  60599. closeArray?: boolean;
  60600. closePath?: boolean;
  60601. offset?: number;
  60602. updatable?: boolean;
  60603. sideOrientation?: number;
  60604. frontUVs?: Vector4;
  60605. backUVs?: Vector4;
  60606. instance?: Mesh;
  60607. invertUV?: boolean;
  60608. uvs?: Vector2[];
  60609. colors?: Color4[];
  60610. }, scene?: Nullable<Scene>): Mesh;
  60611. }
  60612. }
  60613. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  60614. import { Nullable } from "babylonjs/types";
  60615. import { Scene } from "babylonjs/scene";
  60616. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60617. import { Mesh } from "babylonjs/Meshes/mesh";
  60618. /**
  60619. * Class containing static functions to help procedurally build meshes
  60620. */
  60621. export class ShapeBuilder {
  60622. /**
  60623. * 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.
  60624. * * 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.
  60625. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60626. * * 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.
  60627. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60628. * * 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
  60629. * * 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
  60630. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60632. * * 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
  60633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60635. * @param name defines the name of the mesh
  60636. * @param options defines the options used to create the mesh
  60637. * @param scene defines the hosting scene
  60638. * @returns the extruded shape mesh
  60639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60641. */
  60642. static ExtrudeShape(name: string, options: {
  60643. shape: Vector3[];
  60644. path: Vector3[];
  60645. scale?: number;
  60646. rotation?: number;
  60647. cap?: number;
  60648. updatable?: boolean;
  60649. sideOrientation?: number;
  60650. frontUVs?: Vector4;
  60651. backUVs?: Vector4;
  60652. instance?: Mesh;
  60653. invertUV?: boolean;
  60654. }, scene?: Nullable<Scene>): Mesh;
  60655. /**
  60656. * Creates an custom extruded shape mesh.
  60657. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60658. * * 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.
  60659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60660. * * 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
  60661. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60662. * * 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
  60663. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60664. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60665. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60666. * * 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
  60667. * * 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
  60668. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60670. * * 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
  60671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60673. * @param name defines the name of the mesh
  60674. * @param options defines the options used to create the mesh
  60675. * @param scene defines the hosting scene
  60676. * @returns the custom extruded shape mesh
  60677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60678. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60680. */
  60681. static ExtrudeShapeCustom(name: string, options: {
  60682. shape: Vector3[];
  60683. path: Vector3[];
  60684. scaleFunction?: any;
  60685. rotationFunction?: any;
  60686. ribbonCloseArray?: boolean;
  60687. ribbonClosePath?: boolean;
  60688. cap?: number;
  60689. updatable?: boolean;
  60690. sideOrientation?: number;
  60691. frontUVs?: Vector4;
  60692. backUVs?: Vector4;
  60693. instance?: Mesh;
  60694. invertUV?: boolean;
  60695. }, scene?: Nullable<Scene>): Mesh;
  60696. private static _ExtrudeShapeGeneric;
  60697. }
  60698. }
  60699. declare module "babylonjs/Debug/skeletonViewer" {
  60700. import { Color3 } from "babylonjs/Maths/math.color";
  60701. import { Scene } from "babylonjs/scene";
  60702. import { Nullable } from "babylonjs/types";
  60703. import { Skeleton } from "babylonjs/Bones/skeleton";
  60704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60705. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60706. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60707. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  60708. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  60709. /**
  60710. * Class used to render a debug view of a given skeleton
  60711. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  60712. */
  60713. export class SkeletonViewer {
  60714. /** defines the skeleton to render */
  60715. skeleton: Skeleton;
  60716. /** defines the mesh attached to the skeleton */
  60717. mesh: AbstractMesh;
  60718. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  60719. autoUpdateBonesMatrices: boolean;
  60720. /** defines the rendering group id to use with the viewer */
  60721. renderingGroupId: number;
  60722. /** is the options for the viewer */
  60723. options: Partial<ISkeletonViewerOptions>;
  60724. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  60725. static readonly DISPLAY_LINES: number;
  60726. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  60727. static readonly DISPLAY_SPHERES: number;
  60728. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  60729. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  60730. /** public static method to create a BoneWeight Shader
  60731. * @param options The constructor options
  60732. * @param scene The scene that the shader is scoped to
  60733. * @returns The created ShaderMaterial
  60734. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  60735. */
  60736. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  60737. /** public static method to create a BoneWeight Shader
  60738. * @param options The constructor options
  60739. * @param scene The scene that the shader is scoped to
  60740. * @returns The created ShaderMaterial
  60741. */
  60742. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  60743. /** private static method to create a BoneWeight Shader
  60744. * @param size The size of the buffer to create (usually the bone count)
  60745. * @param colorMap The gradient data to generate
  60746. * @param scene The scene that the shader is scoped to
  60747. * @returns an Array of floats from the color gradient values
  60748. */
  60749. private static _CreateBoneMapColorBuffer;
  60750. /** If SkeletonViewer scene scope. */
  60751. private _scene;
  60752. /** Gets or sets the color used to render the skeleton */
  60753. color: Color3;
  60754. /** Array of the points of the skeleton fo the line view. */
  60755. private _debugLines;
  60756. /** The SkeletonViewers Mesh. */
  60757. private _debugMesh;
  60758. /** The local axes Meshes. */
  60759. private _localAxes;
  60760. /** If SkeletonViewer is enabled. */
  60761. private _isEnabled;
  60762. /** If SkeletonViewer is ready. */
  60763. private _ready;
  60764. /** SkeletonViewer render observable. */
  60765. private _obs;
  60766. /** The Utility Layer to render the gizmos in. */
  60767. private _utilityLayer;
  60768. private _boneIndices;
  60769. /** Gets the Scene. */
  60770. get scene(): Scene;
  60771. /** Gets the utilityLayer. */
  60772. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  60773. /** Checks Ready Status. */
  60774. get isReady(): Boolean;
  60775. /** Sets Ready Status. */
  60776. set ready(value: boolean);
  60777. /** Gets the debugMesh */
  60778. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  60779. /** Sets the debugMesh */
  60780. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  60781. /** Gets the displayMode */
  60782. get displayMode(): number;
  60783. /** Sets the displayMode */
  60784. set displayMode(value: number);
  60785. /**
  60786. * Creates a new SkeletonViewer
  60787. * @param skeleton defines the skeleton to render
  60788. * @param mesh defines the mesh attached to the skeleton
  60789. * @param scene defines the hosting scene
  60790. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  60791. * @param renderingGroupId defines the rendering group id to use with the viewer
  60792. * @param options All of the extra constructor options for the SkeletonViewer
  60793. */
  60794. constructor(
  60795. /** defines the skeleton to render */
  60796. skeleton: Skeleton,
  60797. /** defines the mesh attached to the skeleton */
  60798. mesh: AbstractMesh,
  60799. /** The Scene scope*/
  60800. scene: Scene,
  60801. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  60802. autoUpdateBonesMatrices?: boolean,
  60803. /** defines the rendering group id to use with the viewer */
  60804. renderingGroupId?: number,
  60805. /** is the options for the viewer */
  60806. options?: Partial<ISkeletonViewerOptions>);
  60807. /** The Dynamic bindings for the update functions */
  60808. private _bindObs;
  60809. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  60810. update(): void;
  60811. /** Gets or sets a boolean indicating if the viewer is enabled */
  60812. set isEnabled(value: boolean);
  60813. get isEnabled(): boolean;
  60814. private _getBonePosition;
  60815. private _getLinesForBonesWithLength;
  60816. private _getLinesForBonesNoLength;
  60817. /** function to revert the mesh and scene back to the initial state. */
  60818. private _revert;
  60819. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  60820. private _getAbsoluteBindPoseToRef;
  60821. /** function to build and bind sphere joint points and spur bone representations. */
  60822. private _buildSpheresAndSpurs;
  60823. private _buildLocalAxes;
  60824. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  60825. private _displayLinesUpdate;
  60826. /** Changes the displayMode of the skeleton viewer
  60827. * @param mode The displayMode numerical value
  60828. */
  60829. changeDisplayMode(mode: number): void;
  60830. /** Sets a display option of the skeleton viewer
  60831. *
  60832. * | Option | Type | Default | Description |
  60833. * | ---------------- | ------- | ------- | ----------- |
  60834. * | 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`. |
  60835. * | 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`. |
  60836. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  60837. * | 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`. |
  60838. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  60839. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  60840. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  60841. *
  60842. * @param option String of the option name
  60843. * @param value The numerical option value
  60844. */
  60845. changeDisplayOptions(option: string, value: number): void;
  60846. /** Release associated resources */
  60847. dispose(): void;
  60848. }
  60849. }
  60850. declare module "babylonjs/Debug/index" {
  60851. export * from "babylonjs/Debug/axesViewer";
  60852. export * from "babylonjs/Debug/boneAxesViewer";
  60853. export * from "babylonjs/Debug/debugLayer";
  60854. export * from "babylonjs/Debug/physicsViewer";
  60855. export * from "babylonjs/Debug/rayHelper";
  60856. export * from "babylonjs/Debug/skeletonViewer";
  60857. export * from "babylonjs/Debug/ISkeletonViewer";
  60858. }
  60859. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  60860. /**
  60861. * Enum for Device Types
  60862. */
  60863. export enum DeviceType {
  60864. /** Generic */
  60865. Generic = 0,
  60866. /** Keyboard */
  60867. Keyboard = 1,
  60868. /** Mouse */
  60869. Mouse = 2,
  60870. /** Touch Pointers */
  60871. Touch = 3,
  60872. /** PS4 Dual Shock */
  60873. DualShock = 4,
  60874. /** Xbox */
  60875. Xbox = 5,
  60876. /** Switch Controller */
  60877. Switch = 6
  60878. }
  60879. /**
  60880. * Enum for All Pointers (Touch/Mouse)
  60881. */
  60882. export enum PointerInput {
  60883. /** Horizontal Axis */
  60884. Horizontal = 0,
  60885. /** Vertical Axis */
  60886. Vertical = 1,
  60887. /** Left Click or Touch */
  60888. LeftClick = 2,
  60889. /** Middle Click */
  60890. MiddleClick = 3,
  60891. /** Right Click */
  60892. RightClick = 4,
  60893. /** Browser Back */
  60894. BrowserBack = 5,
  60895. /** Browser Forward */
  60896. BrowserForward = 6
  60897. }
  60898. /**
  60899. * Enum for Dual Shock Gamepad
  60900. */
  60901. export enum DualShockInput {
  60902. /** Cross */
  60903. Cross = 0,
  60904. /** Circle */
  60905. Circle = 1,
  60906. /** Square */
  60907. Square = 2,
  60908. /** Triangle */
  60909. Triangle = 3,
  60910. /** L1 */
  60911. L1 = 4,
  60912. /** R1 */
  60913. R1 = 5,
  60914. /** L2 */
  60915. L2 = 6,
  60916. /** R2 */
  60917. R2 = 7,
  60918. /** Share */
  60919. Share = 8,
  60920. /** Options */
  60921. Options = 9,
  60922. /** L3 */
  60923. L3 = 10,
  60924. /** R3 */
  60925. R3 = 11,
  60926. /** DPadUp */
  60927. DPadUp = 12,
  60928. /** DPadDown */
  60929. DPadDown = 13,
  60930. /** DPadLeft */
  60931. DPadLeft = 14,
  60932. /** DRight */
  60933. DPadRight = 15,
  60934. /** Home */
  60935. Home = 16,
  60936. /** TouchPad */
  60937. TouchPad = 17,
  60938. /** LStickXAxis */
  60939. LStickXAxis = 18,
  60940. /** LStickYAxis */
  60941. LStickYAxis = 19,
  60942. /** RStickXAxis */
  60943. RStickXAxis = 20,
  60944. /** RStickYAxis */
  60945. RStickYAxis = 21
  60946. }
  60947. /**
  60948. * Enum for Xbox Gamepad
  60949. */
  60950. export enum XboxInput {
  60951. /** A */
  60952. A = 0,
  60953. /** B */
  60954. B = 1,
  60955. /** X */
  60956. X = 2,
  60957. /** Y */
  60958. Y = 3,
  60959. /** LB */
  60960. LB = 4,
  60961. /** RB */
  60962. RB = 5,
  60963. /** LT */
  60964. LT = 6,
  60965. /** RT */
  60966. RT = 7,
  60967. /** Back */
  60968. Back = 8,
  60969. /** Start */
  60970. Start = 9,
  60971. /** LS */
  60972. LS = 10,
  60973. /** RS */
  60974. RS = 11,
  60975. /** DPadUp */
  60976. DPadUp = 12,
  60977. /** DPadDown */
  60978. DPadDown = 13,
  60979. /** DPadLeft */
  60980. DPadLeft = 14,
  60981. /** DRight */
  60982. DPadRight = 15,
  60983. /** Home */
  60984. Home = 16,
  60985. /** LStickXAxis */
  60986. LStickXAxis = 17,
  60987. /** LStickYAxis */
  60988. LStickYAxis = 18,
  60989. /** RStickXAxis */
  60990. RStickXAxis = 19,
  60991. /** RStickYAxis */
  60992. RStickYAxis = 20
  60993. }
  60994. /**
  60995. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  60996. */
  60997. export enum SwitchInput {
  60998. /** B */
  60999. B = 0,
  61000. /** A */
  61001. A = 1,
  61002. /** Y */
  61003. Y = 2,
  61004. /** X */
  61005. X = 3,
  61006. /** L */
  61007. L = 4,
  61008. /** R */
  61009. R = 5,
  61010. /** ZL */
  61011. ZL = 6,
  61012. /** ZR */
  61013. ZR = 7,
  61014. /** Minus */
  61015. Minus = 8,
  61016. /** Plus */
  61017. Plus = 9,
  61018. /** LS */
  61019. LS = 10,
  61020. /** RS */
  61021. RS = 11,
  61022. /** DPadUp */
  61023. DPadUp = 12,
  61024. /** DPadDown */
  61025. DPadDown = 13,
  61026. /** DPadLeft */
  61027. DPadLeft = 14,
  61028. /** DRight */
  61029. DPadRight = 15,
  61030. /** Home */
  61031. Home = 16,
  61032. /** Capture */
  61033. Capture = 17,
  61034. /** LStickXAxis */
  61035. LStickXAxis = 18,
  61036. /** LStickYAxis */
  61037. LStickYAxis = 19,
  61038. /** RStickXAxis */
  61039. RStickXAxis = 20,
  61040. /** RStickYAxis */
  61041. RStickYAxis = 21
  61042. }
  61043. }
  61044. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  61045. import { Engine } from "babylonjs/Engines/engine";
  61046. import { IDisposable } from "babylonjs/scene";
  61047. import { Nullable } from "babylonjs/types";
  61048. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61049. /**
  61050. * This class will take all inputs from Keyboard, Pointer, and
  61051. * any Gamepads and provide a polling system that all devices
  61052. * will use. This class assumes that there will only be one
  61053. * pointer device and one keyboard.
  61054. */
  61055. export class DeviceInputSystem implements IDisposable {
  61056. /**
  61057. * Returns onDeviceConnected callback property
  61058. * @returns Callback with function to execute when a device is connected
  61059. */
  61060. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  61061. /**
  61062. * Sets callback function when a device is connected and executes against all connected devices
  61063. * @param callback Function to execute when a device is connected
  61064. */
  61065. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  61066. /**
  61067. * Callback to be triggered when a device is disconnected
  61068. */
  61069. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  61070. /**
  61071. * Callback to be triggered when event driven input is updated
  61072. */
  61073. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  61074. private _inputs;
  61075. private _gamepads;
  61076. private _keyboardActive;
  61077. private _pointerActive;
  61078. private _elementToAttachTo;
  61079. private _keyboardDownEvent;
  61080. private _keyboardUpEvent;
  61081. private _pointerMoveEvent;
  61082. private _pointerDownEvent;
  61083. private _pointerUpEvent;
  61084. private _gamepadConnectedEvent;
  61085. private _gamepadDisconnectedEvent;
  61086. private _onDeviceConnected;
  61087. private static _MAX_KEYCODES;
  61088. private static _MAX_POINTER_INPUTS;
  61089. private constructor();
  61090. /**
  61091. * Creates a new DeviceInputSystem instance
  61092. * @param engine Engine to pull input element from
  61093. * @returns The new instance
  61094. */
  61095. static Create(engine: Engine): DeviceInputSystem;
  61096. /**
  61097. * Checks for current device input value, given an id and input index
  61098. * @param deviceName Id of connected device
  61099. * @param inputIndex Index of device input
  61100. * @returns Current value of input
  61101. */
  61102. /**
  61103. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  61104. * @param deviceType Enum specifiying device type
  61105. * @param deviceSlot "Slot" or index that device is referenced in
  61106. * @param inputIndex Id of input to be checked
  61107. * @returns Current value of input
  61108. */
  61109. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  61110. /**
  61111. * Dispose of all the eventlisteners
  61112. */
  61113. dispose(): void;
  61114. /**
  61115. * Checks for existing connections to devices and register them, if necessary
  61116. * Currently handles gamepads and mouse
  61117. */
  61118. private _checkForConnectedDevices;
  61119. /**
  61120. * Add a gamepad to the DeviceInputSystem
  61121. * @param gamepad A single DOM Gamepad object
  61122. */
  61123. private _addGamePad;
  61124. /**
  61125. * Add pointer device to DeviceInputSystem
  61126. * @param deviceType Type of Pointer to add
  61127. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  61128. * @param currentX Current X at point of adding
  61129. * @param currentY Current Y at point of adding
  61130. */
  61131. private _addPointerDevice;
  61132. /**
  61133. * Add device and inputs to device array
  61134. * @param deviceType Enum specifiying device type
  61135. * @param deviceSlot "Slot" or index that device is referenced in
  61136. * @param numberOfInputs Number of input entries to create for given device
  61137. */
  61138. private _registerDevice;
  61139. /**
  61140. * Given a specific device name, remove that device from the device map
  61141. * @param deviceType Enum specifiying device type
  61142. * @param deviceSlot "Slot" or index that device is referenced in
  61143. */
  61144. private _unregisterDevice;
  61145. /**
  61146. * Handle all actions that come from keyboard interaction
  61147. */
  61148. private _handleKeyActions;
  61149. /**
  61150. * Handle all actions that come from pointer interaction
  61151. */
  61152. private _handlePointerActions;
  61153. /**
  61154. * Handle all actions that come from gamepad interaction
  61155. */
  61156. private _handleGamepadActions;
  61157. /**
  61158. * Update all non-event based devices with each frame
  61159. * @param deviceType Enum specifiying device type
  61160. * @param deviceSlot "Slot" or index that device is referenced in
  61161. * @param inputIndex Id of input to be checked
  61162. */
  61163. private _updateDevice;
  61164. /**
  61165. * Gets DeviceType from the device name
  61166. * @param deviceName Name of Device from DeviceInputSystem
  61167. * @returns DeviceType enum value
  61168. */
  61169. private _getGamepadDeviceType;
  61170. }
  61171. }
  61172. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  61173. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61174. /**
  61175. * Type to handle enforcement of inputs
  61176. */
  61177. 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;
  61178. }
  61179. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  61180. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  61181. import { Engine } from "babylonjs/Engines/engine";
  61182. import { IDisposable } from "babylonjs/scene";
  61183. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61184. import { Nullable } from "babylonjs/types";
  61185. import { Observable } from "babylonjs/Misc/observable";
  61186. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61187. /**
  61188. * Class that handles all input for a specific device
  61189. */
  61190. export class DeviceSource<T extends DeviceType> {
  61191. /** Type of device */
  61192. readonly deviceType: DeviceType;
  61193. /** "Slot" or index that device is referenced in */
  61194. readonly deviceSlot: number;
  61195. /**
  61196. * Observable to handle device input changes per device
  61197. */
  61198. readonly onInputChangedObservable: Observable<{
  61199. inputIndex: DeviceInput<T>;
  61200. previousState: Nullable<number>;
  61201. currentState: Nullable<number>;
  61202. }>;
  61203. private readonly _deviceInputSystem;
  61204. /**
  61205. * Default Constructor
  61206. * @param deviceInputSystem Reference to DeviceInputSystem
  61207. * @param deviceType Type of device
  61208. * @param deviceSlot "Slot" or index that device is referenced in
  61209. */
  61210. constructor(deviceInputSystem: DeviceInputSystem,
  61211. /** Type of device */
  61212. deviceType: DeviceType,
  61213. /** "Slot" or index that device is referenced in */
  61214. deviceSlot?: number);
  61215. /**
  61216. * Get input for specific input
  61217. * @param inputIndex index of specific input on device
  61218. * @returns Input value from DeviceInputSystem
  61219. */
  61220. getInput(inputIndex: DeviceInput<T>): number;
  61221. }
  61222. /**
  61223. * Class to keep track of devices
  61224. */
  61225. export class DeviceSourceManager implements IDisposable {
  61226. /**
  61227. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  61228. */
  61229. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  61230. /**
  61231. * Observable to be triggered when after a device is disconnected
  61232. */
  61233. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  61234. private readonly _devices;
  61235. private readonly _firstDevice;
  61236. private readonly _deviceInputSystem;
  61237. /**
  61238. * Default Constructor
  61239. * @param engine engine to pull input element from
  61240. */
  61241. constructor(engine: Engine);
  61242. /**
  61243. * Gets a DeviceSource, given a type and slot
  61244. * @param deviceType Enum specifying device type
  61245. * @param deviceSlot "Slot" or index that device is referenced in
  61246. * @returns DeviceSource object
  61247. */
  61248. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  61249. /**
  61250. * Gets an array of DeviceSource objects for a given device type
  61251. * @param deviceType Enum specifying device type
  61252. * @returns Array of DeviceSource objects
  61253. */
  61254. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  61255. /**
  61256. * Returns a read-only list of all available devices
  61257. * @returns Read-only array with active devices
  61258. */
  61259. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  61260. /**
  61261. * Dispose of DeviceInputSystem and other parts
  61262. */
  61263. dispose(): void;
  61264. /**
  61265. * Function to add device name to device list
  61266. * @param deviceType Enum specifying device type
  61267. * @param deviceSlot "Slot" or index that device is referenced in
  61268. */
  61269. private _addDevice;
  61270. /**
  61271. * Function to remove device name to device list
  61272. * @param deviceType Enum specifying device type
  61273. * @param deviceSlot "Slot" or index that device is referenced in
  61274. */
  61275. private _removeDevice;
  61276. /**
  61277. * Updates array storing first connected device of each type
  61278. * @param type Type of Device
  61279. */
  61280. private _updateFirstDevices;
  61281. }
  61282. }
  61283. declare module "babylonjs/DeviceInput/index" {
  61284. export * from "babylonjs/DeviceInput/deviceInputSystem";
  61285. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61286. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61287. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61288. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61289. }
  61290. declare module "babylonjs/Engines/nullEngine" {
  61291. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  61292. import { Engine } from "babylonjs/Engines/engine";
  61293. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  61294. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  61295. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61296. import { Effect } from "babylonjs/Materials/effect";
  61297. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  61298. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  61299. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  61300. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  61301. /**
  61302. * Options to create the null engine
  61303. */
  61304. export class NullEngineOptions {
  61305. /**
  61306. * Render width (Default: 512)
  61307. */
  61308. renderWidth: number;
  61309. /**
  61310. * Render height (Default: 256)
  61311. */
  61312. renderHeight: number;
  61313. /**
  61314. * Texture size (Default: 512)
  61315. */
  61316. textureSize: number;
  61317. /**
  61318. * If delta time between frames should be constant
  61319. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61320. */
  61321. deterministicLockstep: boolean;
  61322. /**
  61323. * Maximum about of steps between frames (Default: 4)
  61324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61325. */
  61326. lockstepMaxSteps: number;
  61327. /**
  61328. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  61329. */
  61330. useHighPrecisionMatrix?: boolean;
  61331. }
  61332. /**
  61333. * The null engine class provides support for headless version of babylon.js.
  61334. * This can be used in server side scenario or for testing purposes
  61335. */
  61336. export class NullEngine extends Engine {
  61337. private _options;
  61338. /**
  61339. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  61340. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61341. * @returns true if engine is in deterministic lock step mode
  61342. */
  61343. isDeterministicLockStep(): boolean;
  61344. /**
  61345. * Gets the max steps when engine is running in deterministic lock step
  61346. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61347. * @returns the max steps
  61348. */
  61349. getLockstepMaxSteps(): number;
  61350. /**
  61351. * Gets the current hardware scaling level.
  61352. * By default the hardware scaling level is computed from the window device ratio.
  61353. * 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.
  61354. * @returns a number indicating the current hardware scaling level
  61355. */
  61356. getHardwareScalingLevel(): number;
  61357. constructor(options?: NullEngineOptions);
  61358. /**
  61359. * Creates a vertex buffer
  61360. * @param vertices the data for the vertex buffer
  61361. * @returns the new WebGL static buffer
  61362. */
  61363. createVertexBuffer(vertices: FloatArray): DataBuffer;
  61364. /**
  61365. * Creates a new index buffer
  61366. * @param indices defines the content of the index buffer
  61367. * @param updatable defines if the index buffer must be updatable
  61368. * @returns a new webGL buffer
  61369. */
  61370. createIndexBuffer(indices: IndicesArray): DataBuffer;
  61371. /**
  61372. * Clear the current render buffer or the current render target (if any is set up)
  61373. * @param color defines the color to use
  61374. * @param backBuffer defines if the back buffer must be cleared
  61375. * @param depth defines if the depth buffer must be cleared
  61376. * @param stencil defines if the stencil buffer must be cleared
  61377. */
  61378. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  61379. /**
  61380. * Gets the current render width
  61381. * @param useScreen defines if screen size must be used (or the current render target if any)
  61382. * @returns a number defining the current render width
  61383. */
  61384. getRenderWidth(useScreen?: boolean): number;
  61385. /**
  61386. * Gets the current render height
  61387. * @param useScreen defines if screen size must be used (or the current render target if any)
  61388. * @returns a number defining the current render height
  61389. */
  61390. getRenderHeight(useScreen?: boolean): number;
  61391. /**
  61392. * Set the WebGL's viewport
  61393. * @param viewport defines the viewport element to be used
  61394. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  61395. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  61396. */
  61397. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  61398. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  61399. /**
  61400. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  61401. * @param pipelineContext defines the pipeline context to use
  61402. * @param uniformsNames defines the list of uniform names
  61403. * @returns an array of webGL uniform locations
  61404. */
  61405. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  61406. /**
  61407. * Gets the lsit of active attributes for a given webGL program
  61408. * @param pipelineContext defines the pipeline context to use
  61409. * @param attributesNames defines the list of attribute names to get
  61410. * @returns an array of indices indicating the offset of each attribute
  61411. */
  61412. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  61413. /**
  61414. * Binds an effect to the webGL context
  61415. * @param effect defines the effect to bind
  61416. */
  61417. bindSamplers(effect: Effect): void;
  61418. /**
  61419. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  61420. * @param effect defines the effect to activate
  61421. */
  61422. enableEffect(effect: Effect): void;
  61423. /**
  61424. * Set various states to the webGL context
  61425. * @param culling defines backface culling state
  61426. * @param zOffset defines the value to apply to zOffset (0 by default)
  61427. * @param force defines if states must be applied even if cache is up to date
  61428. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  61429. */
  61430. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  61431. /**
  61432. * Set the value of an uniform to an array of int32
  61433. * @param uniform defines the webGL uniform location where to store the value
  61434. * @param array defines the array of int32 to store
  61435. * @returns true if value was set
  61436. */
  61437. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61438. /**
  61439. * Set the value of an uniform to an array of int32 (stored as vec2)
  61440. * @param uniform defines the webGL uniform location where to store the value
  61441. * @param array defines the array of int32 to store
  61442. * @returns true if value was set
  61443. */
  61444. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61445. /**
  61446. * Set the value of an uniform to an array of int32 (stored as vec3)
  61447. * @param uniform defines the webGL uniform location where to store the value
  61448. * @param array defines the array of int32 to store
  61449. * @returns true if value was set
  61450. */
  61451. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61452. /**
  61453. * Set the value of an uniform to an array of int32 (stored as vec4)
  61454. * @param uniform defines the webGL uniform location where to store the value
  61455. * @param array defines the array of int32 to store
  61456. * @returns true if value was set
  61457. */
  61458. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61459. /**
  61460. * Set the value of an uniform to an array of float32
  61461. * @param uniform defines the webGL uniform location where to store the value
  61462. * @param array defines the array of float32 to store
  61463. * @returns true if value was set
  61464. */
  61465. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61466. /**
  61467. * Set the value of an uniform to an array of float32 (stored as vec2)
  61468. * @param uniform defines the webGL uniform location where to store the value
  61469. * @param array defines the array of float32 to store
  61470. * @returns true if value was set
  61471. */
  61472. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61473. /**
  61474. * Set the value of an uniform to an array of float32 (stored as vec3)
  61475. * @param uniform defines the webGL uniform location where to store the value
  61476. * @param array defines the array of float32 to store
  61477. * @returns true if value was set
  61478. */
  61479. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61480. /**
  61481. * Set the value of an uniform to an array of float32 (stored as vec4)
  61482. * @param uniform defines the webGL uniform location where to store the value
  61483. * @param array defines the array of float32 to store
  61484. * @returns true if value was set
  61485. */
  61486. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61487. /**
  61488. * Set the value of an uniform to an array of number
  61489. * @param uniform defines the webGL uniform location where to store the value
  61490. * @param array defines the array of number to store
  61491. * @returns true if value was set
  61492. */
  61493. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  61494. /**
  61495. * Set the value of an uniform to an array of number (stored as vec2)
  61496. * @param uniform defines the webGL uniform location where to store the value
  61497. * @param array defines the array of number to store
  61498. * @returns true if value was set
  61499. */
  61500. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  61501. /**
  61502. * Set the value of an uniform to an array of number (stored as vec3)
  61503. * @param uniform defines the webGL uniform location where to store the value
  61504. * @param array defines the array of number to store
  61505. * @returns true if value was set
  61506. */
  61507. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  61508. /**
  61509. * Set the value of an uniform to an array of number (stored as vec4)
  61510. * @param uniform defines the webGL uniform location where to store the value
  61511. * @param array defines the array of number to store
  61512. * @returns true if value was set
  61513. */
  61514. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  61515. /**
  61516. * Set the value of an uniform to an array of float32 (stored as matrices)
  61517. * @param uniform defines the webGL uniform location where to store the value
  61518. * @param matrices defines the array of float32 to store
  61519. * @returns true if value was set
  61520. */
  61521. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  61522. /**
  61523. * Set the value of an uniform to a matrix (3x3)
  61524. * @param uniform defines the webGL uniform location where to store the value
  61525. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  61526. * @returns true if value was set
  61527. */
  61528. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61529. /**
  61530. * Set the value of an uniform to a matrix (2x2)
  61531. * @param uniform defines the webGL uniform location where to store the value
  61532. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  61533. * @returns true if value was set
  61534. */
  61535. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61536. /**
  61537. * Set the value of an uniform to a number (float)
  61538. * @param uniform defines the webGL uniform location where to store the value
  61539. * @param value defines the float number to store
  61540. * @returns true if value was set
  61541. */
  61542. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  61543. /**
  61544. * Set the value of an uniform to a vec2
  61545. * @param uniform defines the webGL uniform location where to store the value
  61546. * @param x defines the 1st component of the value
  61547. * @param y defines the 2nd component of the value
  61548. * @returns true if value was set
  61549. */
  61550. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  61551. /**
  61552. * Set the value of an uniform to a vec3
  61553. * @param uniform defines the webGL uniform location where to store the value
  61554. * @param x defines the 1st component of the value
  61555. * @param y defines the 2nd component of the value
  61556. * @param z defines the 3rd component of the value
  61557. * @returns true if value was set
  61558. */
  61559. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  61560. /**
  61561. * Set the value of an uniform to a boolean
  61562. * @param uniform defines the webGL uniform location where to store the value
  61563. * @param bool defines the boolean to store
  61564. * @returns true if value was set
  61565. */
  61566. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  61567. /**
  61568. * Set the value of an uniform to a vec4
  61569. * @param uniform defines the webGL uniform location where to store the value
  61570. * @param x defines the 1st component of the value
  61571. * @param y defines the 2nd component of the value
  61572. * @param z defines the 3rd component of the value
  61573. * @param w defines the 4th component of the value
  61574. * @returns true if value was set
  61575. */
  61576. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  61577. /**
  61578. * Sets the current alpha mode
  61579. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  61580. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  61581. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61582. */
  61583. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  61584. /**
  61585. * Bind webGl buffers directly to the webGL context
  61586. * @param vertexBuffers defines the vertex buffer to bind
  61587. * @param indexBuffer defines the index buffer to bind
  61588. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  61589. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  61590. * @param effect defines the effect associated with the vertex buffer
  61591. */
  61592. bindBuffers(vertexBuffers: {
  61593. [key: string]: VertexBuffer;
  61594. }, indexBuffer: DataBuffer, effect: Effect): void;
  61595. /**
  61596. * Force the entire cache to be cleared
  61597. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  61598. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  61599. */
  61600. wipeCaches(bruteForce?: boolean): void;
  61601. /**
  61602. * Send a draw order
  61603. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  61604. * @param indexStart defines the starting index
  61605. * @param indexCount defines the number of index to draw
  61606. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61607. */
  61608. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  61609. /**
  61610. * Draw a list of indexed primitives
  61611. * @param fillMode defines the primitive to use
  61612. * @param indexStart defines the starting index
  61613. * @param indexCount defines the number of index to draw
  61614. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61615. */
  61616. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  61617. /**
  61618. * Draw a list of unindexed primitives
  61619. * @param fillMode defines the primitive to use
  61620. * @param verticesStart defines the index of first vertex to draw
  61621. * @param verticesCount defines the count of vertices to draw
  61622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61623. */
  61624. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  61625. /** @hidden */
  61626. protected _createTexture(): WebGLTexture;
  61627. /** @hidden */
  61628. _releaseTexture(texture: InternalTexture): void;
  61629. /**
  61630. * Usually called from Texture.ts.
  61631. * Passed information to create a WebGLTexture
  61632. * @param urlArg defines a value which contains one of the following:
  61633. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  61634. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  61635. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  61636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  61637. * @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)
  61638. * @param scene needed for loading to the correct scene
  61639. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  61640. * @param onLoad optional callback to be called upon successful completion
  61641. * @param onError optional callback to be called upon failure
  61642. * @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
  61643. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  61644. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  61645. * @param forcedExtension defines the extension to use to pick the right loader
  61646. * @param mimeType defines an optional mime type
  61647. * @returns a InternalTexture for assignment back into BABYLON.Texture
  61648. */
  61649. 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;
  61650. /**
  61651. * Creates a new render target texture
  61652. * @param size defines the size of the texture
  61653. * @param options defines the options used to create the texture
  61654. * @returns a new render target texture stored in an InternalTexture
  61655. */
  61656. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  61657. /**
  61658. * Update the sampling mode of a given texture
  61659. * @param samplingMode defines the required sampling mode
  61660. * @param texture defines the texture to update
  61661. */
  61662. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  61663. /**
  61664. * Binds the frame buffer to the specified texture.
  61665. * @param texture The texture to render to or null for the default canvas
  61666. * @param faceIndex The face of the texture to render to in case of cube texture
  61667. * @param requiredWidth The width of the target to render to
  61668. * @param requiredHeight The height of the target to render to
  61669. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  61670. * @param lodLevel defines le lod level to bind to the frame buffer
  61671. */
  61672. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  61673. /**
  61674. * Unbind the current render target texture from the webGL context
  61675. * @param texture defines the render target texture to unbind
  61676. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  61677. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  61678. */
  61679. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  61680. /**
  61681. * Creates a dynamic vertex buffer
  61682. * @param vertices the data for the dynamic vertex buffer
  61683. * @returns the new WebGL dynamic buffer
  61684. */
  61685. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  61686. /**
  61687. * Update the content of a dynamic texture
  61688. * @param texture defines the texture to update
  61689. * @param canvas defines the canvas containing the source
  61690. * @param invertY defines if data must be stored with Y axis inverted
  61691. * @param premulAlpha defines if alpha is stored as premultiplied
  61692. * @param format defines the format of the data
  61693. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  61694. */
  61695. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  61696. /**
  61697. * Gets a boolean indicating if all created effects are ready
  61698. * @returns true if all effects are ready
  61699. */
  61700. areAllEffectsReady(): boolean;
  61701. /**
  61702. * @hidden
  61703. * Get the current error code of the webGL context
  61704. * @returns the error code
  61705. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  61706. */
  61707. getError(): number;
  61708. /** @hidden */
  61709. _getUnpackAlignement(): number;
  61710. /** @hidden */
  61711. _unpackFlipY(value: boolean): void;
  61712. /**
  61713. * Update a dynamic index buffer
  61714. * @param indexBuffer defines the target index buffer
  61715. * @param indices defines the data to update
  61716. * @param offset defines the offset in the target index buffer where update should start
  61717. */
  61718. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  61719. /**
  61720. * Updates a dynamic vertex buffer.
  61721. * @param vertexBuffer the vertex buffer to update
  61722. * @param vertices the data used to update the vertex buffer
  61723. * @param byteOffset the byte offset of the data (optional)
  61724. * @param byteLength the byte length of the data (optional)
  61725. */
  61726. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  61727. /** @hidden */
  61728. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  61729. /** @hidden */
  61730. _bindTexture(channel: number, texture: InternalTexture): void;
  61731. protected _deleteBuffer(buffer: WebGLBuffer): void;
  61732. /**
  61733. * 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
  61734. */
  61735. releaseEffects(): void;
  61736. displayLoadingUI(): void;
  61737. hideLoadingUI(): void;
  61738. /** @hidden */
  61739. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61740. /** @hidden */
  61741. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61742. /** @hidden */
  61743. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61744. /** @hidden */
  61745. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  61746. }
  61747. }
  61748. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  61749. import { Nullable, int } from "babylonjs/types";
  61750. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  61751. /** @hidden */
  61752. export class _OcclusionDataStorage {
  61753. /** @hidden */
  61754. occlusionInternalRetryCounter: number;
  61755. /** @hidden */
  61756. isOcclusionQueryInProgress: boolean;
  61757. /** @hidden */
  61758. isOccluded: boolean;
  61759. /** @hidden */
  61760. occlusionRetryCount: number;
  61761. /** @hidden */
  61762. occlusionType: number;
  61763. /** @hidden */
  61764. occlusionQueryAlgorithmType: number;
  61765. }
  61766. module "babylonjs/Engines/engine" {
  61767. interface Engine {
  61768. /**
  61769. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  61770. * @return the new query
  61771. */
  61772. createQuery(): WebGLQuery;
  61773. /**
  61774. * Delete and release a webGL query
  61775. * @param query defines the query to delete
  61776. * @return the current engine
  61777. */
  61778. deleteQuery(query: WebGLQuery): Engine;
  61779. /**
  61780. * Check if a given query has resolved and got its value
  61781. * @param query defines the query to check
  61782. * @returns true if the query got its value
  61783. */
  61784. isQueryResultAvailable(query: WebGLQuery): boolean;
  61785. /**
  61786. * Gets the value of a given query
  61787. * @param query defines the query to check
  61788. * @returns the value of the query
  61789. */
  61790. getQueryResult(query: WebGLQuery): number;
  61791. /**
  61792. * Initiates an occlusion query
  61793. * @param algorithmType defines the algorithm to use
  61794. * @param query defines the query to use
  61795. * @returns the current engine
  61796. * @see https://doc.babylonjs.com/features/occlusionquery
  61797. */
  61798. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  61799. /**
  61800. * Ends an occlusion query
  61801. * @see https://doc.babylonjs.com/features/occlusionquery
  61802. * @param algorithmType defines the algorithm to use
  61803. * @returns the current engine
  61804. */
  61805. endOcclusionQuery(algorithmType: number): Engine;
  61806. /**
  61807. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  61808. * Please note that only one query can be issued at a time
  61809. * @returns a time token used to track the time span
  61810. */
  61811. startTimeQuery(): Nullable<_TimeToken>;
  61812. /**
  61813. * Ends a time query
  61814. * @param token defines the token used to measure the time span
  61815. * @returns the time spent (in ns)
  61816. */
  61817. endTimeQuery(token: _TimeToken): int;
  61818. /** @hidden */
  61819. _currentNonTimestampToken: Nullable<_TimeToken>;
  61820. /** @hidden */
  61821. _createTimeQuery(): WebGLQuery;
  61822. /** @hidden */
  61823. _deleteTimeQuery(query: WebGLQuery): void;
  61824. /** @hidden */
  61825. _getGlAlgorithmType(algorithmType: number): number;
  61826. /** @hidden */
  61827. _getTimeQueryResult(query: WebGLQuery): any;
  61828. /** @hidden */
  61829. _getTimeQueryAvailability(query: WebGLQuery): any;
  61830. }
  61831. }
  61832. module "babylonjs/Meshes/abstractMesh" {
  61833. interface AbstractMesh {
  61834. /**
  61835. * Backing filed
  61836. * @hidden
  61837. */
  61838. __occlusionDataStorage: _OcclusionDataStorage;
  61839. /**
  61840. * Access property
  61841. * @hidden
  61842. */
  61843. _occlusionDataStorage: _OcclusionDataStorage;
  61844. /**
  61845. * 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.
  61846. * The default value is -1 which means don't break the query and wait till the result
  61847. * @see https://doc.babylonjs.com/features/occlusionquery
  61848. */
  61849. occlusionRetryCount: number;
  61850. /**
  61851. * 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:
  61852. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  61853. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  61854. * * 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.
  61855. * @see https://doc.babylonjs.com/features/occlusionquery
  61856. */
  61857. occlusionType: number;
  61858. /**
  61859. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  61860. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  61861. * * 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.
  61862. * @see https://doc.babylonjs.com/features/occlusionquery
  61863. */
  61864. occlusionQueryAlgorithmType: number;
  61865. /**
  61866. * 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
  61867. * @see https://doc.babylonjs.com/features/occlusionquery
  61868. */
  61869. isOccluded: boolean;
  61870. /**
  61871. * Flag to check the progress status of the query
  61872. * @see https://doc.babylonjs.com/features/occlusionquery
  61873. */
  61874. isOcclusionQueryInProgress: boolean;
  61875. }
  61876. }
  61877. }
  61878. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  61879. import { Nullable } from "babylonjs/types";
  61880. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  61881. /** @hidden */
  61882. export var _forceTransformFeedbackToBundle: boolean;
  61883. module "babylonjs/Engines/engine" {
  61884. interface Engine {
  61885. /**
  61886. * Creates a webGL transform feedback object
  61887. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  61888. * @returns the webGL transform feedback object
  61889. */
  61890. createTransformFeedback(): WebGLTransformFeedback;
  61891. /**
  61892. * Delete a webGL transform feedback object
  61893. * @param value defines the webGL transform feedback object to delete
  61894. */
  61895. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  61896. /**
  61897. * Bind a webGL transform feedback object to the webgl context
  61898. * @param value defines the webGL transform feedback object to bind
  61899. */
  61900. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  61901. /**
  61902. * Begins a transform feedback operation
  61903. * @param usePoints defines if points or triangles must be used
  61904. */
  61905. beginTransformFeedback(usePoints: boolean): void;
  61906. /**
  61907. * Ends a transform feedback operation
  61908. */
  61909. endTransformFeedback(): void;
  61910. /**
  61911. * Specify the varyings to use with transform feedback
  61912. * @param program defines the associated webGL program
  61913. * @param value defines the list of strings representing the varying names
  61914. */
  61915. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  61916. /**
  61917. * Bind a webGL buffer for a transform feedback operation
  61918. * @param value defines the webGL buffer to bind
  61919. */
  61920. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  61921. }
  61922. }
  61923. }
  61924. declare module "babylonjs/Engines/Extensions/engine.views" {
  61925. import { Camera } from "babylonjs/Cameras/camera";
  61926. import { Nullable } from "babylonjs/types";
  61927. /**
  61928. * Class used to define an additional view for the engine
  61929. * @see https://doc.babylonjs.com/how_to/multi_canvases
  61930. */
  61931. export class EngineView {
  61932. /** Defines the canvas where to render the view */
  61933. target: HTMLCanvasElement;
  61934. /** Defines an optional camera used to render the view (will use active camera else) */
  61935. camera?: Camera;
  61936. }
  61937. module "babylonjs/Engines/engine" {
  61938. interface Engine {
  61939. /**
  61940. * Gets or sets the HTML element to use for attaching events
  61941. */
  61942. inputElement: Nullable<HTMLElement>;
  61943. /**
  61944. * Gets the current engine view
  61945. * @see https://doc.babylonjs.com/how_to/multi_canvases
  61946. */
  61947. activeView: Nullable<EngineView>;
  61948. /** Gets or sets the list of views */
  61949. views: EngineView[];
  61950. /**
  61951. * Register a new child canvas
  61952. * @param canvas defines the canvas to register
  61953. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  61954. * @returns the associated view
  61955. */
  61956. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  61957. /**
  61958. * Remove a registered child canvas
  61959. * @param canvas defines the canvas to remove
  61960. * @returns the current engine
  61961. */
  61962. unRegisterView(canvas: HTMLCanvasElement): Engine;
  61963. }
  61964. }
  61965. }
  61966. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  61967. import { Nullable } from "babylonjs/types";
  61968. module "babylonjs/Engines/engine" {
  61969. interface Engine {
  61970. /** @hidden */
  61971. _excludedCompressedTextures: string[];
  61972. /** @hidden */
  61973. _textureFormatInUse: string;
  61974. /**
  61975. * Gets the list of texture formats supported
  61976. */
  61977. readonly texturesSupported: Array<string>;
  61978. /**
  61979. * Gets the texture format in use
  61980. */
  61981. readonly textureFormatInUse: Nullable<string>;
  61982. /**
  61983. * Set the compressed texture extensions or file names to skip.
  61984. *
  61985. * @param skippedFiles defines the list of those texture files you want to skip
  61986. * Example: [".dds", ".env", "myfile.png"]
  61987. */
  61988. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  61989. /**
  61990. * Set the compressed texture format to use, based on the formats you have, and the formats
  61991. * supported by the hardware / browser.
  61992. *
  61993. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  61994. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  61995. * to API arguments needed to compressed textures. This puts the burden on the container
  61996. * generator to house the arcane code for determining these for current & future formats.
  61997. *
  61998. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61999. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62000. *
  62001. * Note: The result of this call is not taken into account when a texture is base64.
  62002. *
  62003. * @param formatsAvailable defines the list of those format families you have created
  62004. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  62005. *
  62006. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  62007. * @returns The extension selected.
  62008. */
  62009. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  62010. }
  62011. }
  62012. }
  62013. declare module "babylonjs/Engines/Extensions/index" {
  62014. export * from "babylonjs/Engines/Extensions/engine.alpha";
  62015. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  62016. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  62017. export * from "babylonjs/Engines/Extensions/engine.multiview";
  62018. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  62019. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62020. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  62021. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  62022. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  62023. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  62024. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62025. export * from "babylonjs/Engines/Extensions/engine.webVR";
  62026. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  62027. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  62028. export * from "babylonjs/Engines/Extensions/engine.views";
  62029. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  62030. import "babylonjs/Engines/Extensions/engine.textureSelector";
  62031. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  62032. }
  62033. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  62034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62035. /** @hidden */
  62036. export var rgbdEncodePixelShader: {
  62037. name: string;
  62038. shader: string;
  62039. };
  62040. }
  62041. declare module "babylonjs/Misc/environmentTextureTools" {
  62042. import { Nullable } from "babylonjs/types";
  62043. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  62044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62046. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62047. import "babylonjs/Engines/Extensions/engine.readTexture";
  62048. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62049. import "babylonjs/Shaders/rgbdEncode.fragment";
  62050. import "babylonjs/Shaders/rgbdDecode.fragment";
  62051. /**
  62052. * Raw texture data and descriptor sufficient for WebGL texture upload
  62053. */
  62054. export interface EnvironmentTextureInfo {
  62055. /**
  62056. * Version of the environment map
  62057. */
  62058. version: number;
  62059. /**
  62060. * Width of image
  62061. */
  62062. width: number;
  62063. /**
  62064. * Irradiance information stored in the file.
  62065. */
  62066. irradiance: any;
  62067. /**
  62068. * Specular information stored in the file.
  62069. */
  62070. specular: any;
  62071. }
  62072. /**
  62073. * Defines One Image in the file. It requires only the position in the file
  62074. * as well as the length.
  62075. */
  62076. interface BufferImageData {
  62077. /**
  62078. * Length of the image data.
  62079. */
  62080. length: number;
  62081. /**
  62082. * Position of the data from the null terminator delimiting the end of the JSON.
  62083. */
  62084. position: number;
  62085. }
  62086. /**
  62087. * Defines the specular data enclosed in the file.
  62088. * This corresponds to the version 1 of the data.
  62089. */
  62090. export interface EnvironmentTextureSpecularInfoV1 {
  62091. /**
  62092. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  62093. */
  62094. specularDataPosition?: number;
  62095. /**
  62096. * This contains all the images data needed to reconstruct the cubemap.
  62097. */
  62098. mipmaps: Array<BufferImageData>;
  62099. /**
  62100. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  62101. */
  62102. lodGenerationScale: number;
  62103. }
  62104. /**
  62105. * Sets of helpers addressing the serialization and deserialization of environment texture
  62106. * stored in a BabylonJS env file.
  62107. * Those files are usually stored as .env files.
  62108. */
  62109. export class EnvironmentTextureTools {
  62110. /**
  62111. * Magic number identifying the env file.
  62112. */
  62113. private static _MagicBytes;
  62114. /**
  62115. * Gets the environment info from an env file.
  62116. * @param data The array buffer containing the .env bytes.
  62117. * @returns the environment file info (the json header) if successfully parsed.
  62118. */
  62119. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  62120. /**
  62121. * Creates an environment texture from a loaded cube texture.
  62122. * @param texture defines the cube texture to convert in env file
  62123. * @return a promise containing the environment data if succesfull.
  62124. */
  62125. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  62126. /**
  62127. * Creates a JSON representation of the spherical data.
  62128. * @param texture defines the texture containing the polynomials
  62129. * @return the JSON representation of the spherical info
  62130. */
  62131. private static _CreateEnvTextureIrradiance;
  62132. /**
  62133. * Creates the ArrayBufferViews used for initializing environment texture image data.
  62134. * @param data the image data
  62135. * @param info parameters that determine what views will be created for accessing the underlying buffer
  62136. * @return the views described by info providing access to the underlying buffer
  62137. */
  62138. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  62139. /**
  62140. * Uploads the texture info contained in the env file to the GPU.
  62141. * @param texture defines the internal texture to upload to
  62142. * @param data defines the data to load
  62143. * @param info defines the texture info retrieved through the GetEnvInfo method
  62144. * @returns a promise
  62145. */
  62146. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  62147. private static _OnImageReadyAsync;
  62148. /**
  62149. * Uploads the levels of image data to the GPU.
  62150. * @param texture defines the internal texture to upload to
  62151. * @param imageData defines the array buffer views of image data [mipmap][face]
  62152. * @returns a promise
  62153. */
  62154. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  62155. /**
  62156. * Uploads spherical polynomials information to the texture.
  62157. * @param texture defines the texture we are trying to upload the information to
  62158. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  62159. */
  62160. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  62161. /** @hidden */
  62162. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62163. }
  62164. }
  62165. declare module "babylonjs/Engines/nativeEngine" {
  62166. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  62167. import { Engine } from "babylonjs/Engines/engine";
  62168. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  62169. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62171. import { Effect } from "babylonjs/Materials/effect";
  62172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62173. import { Scene } from "babylonjs/scene";
  62174. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  62175. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  62176. import { IMatrixLike, IColor3Like, IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  62177. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  62178. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  62179. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  62180. /**
  62181. * Container for accessors for natively-stored mesh data buffers.
  62182. */
  62183. class NativeDataBuffer extends DataBuffer {
  62184. /**
  62185. * Accessor value used to identify/retrieve a natively-stored index buffer.
  62186. */
  62187. nativeIndexBuffer?: any;
  62188. /**
  62189. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  62190. */
  62191. nativeVertexBuffer?: any;
  62192. }
  62193. /** @hidden */
  62194. class NativeTexture extends InternalTexture {
  62195. getInternalTexture(): InternalTexture;
  62196. getViewCount(): number;
  62197. }
  62198. /** @hidden */
  62199. export class NativeEngine extends Engine {
  62200. private readonly _native;
  62201. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  62202. private readonly INVALID_HANDLE;
  62203. private _boundBuffersVertexArray;
  62204. private _currentDepthTest;
  62205. getHardwareScalingLevel(): number;
  62206. constructor();
  62207. dispose(): void;
  62208. /**
  62209. * Can be used to override the current requestAnimationFrame requester.
  62210. * @hidden
  62211. */
  62212. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  62213. /**
  62214. * Override default engine behavior.
  62215. * @param color
  62216. * @param backBuffer
  62217. * @param depth
  62218. * @param stencil
  62219. */
  62220. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  62221. /**
  62222. * Gets host document
  62223. * @returns the host document object
  62224. */
  62225. getHostDocument(): Nullable<Document>;
  62226. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  62227. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  62228. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  62229. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  62230. [key: string]: VertexBuffer;
  62231. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62232. bindBuffers(vertexBuffers: {
  62233. [key: string]: VertexBuffer;
  62234. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62235. recordVertexArrayObject(vertexBuffers: {
  62236. [key: string]: VertexBuffer;
  62237. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  62238. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62239. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62240. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  62241. /**
  62242. * Draw a list of indexed primitives
  62243. * @param fillMode defines the primitive to use
  62244. * @param indexStart defines the starting index
  62245. * @param indexCount defines the number of index to draw
  62246. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62247. */
  62248. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  62249. /**
  62250. * Draw a list of unindexed primitives
  62251. * @param fillMode defines the primitive to use
  62252. * @param verticesStart defines the index of first vertex to draw
  62253. * @param verticesCount defines the count of vertices to draw
  62254. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62255. */
  62256. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  62257. createPipelineContext(): IPipelineContext;
  62258. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  62259. /** @hidden */
  62260. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  62261. /** @hidden */
  62262. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  62263. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62265. protected _setProgram(program: WebGLProgram): void;
  62266. _releaseEffect(effect: Effect): void;
  62267. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  62268. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  62269. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  62270. bindSamplers(effect: Effect): void;
  62271. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  62272. getRenderWidth(useScreen?: boolean): number;
  62273. getRenderHeight(useScreen?: boolean): number;
  62274. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  62275. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  62276. /**
  62277. * Set the z offset to apply to current rendering
  62278. * @param value defines the offset to apply
  62279. */
  62280. setZOffset(value: number): void;
  62281. /**
  62282. * Gets the current value of the zOffset
  62283. * @returns the current zOffset state
  62284. */
  62285. getZOffset(): number;
  62286. /**
  62287. * Enable or disable depth buffering
  62288. * @param enable defines the state to set
  62289. */
  62290. setDepthBuffer(enable: boolean): void;
  62291. /**
  62292. * Gets a boolean indicating if depth writing is enabled
  62293. * @returns the current depth writing state
  62294. */
  62295. getDepthWrite(): boolean;
  62296. setDepthFunctionToGreater(): void;
  62297. setDepthFunctionToGreaterOrEqual(): void;
  62298. setDepthFunctionToLess(): void;
  62299. setDepthFunctionToLessOrEqual(): void;
  62300. /**
  62301. * Enable or disable depth writing
  62302. * @param enable defines the state to set
  62303. */
  62304. setDepthWrite(enable: boolean): void;
  62305. /**
  62306. * Enable or disable color writing
  62307. * @param enable defines the state to set
  62308. */
  62309. setColorWrite(enable: boolean): void;
  62310. /**
  62311. * Gets a boolean indicating if color writing is enabled
  62312. * @returns the current color writing state
  62313. */
  62314. getColorWrite(): boolean;
  62315. /**
  62316. * Sets alpha constants used by some alpha blending modes
  62317. * @param r defines the red component
  62318. * @param g defines the green component
  62319. * @param b defines the blue component
  62320. * @param a defines the alpha component
  62321. */
  62322. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  62323. /**
  62324. * Sets the current alpha mode
  62325. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  62326. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  62327. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62328. */
  62329. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  62330. /**
  62331. * Gets the current alpha mode
  62332. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62333. * @returns the current alpha mode
  62334. */
  62335. getAlphaMode(): number;
  62336. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  62337. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62338. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62339. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62340. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62341. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62342. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62343. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62344. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62345. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  62346. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  62347. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  62348. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  62349. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  62350. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62351. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62352. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  62353. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  62354. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  62355. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  62356. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  62357. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  62358. wipeCaches(bruteForce?: boolean): void;
  62359. protected _createTexture(): WebGLTexture;
  62360. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  62361. /**
  62362. * Update the content of a dynamic texture
  62363. * @param texture defines the texture to update
  62364. * @param canvas defines the canvas containing the source
  62365. * @param invertY defines if data must be stored with Y axis inverted
  62366. * @param premulAlpha defines if alpha is stored as premultiplied
  62367. * @param format defines the format of the data
  62368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  62369. */
  62370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  62371. /**
  62372. * Usually called from Texture.ts.
  62373. * Passed information to create a WebGLTexture
  62374. * @param url defines a value which contains one of the following:
  62375. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  62376. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  62377. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  62378. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  62379. * @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)
  62380. * @param scene needed for loading to the correct scene
  62381. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  62382. * @param onLoad optional callback to be called upon successful completion
  62383. * @param onError optional callback to be called upon failure
  62384. * @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
  62385. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  62386. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  62387. * @param forcedExtension defines the extension to use to pick the right loader
  62388. * @param mimeType defines an optional mime type
  62389. * @param loaderOptions options to be passed to the loader
  62390. * @returns a InternalTexture for assignment back into BABYLON.Texture
  62391. */
  62392. 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;
  62393. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  62394. _releaseFramebufferObjects(texture: InternalTexture): void;
  62395. /**
  62396. * Creates a cube texture
  62397. * @param rootUrl defines the url where the files to load is located
  62398. * @param scene defines the current scene
  62399. * @param files defines the list of files to load (1 per face)
  62400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  62401. * @param onLoad defines an optional callback raised when the texture is loaded
  62402. * @param onError defines an optional callback raised if there is an issue to load the texture
  62403. * @param format defines the format of the data
  62404. * @param forcedExtension defines the extension to use to pick the right loader
  62405. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  62406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62408. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  62409. * @returns the cube texture as an InternalTexture
  62410. */
  62411. 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;
  62412. createRenderTargetTexture(size: number | {
  62413. width: number;
  62414. height: number;
  62415. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  62416. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  62417. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  62418. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  62419. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  62420. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  62421. /**
  62422. * Updates a dynamic vertex buffer.
  62423. * @param vertexBuffer the vertex buffer to update
  62424. * @param data the data used to update the vertex buffer
  62425. * @param byteOffset the byte offset of the data (optional)
  62426. * @param byteLength the byte length of the data (optional)
  62427. */
  62428. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  62429. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  62430. private _updateAnisotropicLevel;
  62431. private _getAddressMode;
  62432. /** @hidden */
  62433. _bindTexture(channel: number, texture: InternalTexture): void;
  62434. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  62435. releaseEffects(): void;
  62436. /** @hidden */
  62437. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62438. /** @hidden */
  62439. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62440. /** @hidden */
  62441. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62442. /** @hidden */
  62443. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  62444. private _getNativeSamplingMode;
  62445. private _getNativeTextureFormat;
  62446. private _getNativeAlphaMode;
  62447. private _getNativeAttribType;
  62448. }
  62449. }
  62450. declare module "babylonjs/Engines/index" {
  62451. export * from "babylonjs/Engines/constants";
  62452. export * from "babylonjs/Engines/engineCapabilities";
  62453. export * from "babylonjs/Engines/instancingAttributeInfo";
  62454. export * from "babylonjs/Engines/thinEngine";
  62455. export * from "babylonjs/Engines/engine";
  62456. export * from "babylonjs/Engines/engineStore";
  62457. export * from "babylonjs/Engines/nullEngine";
  62458. export * from "babylonjs/Engines/Extensions/index";
  62459. export * from "babylonjs/Engines/IPipelineContext";
  62460. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  62461. export * from "babylonjs/Engines/WebGPU/webgpuConstants";
  62462. export * from "babylonjs/Engines/webgpuEngine";
  62463. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  62464. export * from "babylonjs/Engines/nativeEngine";
  62465. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  62466. export * from "babylonjs/Engines/performanceConfigurator";
  62467. export * from "babylonjs/Engines/engineFeatures";
  62468. }
  62469. declare module "babylonjs/Events/clipboardEvents" {
  62470. /**
  62471. * Gather the list of clipboard event types as constants.
  62472. */
  62473. export class ClipboardEventTypes {
  62474. /**
  62475. * The clipboard event is fired when a copy command is active (pressed).
  62476. */
  62477. static readonly COPY: number;
  62478. /**
  62479. * The clipboard event is fired when a cut command is active (pressed).
  62480. */
  62481. static readonly CUT: number;
  62482. /**
  62483. * The clipboard event is fired when a paste command is active (pressed).
  62484. */
  62485. static readonly PASTE: number;
  62486. }
  62487. /**
  62488. * This class is used to store clipboard related info for the onClipboardObservable event.
  62489. */
  62490. export class ClipboardInfo {
  62491. /**
  62492. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62493. */
  62494. type: number;
  62495. /**
  62496. * Defines the related dom event
  62497. */
  62498. event: ClipboardEvent;
  62499. /**
  62500. *Creates an instance of ClipboardInfo.
  62501. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  62502. * @param event Defines the related dom event
  62503. */
  62504. constructor(
  62505. /**
  62506. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62507. */
  62508. type: number,
  62509. /**
  62510. * Defines the related dom event
  62511. */
  62512. event: ClipboardEvent);
  62513. /**
  62514. * Get the clipboard event's type from the keycode.
  62515. * @param keyCode Defines the keyCode for the current keyboard event.
  62516. * @return {number}
  62517. */
  62518. static GetTypeFromCharacter(keyCode: number): number;
  62519. }
  62520. }
  62521. declare module "babylonjs/Events/index" {
  62522. export * from "babylonjs/Events/keyboardEvents";
  62523. export * from "babylonjs/Events/pointerEvents";
  62524. export * from "babylonjs/Events/clipboardEvents";
  62525. }
  62526. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  62527. import { Scene } from "babylonjs/scene";
  62528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62529. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62530. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62531. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62532. /**
  62533. * Google Daydream controller
  62534. */
  62535. export class DaydreamController extends WebVRController {
  62536. /**
  62537. * Base Url for the controller model.
  62538. */
  62539. static MODEL_BASE_URL: string;
  62540. /**
  62541. * File name for the controller model.
  62542. */
  62543. static MODEL_FILENAME: string;
  62544. /**
  62545. * Gamepad Id prefix used to identify Daydream Controller.
  62546. */
  62547. static readonly GAMEPAD_ID_PREFIX: string;
  62548. /**
  62549. * Creates a new DaydreamController from a gamepad
  62550. * @param vrGamepad the gamepad that the controller should be created from
  62551. */
  62552. constructor(vrGamepad: any);
  62553. /**
  62554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62555. * @param scene scene in which to add meshes
  62556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62557. */
  62558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62559. /**
  62560. * Called once for each button that changed state since the last frame
  62561. * @param buttonIdx Which button index changed
  62562. * @param state New state of the button
  62563. * @param changes Which properties on the state changed since last frame
  62564. */
  62565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62566. }
  62567. }
  62568. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  62569. import { Scene } from "babylonjs/scene";
  62570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62571. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62572. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62573. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62574. /**
  62575. * Gear VR Controller
  62576. */
  62577. export class GearVRController extends WebVRController {
  62578. /**
  62579. * Base Url for the controller model.
  62580. */
  62581. static MODEL_BASE_URL: string;
  62582. /**
  62583. * File name for the controller model.
  62584. */
  62585. static MODEL_FILENAME: string;
  62586. /**
  62587. * Gamepad Id prefix used to identify this controller.
  62588. */
  62589. static readonly GAMEPAD_ID_PREFIX: string;
  62590. private readonly _buttonIndexToObservableNameMap;
  62591. /**
  62592. * Creates a new GearVRController from a gamepad
  62593. * @param vrGamepad the gamepad that the controller should be created from
  62594. */
  62595. constructor(vrGamepad: any);
  62596. /**
  62597. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62598. * @param scene scene in which to add meshes
  62599. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62600. */
  62601. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62602. /**
  62603. * Called once for each button that changed state since the last frame
  62604. * @param buttonIdx Which button index changed
  62605. * @param state New state of the button
  62606. * @param changes Which properties on the state changed since last frame
  62607. */
  62608. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62609. }
  62610. }
  62611. declare module "babylonjs/Gamepads/Controllers/genericController" {
  62612. import { Scene } from "babylonjs/scene";
  62613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62614. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62615. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62616. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62617. /**
  62618. * Generic Controller
  62619. */
  62620. export class GenericController extends WebVRController {
  62621. /**
  62622. * Base Url for the controller model.
  62623. */
  62624. static readonly MODEL_BASE_URL: string;
  62625. /**
  62626. * File name for the controller model.
  62627. */
  62628. static readonly MODEL_FILENAME: string;
  62629. /**
  62630. * Creates a new GenericController from a gamepad
  62631. * @param vrGamepad the gamepad that the controller should be created from
  62632. */
  62633. constructor(vrGamepad: any);
  62634. /**
  62635. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62636. * @param scene scene in which to add meshes
  62637. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62638. */
  62639. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62640. /**
  62641. * Called once for each button that changed state since the last frame
  62642. * @param buttonIdx Which button index changed
  62643. * @param state New state of the button
  62644. * @param changes Which properties on the state changed since last frame
  62645. */
  62646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62647. }
  62648. }
  62649. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  62650. import { Observable } from "babylonjs/Misc/observable";
  62651. import { Scene } from "babylonjs/scene";
  62652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62653. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62654. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62655. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62656. /**
  62657. * Oculus Touch Controller
  62658. */
  62659. export class OculusTouchController extends WebVRController {
  62660. /**
  62661. * Base Url for the controller model.
  62662. */
  62663. static MODEL_BASE_URL: string;
  62664. /**
  62665. * File name for the left controller model.
  62666. */
  62667. static MODEL_LEFT_FILENAME: string;
  62668. /**
  62669. * File name for the right controller model.
  62670. */
  62671. static MODEL_RIGHT_FILENAME: string;
  62672. /**
  62673. * Base Url for the Quest controller model.
  62674. */
  62675. static QUEST_MODEL_BASE_URL: string;
  62676. /**
  62677. * @hidden
  62678. * If the controllers are running on a device that needs the updated Quest controller models
  62679. */
  62680. static _IsQuest: boolean;
  62681. /**
  62682. * Fired when the secondary trigger on this controller is modified
  62683. */
  62684. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  62685. /**
  62686. * Fired when the thumb rest on this controller is modified
  62687. */
  62688. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  62689. /**
  62690. * Creates a new OculusTouchController from a gamepad
  62691. * @param vrGamepad the gamepad that the controller should be created from
  62692. */
  62693. constructor(vrGamepad: any);
  62694. /**
  62695. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62696. * @param scene scene in which to add meshes
  62697. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62698. */
  62699. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62700. /**
  62701. * Fired when the A button on this controller is modified
  62702. */
  62703. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62704. /**
  62705. * Fired when the B button on this controller is modified
  62706. */
  62707. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62708. /**
  62709. * Fired when the X button on this controller is modified
  62710. */
  62711. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62712. /**
  62713. * Fired when the Y button on this controller is modified
  62714. */
  62715. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62716. /**
  62717. * Called once for each button that changed state since the last frame
  62718. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  62719. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  62720. * 2) secondary trigger (same)
  62721. * 3) A (right) X (left), touch, pressed = value
  62722. * 4) B / Y
  62723. * 5) thumb rest
  62724. * @param buttonIdx Which button index changed
  62725. * @param state New state of the button
  62726. * @param changes Which properties on the state changed since last frame
  62727. */
  62728. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62729. }
  62730. }
  62731. declare module "babylonjs/Gamepads/Controllers/viveController" {
  62732. import { Scene } from "babylonjs/scene";
  62733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62734. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62735. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62736. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62737. import { Observable } from "babylonjs/Misc/observable";
  62738. /**
  62739. * Vive Controller
  62740. */
  62741. export class ViveController extends WebVRController {
  62742. /**
  62743. * Base Url for the controller model.
  62744. */
  62745. static MODEL_BASE_URL: string;
  62746. /**
  62747. * File name for the controller model.
  62748. */
  62749. static MODEL_FILENAME: string;
  62750. /**
  62751. * Creates a new ViveController from a gamepad
  62752. * @param vrGamepad the gamepad that the controller should be created from
  62753. */
  62754. constructor(vrGamepad: any);
  62755. /**
  62756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62757. * @param scene scene in which to add meshes
  62758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62759. */
  62760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62761. /**
  62762. * Fired when the left button on this controller is modified
  62763. */
  62764. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62765. /**
  62766. * Fired when the right button on this controller is modified
  62767. */
  62768. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62769. /**
  62770. * Fired when the menu button on this controller is modified
  62771. */
  62772. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62773. /**
  62774. * Called once for each button that changed state since the last frame
  62775. * Vive mapping:
  62776. * 0: touchpad
  62777. * 1: trigger
  62778. * 2: left AND right buttons
  62779. * 3: menu button
  62780. * @param buttonIdx Which button index changed
  62781. * @param state New state of the button
  62782. * @param changes Which properties on the state changed since last frame
  62783. */
  62784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62785. }
  62786. }
  62787. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  62788. import { Observable } from "babylonjs/Misc/observable";
  62789. import { Scene } from "babylonjs/scene";
  62790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62791. import { Ray } from "babylonjs/Culling/ray";
  62792. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62793. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62794. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62795. /**
  62796. * Defines the WindowsMotionController object that the state of the windows motion controller
  62797. */
  62798. export class WindowsMotionController extends WebVRController {
  62799. /**
  62800. * The base url used to load the left and right controller models
  62801. */
  62802. static MODEL_BASE_URL: string;
  62803. /**
  62804. * The name of the left controller model file
  62805. */
  62806. static MODEL_LEFT_FILENAME: string;
  62807. /**
  62808. * The name of the right controller model file
  62809. */
  62810. static MODEL_RIGHT_FILENAME: string;
  62811. /**
  62812. * The controller name prefix for this controller type
  62813. */
  62814. static readonly GAMEPAD_ID_PREFIX: string;
  62815. /**
  62816. * The controller id pattern for this controller type
  62817. */
  62818. private static readonly GAMEPAD_ID_PATTERN;
  62819. private _loadedMeshInfo;
  62820. protected readonly _mapping: {
  62821. buttons: string[];
  62822. buttonMeshNames: {
  62823. trigger: string;
  62824. menu: string;
  62825. grip: string;
  62826. thumbstick: string;
  62827. trackpad: string;
  62828. };
  62829. buttonObservableNames: {
  62830. trigger: string;
  62831. menu: string;
  62832. grip: string;
  62833. thumbstick: string;
  62834. trackpad: string;
  62835. };
  62836. axisMeshNames: string[];
  62837. pointingPoseMeshName: string;
  62838. };
  62839. /**
  62840. * Fired when the trackpad on this controller is clicked
  62841. */
  62842. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  62843. /**
  62844. * Fired when the trackpad on this controller is modified
  62845. */
  62846. onTrackpadValuesChangedObservable: Observable<StickValues>;
  62847. /**
  62848. * The current x and y values of this controller's trackpad
  62849. */
  62850. trackpad: StickValues;
  62851. /**
  62852. * Creates a new WindowsMotionController from a gamepad
  62853. * @param vrGamepad the gamepad that the controller should be created from
  62854. */
  62855. constructor(vrGamepad: any);
  62856. /**
  62857. * Fired when the trigger on this controller is modified
  62858. */
  62859. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62860. /**
  62861. * Fired when the menu button on this controller is modified
  62862. */
  62863. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62864. /**
  62865. * Fired when the grip button on this controller is modified
  62866. */
  62867. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62868. /**
  62869. * Fired when the thumbstick button on this controller is modified
  62870. */
  62871. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62872. /**
  62873. * Fired when the touchpad button on this controller is modified
  62874. */
  62875. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62876. /**
  62877. * Fired when the touchpad values on this controller are modified
  62878. */
  62879. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  62880. protected _updateTrackpad(): void;
  62881. /**
  62882. * Called once per frame by the engine.
  62883. */
  62884. update(): void;
  62885. /**
  62886. * Called once for each button that changed state since the last frame
  62887. * @param buttonIdx Which button index changed
  62888. * @param state New state of the button
  62889. * @param changes Which properties on the state changed since last frame
  62890. */
  62891. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62892. /**
  62893. * Moves the buttons on the controller mesh based on their current state
  62894. * @param buttonName the name of the button to move
  62895. * @param buttonValue the value of the button which determines the buttons new position
  62896. */
  62897. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  62898. /**
  62899. * Moves the axis on the controller mesh based on its current state
  62900. * @param axis the index of the axis
  62901. * @param axisValue the value of the axis which determines the meshes new position
  62902. * @hidden
  62903. */
  62904. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  62905. /**
  62906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62907. * @param scene scene in which to add meshes
  62908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62909. */
  62910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  62911. /**
  62912. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  62913. * can be transformed by button presses and axes values, based on this._mapping.
  62914. *
  62915. * @param scene scene in which the meshes exist
  62916. * @param meshes list of meshes that make up the controller model to process
  62917. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  62918. */
  62919. private processModel;
  62920. private createMeshInfo;
  62921. /**
  62922. * Gets the ray of the controller in the direction the controller is pointing
  62923. * @param length the length the resulting ray should be
  62924. * @returns a ray in the direction the controller is pointing
  62925. */
  62926. getForwardRay(length?: number): Ray;
  62927. /**
  62928. * Disposes of the controller
  62929. */
  62930. dispose(): void;
  62931. }
  62932. /**
  62933. * This class represents a new windows motion controller in XR.
  62934. */
  62935. export class XRWindowsMotionController extends WindowsMotionController {
  62936. /**
  62937. * Changing the original WIndowsMotionController mapping to fir the new mapping
  62938. */
  62939. protected readonly _mapping: {
  62940. buttons: string[];
  62941. buttonMeshNames: {
  62942. trigger: string;
  62943. menu: string;
  62944. grip: string;
  62945. thumbstick: string;
  62946. trackpad: string;
  62947. };
  62948. buttonObservableNames: {
  62949. trigger: string;
  62950. menu: string;
  62951. grip: string;
  62952. thumbstick: string;
  62953. trackpad: string;
  62954. };
  62955. axisMeshNames: string[];
  62956. pointingPoseMeshName: string;
  62957. };
  62958. /**
  62959. * Construct a new XR-Based windows motion controller
  62960. *
  62961. * @param gamepadInfo the gamepad object from the browser
  62962. */
  62963. constructor(gamepadInfo: any);
  62964. /**
  62965. * holds the thumbstick values (X,Y)
  62966. */
  62967. thumbstickValues: StickValues;
  62968. /**
  62969. * Fired when the thumbstick on this controller is clicked
  62970. */
  62971. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  62972. /**
  62973. * Fired when the thumbstick on this controller is modified
  62974. */
  62975. onThumbstickValuesChangedObservable: Observable<StickValues>;
  62976. /**
  62977. * Fired when the touchpad button on this controller is modified
  62978. */
  62979. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  62980. /**
  62981. * Fired when the touchpad values on this controller are modified
  62982. */
  62983. onTrackpadValuesChangedObservable: Observable<StickValues>;
  62984. /**
  62985. * Fired when the thumbstick button on this controller is modified
  62986. * here to prevent breaking changes
  62987. */
  62988. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62989. /**
  62990. * updating the thumbstick(!) and not the trackpad.
  62991. * This is named this way due to the difference between WebVR and XR and to avoid
  62992. * changing the parent class.
  62993. */
  62994. protected _updateTrackpad(): void;
  62995. /**
  62996. * Disposes the class with joy
  62997. */
  62998. dispose(): void;
  62999. }
  63000. }
  63001. declare module "babylonjs/Gamepads/Controllers/index" {
  63002. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  63003. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  63004. export * from "babylonjs/Gamepads/Controllers/genericController";
  63005. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  63006. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63007. export * from "babylonjs/Gamepads/Controllers/viveController";
  63008. export * from "babylonjs/Gamepads/Controllers/webVRController";
  63009. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  63010. }
  63011. declare module "babylonjs/Gamepads/index" {
  63012. export * from "babylonjs/Gamepads/Controllers/index";
  63013. export * from "babylonjs/Gamepads/gamepad";
  63014. export * from "babylonjs/Gamepads/gamepadManager";
  63015. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  63016. export * from "babylonjs/Gamepads/xboxGamepad";
  63017. export * from "babylonjs/Gamepads/dualShockGamepad";
  63018. }
  63019. declare module "babylonjs/Lights/directionalLight" {
  63020. import { Camera } from "babylonjs/Cameras/camera";
  63021. import { Scene } from "babylonjs/scene";
  63022. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63024. import { Light } from "babylonjs/Lights/light";
  63025. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63026. import { Effect } from "babylonjs/Materials/effect";
  63027. /**
  63028. * A directional light is defined by a direction (what a surprise!).
  63029. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  63030. * 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.
  63031. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63032. */
  63033. export class DirectionalLight extends ShadowLight {
  63034. private _shadowFrustumSize;
  63035. /**
  63036. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  63037. */
  63038. get shadowFrustumSize(): number;
  63039. /**
  63040. * Specifies a fix frustum size for the shadow generation.
  63041. */
  63042. set shadowFrustumSize(value: number);
  63043. private _shadowOrthoScale;
  63044. /**
  63045. * Gets the shadow projection scale against the optimal computed one.
  63046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63048. */
  63049. get shadowOrthoScale(): number;
  63050. /**
  63051. * Sets the shadow projection scale against the optimal computed one.
  63052. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63053. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63054. */
  63055. set shadowOrthoScale(value: number);
  63056. /**
  63057. * Automatically compute the projection matrix to best fit (including all the casters)
  63058. * on each frame.
  63059. */
  63060. autoUpdateExtends: boolean;
  63061. /**
  63062. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  63063. * on each frame. autoUpdateExtends must be set to true for this to work
  63064. */
  63065. autoCalcShadowZBounds: boolean;
  63066. private _orthoLeft;
  63067. private _orthoRight;
  63068. private _orthoTop;
  63069. private _orthoBottom;
  63070. /**
  63071. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  63072. * The directional light is emitted from everywhere in the given direction.
  63073. * It can cast shadows.
  63074. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63075. * @param name The friendly name of the light
  63076. * @param direction The direction of the light
  63077. * @param scene The scene the light belongs to
  63078. */
  63079. constructor(name: string, direction: Vector3, scene: Scene);
  63080. /**
  63081. * Returns the string "DirectionalLight".
  63082. * @return The class name
  63083. */
  63084. getClassName(): string;
  63085. /**
  63086. * Returns the integer 1.
  63087. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63088. */
  63089. getTypeID(): number;
  63090. /**
  63091. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  63092. * Returns the DirectionalLight Shadow projection matrix.
  63093. */
  63094. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63095. /**
  63096. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  63097. * Returns the DirectionalLight Shadow projection matrix.
  63098. */
  63099. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  63100. /**
  63101. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  63102. * Returns the DirectionalLight Shadow projection matrix.
  63103. */
  63104. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63105. protected _buildUniformLayout(): void;
  63106. /**
  63107. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  63108. * @param effect The effect to update
  63109. * @param lightIndex The index of the light in the effect to update
  63110. * @returns The directional light
  63111. */
  63112. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  63113. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  63114. /**
  63115. * Gets the minZ used for shadow according to both the scene and the light.
  63116. *
  63117. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63118. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63119. * @param activeCamera The camera we are returning the min for
  63120. * @returns the depth min z
  63121. */
  63122. getDepthMinZ(activeCamera: Camera): number;
  63123. /**
  63124. * Gets the maxZ used for shadow according to both the scene and the light.
  63125. *
  63126. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63127. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63128. * @param activeCamera The camera we are returning the max for
  63129. * @returns the depth max z
  63130. */
  63131. getDepthMaxZ(activeCamera: Camera): number;
  63132. /**
  63133. * Prepares the list of defines specific to the light type.
  63134. * @param defines the list of defines
  63135. * @param lightIndex defines the index of the light for the effect
  63136. */
  63137. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63138. }
  63139. }
  63140. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  63141. import { Mesh } from "babylonjs/Meshes/mesh";
  63142. /**
  63143. * Class containing static functions to help procedurally build meshes
  63144. */
  63145. export class HemisphereBuilder {
  63146. /**
  63147. * Creates a hemisphere mesh
  63148. * @param name defines the name of the mesh
  63149. * @param options defines the options used to create the mesh
  63150. * @param scene defines the hosting scene
  63151. * @returns the hemisphere mesh
  63152. */
  63153. static CreateHemisphere(name: string, options: {
  63154. segments?: number;
  63155. diameter?: number;
  63156. sideOrientation?: number;
  63157. }, scene: any): Mesh;
  63158. }
  63159. }
  63160. declare module "babylonjs/Lights/spotLight" {
  63161. import { Nullable } from "babylonjs/types";
  63162. import { Scene } from "babylonjs/scene";
  63163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63165. import { Effect } from "babylonjs/Materials/effect";
  63166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63167. import { Light } from "babylonjs/Lights/light";
  63168. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63169. /**
  63170. * A spot light is defined by a position, a direction, an angle, and an exponent.
  63171. * These values define a cone of light starting from the position, emitting toward the direction.
  63172. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  63173. * and the exponent defines the speed of the decay of the light with distance (reach).
  63174. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63175. */
  63176. export class SpotLight extends ShadowLight {
  63177. private _angle;
  63178. private _innerAngle;
  63179. private _cosHalfAngle;
  63180. private _lightAngleScale;
  63181. private _lightAngleOffset;
  63182. /**
  63183. * Gets the cone angle of the spot light in Radians.
  63184. */
  63185. get angle(): number;
  63186. /**
  63187. * Sets the cone angle of the spot light in Radians.
  63188. */
  63189. set angle(value: number);
  63190. /**
  63191. * Only used in gltf falloff mode, this defines the angle where
  63192. * the directional falloff will start before cutting at angle which could be seen
  63193. * as outer angle.
  63194. */
  63195. get innerAngle(): number;
  63196. /**
  63197. * Only used in gltf falloff mode, this defines the angle where
  63198. * the directional falloff will start before cutting at angle which could be seen
  63199. * as outer angle.
  63200. */
  63201. set innerAngle(value: number);
  63202. private _shadowAngleScale;
  63203. /**
  63204. * Allows scaling the angle of the light for shadow generation only.
  63205. */
  63206. get shadowAngleScale(): number;
  63207. /**
  63208. * Allows scaling the angle of the light for shadow generation only.
  63209. */
  63210. set shadowAngleScale(value: number);
  63211. /**
  63212. * The light decay speed with the distance from the emission spot.
  63213. */
  63214. exponent: number;
  63215. private _projectionTextureMatrix;
  63216. /**
  63217. * Allows reading the projecton texture
  63218. */
  63219. get projectionTextureMatrix(): Matrix;
  63220. protected _projectionTextureLightNear: number;
  63221. /**
  63222. * Gets the near clip of the Spotlight for texture projection.
  63223. */
  63224. get projectionTextureLightNear(): number;
  63225. /**
  63226. * Sets the near clip of the Spotlight for texture projection.
  63227. */
  63228. set projectionTextureLightNear(value: number);
  63229. protected _projectionTextureLightFar: number;
  63230. /**
  63231. * Gets the far clip of the Spotlight for texture projection.
  63232. */
  63233. get projectionTextureLightFar(): number;
  63234. /**
  63235. * Sets the far clip of the Spotlight for texture projection.
  63236. */
  63237. set projectionTextureLightFar(value: number);
  63238. protected _projectionTextureUpDirection: Vector3;
  63239. /**
  63240. * Gets the Up vector of the Spotlight for texture projection.
  63241. */
  63242. get projectionTextureUpDirection(): Vector3;
  63243. /**
  63244. * Sets the Up vector of the Spotlight for texture projection.
  63245. */
  63246. set projectionTextureUpDirection(value: Vector3);
  63247. private _projectionTexture;
  63248. /**
  63249. * Gets the projection texture of the light.
  63250. */
  63251. get projectionTexture(): Nullable<BaseTexture>;
  63252. /**
  63253. * Sets the projection texture of the light.
  63254. */
  63255. set projectionTexture(value: Nullable<BaseTexture>);
  63256. private static _IsProceduralTexture;
  63257. private static _IsTexture;
  63258. private _projectionTextureViewLightDirty;
  63259. private _projectionTextureProjectionLightDirty;
  63260. private _projectionTextureDirty;
  63261. private _projectionTextureViewTargetVector;
  63262. private _projectionTextureViewLightMatrix;
  63263. private _projectionTextureProjectionLightMatrix;
  63264. private _projectionTextureScalingMatrix;
  63265. /**
  63266. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  63267. * It can cast shadows.
  63268. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63269. * @param name The light friendly name
  63270. * @param position The position of the spot light in the scene
  63271. * @param direction The direction of the light in the scene
  63272. * @param angle The cone angle of the light in Radians
  63273. * @param exponent The light decay speed with the distance from the emission spot
  63274. * @param scene The scene the lights belongs to
  63275. */
  63276. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  63277. /**
  63278. * Returns the string "SpotLight".
  63279. * @returns the class name
  63280. */
  63281. getClassName(): string;
  63282. /**
  63283. * Returns the integer 2.
  63284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63285. */
  63286. getTypeID(): number;
  63287. /**
  63288. * Overrides the direction setter to recompute the projection texture view light Matrix.
  63289. */
  63290. protected _setDirection(value: Vector3): void;
  63291. /**
  63292. * Overrides the position setter to recompute the projection texture view light Matrix.
  63293. */
  63294. protected _setPosition(value: Vector3): void;
  63295. /**
  63296. * 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.
  63297. * Returns the SpotLight.
  63298. */
  63299. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63300. protected _computeProjectionTextureViewLightMatrix(): void;
  63301. protected _computeProjectionTextureProjectionLightMatrix(): void;
  63302. /**
  63303. * Main function for light texture projection matrix computing.
  63304. */
  63305. protected _computeProjectionTextureMatrix(): void;
  63306. protected _buildUniformLayout(): void;
  63307. private _computeAngleValues;
  63308. /**
  63309. * Sets the passed Effect "effect" with the Light textures.
  63310. * @param effect The effect to update
  63311. * @param lightIndex The index of the light in the effect to update
  63312. * @returns The light
  63313. */
  63314. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  63315. /**
  63316. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  63317. * @param effect The effect to update
  63318. * @param lightIndex The index of the light in the effect to update
  63319. * @returns The spot light
  63320. */
  63321. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  63322. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63323. /**
  63324. * Disposes the light and the associated resources.
  63325. */
  63326. dispose(): void;
  63327. /**
  63328. * Prepares the list of defines specific to the light type.
  63329. * @param defines the list of defines
  63330. * @param lightIndex defines the index of the light for the effect
  63331. */
  63332. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63333. }
  63334. }
  63335. declare module "babylonjs/Gizmos/lightGizmo" {
  63336. import { Nullable } from "babylonjs/types";
  63337. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63338. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63339. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63340. import { Light } from "babylonjs/Lights/light";
  63341. import { Observable } from "babylonjs/Misc/observable";
  63342. /**
  63343. * Gizmo that enables viewing a light
  63344. */
  63345. export class LightGizmo extends Gizmo {
  63346. private _lightMesh;
  63347. private _material;
  63348. private _cachedPosition;
  63349. private _cachedForward;
  63350. private _attachedMeshParent;
  63351. private _pointerObserver;
  63352. /**
  63353. * Event that fires each time the gizmo is clicked
  63354. */
  63355. onClickedObservable: Observable<Light>;
  63356. /**
  63357. * Creates a LightGizmo
  63358. * @param gizmoLayer The utility layer the gizmo will be added to
  63359. */
  63360. constructor(gizmoLayer?: UtilityLayerRenderer);
  63361. private _light;
  63362. /**
  63363. * The light that the gizmo is attached to
  63364. */
  63365. set light(light: Nullable<Light>);
  63366. get light(): Nullable<Light>;
  63367. /**
  63368. * Gets the material used to render the light gizmo
  63369. */
  63370. get material(): StandardMaterial;
  63371. /**
  63372. * @hidden
  63373. * Updates the gizmo to match the attached mesh's position/rotation
  63374. */
  63375. protected _update(): void;
  63376. private static _Scale;
  63377. /**
  63378. * Creates the lines for a light mesh
  63379. */
  63380. private static _CreateLightLines;
  63381. /**
  63382. * Disposes of the light gizmo
  63383. */
  63384. dispose(): void;
  63385. private static _CreateHemisphericLightMesh;
  63386. private static _CreatePointLightMesh;
  63387. private static _CreateSpotLightMesh;
  63388. private static _CreateDirectionalLightMesh;
  63389. }
  63390. }
  63391. declare module "babylonjs/Gizmos/cameraGizmo" {
  63392. import { Nullable } from "babylonjs/types";
  63393. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63394. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63395. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63396. import { Camera } from "babylonjs/Cameras/camera";
  63397. import { Observable } from "babylonjs/Misc/observable";
  63398. /**
  63399. * Gizmo that enables viewing a camera
  63400. */
  63401. export class CameraGizmo extends Gizmo {
  63402. private _cameraMesh;
  63403. private _cameraLinesMesh;
  63404. private _material;
  63405. private _pointerObserver;
  63406. /**
  63407. * Event that fires each time the gizmo is clicked
  63408. */
  63409. onClickedObservable: Observable<Camera>;
  63410. /**
  63411. * Creates a CameraGizmo
  63412. * @param gizmoLayer The utility layer the gizmo will be added to
  63413. */
  63414. constructor(gizmoLayer?: UtilityLayerRenderer);
  63415. private _camera;
  63416. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  63417. get displayFrustum(): boolean;
  63418. set displayFrustum(value: boolean);
  63419. /**
  63420. * The camera that the gizmo is attached to
  63421. */
  63422. set camera(camera: Nullable<Camera>);
  63423. get camera(): Nullable<Camera>;
  63424. /**
  63425. * Gets the material used to render the camera gizmo
  63426. */
  63427. get material(): StandardMaterial;
  63428. /**
  63429. * @hidden
  63430. * Updates the gizmo to match the attached mesh's position/rotation
  63431. */
  63432. protected _update(): void;
  63433. private static _Scale;
  63434. private _invProjection;
  63435. /**
  63436. * Disposes of the camera gizmo
  63437. */
  63438. dispose(): void;
  63439. private static _CreateCameraMesh;
  63440. private static _CreateCameraFrustum;
  63441. }
  63442. }
  63443. declare module "babylonjs/Gizmos/index" {
  63444. export * from "babylonjs/Gizmos/axisDragGizmo";
  63445. export * from "babylonjs/Gizmos/axisScaleGizmo";
  63446. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  63447. export * from "babylonjs/Gizmos/gizmo";
  63448. export * from "babylonjs/Gizmos/gizmoManager";
  63449. export * from "babylonjs/Gizmos/planeRotationGizmo";
  63450. export * from "babylonjs/Gizmos/positionGizmo";
  63451. export * from "babylonjs/Gizmos/rotationGizmo";
  63452. export * from "babylonjs/Gizmos/scaleGizmo";
  63453. export * from "babylonjs/Gizmos/lightGizmo";
  63454. export * from "babylonjs/Gizmos/cameraGizmo";
  63455. export * from "babylonjs/Gizmos/planeDragGizmo";
  63456. }
  63457. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  63458. /** @hidden */
  63459. export var backgroundFragmentDeclaration: {
  63460. name: string;
  63461. shader: string;
  63462. };
  63463. }
  63464. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  63465. /** @hidden */
  63466. export var backgroundUboDeclaration: {
  63467. name: string;
  63468. shader: string;
  63469. };
  63470. }
  63471. declare module "babylonjs/Shaders/background.fragment" {
  63472. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  63473. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63474. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  63475. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63476. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63477. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63478. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63479. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  63480. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  63481. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  63483. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63485. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  63486. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  63487. /** @hidden */
  63488. export var backgroundPixelShader: {
  63489. name: string;
  63490. shader: string;
  63491. };
  63492. }
  63493. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  63494. /** @hidden */
  63495. export var backgroundVertexDeclaration: {
  63496. name: string;
  63497. shader: string;
  63498. };
  63499. }
  63500. declare module "babylonjs/Shaders/background.vertex" {
  63501. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  63502. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63503. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63504. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63505. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63506. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  63507. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  63508. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63509. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63510. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63511. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63512. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63513. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  63514. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  63515. /** @hidden */
  63516. export var backgroundVertexShader: {
  63517. name: string;
  63518. shader: string;
  63519. };
  63520. }
  63521. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  63522. import { Nullable, int, float } from "babylonjs/types";
  63523. import { Scene } from "babylonjs/scene";
  63524. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63525. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63527. import { Mesh } from "babylonjs/Meshes/mesh";
  63528. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  63529. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  63530. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  63531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63532. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  63533. import { Color3 } from "babylonjs/Maths/math.color";
  63534. import "babylonjs/Shaders/background.fragment";
  63535. import "babylonjs/Shaders/background.vertex";
  63536. /**
  63537. * Background material used to create an efficient environement around your scene.
  63538. */
  63539. export class BackgroundMaterial extends PushMaterial {
  63540. /**
  63541. * Standard reflectance value at parallel view angle.
  63542. */
  63543. static StandardReflectance0: number;
  63544. /**
  63545. * Standard reflectance value at grazing angle.
  63546. */
  63547. static StandardReflectance90: number;
  63548. protected _primaryColor: Color3;
  63549. /**
  63550. * Key light Color (multiply against the environement texture)
  63551. */
  63552. primaryColor: Color3;
  63553. protected __perceptualColor: Nullable<Color3>;
  63554. /**
  63555. * Experimental Internal Use Only.
  63556. *
  63557. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  63558. * This acts as a helper to set the primary color to a more "human friendly" value.
  63559. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  63560. * output color as close as possible from the chosen value.
  63561. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  63562. * part of lighting setup.)
  63563. */
  63564. get _perceptualColor(): Nullable<Color3>;
  63565. set _perceptualColor(value: Nullable<Color3>);
  63566. protected _primaryColorShadowLevel: float;
  63567. /**
  63568. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  63569. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  63570. */
  63571. get primaryColorShadowLevel(): float;
  63572. set primaryColorShadowLevel(value: float);
  63573. protected _primaryColorHighlightLevel: float;
  63574. /**
  63575. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  63576. * The primary color is used at the level chosen to define what the white area would look.
  63577. */
  63578. get primaryColorHighlightLevel(): float;
  63579. set primaryColorHighlightLevel(value: float);
  63580. protected _reflectionTexture: Nullable<BaseTexture>;
  63581. /**
  63582. * Reflection Texture used in the material.
  63583. * Should be author in a specific way for the best result (refer to the documentation).
  63584. */
  63585. reflectionTexture: Nullable<BaseTexture>;
  63586. protected _reflectionBlur: float;
  63587. /**
  63588. * Reflection Texture level of blur.
  63589. *
  63590. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  63591. * texture twice.
  63592. */
  63593. reflectionBlur: float;
  63594. protected _diffuseTexture: Nullable<BaseTexture>;
  63595. /**
  63596. * Diffuse Texture used in the material.
  63597. * Should be author in a specific way for the best result (refer to the documentation).
  63598. */
  63599. diffuseTexture: Nullable<BaseTexture>;
  63600. protected _shadowLights: Nullable<IShadowLight[]>;
  63601. /**
  63602. * Specify the list of lights casting shadow on the material.
  63603. * All scene shadow lights will be included if null.
  63604. */
  63605. shadowLights: Nullable<IShadowLight[]>;
  63606. protected _shadowLevel: float;
  63607. /**
  63608. * Helps adjusting the shadow to a softer level if required.
  63609. * 0 means black shadows and 1 means no shadows.
  63610. */
  63611. shadowLevel: float;
  63612. protected _sceneCenter: Vector3;
  63613. /**
  63614. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  63615. * It is usually zero but might be interesting to modify according to your setup.
  63616. */
  63617. sceneCenter: Vector3;
  63618. protected _opacityFresnel: boolean;
  63619. /**
  63620. * This helps specifying that the material is falling off to the sky box at grazing angle.
  63621. * This helps ensuring a nice transition when the camera goes under the ground.
  63622. */
  63623. opacityFresnel: boolean;
  63624. protected _reflectionFresnel: boolean;
  63625. /**
  63626. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  63627. * This helps adding a mirror texture on the ground.
  63628. */
  63629. reflectionFresnel: boolean;
  63630. protected _reflectionFalloffDistance: number;
  63631. /**
  63632. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  63633. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  63634. */
  63635. reflectionFalloffDistance: number;
  63636. protected _reflectionAmount: number;
  63637. /**
  63638. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  63639. */
  63640. reflectionAmount: number;
  63641. protected _reflectionReflectance0: number;
  63642. /**
  63643. * This specifies the weight of the reflection at grazing angle.
  63644. */
  63645. reflectionReflectance0: number;
  63646. protected _reflectionReflectance90: number;
  63647. /**
  63648. * This specifies the weight of the reflection at a perpendicular point of view.
  63649. */
  63650. reflectionReflectance90: number;
  63651. /**
  63652. * Sets the reflection reflectance fresnel values according to the default standard
  63653. * empirically know to work well :-)
  63654. */
  63655. set reflectionStandardFresnelWeight(value: number);
  63656. protected _useRGBColor: boolean;
  63657. /**
  63658. * Helps to directly use the maps channels instead of their level.
  63659. */
  63660. useRGBColor: boolean;
  63661. protected _enableNoise: boolean;
  63662. /**
  63663. * This helps reducing the banding effect that could occur on the background.
  63664. */
  63665. enableNoise: boolean;
  63666. /**
  63667. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  63668. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  63669. * Recommended to be keep at 1.0 except for special cases.
  63670. */
  63671. get fovMultiplier(): number;
  63672. set fovMultiplier(value: number);
  63673. private _fovMultiplier;
  63674. /**
  63675. * Enable the FOV adjustment feature controlled by fovMultiplier.
  63676. */
  63677. useEquirectangularFOV: boolean;
  63678. private _maxSimultaneousLights;
  63679. /**
  63680. * Number of Simultaneous lights allowed on the material.
  63681. */
  63682. maxSimultaneousLights: int;
  63683. private _shadowOnly;
  63684. /**
  63685. * Make the material only render shadows
  63686. */
  63687. shadowOnly: boolean;
  63688. /**
  63689. * Default configuration related to image processing available in the Background Material.
  63690. */
  63691. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  63692. /**
  63693. * Keep track of the image processing observer to allow dispose and replace.
  63694. */
  63695. private _imageProcessingObserver;
  63696. /**
  63697. * Attaches a new image processing configuration to the PBR Material.
  63698. * @param configuration (if null the scene configuration will be use)
  63699. */
  63700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  63701. /**
  63702. * Gets the image processing configuration used either in this material.
  63703. */
  63704. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  63705. /**
  63706. * Sets the Default image processing configuration used either in the this material.
  63707. *
  63708. * If sets to null, the scene one is in use.
  63709. */
  63710. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  63711. /**
  63712. * Gets wether the color curves effect is enabled.
  63713. */
  63714. get cameraColorCurvesEnabled(): boolean;
  63715. /**
  63716. * Sets wether the color curves effect is enabled.
  63717. */
  63718. set cameraColorCurvesEnabled(value: boolean);
  63719. /**
  63720. * Gets wether the color grading effect is enabled.
  63721. */
  63722. get cameraColorGradingEnabled(): boolean;
  63723. /**
  63724. * Gets wether the color grading effect is enabled.
  63725. */
  63726. set cameraColorGradingEnabled(value: boolean);
  63727. /**
  63728. * Gets wether tonemapping is enabled or not.
  63729. */
  63730. get cameraToneMappingEnabled(): boolean;
  63731. /**
  63732. * Sets wether tonemapping is enabled or not
  63733. */
  63734. set cameraToneMappingEnabled(value: boolean);
  63735. /**
  63736. * The camera exposure used on this material.
  63737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  63738. * This corresponds to a photographic exposure.
  63739. */
  63740. get cameraExposure(): float;
  63741. /**
  63742. * The camera exposure used on this material.
  63743. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  63744. * This corresponds to a photographic exposure.
  63745. */
  63746. set cameraExposure(value: float);
  63747. /**
  63748. * Gets The camera contrast used on this material.
  63749. */
  63750. get cameraContrast(): float;
  63751. /**
  63752. * Sets The camera contrast used on this material.
  63753. */
  63754. set cameraContrast(value: float);
  63755. /**
  63756. * Gets the Color Grading 2D Lookup Texture.
  63757. */
  63758. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  63759. /**
  63760. * Sets the Color Grading 2D Lookup Texture.
  63761. */
  63762. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  63763. /**
  63764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  63765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  63766. * 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;
  63767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  63768. */
  63769. get cameraColorCurves(): Nullable<ColorCurves>;
  63770. /**
  63771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  63772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  63773. * 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;
  63774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  63775. */
  63776. set cameraColorCurves(value: Nullable<ColorCurves>);
  63777. /**
  63778. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  63779. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  63780. */
  63781. switchToBGR: boolean;
  63782. private _renderTargets;
  63783. private _reflectionControls;
  63784. private _white;
  63785. private _primaryShadowColor;
  63786. private _primaryHighlightColor;
  63787. /**
  63788. * Instantiates a Background Material in the given scene
  63789. * @param name The friendly name of the material
  63790. * @param scene The scene to add the material to
  63791. */
  63792. constructor(name: string, scene: Scene);
  63793. /**
  63794. * Gets a boolean indicating that current material needs to register RTT
  63795. */
  63796. get hasRenderTargetTextures(): boolean;
  63797. /**
  63798. * The entire material has been created in order to prevent overdraw.
  63799. * @returns false
  63800. */
  63801. needAlphaTesting(): boolean;
  63802. /**
  63803. * The entire material has been created in order to prevent overdraw.
  63804. * @returns true if blending is enable
  63805. */
  63806. needAlphaBlending(): boolean;
  63807. /**
  63808. * Checks wether the material is ready to be rendered for a given mesh.
  63809. * @param mesh The mesh to render
  63810. * @param subMesh The submesh to check against
  63811. * @param useInstances Specify wether or not the material is used with instances
  63812. * @returns true if all the dependencies are ready (Textures, Effects...)
  63813. */
  63814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  63815. /**
  63816. * Compute the primary color according to the chosen perceptual color.
  63817. */
  63818. private _computePrimaryColorFromPerceptualColor;
  63819. /**
  63820. * Compute the highlights and shadow colors according to their chosen levels.
  63821. */
  63822. private _computePrimaryColors;
  63823. /**
  63824. * Build the uniform buffer used in the material.
  63825. */
  63826. buildUniformLayout(): void;
  63827. /**
  63828. * Unbind the material.
  63829. */
  63830. unbind(): void;
  63831. /**
  63832. * Bind only the world matrix to the material.
  63833. * @param world The world matrix to bind.
  63834. */
  63835. bindOnlyWorldMatrix(world: Matrix): void;
  63836. /**
  63837. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  63838. * @param world The world matrix to bind.
  63839. * @param subMesh The submesh to bind for.
  63840. */
  63841. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  63842. /**
  63843. * Checks to see if a texture is used in the material.
  63844. * @param texture - Base texture to use.
  63845. * @returns - Boolean specifying if a texture is used in the material.
  63846. */
  63847. hasTexture(texture: BaseTexture): boolean;
  63848. /**
  63849. * Dispose the material.
  63850. * @param forceDisposeEffect Force disposal of the associated effect.
  63851. * @param forceDisposeTextures Force disposal of the associated textures.
  63852. */
  63853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  63854. /**
  63855. * Clones the material.
  63856. * @param name The cloned name.
  63857. * @returns The cloned material.
  63858. */
  63859. clone(name: string): BackgroundMaterial;
  63860. /**
  63861. * Serializes the current material to its JSON representation.
  63862. * @returns The JSON representation.
  63863. */
  63864. serialize(): any;
  63865. /**
  63866. * Gets the class name of the material
  63867. * @returns "BackgroundMaterial"
  63868. */
  63869. getClassName(): string;
  63870. /**
  63871. * Parse a JSON input to create back a background material.
  63872. * @param source The JSON data to parse
  63873. * @param scene The scene to create the parsed material in
  63874. * @param rootUrl The root url of the assets the material depends upon
  63875. * @returns the instantiated BackgroundMaterial.
  63876. */
  63877. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  63878. }
  63879. }
  63880. declare module "babylonjs/Helpers/environmentHelper" {
  63881. import { Observable } from "babylonjs/Misc/observable";
  63882. import { Nullable } from "babylonjs/types";
  63883. import { Scene } from "babylonjs/scene";
  63884. import { Vector3 } from "babylonjs/Maths/math.vector";
  63885. import { Color3 } from "babylonjs/Maths/math.color";
  63886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63887. import { Mesh } from "babylonjs/Meshes/mesh";
  63888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63889. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  63890. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  63891. import "babylonjs/Meshes/Builders/planeBuilder";
  63892. import "babylonjs/Meshes/Builders/boxBuilder";
  63893. /**
  63894. * Represents the different options available during the creation of
  63895. * a Environment helper.
  63896. *
  63897. * This can control the default ground, skybox and image processing setup of your scene.
  63898. */
  63899. export interface IEnvironmentHelperOptions {
  63900. /**
  63901. * Specifies whether or not to create a ground.
  63902. * True by default.
  63903. */
  63904. createGround: boolean;
  63905. /**
  63906. * Specifies the ground size.
  63907. * 15 by default.
  63908. */
  63909. groundSize: number;
  63910. /**
  63911. * The texture used on the ground for the main color.
  63912. * Comes from the BabylonJS CDN by default.
  63913. *
  63914. * Remarks: Can be either a texture or a url.
  63915. */
  63916. groundTexture: string | BaseTexture;
  63917. /**
  63918. * The color mixed in the ground texture by default.
  63919. * BabylonJS clearColor by default.
  63920. */
  63921. groundColor: Color3;
  63922. /**
  63923. * Specifies the ground opacity.
  63924. * 1 by default.
  63925. */
  63926. groundOpacity: number;
  63927. /**
  63928. * Enables the ground to receive shadows.
  63929. * True by default.
  63930. */
  63931. enableGroundShadow: boolean;
  63932. /**
  63933. * Helps preventing the shadow to be fully black on the ground.
  63934. * 0.5 by default.
  63935. */
  63936. groundShadowLevel: number;
  63937. /**
  63938. * Creates a mirror texture attach to the ground.
  63939. * false by default.
  63940. */
  63941. enableGroundMirror: boolean;
  63942. /**
  63943. * Specifies the ground mirror size ratio.
  63944. * 0.3 by default as the default kernel is 64.
  63945. */
  63946. groundMirrorSizeRatio: number;
  63947. /**
  63948. * Specifies the ground mirror blur kernel size.
  63949. * 64 by default.
  63950. */
  63951. groundMirrorBlurKernel: number;
  63952. /**
  63953. * Specifies the ground mirror visibility amount.
  63954. * 1 by default
  63955. */
  63956. groundMirrorAmount: number;
  63957. /**
  63958. * Specifies the ground mirror reflectance weight.
  63959. * This uses the standard weight of the background material to setup the fresnel effect
  63960. * of the mirror.
  63961. * 1 by default.
  63962. */
  63963. groundMirrorFresnelWeight: number;
  63964. /**
  63965. * Specifies the ground mirror Falloff distance.
  63966. * This can helps reducing the size of the reflection.
  63967. * 0 by Default.
  63968. */
  63969. groundMirrorFallOffDistance: number;
  63970. /**
  63971. * Specifies the ground mirror texture type.
  63972. * Unsigned Int by Default.
  63973. */
  63974. groundMirrorTextureType: number;
  63975. /**
  63976. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  63977. * the shown objects.
  63978. */
  63979. groundYBias: number;
  63980. /**
  63981. * Specifies whether or not to create a skybox.
  63982. * True by default.
  63983. */
  63984. createSkybox: boolean;
  63985. /**
  63986. * Specifies the skybox size.
  63987. * 20 by default.
  63988. */
  63989. skyboxSize: number;
  63990. /**
  63991. * The texture used on the skybox for the main color.
  63992. * Comes from the BabylonJS CDN by default.
  63993. *
  63994. * Remarks: Can be either a texture or a url.
  63995. */
  63996. skyboxTexture: string | BaseTexture;
  63997. /**
  63998. * The color mixed in the skybox texture by default.
  63999. * BabylonJS clearColor by default.
  64000. */
  64001. skyboxColor: Color3;
  64002. /**
  64003. * The background rotation around the Y axis of the scene.
  64004. * This helps aligning the key lights of your scene with the background.
  64005. * 0 by default.
  64006. */
  64007. backgroundYRotation: number;
  64008. /**
  64009. * Compute automatically the size of the elements to best fit with the scene.
  64010. */
  64011. sizeAuto: boolean;
  64012. /**
  64013. * Default position of the rootMesh if autoSize is not true.
  64014. */
  64015. rootPosition: Vector3;
  64016. /**
  64017. * Sets up the image processing in the scene.
  64018. * true by default.
  64019. */
  64020. setupImageProcessing: boolean;
  64021. /**
  64022. * The texture used as your environment texture in the scene.
  64023. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  64024. *
  64025. * Remarks: Can be either a texture or a url.
  64026. */
  64027. environmentTexture: string | BaseTexture;
  64028. /**
  64029. * The value of the exposure to apply to the scene.
  64030. * 0.6 by default if setupImageProcessing is true.
  64031. */
  64032. cameraExposure: number;
  64033. /**
  64034. * The value of the contrast to apply to the scene.
  64035. * 1.6 by default if setupImageProcessing is true.
  64036. */
  64037. cameraContrast: number;
  64038. /**
  64039. * Specifies whether or not tonemapping should be enabled in the scene.
  64040. * true by default if setupImageProcessing is true.
  64041. */
  64042. toneMappingEnabled: boolean;
  64043. }
  64044. /**
  64045. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  64046. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  64047. * It also helps with the default setup of your imageProcessing configuration.
  64048. */
  64049. export class EnvironmentHelper {
  64050. /**
  64051. * Default ground texture URL.
  64052. */
  64053. private static _groundTextureCDNUrl;
  64054. /**
  64055. * Default skybox texture URL.
  64056. */
  64057. private static _skyboxTextureCDNUrl;
  64058. /**
  64059. * Default environment texture URL.
  64060. */
  64061. private static _environmentTextureCDNUrl;
  64062. /**
  64063. * Creates the default options for the helper.
  64064. */
  64065. private static _getDefaultOptions;
  64066. private _rootMesh;
  64067. /**
  64068. * Gets the root mesh created by the helper.
  64069. */
  64070. get rootMesh(): Mesh;
  64071. private _skybox;
  64072. /**
  64073. * Gets the skybox created by the helper.
  64074. */
  64075. get skybox(): Nullable<Mesh>;
  64076. private _skyboxTexture;
  64077. /**
  64078. * Gets the skybox texture created by the helper.
  64079. */
  64080. get skyboxTexture(): Nullable<BaseTexture>;
  64081. private _skyboxMaterial;
  64082. /**
  64083. * Gets the skybox material created by the helper.
  64084. */
  64085. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  64086. private _ground;
  64087. /**
  64088. * Gets the ground mesh created by the helper.
  64089. */
  64090. get ground(): Nullable<Mesh>;
  64091. private _groundTexture;
  64092. /**
  64093. * Gets the ground texture created by the helper.
  64094. */
  64095. get groundTexture(): Nullable<BaseTexture>;
  64096. private _groundMirror;
  64097. /**
  64098. * Gets the ground mirror created by the helper.
  64099. */
  64100. get groundMirror(): Nullable<MirrorTexture>;
  64101. /**
  64102. * Gets the ground mirror render list to helps pushing the meshes
  64103. * you wish in the ground reflection.
  64104. */
  64105. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  64106. private _groundMaterial;
  64107. /**
  64108. * Gets the ground material created by the helper.
  64109. */
  64110. get groundMaterial(): Nullable<BackgroundMaterial>;
  64111. /**
  64112. * Stores the creation options.
  64113. */
  64114. private readonly _scene;
  64115. private _options;
  64116. /**
  64117. * This observable will be notified with any error during the creation of the environment,
  64118. * mainly texture creation errors.
  64119. */
  64120. onErrorObservable: Observable<{
  64121. message?: string;
  64122. exception?: any;
  64123. }>;
  64124. /**
  64125. * constructor
  64126. * @param options Defines the options we want to customize the helper
  64127. * @param scene The scene to add the material to
  64128. */
  64129. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  64130. /**
  64131. * Updates the background according to the new options
  64132. * @param options
  64133. */
  64134. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  64135. /**
  64136. * Sets the primary color of all the available elements.
  64137. * @param color the main color to affect to the ground and the background
  64138. */
  64139. setMainColor(color: Color3): void;
  64140. /**
  64141. * Setup the image processing according to the specified options.
  64142. */
  64143. private _setupImageProcessing;
  64144. /**
  64145. * Setup the environment texture according to the specified options.
  64146. */
  64147. private _setupEnvironmentTexture;
  64148. /**
  64149. * Setup the background according to the specified options.
  64150. */
  64151. private _setupBackground;
  64152. /**
  64153. * Get the scene sizes according to the setup.
  64154. */
  64155. private _getSceneSize;
  64156. /**
  64157. * Setup the ground according to the specified options.
  64158. */
  64159. private _setupGround;
  64160. /**
  64161. * Setup the ground material according to the specified options.
  64162. */
  64163. private _setupGroundMaterial;
  64164. /**
  64165. * Setup the ground diffuse texture according to the specified options.
  64166. */
  64167. private _setupGroundDiffuseTexture;
  64168. /**
  64169. * Setup the ground mirror texture according to the specified options.
  64170. */
  64171. private _setupGroundMirrorTexture;
  64172. /**
  64173. * Setup the ground to receive the mirror texture.
  64174. */
  64175. private _setupMirrorInGroundMaterial;
  64176. /**
  64177. * Setup the skybox according to the specified options.
  64178. */
  64179. private _setupSkybox;
  64180. /**
  64181. * Setup the skybox material according to the specified options.
  64182. */
  64183. private _setupSkyboxMaterial;
  64184. /**
  64185. * Setup the skybox reflection texture according to the specified options.
  64186. */
  64187. private _setupSkyboxReflectionTexture;
  64188. private _errorHandler;
  64189. /**
  64190. * Dispose all the elements created by the Helper.
  64191. */
  64192. dispose(): void;
  64193. }
  64194. }
  64195. declare module "babylonjs/Helpers/textureDome" {
  64196. import { Scene } from "babylonjs/scene";
  64197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64198. import { Mesh } from "babylonjs/Meshes/mesh";
  64199. import { Texture } from "babylonjs/Materials/Textures/texture";
  64200. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64201. import "babylonjs/Meshes/Builders/sphereBuilder";
  64202. import { Nullable } from "babylonjs/types";
  64203. import { Observable } from "babylonjs/Misc/observable";
  64204. /**
  64205. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  64206. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  64207. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64208. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64209. */
  64210. export abstract class TextureDome<T extends Texture> extends TransformNode {
  64211. protected onError: Nullable<(message?: string, exception?: any) => void>;
  64212. /**
  64213. * Define the source as a Monoscopic panoramic 360/180.
  64214. */
  64215. static readonly MODE_MONOSCOPIC: number;
  64216. /**
  64217. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  64218. */
  64219. static readonly MODE_TOPBOTTOM: number;
  64220. /**
  64221. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  64222. */
  64223. static readonly MODE_SIDEBYSIDE: number;
  64224. private _halfDome;
  64225. private _crossEye;
  64226. protected _useDirectMapping: boolean;
  64227. /**
  64228. * The texture being displayed on the sphere
  64229. */
  64230. protected _texture: T;
  64231. /**
  64232. * Gets the texture being displayed on the sphere
  64233. */
  64234. get texture(): T;
  64235. /**
  64236. * Sets the texture being displayed on the sphere
  64237. */
  64238. set texture(newTexture: T);
  64239. /**
  64240. * The skybox material
  64241. */
  64242. protected _material: BackgroundMaterial;
  64243. /**
  64244. * The surface used for the dome
  64245. */
  64246. protected _mesh: Mesh;
  64247. /**
  64248. * Gets the mesh used for the dome.
  64249. */
  64250. get mesh(): Mesh;
  64251. /**
  64252. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  64253. */
  64254. private _halfDomeMask;
  64255. /**
  64256. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  64257. * Also see the options.resolution property.
  64258. */
  64259. get fovMultiplier(): number;
  64260. set fovMultiplier(value: number);
  64261. protected _textureMode: number;
  64262. /**
  64263. * Gets or set the current texture mode for the texture. It can be:
  64264. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64265. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64266. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64267. */
  64268. get textureMode(): number;
  64269. /**
  64270. * Sets the current texture mode for the texture. It can be:
  64271. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64272. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64273. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64274. */
  64275. set textureMode(value: number);
  64276. /**
  64277. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  64278. */
  64279. get halfDome(): boolean;
  64280. /**
  64281. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  64282. */
  64283. set halfDome(enabled: boolean);
  64284. /**
  64285. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  64286. */
  64287. set crossEye(enabled: boolean);
  64288. /**
  64289. * Is it a cross-eye texture?
  64290. */
  64291. get crossEye(): boolean;
  64292. /**
  64293. * The background material of this dome.
  64294. */
  64295. get material(): BackgroundMaterial;
  64296. /**
  64297. * Oberserver used in Stereoscopic VR Mode.
  64298. */
  64299. private _onBeforeCameraRenderObserver;
  64300. /**
  64301. * Observable raised when an error occured while loading the 360 image
  64302. */
  64303. onLoadErrorObservable: Observable<string>;
  64304. /**
  64305. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  64306. * @param name Element's name, child elements will append suffixes for their own names.
  64307. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  64308. * @param options An object containing optional or exposed sub element properties
  64309. */
  64310. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  64311. resolution?: number;
  64312. clickToPlay?: boolean;
  64313. autoPlay?: boolean;
  64314. loop?: boolean;
  64315. size?: number;
  64316. poster?: string;
  64317. faceForward?: boolean;
  64318. useDirectMapping?: boolean;
  64319. halfDomeMode?: boolean;
  64320. crossEyeMode?: boolean;
  64321. generateMipMaps?: boolean;
  64322. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  64323. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  64324. protected _changeTextureMode(value: number): void;
  64325. /**
  64326. * Releases resources associated with this node.
  64327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64329. */
  64330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64331. }
  64332. }
  64333. declare module "babylonjs/Helpers/photoDome" {
  64334. import { Scene } from "babylonjs/scene";
  64335. import { Texture } from "babylonjs/Materials/Textures/texture";
  64336. import { TextureDome } from "babylonjs/Helpers/textureDome";
  64337. /**
  64338. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  64339. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  64340. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64341. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64342. */
  64343. export class PhotoDome extends TextureDome<Texture> {
  64344. /**
  64345. * Define the image as a Monoscopic panoramic 360 image.
  64346. */
  64347. static readonly MODE_MONOSCOPIC: number;
  64348. /**
  64349. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  64350. */
  64351. static readonly MODE_TOPBOTTOM: number;
  64352. /**
  64353. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  64354. */
  64355. static readonly MODE_SIDEBYSIDE: number;
  64356. /**
  64357. * Gets or sets the texture being displayed on the sphere
  64358. */
  64359. get photoTexture(): Texture;
  64360. /**
  64361. * sets the texture being displayed on the sphere
  64362. */
  64363. set photoTexture(value: Texture);
  64364. /**
  64365. * Gets the current video mode for the video. It can be:
  64366. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64367. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64368. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64369. */
  64370. get imageMode(): number;
  64371. /**
  64372. * Sets the current video mode for the video. It can be:
  64373. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64374. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64375. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64376. */
  64377. set imageMode(value: number);
  64378. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  64379. }
  64380. }
  64381. declare module "babylonjs/Misc/dds" {
  64382. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64384. import { Nullable } from "babylonjs/types";
  64385. import { Scene } from "babylonjs/scene";
  64386. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  64387. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64388. /**
  64389. * Direct draw surface info
  64390. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  64391. */
  64392. export interface DDSInfo {
  64393. /**
  64394. * Width of the texture
  64395. */
  64396. width: number;
  64397. /**
  64398. * Width of the texture
  64399. */
  64400. height: number;
  64401. /**
  64402. * Number of Mipmaps for the texture
  64403. * @see https://en.wikipedia.org/wiki/Mipmap
  64404. */
  64405. mipmapCount: number;
  64406. /**
  64407. * If the textures format is a known fourCC format
  64408. * @see https://www.fourcc.org/
  64409. */
  64410. isFourCC: boolean;
  64411. /**
  64412. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  64413. */
  64414. isRGB: boolean;
  64415. /**
  64416. * If the texture is a lumincance format
  64417. */
  64418. isLuminance: boolean;
  64419. /**
  64420. * If this is a cube texture
  64421. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  64422. */
  64423. isCube: boolean;
  64424. /**
  64425. * If the texture is a compressed format eg. FOURCC_DXT1
  64426. */
  64427. isCompressed: boolean;
  64428. /**
  64429. * The dxgiFormat of the texture
  64430. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  64431. */
  64432. dxgiFormat: number;
  64433. /**
  64434. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  64435. */
  64436. textureType: number;
  64437. /**
  64438. * Sphericle polynomial created for the dds texture
  64439. */
  64440. sphericalPolynomial?: SphericalPolynomial;
  64441. }
  64442. /**
  64443. * Class used to provide DDS decompression tools
  64444. */
  64445. export class DDSTools {
  64446. /**
  64447. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  64448. */
  64449. static StoreLODInAlphaChannel: boolean;
  64450. /**
  64451. * Gets DDS information from an array buffer
  64452. * @param data defines the array buffer view to read data from
  64453. * @returns the DDS information
  64454. */
  64455. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  64456. private static _FloatView;
  64457. private static _Int32View;
  64458. private static _ToHalfFloat;
  64459. private static _FromHalfFloat;
  64460. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  64461. private static _GetHalfFloatRGBAArrayBuffer;
  64462. private static _GetFloatRGBAArrayBuffer;
  64463. private static _GetFloatAsUIntRGBAArrayBuffer;
  64464. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  64465. private static _GetRGBAArrayBuffer;
  64466. private static _ExtractLongWordOrder;
  64467. private static _GetRGBArrayBuffer;
  64468. private static _GetLuminanceArrayBuffer;
  64469. /**
  64470. * Uploads DDS Levels to a Babylon Texture
  64471. * @hidden
  64472. */
  64473. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  64474. }
  64475. module "babylonjs/Engines/thinEngine" {
  64476. interface ThinEngine {
  64477. /**
  64478. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  64479. * @param rootUrl defines the url where the file to load is located
  64480. * @param scene defines the current scene
  64481. * @param lodScale defines scale to apply to the mip map selection
  64482. * @param lodOffset defines offset to apply to the mip map selection
  64483. * @param onLoad defines an optional callback raised when the texture is loaded
  64484. * @param onError defines an optional callback raised if there is an issue to load the texture
  64485. * @param format defines the format of the data
  64486. * @param forcedExtension defines the extension to use to pick the right loader
  64487. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  64488. * @returns the cube texture as an InternalTexture
  64489. */
  64490. 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;
  64491. }
  64492. }
  64493. }
  64494. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  64495. import { Nullable } from "babylonjs/types";
  64496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64497. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64498. /**
  64499. * Implementation of the DDS Texture Loader.
  64500. * @hidden
  64501. */
  64502. export class _DDSTextureLoader implements IInternalTextureLoader {
  64503. /**
  64504. * Defines wether the loader supports cascade loading the different faces.
  64505. */
  64506. readonly supportCascades: boolean;
  64507. /**
  64508. * This returns if the loader support the current file information.
  64509. * @param extension defines the file extension of the file being loaded
  64510. * @returns true if the loader can load the specified file
  64511. */
  64512. canLoad(extension: string): boolean;
  64513. /**
  64514. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64515. * @param data contains the texture data
  64516. * @param texture defines the BabylonJS internal texture
  64517. * @param createPolynomials will be true if polynomials have been requested
  64518. * @param onLoad defines the callback to trigger once the texture is ready
  64519. * @param onError defines the callback to trigger in case of error
  64520. */
  64521. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64522. /**
  64523. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64524. * @param data contains the texture data
  64525. * @param texture defines the BabylonJS internal texture
  64526. * @param callback defines the method to call once ready to upload
  64527. */
  64528. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64529. }
  64530. }
  64531. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  64532. import { Nullable } from "babylonjs/types";
  64533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64534. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64535. /**
  64536. * Implementation of the ENV Texture Loader.
  64537. * @hidden
  64538. */
  64539. export class _ENVTextureLoader implements IInternalTextureLoader {
  64540. /**
  64541. * Defines wether the loader supports cascade loading the different faces.
  64542. */
  64543. readonly supportCascades: boolean;
  64544. /**
  64545. * This returns if the loader support the current file information.
  64546. * @param extension defines the file extension of the file being loaded
  64547. * @returns true if the loader can load the specified file
  64548. */
  64549. canLoad(extension: string): boolean;
  64550. /**
  64551. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64552. * @param data contains the texture data
  64553. * @param texture defines the BabylonJS internal texture
  64554. * @param createPolynomials will be true if polynomials have been requested
  64555. * @param onLoad defines the callback to trigger once the texture is ready
  64556. * @param onError defines the callback to trigger in case of error
  64557. */
  64558. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64559. /**
  64560. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64561. * @param data contains the texture data
  64562. * @param texture defines the BabylonJS internal texture
  64563. * @param callback defines the method to call once ready to upload
  64564. */
  64565. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64566. }
  64567. }
  64568. declare module "babylonjs/Misc/khronosTextureContainer" {
  64569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64570. /**
  64571. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  64572. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  64573. */
  64574. export class KhronosTextureContainer {
  64575. /** contents of the KTX container file */
  64576. data: ArrayBufferView;
  64577. private static HEADER_LEN;
  64578. private static COMPRESSED_2D;
  64579. private static COMPRESSED_3D;
  64580. private static TEX_2D;
  64581. private static TEX_3D;
  64582. /**
  64583. * Gets the openGL type
  64584. */
  64585. glType: number;
  64586. /**
  64587. * Gets the openGL type size
  64588. */
  64589. glTypeSize: number;
  64590. /**
  64591. * Gets the openGL format
  64592. */
  64593. glFormat: number;
  64594. /**
  64595. * Gets the openGL internal format
  64596. */
  64597. glInternalFormat: number;
  64598. /**
  64599. * Gets the base internal format
  64600. */
  64601. glBaseInternalFormat: number;
  64602. /**
  64603. * Gets image width in pixel
  64604. */
  64605. pixelWidth: number;
  64606. /**
  64607. * Gets image height in pixel
  64608. */
  64609. pixelHeight: number;
  64610. /**
  64611. * Gets image depth in pixels
  64612. */
  64613. pixelDepth: number;
  64614. /**
  64615. * Gets the number of array elements
  64616. */
  64617. numberOfArrayElements: number;
  64618. /**
  64619. * Gets the number of faces
  64620. */
  64621. numberOfFaces: number;
  64622. /**
  64623. * Gets the number of mipmap levels
  64624. */
  64625. numberOfMipmapLevels: number;
  64626. /**
  64627. * Gets the bytes of key value data
  64628. */
  64629. bytesOfKeyValueData: number;
  64630. /**
  64631. * Gets the load type
  64632. */
  64633. loadType: number;
  64634. /**
  64635. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  64636. */
  64637. isInvalid: boolean;
  64638. /**
  64639. * Creates a new KhronosTextureContainer
  64640. * @param data contents of the KTX container file
  64641. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  64642. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  64643. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  64644. */
  64645. constructor(
  64646. /** contents of the KTX container file */
  64647. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  64648. /**
  64649. * Uploads KTX content to a Babylon Texture.
  64650. * It is assumed that the texture has already been created & is currently bound
  64651. * @hidden
  64652. */
  64653. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  64654. private _upload2DCompressedLevels;
  64655. /**
  64656. * Checks if the given data starts with a KTX file identifier.
  64657. * @param data the data to check
  64658. * @returns true if the data is a KTX file or false otherwise
  64659. */
  64660. static IsValid(data: ArrayBufferView): boolean;
  64661. }
  64662. }
  64663. declare module "babylonjs/Misc/workerPool" {
  64664. import { IDisposable } from "babylonjs/scene";
  64665. /**
  64666. * Helper class to push actions to a pool of workers.
  64667. */
  64668. export class WorkerPool implements IDisposable {
  64669. private _workerInfos;
  64670. private _pendingActions;
  64671. /**
  64672. * Constructor
  64673. * @param workers Array of workers to use for actions
  64674. */
  64675. constructor(workers: Array<Worker>);
  64676. /**
  64677. * Terminates all workers and clears any pending actions.
  64678. */
  64679. dispose(): void;
  64680. /**
  64681. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64682. * pended until a worker has completed its action.
  64683. * @param action The action to perform. Call onComplete when the action is complete.
  64684. */
  64685. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64686. private _execute;
  64687. }
  64688. }
  64689. declare module "babylonjs/Misc/khronosTextureContainer2" {
  64690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64691. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64692. /**
  64693. * Class for loading KTX2 files
  64694. */
  64695. export class KhronosTextureContainer2 {
  64696. private static _WorkerPoolPromise?;
  64697. private static _Initialized;
  64698. private static _Ktx2Decoder;
  64699. /**
  64700. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  64701. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  64702. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  64703. * Urls you can change:
  64704. * URLConfig.jsDecoderModule
  64705. * URLConfig.wasmUASTCToASTC
  64706. * URLConfig.wasmUASTCToBC7
  64707. * URLConfig.wasmUASTCToRGBA_UNORM
  64708. * URLConfig.wasmUASTCToRGBA_SRGB
  64709. * URLConfig.jsMSCTranscoder
  64710. * URLConfig.wasmMSCTranscoder
  64711. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  64712. */
  64713. static URLConfig: {
  64714. jsDecoderModule: string;
  64715. wasmUASTCToASTC: null;
  64716. wasmUASTCToBC7: null;
  64717. wasmUASTCToRGBA_UNORM: null;
  64718. wasmUASTCToRGBA_SRGB: null;
  64719. jsMSCTranscoder: null;
  64720. wasmMSCTranscoder: null;
  64721. };
  64722. /**
  64723. * Default number of workers used to handle data decoding
  64724. */
  64725. static DefaultNumWorkers: number;
  64726. private static GetDefaultNumWorkers;
  64727. private _engine;
  64728. private static _CreateWorkerPool;
  64729. /**
  64730. * Constructor
  64731. * @param engine The engine to use
  64732. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64733. */
  64734. constructor(engine: ThinEngine, numWorkers?: number);
  64735. /** @hidden */
  64736. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  64737. /**
  64738. * Stop all async operations and release resources.
  64739. */
  64740. dispose(): void;
  64741. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  64742. /**
  64743. * Checks if the given data starts with a KTX2 file identifier.
  64744. * @param data the data to check
  64745. * @returns true if the data is a KTX2 file or false otherwise
  64746. */
  64747. static IsValid(data: ArrayBufferView): boolean;
  64748. }
  64749. }
  64750. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  64751. import { Nullable } from "babylonjs/types";
  64752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64753. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64754. /**
  64755. * Implementation of the KTX Texture Loader.
  64756. * @hidden
  64757. */
  64758. export class _KTXTextureLoader implements IInternalTextureLoader {
  64759. /**
  64760. * Defines wether the loader supports cascade loading the different faces.
  64761. */
  64762. readonly supportCascades: boolean;
  64763. /**
  64764. * This returns if the loader support the current file information.
  64765. * @param extension defines the file extension of the file being loaded
  64766. * @param mimeType defines the optional mime type of the file being loaded
  64767. * @returns true if the loader can load the specified file
  64768. */
  64769. canLoad(extension: string, mimeType?: string): boolean;
  64770. /**
  64771. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64772. * @param data contains the texture data
  64773. * @param texture defines the BabylonJS internal texture
  64774. * @param createPolynomials will be true if polynomials have been requested
  64775. * @param onLoad defines the callback to trigger once the texture is ready
  64776. * @param onError defines the callback to trigger in case of error
  64777. */
  64778. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64779. /**
  64780. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64781. * @param data contains the texture data
  64782. * @param texture defines the BabylonJS internal texture
  64783. * @param callback defines the method to call once ready to upload
  64784. */
  64785. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  64786. }
  64787. }
  64788. declare module "babylonjs/Helpers/sceneHelpers" {
  64789. import { Nullable } from "babylonjs/types";
  64790. import { Mesh } from "babylonjs/Meshes/mesh";
  64791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64792. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  64793. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  64794. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64795. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64796. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64797. import "babylonjs/Meshes/Builders/boxBuilder";
  64798. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  64799. /** @hidden */
  64800. export var _forceSceneHelpersToBundle: boolean;
  64801. module "babylonjs/scene" {
  64802. interface Scene {
  64803. /**
  64804. * Creates a default light for the scene.
  64805. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  64806. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  64807. */
  64808. createDefaultLight(replace?: boolean): void;
  64809. /**
  64810. * Creates a default camera for the scene.
  64811. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  64812. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  64813. * @param replace has default false, when true replaces the active camera in the scene
  64814. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  64815. */
  64816. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  64817. /**
  64818. * Creates a default camera and a default light.
  64819. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  64820. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  64821. * @param replace has the default false, when true replaces the active camera/light in the scene
  64822. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  64823. */
  64824. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  64825. /**
  64826. * Creates a new sky box
  64827. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  64828. * @param environmentTexture defines the texture to use as environment texture
  64829. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  64830. * @param scale defines the overall scale of the skybox
  64831. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  64832. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  64833. * @returns a new mesh holding the sky box
  64834. */
  64835. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  64836. /**
  64837. * Creates a new environment
  64838. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  64839. * @param options defines the options you can use to configure the environment
  64840. * @returns the new EnvironmentHelper
  64841. */
  64842. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  64843. /**
  64844. * Creates a new VREXperienceHelper
  64845. * @see https://doc.babylonjs.com/how_to/webvr_helper
  64846. * @param webVROptions defines the options used to create the new VREXperienceHelper
  64847. * @returns a new VREXperienceHelper
  64848. */
  64849. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  64850. /**
  64851. * Creates a new WebXRDefaultExperience
  64852. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  64853. * @param options experience options
  64854. * @returns a promise for a new WebXRDefaultExperience
  64855. */
  64856. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  64857. }
  64858. }
  64859. }
  64860. declare module "babylonjs/Helpers/videoDome" {
  64861. import { Scene } from "babylonjs/scene";
  64862. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  64863. import { TextureDome } from "babylonjs/Helpers/textureDome";
  64864. /**
  64865. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  64866. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  64867. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  64868. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64869. */
  64870. export class VideoDome extends TextureDome<VideoTexture> {
  64871. /**
  64872. * Define the video source as a Monoscopic panoramic 360 video.
  64873. */
  64874. static readonly MODE_MONOSCOPIC: number;
  64875. /**
  64876. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  64877. */
  64878. static readonly MODE_TOPBOTTOM: number;
  64879. /**
  64880. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  64881. */
  64882. static readonly MODE_SIDEBYSIDE: number;
  64883. /**
  64884. * Get the video texture associated with this video dome
  64885. */
  64886. get videoTexture(): VideoTexture;
  64887. /**
  64888. * Get the video mode of this dome
  64889. */
  64890. get videoMode(): number;
  64891. /**
  64892. * Set the video mode of this dome.
  64893. * @see textureMode
  64894. */
  64895. set videoMode(value: number);
  64896. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  64897. }
  64898. }
  64899. declare module "babylonjs/Helpers/index" {
  64900. export * from "babylonjs/Helpers/environmentHelper";
  64901. export * from "babylonjs/Helpers/photoDome";
  64902. export * from "babylonjs/Helpers/sceneHelpers";
  64903. export * from "babylonjs/Helpers/videoDome";
  64904. }
  64905. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  64906. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  64907. import { IDisposable } from "babylonjs/scene";
  64908. import { Engine } from "babylonjs/Engines/engine";
  64909. /**
  64910. * This class can be used to get instrumentation data from a Babylon engine
  64911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  64912. */
  64913. export class EngineInstrumentation implements IDisposable {
  64914. /**
  64915. * Define the instrumented engine.
  64916. */
  64917. engine: Engine;
  64918. private _captureGPUFrameTime;
  64919. private _gpuFrameTimeToken;
  64920. private _gpuFrameTime;
  64921. private _captureShaderCompilationTime;
  64922. private _shaderCompilationTime;
  64923. private _onBeginFrameObserver;
  64924. private _onEndFrameObserver;
  64925. private _onBeforeShaderCompilationObserver;
  64926. private _onAfterShaderCompilationObserver;
  64927. /**
  64928. * Gets the perf counter used for GPU frame time
  64929. */
  64930. get gpuFrameTimeCounter(): PerfCounter;
  64931. /**
  64932. * Gets the GPU frame time capture status
  64933. */
  64934. get captureGPUFrameTime(): boolean;
  64935. /**
  64936. * Enable or disable the GPU frame time capture
  64937. */
  64938. set captureGPUFrameTime(value: boolean);
  64939. /**
  64940. * Gets the perf counter used for shader compilation time
  64941. */
  64942. get shaderCompilationTimeCounter(): PerfCounter;
  64943. /**
  64944. * Gets the shader compilation time capture status
  64945. */
  64946. get captureShaderCompilationTime(): boolean;
  64947. /**
  64948. * Enable or disable the shader compilation time capture
  64949. */
  64950. set captureShaderCompilationTime(value: boolean);
  64951. /**
  64952. * Instantiates a new engine instrumentation.
  64953. * This class can be used to get instrumentation data from a Babylon engine
  64954. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  64955. * @param engine Defines the engine to instrument
  64956. */
  64957. constructor(
  64958. /**
  64959. * Define the instrumented engine.
  64960. */
  64961. engine: Engine);
  64962. /**
  64963. * Dispose and release associated resources.
  64964. */
  64965. dispose(): void;
  64966. }
  64967. }
  64968. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  64969. import { Scene, IDisposable } from "babylonjs/scene";
  64970. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  64971. /**
  64972. * This class can be used to get instrumentation data from a Babylon engine
  64973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  64974. */
  64975. export class SceneInstrumentation implements IDisposable {
  64976. /**
  64977. * Defines the scene to instrument
  64978. */
  64979. scene: Scene;
  64980. private _captureActiveMeshesEvaluationTime;
  64981. private _activeMeshesEvaluationTime;
  64982. private _captureRenderTargetsRenderTime;
  64983. private _renderTargetsRenderTime;
  64984. private _captureFrameTime;
  64985. private _frameTime;
  64986. private _captureRenderTime;
  64987. private _renderTime;
  64988. private _captureInterFrameTime;
  64989. private _interFrameTime;
  64990. private _captureParticlesRenderTime;
  64991. private _particlesRenderTime;
  64992. private _captureSpritesRenderTime;
  64993. private _spritesRenderTime;
  64994. private _capturePhysicsTime;
  64995. private _physicsTime;
  64996. private _captureAnimationsTime;
  64997. private _animationsTime;
  64998. private _captureCameraRenderTime;
  64999. private _cameraRenderTime;
  65000. private _onBeforeActiveMeshesEvaluationObserver;
  65001. private _onAfterActiveMeshesEvaluationObserver;
  65002. private _onBeforeRenderTargetsRenderObserver;
  65003. private _onAfterRenderTargetsRenderObserver;
  65004. private _onAfterRenderObserver;
  65005. private _onBeforeDrawPhaseObserver;
  65006. private _onAfterDrawPhaseObserver;
  65007. private _onBeforeAnimationsObserver;
  65008. private _onBeforeParticlesRenderingObserver;
  65009. private _onAfterParticlesRenderingObserver;
  65010. private _onBeforeSpritesRenderingObserver;
  65011. private _onAfterSpritesRenderingObserver;
  65012. private _onBeforePhysicsObserver;
  65013. private _onAfterPhysicsObserver;
  65014. private _onAfterAnimationsObserver;
  65015. private _onBeforeCameraRenderObserver;
  65016. private _onAfterCameraRenderObserver;
  65017. /**
  65018. * Gets the perf counter used for active meshes evaluation time
  65019. */
  65020. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  65021. /**
  65022. * Gets the active meshes evaluation time capture status
  65023. */
  65024. get captureActiveMeshesEvaluationTime(): boolean;
  65025. /**
  65026. * Enable or disable the active meshes evaluation time capture
  65027. */
  65028. set captureActiveMeshesEvaluationTime(value: boolean);
  65029. /**
  65030. * Gets the perf counter used for render targets render time
  65031. */
  65032. get renderTargetsRenderTimeCounter(): PerfCounter;
  65033. /**
  65034. * Gets the render targets render time capture status
  65035. */
  65036. get captureRenderTargetsRenderTime(): boolean;
  65037. /**
  65038. * Enable or disable the render targets render time capture
  65039. */
  65040. set captureRenderTargetsRenderTime(value: boolean);
  65041. /**
  65042. * Gets the perf counter used for particles render time
  65043. */
  65044. get particlesRenderTimeCounter(): PerfCounter;
  65045. /**
  65046. * Gets the particles render time capture status
  65047. */
  65048. get captureParticlesRenderTime(): boolean;
  65049. /**
  65050. * Enable or disable the particles render time capture
  65051. */
  65052. set captureParticlesRenderTime(value: boolean);
  65053. /**
  65054. * Gets the perf counter used for sprites render time
  65055. */
  65056. get spritesRenderTimeCounter(): PerfCounter;
  65057. /**
  65058. * Gets the sprites render time capture status
  65059. */
  65060. get captureSpritesRenderTime(): boolean;
  65061. /**
  65062. * Enable or disable the sprites render time capture
  65063. */
  65064. set captureSpritesRenderTime(value: boolean);
  65065. /**
  65066. * Gets the perf counter used for physics time
  65067. */
  65068. get physicsTimeCounter(): PerfCounter;
  65069. /**
  65070. * Gets the physics time capture status
  65071. */
  65072. get capturePhysicsTime(): boolean;
  65073. /**
  65074. * Enable or disable the physics time capture
  65075. */
  65076. set capturePhysicsTime(value: boolean);
  65077. /**
  65078. * Gets the perf counter used for animations time
  65079. */
  65080. get animationsTimeCounter(): PerfCounter;
  65081. /**
  65082. * Gets the animations time capture status
  65083. */
  65084. get captureAnimationsTime(): boolean;
  65085. /**
  65086. * Enable or disable the animations time capture
  65087. */
  65088. set captureAnimationsTime(value: boolean);
  65089. /**
  65090. * Gets the perf counter used for frame time capture
  65091. */
  65092. get frameTimeCounter(): PerfCounter;
  65093. /**
  65094. * Gets the frame time capture status
  65095. */
  65096. get captureFrameTime(): boolean;
  65097. /**
  65098. * Enable or disable the frame time capture
  65099. */
  65100. set captureFrameTime(value: boolean);
  65101. /**
  65102. * Gets the perf counter used for inter-frames time capture
  65103. */
  65104. get interFrameTimeCounter(): PerfCounter;
  65105. /**
  65106. * Gets the inter-frames time capture status
  65107. */
  65108. get captureInterFrameTime(): boolean;
  65109. /**
  65110. * Enable or disable the inter-frames time capture
  65111. */
  65112. set captureInterFrameTime(value: boolean);
  65113. /**
  65114. * Gets the perf counter used for render time capture
  65115. */
  65116. get renderTimeCounter(): PerfCounter;
  65117. /**
  65118. * Gets the render time capture status
  65119. */
  65120. get captureRenderTime(): boolean;
  65121. /**
  65122. * Enable or disable the render time capture
  65123. */
  65124. set captureRenderTime(value: boolean);
  65125. /**
  65126. * Gets the perf counter used for camera render time capture
  65127. */
  65128. get cameraRenderTimeCounter(): PerfCounter;
  65129. /**
  65130. * Gets the camera render time capture status
  65131. */
  65132. get captureCameraRenderTime(): boolean;
  65133. /**
  65134. * Enable or disable the camera render time capture
  65135. */
  65136. set captureCameraRenderTime(value: boolean);
  65137. /**
  65138. * Gets the perf counter used for draw calls
  65139. */
  65140. get drawCallsCounter(): PerfCounter;
  65141. /**
  65142. * Instantiates a new scene instrumentation.
  65143. * This class can be used to get instrumentation data from a Babylon engine
  65144. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65145. * @param scene Defines the scene to instrument
  65146. */
  65147. constructor(
  65148. /**
  65149. * Defines the scene to instrument
  65150. */
  65151. scene: Scene);
  65152. /**
  65153. * Dispose and release associated resources.
  65154. */
  65155. dispose(): void;
  65156. }
  65157. }
  65158. declare module "babylonjs/Instrumentation/index" {
  65159. export * from "babylonjs/Instrumentation/engineInstrumentation";
  65160. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  65161. export * from "babylonjs/Instrumentation/timeToken";
  65162. }
  65163. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  65164. /** @hidden */
  65165. export var glowMapGenerationPixelShader: {
  65166. name: string;
  65167. shader: string;
  65168. };
  65169. }
  65170. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  65171. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65174. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65175. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65176. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65177. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65178. /** @hidden */
  65179. export var glowMapGenerationVertexShader: {
  65180. name: string;
  65181. shader: string;
  65182. };
  65183. }
  65184. declare module "babylonjs/Layers/effectLayer" {
  65185. import { Observable } from "babylonjs/Misc/observable";
  65186. import { Nullable } from "babylonjs/types";
  65187. import { Camera } from "babylonjs/Cameras/camera";
  65188. import { Scene } from "babylonjs/scene";
  65189. import { ISize } from "babylonjs/Maths/math.size";
  65190. import { Color4 } from "babylonjs/Maths/math.color";
  65191. import { Engine } from "babylonjs/Engines/engine";
  65192. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65194. import { Mesh } from "babylonjs/Meshes/mesh";
  65195. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65198. import { Effect } from "babylonjs/Materials/effect";
  65199. import { Material } from "babylonjs/Materials/material";
  65200. import "babylonjs/Shaders/glowMapGeneration.fragment";
  65201. import "babylonjs/Shaders/glowMapGeneration.vertex";
  65202. /**
  65203. * Effect layer options. This helps customizing the behaviour
  65204. * of the effect layer.
  65205. */
  65206. export interface IEffectLayerOptions {
  65207. /**
  65208. * Multiplication factor apply to the canvas size to compute the render target size
  65209. * used to generated the objects (the smaller the faster).
  65210. */
  65211. mainTextureRatio: number;
  65212. /**
  65213. * Enforces a fixed size texture to ensure effect stability across devices.
  65214. */
  65215. mainTextureFixedSize?: number;
  65216. /**
  65217. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  65218. */
  65219. alphaBlendingMode: number;
  65220. /**
  65221. * The camera attached to the layer.
  65222. */
  65223. camera: Nullable<Camera>;
  65224. /**
  65225. * The rendering group to draw the layer in.
  65226. */
  65227. renderingGroupId: number;
  65228. }
  65229. /**
  65230. * The effect layer Helps adding post process effect blended with the main pass.
  65231. *
  65232. * This can be for instance use to generate glow or higlight effects on the scene.
  65233. *
  65234. * The effect layer class can not be used directly and is intented to inherited from to be
  65235. * customized per effects.
  65236. */
  65237. export abstract class EffectLayer {
  65238. private _vertexBuffers;
  65239. private _indexBuffer;
  65240. private _cachedDefines;
  65241. private _effectLayerMapGenerationEffect;
  65242. private _effectLayerOptions;
  65243. private _mergeEffect;
  65244. protected _scene: Scene;
  65245. protected _engine: Engine;
  65246. protected _maxSize: number;
  65247. protected _mainTextureDesiredSize: ISize;
  65248. protected _mainTexture: RenderTargetTexture;
  65249. protected _shouldRender: boolean;
  65250. protected _postProcesses: PostProcess[];
  65251. protected _textures: BaseTexture[];
  65252. protected _emissiveTextureAndColor: {
  65253. texture: Nullable<BaseTexture>;
  65254. color: Color4;
  65255. };
  65256. /**
  65257. * The name of the layer
  65258. */
  65259. name: string;
  65260. /**
  65261. * The clear color of the texture used to generate the glow map.
  65262. */
  65263. neutralColor: Color4;
  65264. /**
  65265. * Specifies whether the highlight layer is enabled or not.
  65266. */
  65267. isEnabled: boolean;
  65268. /**
  65269. * Gets the camera attached to the layer.
  65270. */
  65271. get camera(): Nullable<Camera>;
  65272. /**
  65273. * Gets the rendering group id the layer should render in.
  65274. */
  65275. get renderingGroupId(): number;
  65276. set renderingGroupId(renderingGroupId: number);
  65277. /**
  65278. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  65279. */
  65280. disableBoundingBoxesFromEffectLayer: boolean;
  65281. /**
  65282. * An event triggered when the effect layer has been disposed.
  65283. */
  65284. onDisposeObservable: Observable<EffectLayer>;
  65285. /**
  65286. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  65287. */
  65288. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  65289. /**
  65290. * An event triggered when the generated texture is being merged in the scene.
  65291. */
  65292. onBeforeComposeObservable: Observable<EffectLayer>;
  65293. /**
  65294. * An event triggered when the mesh is rendered into the effect render target.
  65295. */
  65296. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  65297. /**
  65298. * An event triggered after the mesh has been rendered into the effect render target.
  65299. */
  65300. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  65301. /**
  65302. * An event triggered when the generated texture has been merged in the scene.
  65303. */
  65304. onAfterComposeObservable: Observable<EffectLayer>;
  65305. /**
  65306. * An event triggered when the efffect layer changes its size.
  65307. */
  65308. onSizeChangedObservable: Observable<EffectLayer>;
  65309. /** @hidden */
  65310. static _SceneComponentInitialization: (scene: Scene) => void;
  65311. /**
  65312. * Instantiates a new effect Layer and references it in the scene.
  65313. * @param name The name of the layer
  65314. * @param scene The scene to use the layer in
  65315. */
  65316. constructor(
  65317. /** The Friendly of the effect in the scene */
  65318. name: string, scene: Scene);
  65319. /**
  65320. * Get the effect name of the layer.
  65321. * @return The effect name
  65322. */
  65323. abstract getEffectName(): string;
  65324. /**
  65325. * Checks for the readiness of the element composing the layer.
  65326. * @param subMesh the mesh to check for
  65327. * @param useInstances specify whether or not to use instances to render the mesh
  65328. * @return true if ready otherwise, false
  65329. */
  65330. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65331. /**
  65332. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65333. * @returns true if the effect requires stencil during the main canvas render pass.
  65334. */
  65335. abstract needStencil(): boolean;
  65336. /**
  65337. * Create the merge effect. This is the shader use to blit the information back
  65338. * to the main canvas at the end of the scene rendering.
  65339. * @returns The effect containing the shader used to merge the effect on the main canvas
  65340. */
  65341. protected abstract _createMergeEffect(): Effect;
  65342. /**
  65343. * Creates the render target textures and post processes used in the effect layer.
  65344. */
  65345. protected abstract _createTextureAndPostProcesses(): void;
  65346. /**
  65347. * Implementation specific of rendering the generating effect on the main canvas.
  65348. * @param effect The effect used to render through
  65349. */
  65350. protected abstract _internalRender(effect: Effect): void;
  65351. /**
  65352. * Sets the required values for both the emissive texture and and the main color.
  65353. */
  65354. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65355. /**
  65356. * Free any resources and references associated to a mesh.
  65357. * Internal use
  65358. * @param mesh The mesh to free.
  65359. */
  65360. abstract _disposeMesh(mesh: Mesh): void;
  65361. /**
  65362. * Serializes this layer (Glow or Highlight for example)
  65363. * @returns a serialized layer object
  65364. */
  65365. abstract serialize?(): any;
  65366. /**
  65367. * Initializes the effect layer with the required options.
  65368. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  65369. */
  65370. protected _init(options: Partial<IEffectLayerOptions>): void;
  65371. /**
  65372. * Generates the index buffer of the full screen quad blending to the main canvas.
  65373. */
  65374. private _generateIndexBuffer;
  65375. /**
  65376. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  65377. */
  65378. private _generateVertexBuffer;
  65379. /**
  65380. * Sets the main texture desired size which is the closest power of two
  65381. * of the engine canvas size.
  65382. */
  65383. private _setMainTextureSize;
  65384. /**
  65385. * Creates the main texture for the effect layer.
  65386. */
  65387. protected _createMainTexture(): void;
  65388. /**
  65389. * Adds specific effects defines.
  65390. * @param defines The defines to add specifics to.
  65391. */
  65392. protected _addCustomEffectDefines(defines: string[]): void;
  65393. /**
  65394. * Checks for the readiness of the element composing the layer.
  65395. * @param subMesh the mesh to check for
  65396. * @param useInstances specify whether or not to use instances to render the mesh
  65397. * @param emissiveTexture the associated emissive texture used to generate the glow
  65398. * @return true if ready otherwise, false
  65399. */
  65400. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  65401. /**
  65402. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  65403. */
  65404. render(): void;
  65405. /**
  65406. * Determine if a given mesh will be used in the current effect.
  65407. * @param mesh mesh to test
  65408. * @returns true if the mesh will be used
  65409. */
  65410. hasMesh(mesh: AbstractMesh): boolean;
  65411. /**
  65412. * Returns true if the layer contains information to display, otherwise false.
  65413. * @returns true if the glow layer should be rendered
  65414. */
  65415. shouldRender(): boolean;
  65416. /**
  65417. * Returns true if the mesh should render, otherwise false.
  65418. * @param mesh The mesh to render
  65419. * @returns true if it should render otherwise false
  65420. */
  65421. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  65422. /**
  65423. * Returns true if the mesh can be rendered, otherwise false.
  65424. * @param mesh The mesh to render
  65425. * @param material The material used on the mesh
  65426. * @returns true if it can be rendered otherwise false
  65427. */
  65428. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65429. /**
  65430. * Returns true if the mesh should render, otherwise false.
  65431. * @param mesh The mesh to render
  65432. * @returns true if it should render otherwise false
  65433. */
  65434. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  65435. /**
  65436. * Renders the submesh passed in parameter to the generation map.
  65437. */
  65438. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  65439. /**
  65440. * Defines whether the current material of the mesh should be use to render the effect.
  65441. * @param mesh defines the current mesh to render
  65442. */
  65443. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  65444. /**
  65445. * Rebuild the required buffers.
  65446. * @hidden Internal use only.
  65447. */
  65448. _rebuild(): void;
  65449. /**
  65450. * Dispose only the render target textures and post process.
  65451. */
  65452. private _disposeTextureAndPostProcesses;
  65453. /**
  65454. * Dispose the highlight layer and free resources.
  65455. */
  65456. dispose(): void;
  65457. /**
  65458. * Gets the class name of the effect layer
  65459. * @returns the string with the class name of the effect layer
  65460. */
  65461. getClassName(): string;
  65462. /**
  65463. * Creates an effect layer from parsed effect layer data
  65464. * @param parsedEffectLayer defines effect layer data
  65465. * @param scene defines the current scene
  65466. * @param rootUrl defines the root URL containing the effect layer information
  65467. * @returns a parsed effect Layer
  65468. */
  65469. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  65470. }
  65471. }
  65472. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  65473. import { Scene } from "babylonjs/scene";
  65474. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  65475. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65476. import { AbstractScene } from "babylonjs/abstractScene";
  65477. module "babylonjs/abstractScene" {
  65478. interface AbstractScene {
  65479. /**
  65480. * The list of effect layers (highlights/glow) added to the scene
  65481. * @see https://doc.babylonjs.com/how_to/highlight_layer
  65482. * @see https://doc.babylonjs.com/how_to/glow_layer
  65483. */
  65484. effectLayers: Array<EffectLayer>;
  65485. /**
  65486. * Removes the given effect layer from this scene.
  65487. * @param toRemove defines the effect layer to remove
  65488. * @returns the index of the removed effect layer
  65489. */
  65490. removeEffectLayer(toRemove: EffectLayer): number;
  65491. /**
  65492. * Adds the given effect layer to this scene
  65493. * @param newEffectLayer defines the effect layer to add
  65494. */
  65495. addEffectLayer(newEffectLayer: EffectLayer): void;
  65496. }
  65497. }
  65498. /**
  65499. * Defines the layer scene component responsible to manage any effect layers
  65500. * in a given scene.
  65501. */
  65502. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  65503. /**
  65504. * The component name helpfull to identify the component in the list of scene components.
  65505. */
  65506. readonly name: string;
  65507. /**
  65508. * The scene the component belongs to.
  65509. */
  65510. scene: Scene;
  65511. private _engine;
  65512. private _renderEffects;
  65513. private _needStencil;
  65514. private _previousStencilState;
  65515. /**
  65516. * Creates a new instance of the component for the given scene
  65517. * @param scene Defines the scene to register the component in
  65518. */
  65519. constructor(scene: Scene);
  65520. /**
  65521. * Registers the component in a given scene
  65522. */
  65523. register(): void;
  65524. /**
  65525. * Rebuilds the elements related to this component in case of
  65526. * context lost for instance.
  65527. */
  65528. rebuild(): void;
  65529. /**
  65530. * Serializes the component data to the specified json object
  65531. * @param serializationObject The object to serialize to
  65532. */
  65533. serialize(serializationObject: any): void;
  65534. /**
  65535. * Adds all the elements from the container to the scene
  65536. * @param container the container holding the elements
  65537. */
  65538. addFromContainer(container: AbstractScene): void;
  65539. /**
  65540. * Removes all the elements in the container from the scene
  65541. * @param container contains the elements to remove
  65542. * @param dispose if the removed element should be disposed (default: false)
  65543. */
  65544. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65545. /**
  65546. * Disposes the component and the associated ressources.
  65547. */
  65548. dispose(): void;
  65549. private _isReadyForMesh;
  65550. private _renderMainTexture;
  65551. private _setStencil;
  65552. private _setStencilBack;
  65553. private _draw;
  65554. private _drawCamera;
  65555. private _drawRenderingGroup;
  65556. }
  65557. }
  65558. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  65559. /** @hidden */
  65560. export var glowMapMergePixelShader: {
  65561. name: string;
  65562. shader: string;
  65563. };
  65564. }
  65565. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  65566. /** @hidden */
  65567. export var glowMapMergeVertexShader: {
  65568. name: string;
  65569. shader: string;
  65570. };
  65571. }
  65572. declare module "babylonjs/Layers/glowLayer" {
  65573. import { Nullable } from "babylonjs/types";
  65574. import { Camera } from "babylonjs/Cameras/camera";
  65575. import { Scene } from "babylonjs/scene";
  65576. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65578. import { Mesh } from "babylonjs/Meshes/mesh";
  65579. import { Texture } from "babylonjs/Materials/Textures/texture";
  65580. import { Effect } from "babylonjs/Materials/effect";
  65581. import { Material } from "babylonjs/Materials/material";
  65582. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65583. import { Color4 } from "babylonjs/Maths/math.color";
  65584. import "babylonjs/Shaders/glowMapMerge.fragment";
  65585. import "babylonjs/Shaders/glowMapMerge.vertex";
  65586. import "babylonjs/Layers/effectLayerSceneComponent";
  65587. module "babylonjs/abstractScene" {
  65588. interface AbstractScene {
  65589. /**
  65590. * Return a the first highlight layer of the scene with a given name.
  65591. * @param name The name of the highlight layer to look for.
  65592. * @return The highlight layer if found otherwise null.
  65593. */
  65594. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  65595. }
  65596. }
  65597. /**
  65598. * Glow layer options. This helps customizing the behaviour
  65599. * of the glow layer.
  65600. */
  65601. export interface IGlowLayerOptions {
  65602. /**
  65603. * Multiplication factor apply to the canvas size to compute the render target size
  65604. * used to generated the glowing objects (the smaller the faster).
  65605. */
  65606. mainTextureRatio: number;
  65607. /**
  65608. * Enforces a fixed size texture to ensure resize independant blur.
  65609. */
  65610. mainTextureFixedSize?: number;
  65611. /**
  65612. * How big is the kernel of the blur texture.
  65613. */
  65614. blurKernelSize: number;
  65615. /**
  65616. * The camera attached to the layer.
  65617. */
  65618. camera: Nullable<Camera>;
  65619. /**
  65620. * Enable MSAA by chosing the number of samples.
  65621. */
  65622. mainTextureSamples?: number;
  65623. /**
  65624. * The rendering group to draw the layer in.
  65625. */
  65626. renderingGroupId: number;
  65627. }
  65628. /**
  65629. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  65630. *
  65631. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  65632. *
  65633. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  65634. */
  65635. export class GlowLayer extends EffectLayer {
  65636. /**
  65637. * Effect Name of the layer.
  65638. */
  65639. static readonly EffectName: string;
  65640. /**
  65641. * The default blur kernel size used for the glow.
  65642. */
  65643. static DefaultBlurKernelSize: number;
  65644. /**
  65645. * The default texture size ratio used for the glow.
  65646. */
  65647. static DefaultTextureRatio: number;
  65648. /**
  65649. * Sets the kernel size of the blur.
  65650. */
  65651. set blurKernelSize(value: number);
  65652. /**
  65653. * Gets the kernel size of the blur.
  65654. */
  65655. get blurKernelSize(): number;
  65656. /**
  65657. * Sets the glow intensity.
  65658. */
  65659. set intensity(value: number);
  65660. /**
  65661. * Gets the glow intensity.
  65662. */
  65663. get intensity(): number;
  65664. private _options;
  65665. private _intensity;
  65666. private _horizontalBlurPostprocess1;
  65667. private _verticalBlurPostprocess1;
  65668. private _horizontalBlurPostprocess2;
  65669. private _verticalBlurPostprocess2;
  65670. private _blurTexture1;
  65671. private _blurTexture2;
  65672. private _postProcesses1;
  65673. private _postProcesses2;
  65674. private _includedOnlyMeshes;
  65675. private _excludedMeshes;
  65676. private _meshesUsingTheirOwnMaterials;
  65677. /**
  65678. * Callback used to let the user override the color selection on a per mesh basis
  65679. */
  65680. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  65681. /**
  65682. * Callback used to let the user override the texture selection on a per mesh basis
  65683. */
  65684. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  65685. /**
  65686. * Instantiates a new glow Layer and references it to the scene.
  65687. * @param name The name of the layer
  65688. * @param scene The scene to use the layer in
  65689. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  65690. */
  65691. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  65692. /**
  65693. * Get the effect name of the layer.
  65694. * @return The effect name
  65695. */
  65696. getEffectName(): string;
  65697. /**
  65698. * Create the merge effect. This is the shader use to blit the information back
  65699. * to the main canvas at the end of the scene rendering.
  65700. */
  65701. protected _createMergeEffect(): Effect;
  65702. /**
  65703. * Creates the render target textures and post processes used in the glow layer.
  65704. */
  65705. protected _createTextureAndPostProcesses(): void;
  65706. /**
  65707. * Checks for the readiness of the element composing the layer.
  65708. * @param subMesh the mesh to check for
  65709. * @param useInstances specify wether or not to use instances to render the mesh
  65710. * @param emissiveTexture the associated emissive texture used to generate the glow
  65711. * @return true if ready otherwise, false
  65712. */
  65713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65714. /**
  65715. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65716. */
  65717. needStencil(): boolean;
  65718. /**
  65719. * Returns true if the mesh can be rendered, otherwise false.
  65720. * @param mesh The mesh to render
  65721. * @param material The material used on the mesh
  65722. * @returns true if it can be rendered otherwise false
  65723. */
  65724. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65725. /**
  65726. * Implementation specific of rendering the generating effect on the main canvas.
  65727. * @param effect The effect used to render through
  65728. */
  65729. protected _internalRender(effect: Effect): void;
  65730. /**
  65731. * Sets the required values for both the emissive texture and and the main color.
  65732. */
  65733. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65734. /**
  65735. * Returns true if the mesh should render, otherwise false.
  65736. * @param mesh The mesh to render
  65737. * @returns true if it should render otherwise false
  65738. */
  65739. protected _shouldRenderMesh(mesh: Mesh): boolean;
  65740. /**
  65741. * Adds specific effects defines.
  65742. * @param defines The defines to add specifics to.
  65743. */
  65744. protected _addCustomEffectDefines(defines: string[]): void;
  65745. /**
  65746. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  65747. * @param mesh The mesh to exclude from the glow layer
  65748. */
  65749. addExcludedMesh(mesh: Mesh): void;
  65750. /**
  65751. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  65752. * @param mesh The mesh to remove
  65753. */
  65754. removeExcludedMesh(mesh: Mesh): void;
  65755. /**
  65756. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  65757. * @param mesh The mesh to include in the glow layer
  65758. */
  65759. addIncludedOnlyMesh(mesh: Mesh): void;
  65760. /**
  65761. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  65762. * @param mesh The mesh to remove
  65763. */
  65764. removeIncludedOnlyMesh(mesh: Mesh): void;
  65765. /**
  65766. * Determine if a given mesh will be used in the glow layer
  65767. * @param mesh The mesh to test
  65768. * @returns true if the mesh will be highlighted by the current glow layer
  65769. */
  65770. hasMesh(mesh: AbstractMesh): boolean;
  65771. /**
  65772. * Defines whether the current material of the mesh should be use to render the effect.
  65773. * @param mesh defines the current mesh to render
  65774. */
  65775. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  65776. /**
  65777. * Add a mesh to be rendered through its own material and not with emissive only.
  65778. * @param mesh The mesh for which we need to use its material
  65779. */
  65780. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  65781. /**
  65782. * Remove a mesh from being rendered through its own material and not with emissive only.
  65783. * @param mesh The mesh for which we need to not use its material
  65784. */
  65785. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  65786. /**
  65787. * Free any resources and references associated to a mesh.
  65788. * Internal use
  65789. * @param mesh The mesh to free.
  65790. * @hidden
  65791. */
  65792. _disposeMesh(mesh: Mesh): void;
  65793. /**
  65794. * Gets the class name of the effect layer
  65795. * @returns the string with the class name of the effect layer
  65796. */
  65797. getClassName(): string;
  65798. /**
  65799. * Serializes this glow layer
  65800. * @returns a serialized glow layer object
  65801. */
  65802. serialize(): any;
  65803. /**
  65804. * Creates a Glow Layer from parsed glow layer data
  65805. * @param parsedGlowLayer defines glow layer data
  65806. * @param scene defines the current scene
  65807. * @param rootUrl defines the root URL containing the glow layer information
  65808. * @returns a parsed Glow Layer
  65809. */
  65810. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  65811. }
  65812. }
  65813. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  65814. /** @hidden */
  65815. export var glowBlurPostProcessPixelShader: {
  65816. name: string;
  65817. shader: string;
  65818. };
  65819. }
  65820. declare module "babylonjs/Layers/highlightLayer" {
  65821. import { Observable } from "babylonjs/Misc/observable";
  65822. import { Nullable } from "babylonjs/types";
  65823. import { Camera } from "babylonjs/Cameras/camera";
  65824. import { Scene } from "babylonjs/scene";
  65825. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65827. import { Mesh } from "babylonjs/Meshes/mesh";
  65828. import { Effect } from "babylonjs/Materials/effect";
  65829. import { Material } from "babylonjs/Materials/material";
  65830. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65831. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65832. import "babylonjs/Shaders/glowMapMerge.fragment";
  65833. import "babylonjs/Shaders/glowMapMerge.vertex";
  65834. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  65835. module "babylonjs/abstractScene" {
  65836. interface AbstractScene {
  65837. /**
  65838. * Return a the first highlight layer of the scene with a given name.
  65839. * @param name The name of the highlight layer to look for.
  65840. * @return The highlight layer if found otherwise null.
  65841. */
  65842. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  65843. }
  65844. }
  65845. /**
  65846. * Highlight layer options. This helps customizing the behaviour
  65847. * of the highlight layer.
  65848. */
  65849. export interface IHighlightLayerOptions {
  65850. /**
  65851. * Multiplication factor apply to the canvas size to compute the render target size
  65852. * used to generated the glowing objects (the smaller the faster).
  65853. */
  65854. mainTextureRatio: number;
  65855. /**
  65856. * Enforces a fixed size texture to ensure resize independant blur.
  65857. */
  65858. mainTextureFixedSize?: number;
  65859. /**
  65860. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  65861. * of the picture to blur (the smaller the faster).
  65862. */
  65863. blurTextureSizeRatio: number;
  65864. /**
  65865. * How big in texel of the blur texture is the vertical blur.
  65866. */
  65867. blurVerticalSize: number;
  65868. /**
  65869. * How big in texel of the blur texture is the horizontal blur.
  65870. */
  65871. blurHorizontalSize: number;
  65872. /**
  65873. * Alpha blending mode used to apply the blur. Default is combine.
  65874. */
  65875. alphaBlendingMode: number;
  65876. /**
  65877. * The camera attached to the layer.
  65878. */
  65879. camera: Nullable<Camera>;
  65880. /**
  65881. * Should we display highlight as a solid stroke?
  65882. */
  65883. isStroke?: boolean;
  65884. /**
  65885. * The rendering group to draw the layer in.
  65886. */
  65887. renderingGroupId: number;
  65888. }
  65889. /**
  65890. * The highlight layer Helps adding a glow effect around a mesh.
  65891. *
  65892. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  65893. * glowy meshes to your scene.
  65894. *
  65895. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  65896. */
  65897. export class HighlightLayer extends EffectLayer {
  65898. name: string;
  65899. /**
  65900. * Effect Name of the highlight layer.
  65901. */
  65902. static readonly EffectName: string;
  65903. /**
  65904. * The neutral color used during the preparation of the glow effect.
  65905. * This is black by default as the blend operation is a blend operation.
  65906. */
  65907. static NeutralColor: Color4;
  65908. /**
  65909. * Stencil value used for glowing meshes.
  65910. */
  65911. static GlowingMeshStencilReference: number;
  65912. /**
  65913. * Stencil value used for the other meshes in the scene.
  65914. */
  65915. static NormalMeshStencilReference: number;
  65916. /**
  65917. * Specifies whether or not the inner glow is ACTIVE in the layer.
  65918. */
  65919. innerGlow: boolean;
  65920. /**
  65921. * Specifies whether or not the outer glow is ACTIVE in the layer.
  65922. */
  65923. outerGlow: boolean;
  65924. /**
  65925. * Specifies the horizontal size of the blur.
  65926. */
  65927. set blurHorizontalSize(value: number);
  65928. /**
  65929. * Specifies the vertical size of the blur.
  65930. */
  65931. set blurVerticalSize(value: number);
  65932. /**
  65933. * Gets the horizontal size of the blur.
  65934. */
  65935. get blurHorizontalSize(): number;
  65936. /**
  65937. * Gets the vertical size of the blur.
  65938. */
  65939. get blurVerticalSize(): number;
  65940. /**
  65941. * An event triggered when the highlight layer is being blurred.
  65942. */
  65943. onBeforeBlurObservable: Observable<HighlightLayer>;
  65944. /**
  65945. * An event triggered when the highlight layer has been blurred.
  65946. */
  65947. onAfterBlurObservable: Observable<HighlightLayer>;
  65948. private _instanceGlowingMeshStencilReference;
  65949. private _options;
  65950. private _downSamplePostprocess;
  65951. private _horizontalBlurPostprocess;
  65952. private _verticalBlurPostprocess;
  65953. private _blurTexture;
  65954. private _meshes;
  65955. private _excludedMeshes;
  65956. /**
  65957. * Instantiates a new highlight Layer and references it to the scene..
  65958. * @param name The name of the layer
  65959. * @param scene The scene to use the layer in
  65960. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  65961. */
  65962. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  65963. /**
  65964. * Get the effect name of the layer.
  65965. * @return The effect name
  65966. */
  65967. getEffectName(): string;
  65968. /**
  65969. * Create the merge effect. This is the shader use to blit the information back
  65970. * to the main canvas at the end of the scene rendering.
  65971. */
  65972. protected _createMergeEffect(): Effect;
  65973. /**
  65974. * Creates the render target textures and post processes used in the highlight layer.
  65975. */
  65976. protected _createTextureAndPostProcesses(): void;
  65977. /**
  65978. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  65979. */
  65980. needStencil(): boolean;
  65981. /**
  65982. * Checks for the readiness of the element composing the layer.
  65983. * @param subMesh the mesh to check for
  65984. * @param useInstances specify wether or not to use instances to render the mesh
  65985. * @param emissiveTexture the associated emissive texture used to generate the glow
  65986. * @return true if ready otherwise, false
  65987. */
  65988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65989. /**
  65990. * Implementation specific of rendering the generating effect on the main canvas.
  65991. * @param effect The effect used to render through
  65992. */
  65993. protected _internalRender(effect: Effect): void;
  65994. /**
  65995. * Returns true if the layer contains information to display, otherwise false.
  65996. */
  65997. shouldRender(): boolean;
  65998. /**
  65999. * Returns true if the mesh should render, otherwise false.
  66000. * @param mesh The mesh to render
  66001. * @returns true if it should render otherwise false
  66002. */
  66003. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66004. /**
  66005. * Returns true if the mesh can be rendered, otherwise false.
  66006. * @param mesh The mesh to render
  66007. * @param material The material used on the mesh
  66008. * @returns true if it can be rendered otherwise false
  66009. */
  66010. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66011. /**
  66012. * Adds specific effects defines.
  66013. * @param defines The defines to add specifics to.
  66014. */
  66015. protected _addCustomEffectDefines(defines: string[]): void;
  66016. /**
  66017. * Sets the required values for both the emissive texture and and the main color.
  66018. */
  66019. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66020. /**
  66021. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  66022. * @param mesh The mesh to exclude from the highlight layer
  66023. */
  66024. addExcludedMesh(mesh: Mesh): void;
  66025. /**
  66026. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  66027. * @param mesh The mesh to highlight
  66028. */
  66029. removeExcludedMesh(mesh: Mesh): void;
  66030. /**
  66031. * Determine if a given mesh will be highlighted by the current HighlightLayer
  66032. * @param mesh mesh to test
  66033. * @returns true if the mesh will be highlighted by the current HighlightLayer
  66034. */
  66035. hasMesh(mesh: AbstractMesh): boolean;
  66036. /**
  66037. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  66038. * @param mesh The mesh to highlight
  66039. * @param color The color of the highlight
  66040. * @param glowEmissiveOnly Extract the glow from the emissive texture
  66041. */
  66042. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  66043. /**
  66044. * Remove a mesh from the highlight layer in order to make it stop glowing.
  66045. * @param mesh The mesh to highlight
  66046. */
  66047. removeMesh(mesh: Mesh): void;
  66048. /**
  66049. * Remove all the meshes currently referenced in the highlight layer
  66050. */
  66051. removeAllMeshes(): void;
  66052. /**
  66053. * Force the stencil to the normal expected value for none glowing parts
  66054. */
  66055. private _defaultStencilReference;
  66056. /**
  66057. * Free any resources and references associated to a mesh.
  66058. * Internal use
  66059. * @param mesh The mesh to free.
  66060. * @hidden
  66061. */
  66062. _disposeMesh(mesh: Mesh): void;
  66063. /**
  66064. * Dispose the highlight layer and free resources.
  66065. */
  66066. dispose(): void;
  66067. /**
  66068. * Gets the class name of the effect layer
  66069. * @returns the string with the class name of the effect layer
  66070. */
  66071. getClassName(): string;
  66072. /**
  66073. * Serializes this Highlight layer
  66074. * @returns a serialized Highlight layer object
  66075. */
  66076. serialize(): any;
  66077. /**
  66078. * Creates a Highlight layer from parsed Highlight layer data
  66079. * @param parsedHightlightLayer defines the Highlight layer data
  66080. * @param scene defines the current scene
  66081. * @param rootUrl defines the root URL containing the Highlight layer information
  66082. * @returns a parsed Highlight layer
  66083. */
  66084. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  66085. }
  66086. }
  66087. declare module "babylonjs/Layers/layerSceneComponent" {
  66088. import { Scene } from "babylonjs/scene";
  66089. import { ISceneComponent } from "babylonjs/sceneComponent";
  66090. import { Layer } from "babylonjs/Layers/layer";
  66091. import { AbstractScene } from "babylonjs/abstractScene";
  66092. module "babylonjs/abstractScene" {
  66093. interface AbstractScene {
  66094. /**
  66095. * The list of layers (background and foreground) of the scene
  66096. */
  66097. layers: Array<Layer>;
  66098. }
  66099. }
  66100. /**
  66101. * Defines the layer scene component responsible to manage any layers
  66102. * in a given scene.
  66103. */
  66104. export class LayerSceneComponent implements ISceneComponent {
  66105. /**
  66106. * The component name helpfull to identify the component in the list of scene components.
  66107. */
  66108. readonly name: string;
  66109. /**
  66110. * The scene the component belongs to.
  66111. */
  66112. scene: Scene;
  66113. private _engine;
  66114. /**
  66115. * Creates a new instance of the component for the given scene
  66116. * @param scene Defines the scene to register the component in
  66117. */
  66118. constructor(scene: Scene);
  66119. /**
  66120. * Registers the component in a given scene
  66121. */
  66122. register(): void;
  66123. /**
  66124. * Rebuilds the elements related to this component in case of
  66125. * context lost for instance.
  66126. */
  66127. rebuild(): void;
  66128. /**
  66129. * Disposes the component and the associated ressources.
  66130. */
  66131. dispose(): void;
  66132. private _draw;
  66133. private _drawCameraPredicate;
  66134. private _drawCameraBackground;
  66135. private _drawCameraForeground;
  66136. private _drawRenderTargetPredicate;
  66137. private _drawRenderTargetBackground;
  66138. private _drawRenderTargetForeground;
  66139. /**
  66140. * Adds all the elements from the container to the scene
  66141. * @param container the container holding the elements
  66142. */
  66143. addFromContainer(container: AbstractScene): void;
  66144. /**
  66145. * Removes all the elements in the container from the scene
  66146. * @param container contains the elements to remove
  66147. * @param dispose if the removed element should be disposed (default: false)
  66148. */
  66149. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66150. }
  66151. }
  66152. declare module "babylonjs/Shaders/layer.fragment" {
  66153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66154. /** @hidden */
  66155. export var layerPixelShader: {
  66156. name: string;
  66157. shader: string;
  66158. };
  66159. }
  66160. declare module "babylonjs/Shaders/layer.vertex" {
  66161. /** @hidden */
  66162. export var layerVertexShader: {
  66163. name: string;
  66164. shader: string;
  66165. };
  66166. }
  66167. declare module "babylonjs/Layers/layer" {
  66168. import { Observable } from "babylonjs/Misc/observable";
  66169. import { Nullable } from "babylonjs/types";
  66170. import { Scene } from "babylonjs/scene";
  66171. import { Vector2 } from "babylonjs/Maths/math.vector";
  66172. import { Color4 } from "babylonjs/Maths/math.color";
  66173. import { Texture } from "babylonjs/Materials/Textures/texture";
  66174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66175. import "babylonjs/Shaders/layer.fragment";
  66176. import "babylonjs/Shaders/layer.vertex";
  66177. /**
  66178. * This represents a full screen 2d layer.
  66179. * This can be useful to display a picture in the background of your scene for instance.
  66180. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66181. */
  66182. export class Layer {
  66183. /**
  66184. * Define the name of the layer.
  66185. */
  66186. name: string;
  66187. /**
  66188. * Define the texture the layer should display.
  66189. */
  66190. texture: Nullable<Texture>;
  66191. /**
  66192. * Is the layer in background or foreground.
  66193. */
  66194. isBackground: boolean;
  66195. /**
  66196. * Define the color of the layer (instead of texture).
  66197. */
  66198. color: Color4;
  66199. /**
  66200. * Define the scale of the layer in order to zoom in out of the texture.
  66201. */
  66202. scale: Vector2;
  66203. /**
  66204. * Define an offset for the layer in order to shift the texture.
  66205. */
  66206. offset: Vector2;
  66207. /**
  66208. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  66209. */
  66210. alphaBlendingMode: number;
  66211. /**
  66212. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  66213. * Alpha test will not mix with the background color in case of transparency.
  66214. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  66215. */
  66216. alphaTest: boolean;
  66217. /**
  66218. * Define a mask to restrict the layer to only some of the scene cameras.
  66219. */
  66220. layerMask: number;
  66221. /**
  66222. * Define the list of render target the layer is visible into.
  66223. */
  66224. renderTargetTextures: RenderTargetTexture[];
  66225. /**
  66226. * Define if the layer is only used in renderTarget or if it also
  66227. * renders in the main frame buffer of the canvas.
  66228. */
  66229. renderOnlyInRenderTargetTextures: boolean;
  66230. private _scene;
  66231. private _vertexBuffers;
  66232. private _indexBuffer;
  66233. private _effect;
  66234. private _previousDefines;
  66235. /**
  66236. * An event triggered when the layer is disposed.
  66237. */
  66238. onDisposeObservable: Observable<Layer>;
  66239. private _onDisposeObserver;
  66240. /**
  66241. * Back compatibility with callback before the onDisposeObservable existed.
  66242. * The set callback will be triggered when the layer has been disposed.
  66243. */
  66244. set onDispose(callback: () => void);
  66245. /**
  66246. * An event triggered before rendering the scene
  66247. */
  66248. onBeforeRenderObservable: Observable<Layer>;
  66249. private _onBeforeRenderObserver;
  66250. /**
  66251. * Back compatibility with callback before the onBeforeRenderObservable existed.
  66252. * The set callback will be triggered just before rendering the layer.
  66253. */
  66254. set onBeforeRender(callback: () => void);
  66255. /**
  66256. * An event triggered after rendering the scene
  66257. */
  66258. onAfterRenderObservable: Observable<Layer>;
  66259. private _onAfterRenderObserver;
  66260. /**
  66261. * Back compatibility with callback before the onAfterRenderObservable existed.
  66262. * The set callback will be triggered just after rendering the layer.
  66263. */
  66264. set onAfterRender(callback: () => void);
  66265. /**
  66266. * Instantiates a new layer.
  66267. * This represents a full screen 2d layer.
  66268. * This can be useful to display a picture in the background of your scene for instance.
  66269. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66270. * @param name Define the name of the layer in the scene
  66271. * @param imgUrl Define the url of the texture to display in the layer
  66272. * @param scene Define the scene the layer belongs to
  66273. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  66274. * @param color Defines a color for the layer
  66275. */
  66276. constructor(
  66277. /**
  66278. * Define the name of the layer.
  66279. */
  66280. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  66281. private _createIndexBuffer;
  66282. /** @hidden */
  66283. _rebuild(): void;
  66284. /**
  66285. * Renders the layer in the scene.
  66286. */
  66287. render(): void;
  66288. /**
  66289. * Disposes and releases the associated ressources.
  66290. */
  66291. dispose(): void;
  66292. }
  66293. }
  66294. declare module "babylonjs/Layers/index" {
  66295. export * from "babylonjs/Layers/effectLayer";
  66296. export * from "babylonjs/Layers/effectLayerSceneComponent";
  66297. export * from "babylonjs/Layers/glowLayer";
  66298. export * from "babylonjs/Layers/highlightLayer";
  66299. export * from "babylonjs/Layers/layer";
  66300. export * from "babylonjs/Layers/layerSceneComponent";
  66301. }
  66302. declare module "babylonjs/Shaders/lensFlare.fragment" {
  66303. /** @hidden */
  66304. export var lensFlarePixelShader: {
  66305. name: string;
  66306. shader: string;
  66307. };
  66308. }
  66309. declare module "babylonjs/Shaders/lensFlare.vertex" {
  66310. /** @hidden */
  66311. export var lensFlareVertexShader: {
  66312. name: string;
  66313. shader: string;
  66314. };
  66315. }
  66316. declare module "babylonjs/LensFlares/lensFlareSystem" {
  66317. import { Scene } from "babylonjs/scene";
  66318. import { Vector3 } from "babylonjs/Maths/math.vector";
  66319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66320. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  66321. import "babylonjs/Shaders/lensFlare.fragment";
  66322. import "babylonjs/Shaders/lensFlare.vertex";
  66323. import { Viewport } from "babylonjs/Maths/math.viewport";
  66324. /**
  66325. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66326. * It is usually composed of several `lensFlare`.
  66327. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66328. */
  66329. export class LensFlareSystem {
  66330. /**
  66331. * Define the name of the lens flare system
  66332. */
  66333. name: string;
  66334. /**
  66335. * List of lens flares used in this system.
  66336. */
  66337. lensFlares: LensFlare[];
  66338. /**
  66339. * Define a limit from the border the lens flare can be visible.
  66340. */
  66341. borderLimit: number;
  66342. /**
  66343. * Define a viewport border we do not want to see the lens flare in.
  66344. */
  66345. viewportBorder: number;
  66346. /**
  66347. * Define a predicate which could limit the list of meshes able to occlude the effect.
  66348. */
  66349. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  66350. /**
  66351. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  66352. */
  66353. layerMask: number;
  66354. /**
  66355. * Define the id of the lens flare system in the scene.
  66356. * (equal to name by default)
  66357. */
  66358. id: string;
  66359. private _scene;
  66360. private _emitter;
  66361. private _vertexBuffers;
  66362. private _indexBuffer;
  66363. private _effect;
  66364. private _positionX;
  66365. private _positionY;
  66366. private _isEnabled;
  66367. /** @hidden */
  66368. static _SceneComponentInitialization: (scene: Scene) => void;
  66369. /**
  66370. * Instantiates a lens flare system.
  66371. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66372. * It is usually composed of several `lensFlare`.
  66373. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66374. * @param name Define the name of the lens flare system in the scene
  66375. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  66376. * @param scene Define the scene the lens flare system belongs to
  66377. */
  66378. constructor(
  66379. /**
  66380. * Define the name of the lens flare system
  66381. */
  66382. name: string, emitter: any, scene: Scene);
  66383. /**
  66384. * Define if the lens flare system is enabled.
  66385. */
  66386. get isEnabled(): boolean;
  66387. set isEnabled(value: boolean);
  66388. /**
  66389. * Get the scene the effects belongs to.
  66390. * @returns the scene holding the lens flare system
  66391. */
  66392. getScene(): Scene;
  66393. /**
  66394. * Get the emitter of the lens flare system.
  66395. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66396. * @returns the emitter of the lens flare system
  66397. */
  66398. getEmitter(): any;
  66399. /**
  66400. * Set the emitter of the lens flare system.
  66401. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66402. * @param newEmitter Define the new emitter of the system
  66403. */
  66404. setEmitter(newEmitter: any): void;
  66405. /**
  66406. * Get the lens flare system emitter position.
  66407. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  66408. * @returns the position
  66409. */
  66410. getEmitterPosition(): Vector3;
  66411. /**
  66412. * @hidden
  66413. */
  66414. computeEffectivePosition(globalViewport: Viewport): boolean;
  66415. /** @hidden */
  66416. _isVisible(): boolean;
  66417. /**
  66418. * @hidden
  66419. */
  66420. render(): boolean;
  66421. /**
  66422. * Dispose and release the lens flare with its associated resources.
  66423. */
  66424. dispose(): void;
  66425. /**
  66426. * Parse a lens flare system from a JSON repressentation
  66427. * @param parsedLensFlareSystem Define the JSON to parse
  66428. * @param scene Define the scene the parsed system should be instantiated in
  66429. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  66430. * @returns the parsed system
  66431. */
  66432. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  66433. /**
  66434. * Serialize the current Lens Flare System into a JSON representation.
  66435. * @returns the serialized JSON
  66436. */
  66437. serialize(): any;
  66438. }
  66439. }
  66440. declare module "babylonjs/LensFlares/lensFlare" {
  66441. import { Nullable } from "babylonjs/types";
  66442. import { Color3 } from "babylonjs/Maths/math.color";
  66443. import { Texture } from "babylonjs/Materials/Textures/texture";
  66444. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66445. /**
  66446. * This represents one of the lens effect in a `lensFlareSystem`.
  66447. * It controls one of the indiviual texture used in the effect.
  66448. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66449. */
  66450. export class LensFlare {
  66451. /**
  66452. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66453. */
  66454. size: number;
  66455. /**
  66456. * 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.
  66457. */
  66458. position: number;
  66459. /**
  66460. * Define the lens color.
  66461. */
  66462. color: Color3;
  66463. /**
  66464. * Define the lens texture.
  66465. */
  66466. texture: Nullable<Texture>;
  66467. /**
  66468. * Define the alpha mode to render this particular lens.
  66469. */
  66470. alphaMode: number;
  66471. private _system;
  66472. /**
  66473. * Creates a new Lens Flare.
  66474. * This represents one of the lens effect in a `lensFlareSystem`.
  66475. * It controls one of the indiviual texture used in the effect.
  66476. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66477. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  66478. * @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.
  66479. * @param color Define the lens color
  66480. * @param imgUrl Define the lens texture url
  66481. * @param system Define the `lensFlareSystem` this flare is part of
  66482. * @returns The newly created Lens Flare
  66483. */
  66484. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  66485. /**
  66486. * Instantiates a new Lens Flare.
  66487. * This represents one of the lens effect in a `lensFlareSystem`.
  66488. * It controls one of the indiviual texture used in the effect.
  66489. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66490. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  66491. * @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.
  66492. * @param color Define the lens color
  66493. * @param imgUrl Define the lens texture url
  66494. * @param system Define the `lensFlareSystem` this flare is part of
  66495. */
  66496. constructor(
  66497. /**
  66498. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66499. */
  66500. size: number,
  66501. /**
  66502. * 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.
  66503. */
  66504. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  66505. /**
  66506. * Dispose and release the lens flare with its associated resources.
  66507. */
  66508. dispose(): void;
  66509. }
  66510. }
  66511. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  66512. import { Nullable } from "babylonjs/types";
  66513. import { Scene } from "babylonjs/scene";
  66514. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  66515. import { AbstractScene } from "babylonjs/abstractScene";
  66516. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66517. module "babylonjs/abstractScene" {
  66518. interface AbstractScene {
  66519. /**
  66520. * The list of lens flare system added to the scene
  66521. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66522. */
  66523. lensFlareSystems: Array<LensFlareSystem>;
  66524. /**
  66525. * Removes the given lens flare system from this scene.
  66526. * @param toRemove The lens flare system to remove
  66527. * @returns The index of the removed lens flare system
  66528. */
  66529. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  66530. /**
  66531. * Adds the given lens flare system to this scene
  66532. * @param newLensFlareSystem The lens flare system to add
  66533. */
  66534. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  66535. /**
  66536. * Gets a lens flare system using its name
  66537. * @param name defines the name to look for
  66538. * @returns the lens flare system or null if not found
  66539. */
  66540. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  66541. /**
  66542. * Gets a lens flare system using its id
  66543. * @param id defines the id to look for
  66544. * @returns the lens flare system or null if not found
  66545. */
  66546. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  66547. }
  66548. }
  66549. /**
  66550. * Defines the lens flare scene component responsible to manage any lens flares
  66551. * in a given scene.
  66552. */
  66553. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  66554. /**
  66555. * The component name helpfull to identify the component in the list of scene components.
  66556. */
  66557. readonly name: string;
  66558. /**
  66559. * The scene the component belongs to.
  66560. */
  66561. scene: Scene;
  66562. /**
  66563. * Creates a new instance of the component for the given scene
  66564. * @param scene Defines the scene to register the component in
  66565. */
  66566. constructor(scene: Scene);
  66567. /**
  66568. * Registers the component in a given scene
  66569. */
  66570. register(): void;
  66571. /**
  66572. * Rebuilds the elements related to this component in case of
  66573. * context lost for instance.
  66574. */
  66575. rebuild(): void;
  66576. /**
  66577. * Adds all the elements from the container to the scene
  66578. * @param container the container holding the elements
  66579. */
  66580. addFromContainer(container: AbstractScene): void;
  66581. /**
  66582. * Removes all the elements in the container from the scene
  66583. * @param container contains the elements to remove
  66584. * @param dispose if the removed element should be disposed (default: false)
  66585. */
  66586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66587. /**
  66588. * Serializes the component data to the specified json object
  66589. * @param serializationObject The object to serialize to
  66590. */
  66591. serialize(serializationObject: any): void;
  66592. /**
  66593. * Disposes the component and the associated ressources.
  66594. */
  66595. dispose(): void;
  66596. private _draw;
  66597. }
  66598. }
  66599. declare module "babylonjs/LensFlares/index" {
  66600. export * from "babylonjs/LensFlares/lensFlare";
  66601. export * from "babylonjs/LensFlares/lensFlareSystem";
  66602. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  66603. }
  66604. declare module "babylonjs/Shaders/depth.fragment" {
  66605. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66606. /** @hidden */
  66607. export var depthPixelShader: {
  66608. name: string;
  66609. shader: string;
  66610. };
  66611. }
  66612. declare module "babylonjs/Shaders/depth.vertex" {
  66613. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66614. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66615. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66616. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66617. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66618. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66619. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66620. /** @hidden */
  66621. export var depthVertexShader: {
  66622. name: string;
  66623. shader: string;
  66624. };
  66625. }
  66626. declare module "babylonjs/Rendering/depthRenderer" {
  66627. import { Nullable } from "babylonjs/types";
  66628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66629. import { Scene } from "babylonjs/scene";
  66630. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66631. import { Camera } from "babylonjs/Cameras/camera";
  66632. import "babylonjs/Shaders/depth.fragment";
  66633. import "babylonjs/Shaders/depth.vertex";
  66634. /**
  66635. * This represents a depth renderer in Babylon.
  66636. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66637. */
  66638. export class DepthRenderer {
  66639. private _scene;
  66640. private _depthMap;
  66641. private _effect;
  66642. private readonly _storeNonLinearDepth;
  66643. private readonly _clearColor;
  66644. /** Get if the depth renderer is using packed depth or not */
  66645. readonly isPacked: boolean;
  66646. private _cachedDefines;
  66647. private _camera;
  66648. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  66649. enabled: boolean;
  66650. /**
  66651. * Specifiess that the depth renderer will only be used within
  66652. * the camera it is created for.
  66653. * This can help forcing its rendering during the camera processing.
  66654. */
  66655. useOnlyInActiveCamera: boolean;
  66656. /** @hidden */
  66657. static _SceneComponentInitialization: (scene: Scene) => void;
  66658. /**
  66659. * Instantiates a depth renderer
  66660. * @param scene The scene the renderer belongs to
  66661. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66662. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66663. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66664. */
  66665. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66666. /**
  66667. * Creates the depth rendering effect and checks if the effect is ready.
  66668. * @param subMesh The submesh to be used to render the depth map of
  66669. * @param useInstances If multiple world instances should be used
  66670. * @returns if the depth renderer is ready to render the depth map
  66671. */
  66672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66673. /**
  66674. * Gets the texture which the depth map will be written to.
  66675. * @returns The depth map texture
  66676. */
  66677. getDepthMap(): RenderTargetTexture;
  66678. /**
  66679. * Disposes of the depth renderer.
  66680. */
  66681. dispose(): void;
  66682. }
  66683. }
  66684. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  66685. /** @hidden */
  66686. export var minmaxReduxPixelShader: {
  66687. name: string;
  66688. shader: string;
  66689. };
  66690. }
  66691. declare module "babylonjs/Misc/minMaxReducer" {
  66692. import { Nullable } from "babylonjs/types";
  66693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66694. import { Camera } from "babylonjs/Cameras/camera";
  66695. import { Observer } from "babylonjs/Misc/observable";
  66696. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66697. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  66698. import { Observable } from "babylonjs/Misc/observable";
  66699. import "babylonjs/Shaders/minmaxRedux.fragment";
  66700. /**
  66701. * This class computes a min/max reduction from a texture: it means it computes the minimum
  66702. * and maximum values from all values of the texture.
  66703. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  66704. * The source values are read from the red channel of the texture.
  66705. */
  66706. export class MinMaxReducer {
  66707. /**
  66708. * Observable triggered when the computation has been performed
  66709. */
  66710. onAfterReductionPerformed: Observable<{
  66711. min: number;
  66712. max: number;
  66713. }>;
  66714. protected _camera: Camera;
  66715. protected _sourceTexture: Nullable<RenderTargetTexture>;
  66716. protected _reductionSteps: Nullable<Array<PostProcess>>;
  66717. protected _postProcessManager: PostProcessManager;
  66718. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  66719. protected _forceFullscreenViewport: boolean;
  66720. /**
  66721. * Creates a min/max reducer
  66722. * @param camera The camera to use for the post processes
  66723. */
  66724. constructor(camera: Camera);
  66725. /**
  66726. * Gets the texture used to read the values from.
  66727. */
  66728. get sourceTexture(): Nullable<RenderTargetTexture>;
  66729. /**
  66730. * Sets the source texture to read the values from.
  66731. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  66732. * because in such textures '1' value must not be taken into account to compute the maximum
  66733. * as this value is used to clear the texture.
  66734. * Note that the computation is not activated by calling this function, you must call activate() for that!
  66735. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  66736. * @param depthRedux Indicates if the texture is a depth texture or not
  66737. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  66738. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  66739. */
  66740. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  66741. /**
  66742. * Defines the refresh rate of the computation.
  66743. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  66744. */
  66745. get refreshRate(): number;
  66746. set refreshRate(value: number);
  66747. protected _activated: boolean;
  66748. /**
  66749. * Gets the activation status of the reducer
  66750. */
  66751. get activated(): boolean;
  66752. /**
  66753. * Activates the reduction computation.
  66754. * When activated, the observers registered in onAfterReductionPerformed are
  66755. * called after the compuation is performed
  66756. */
  66757. activate(): void;
  66758. /**
  66759. * Deactivates the reduction computation.
  66760. */
  66761. deactivate(): void;
  66762. /**
  66763. * Disposes the min/max reducer
  66764. * @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.
  66765. */
  66766. dispose(disposeAll?: boolean): void;
  66767. }
  66768. }
  66769. declare module "babylonjs/Misc/depthReducer" {
  66770. import { Nullable } from "babylonjs/types";
  66771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66772. import { Camera } from "babylonjs/Cameras/camera";
  66773. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66774. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  66775. /**
  66776. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  66777. */
  66778. export class DepthReducer extends MinMaxReducer {
  66779. private _depthRenderer;
  66780. private _depthRendererId;
  66781. /**
  66782. * Gets the depth renderer used for the computation.
  66783. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  66784. */
  66785. get depthRenderer(): Nullable<DepthRenderer>;
  66786. /**
  66787. * Creates a depth reducer
  66788. * @param camera The camera used to render the depth texture
  66789. */
  66790. constructor(camera: Camera);
  66791. /**
  66792. * Sets the depth renderer to use to generate the depth map
  66793. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  66794. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  66795. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  66796. */
  66797. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  66798. /** @hidden */
  66799. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  66800. /**
  66801. * Activates the reduction computation.
  66802. * When activated, the observers registered in onAfterReductionPerformed are
  66803. * called after the compuation is performed
  66804. */
  66805. activate(): void;
  66806. /**
  66807. * Deactivates the reduction computation.
  66808. */
  66809. deactivate(): void;
  66810. /**
  66811. * Disposes the depth reducer
  66812. * @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.
  66813. */
  66814. dispose(disposeAll?: boolean): void;
  66815. }
  66816. }
  66817. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  66818. import { Nullable } from "babylonjs/types";
  66819. import { Scene } from "babylonjs/scene";
  66820. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66821. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66823. import { Effect } from "babylonjs/Materials/effect";
  66824. import "babylonjs/Shaders/shadowMap.fragment";
  66825. import "babylonjs/Shaders/shadowMap.vertex";
  66826. import "babylonjs/Shaders/depthBoxBlur.fragment";
  66827. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  66828. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66829. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66830. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66831. /**
  66832. * A CSM implementation allowing casting shadows on large scenes.
  66833. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  66834. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  66835. */
  66836. export class CascadedShadowGenerator extends ShadowGenerator {
  66837. private static readonly frustumCornersNDCSpace;
  66838. /**
  66839. * Name of the CSM class
  66840. */
  66841. static CLASSNAME: string;
  66842. /**
  66843. * Defines the default number of cascades used by the CSM.
  66844. */
  66845. static readonly DEFAULT_CASCADES_COUNT: number;
  66846. /**
  66847. * Defines the minimum number of cascades used by the CSM.
  66848. */
  66849. static readonly MIN_CASCADES_COUNT: number;
  66850. /**
  66851. * Defines the maximum number of cascades used by the CSM.
  66852. */
  66853. static readonly MAX_CASCADES_COUNT: number;
  66854. protected _validateFilter(filter: number): number;
  66855. /**
  66856. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  66857. */
  66858. penumbraDarkness: number;
  66859. private _numCascades;
  66860. /**
  66861. * Gets or set the number of cascades used by the CSM.
  66862. */
  66863. get numCascades(): number;
  66864. set numCascades(value: number);
  66865. /**
  66866. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  66867. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  66868. */
  66869. stabilizeCascades: boolean;
  66870. private _freezeShadowCastersBoundingInfo;
  66871. private _freezeShadowCastersBoundingInfoObservable;
  66872. /**
  66873. * Enables or disables the shadow casters bounding info computation.
  66874. * If your shadow casters don't move, you can disable this feature.
  66875. * If it is enabled, the bounding box computation is done every frame.
  66876. */
  66877. get freezeShadowCastersBoundingInfo(): boolean;
  66878. set freezeShadowCastersBoundingInfo(freeze: boolean);
  66879. private _scbiMin;
  66880. private _scbiMax;
  66881. protected _computeShadowCastersBoundingInfo(): void;
  66882. protected _shadowCastersBoundingInfo: BoundingInfo;
  66883. /**
  66884. * Gets or sets the shadow casters bounding info.
  66885. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  66886. * so that the system won't overwrite the bounds you provide
  66887. */
  66888. get shadowCastersBoundingInfo(): BoundingInfo;
  66889. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  66890. protected _breaksAreDirty: boolean;
  66891. protected _minDistance: number;
  66892. protected _maxDistance: number;
  66893. /**
  66894. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  66895. *
  66896. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  66897. * If you don't know these values, simply leave them to their defaults and don't call this function.
  66898. * @param min minimal distance for the breaks (default to 0.)
  66899. * @param max maximal distance for the breaks (default to 1.)
  66900. */
  66901. setMinMaxDistance(min: number, max: number): void;
  66902. /** Gets the minimal distance used in the cascade break computation */
  66903. get minDistance(): number;
  66904. /** Gets the maximal distance used in the cascade break computation */
  66905. get maxDistance(): number;
  66906. /**
  66907. * Gets the class name of that object
  66908. * @returns "CascadedShadowGenerator"
  66909. */
  66910. getClassName(): string;
  66911. private _cascadeMinExtents;
  66912. private _cascadeMaxExtents;
  66913. /**
  66914. * Gets a cascade minimum extents
  66915. * @param cascadeIndex index of the cascade
  66916. * @returns the minimum cascade extents
  66917. */
  66918. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  66919. /**
  66920. * Gets a cascade maximum extents
  66921. * @param cascadeIndex index of the cascade
  66922. * @returns the maximum cascade extents
  66923. */
  66924. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  66925. private _cascades;
  66926. private _currentLayer;
  66927. private _viewSpaceFrustumsZ;
  66928. private _viewMatrices;
  66929. private _projectionMatrices;
  66930. private _transformMatrices;
  66931. private _transformMatricesAsArray;
  66932. private _frustumLengths;
  66933. private _lightSizeUVCorrection;
  66934. private _depthCorrection;
  66935. private _frustumCornersWorldSpace;
  66936. private _frustumCenter;
  66937. private _shadowCameraPos;
  66938. private _shadowMaxZ;
  66939. /**
  66940. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  66941. * It defaults to camera.maxZ
  66942. */
  66943. get shadowMaxZ(): number;
  66944. /**
  66945. * Sets the shadow max z distance.
  66946. */
  66947. set shadowMaxZ(value: number);
  66948. protected _debug: boolean;
  66949. /**
  66950. * Gets or sets the debug flag.
  66951. * When enabled, the cascades are materialized by different colors on the screen.
  66952. */
  66953. get debug(): boolean;
  66954. set debug(dbg: boolean);
  66955. private _depthClamp;
  66956. /**
  66957. * Gets or sets the depth clamping value.
  66958. *
  66959. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  66960. * to account for the shadow casters far away.
  66961. *
  66962. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  66963. */
  66964. get depthClamp(): boolean;
  66965. set depthClamp(value: boolean);
  66966. private _cascadeBlendPercentage;
  66967. /**
  66968. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  66969. * It defaults to 0.1 (10% blending).
  66970. */
  66971. get cascadeBlendPercentage(): number;
  66972. set cascadeBlendPercentage(value: number);
  66973. private _lambda;
  66974. /**
  66975. * Gets or set the lambda parameter.
  66976. * This parameter is used to split the camera frustum and create the cascades.
  66977. * 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.
  66978. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  66979. */
  66980. get lambda(): number;
  66981. set lambda(value: number);
  66982. /**
  66983. * Gets the view matrix corresponding to a given cascade
  66984. * @param cascadeNum cascade to retrieve the view matrix from
  66985. * @returns the cascade view matrix
  66986. */
  66987. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  66988. /**
  66989. * Gets the projection matrix corresponding to a given cascade
  66990. * @param cascadeNum cascade to retrieve the projection matrix from
  66991. * @returns the cascade projection matrix
  66992. */
  66993. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  66994. /**
  66995. * Gets the transformation matrix corresponding to a given cascade
  66996. * @param cascadeNum cascade to retrieve the transformation matrix from
  66997. * @returns the cascade transformation matrix
  66998. */
  66999. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  67000. private _depthRenderer;
  67001. /**
  67002. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  67003. *
  67004. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  67005. *
  67006. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  67007. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  67008. * @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
  67009. */
  67010. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  67011. private _depthReducer;
  67012. private _autoCalcDepthBounds;
  67013. /**
  67014. * Gets or sets the autoCalcDepthBounds property.
  67015. *
  67016. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  67017. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  67018. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  67019. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  67020. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  67021. */
  67022. get autoCalcDepthBounds(): boolean;
  67023. set autoCalcDepthBounds(value: boolean);
  67024. /**
  67025. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  67026. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67027. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  67028. * for setting the refresh rate on the renderer yourself!
  67029. */
  67030. get autoCalcDepthBoundsRefreshRate(): number;
  67031. set autoCalcDepthBoundsRefreshRate(value: number);
  67032. /**
  67033. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  67034. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  67035. * you change the camera near/far planes!
  67036. */
  67037. splitFrustum(): void;
  67038. private _splitFrustum;
  67039. private _computeMatrices;
  67040. private _computeFrustumInWorldSpace;
  67041. private _computeCascadeFrustum;
  67042. /**
  67043. * Support test.
  67044. */
  67045. static get IsSupported(): boolean;
  67046. /** @hidden */
  67047. static _SceneComponentInitialization: (scene: Scene) => void;
  67048. /**
  67049. * Creates a Cascaded Shadow Generator object.
  67050. * A ShadowGenerator is the required tool to use the shadows.
  67051. * Each directional light casting shadows needs to use its own ShadowGenerator.
  67052. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67053. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67054. * @param light The directional light object generating the shadows.
  67055. * @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.
  67056. */
  67057. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  67058. protected _initializeGenerator(): void;
  67059. protected _createTargetRenderTexture(): void;
  67060. protected _initializeShadowMap(): void;
  67061. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  67062. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  67063. /**
  67064. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67065. * @param defines Defines of the material we want to update
  67066. * @param lightIndex Index of the light in the enabled light list of the material
  67067. */
  67068. prepareDefines(defines: any, lightIndex: number): void;
  67069. /**
  67070. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67071. * defined in the generator but impacting the effect).
  67072. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67073. * @param effect The effect we are binfing the information for
  67074. */
  67075. bindShadowLight(lightIndex: string, effect: Effect): void;
  67076. /**
  67077. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  67078. * (eq to view projection * shadow projection matrices)
  67079. * @returns The transform matrix used to create the shadow map
  67080. */
  67081. getTransformMatrix(): Matrix;
  67082. /**
  67083. * Disposes the ShadowGenerator.
  67084. * Returns nothing.
  67085. */
  67086. dispose(): void;
  67087. /**
  67088. * Serializes the shadow generator setup to a json object.
  67089. * @returns The serialized JSON object
  67090. */
  67091. serialize(): any;
  67092. /**
  67093. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67094. * @param parsedShadowGenerator The JSON object to parse
  67095. * @param scene The scene to create the shadow map for
  67096. * @returns The parsed shadow generator
  67097. */
  67098. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67099. }
  67100. }
  67101. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  67102. import { Scene } from "babylonjs/scene";
  67103. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  67104. import { AbstractScene } from "babylonjs/abstractScene";
  67105. /**
  67106. * Defines the shadow generator component responsible to manage any shadow generators
  67107. * in a given scene.
  67108. */
  67109. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  67110. /**
  67111. * The component name helpfull to identify the component in the list of scene components.
  67112. */
  67113. readonly name: string;
  67114. /**
  67115. * The scene the component belongs to.
  67116. */
  67117. scene: Scene;
  67118. /**
  67119. * Creates a new instance of the component for the given scene
  67120. * @param scene Defines the scene to register the component in
  67121. */
  67122. constructor(scene: Scene);
  67123. /**
  67124. * Registers the component in a given scene
  67125. */
  67126. register(): void;
  67127. /**
  67128. * Rebuilds the elements related to this component in case of
  67129. * context lost for instance.
  67130. */
  67131. rebuild(): void;
  67132. /**
  67133. * Serializes the component data to the specified json object
  67134. * @param serializationObject The object to serialize to
  67135. */
  67136. serialize(serializationObject: any): void;
  67137. /**
  67138. * Adds all the elements from the container to the scene
  67139. * @param container the container holding the elements
  67140. */
  67141. addFromContainer(container: AbstractScene): void;
  67142. /**
  67143. * Removes all the elements in the container from the scene
  67144. * @param container contains the elements to remove
  67145. * @param dispose if the removed element should be disposed (default: false)
  67146. */
  67147. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  67148. /**
  67149. * Rebuilds the elements related to this component in case of
  67150. * context lost for instance.
  67151. */
  67152. dispose(): void;
  67153. private _gatherRenderTargets;
  67154. }
  67155. }
  67156. declare module "babylonjs/Lights/Shadows/index" {
  67157. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  67158. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  67159. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  67160. }
  67161. declare module "babylonjs/Lights/pointLight" {
  67162. import { Scene } from "babylonjs/scene";
  67163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67165. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  67166. import { Effect } from "babylonjs/Materials/effect";
  67167. /**
  67168. * A point light is a light defined by an unique point in world space.
  67169. * The light is emitted in every direction from this point.
  67170. * A good example of a point light is a standard light bulb.
  67171. * Documentation: https://doc.babylonjs.com/babylon101/lights
  67172. */
  67173. export class PointLight extends ShadowLight {
  67174. private _shadowAngle;
  67175. /**
  67176. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67177. * This specifies what angle the shadow will use to be created.
  67178. *
  67179. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67180. */
  67181. get shadowAngle(): number;
  67182. /**
  67183. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67184. * This specifies what angle the shadow will use to be created.
  67185. *
  67186. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67187. */
  67188. set shadowAngle(value: number);
  67189. /**
  67190. * Gets the direction if it has been set.
  67191. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67192. */
  67193. get direction(): Vector3;
  67194. /**
  67195. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67196. */
  67197. set direction(value: Vector3);
  67198. /**
  67199. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  67200. * A PointLight emits the light in every direction.
  67201. * It can cast shadows.
  67202. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  67203. * ```javascript
  67204. * var pointLight = new PointLight("pl", camera.position, scene);
  67205. * ```
  67206. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67207. * @param name The light friendly name
  67208. * @param position The position of the point light in the scene
  67209. * @param scene The scene the lights belongs to
  67210. */
  67211. constructor(name: string, position: Vector3, scene: Scene);
  67212. /**
  67213. * Returns the string "PointLight"
  67214. * @returns the class name
  67215. */
  67216. getClassName(): string;
  67217. /**
  67218. * Returns the integer 0.
  67219. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67220. */
  67221. getTypeID(): number;
  67222. /**
  67223. * Specifies wether or not the shadowmap should be a cube texture.
  67224. * @returns true if the shadowmap needs to be a cube texture.
  67225. */
  67226. needCube(): boolean;
  67227. /**
  67228. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  67229. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67230. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67231. */
  67232. getShadowDirection(faceIndex?: number): Vector3;
  67233. /**
  67234. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  67235. * - fov = PI / 2
  67236. * - aspect ratio : 1.0
  67237. * - z-near and far equal to the active camera minZ and maxZ.
  67238. * Returns the PointLight.
  67239. */
  67240. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67241. protected _buildUniformLayout(): void;
  67242. /**
  67243. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  67244. * @param effect The effect to update
  67245. * @param lightIndex The index of the light in the effect to update
  67246. * @returns The point light
  67247. */
  67248. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  67249. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  67250. /**
  67251. * Prepares the list of defines specific to the light type.
  67252. * @param defines the list of defines
  67253. * @param lightIndex defines the index of the light for the effect
  67254. */
  67255. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67256. }
  67257. }
  67258. declare module "babylonjs/Lights/index" {
  67259. export * from "babylonjs/Lights/light";
  67260. export * from "babylonjs/Lights/shadowLight";
  67261. export * from "babylonjs/Lights/Shadows/index";
  67262. export * from "babylonjs/Lights/directionalLight";
  67263. export * from "babylonjs/Lights/hemisphericLight";
  67264. export * from "babylonjs/Lights/pointLight";
  67265. export * from "babylonjs/Lights/spotLight";
  67266. }
  67267. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  67268. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67269. /**
  67270. * Header information of HDR texture files.
  67271. */
  67272. export interface HDRInfo {
  67273. /**
  67274. * The height of the texture in pixels.
  67275. */
  67276. height: number;
  67277. /**
  67278. * The width of the texture in pixels.
  67279. */
  67280. width: number;
  67281. /**
  67282. * The index of the beginning of the data in the binary file.
  67283. */
  67284. dataPosition: number;
  67285. }
  67286. /**
  67287. * This groups tools to convert HDR texture to native colors array.
  67288. */
  67289. export class HDRTools {
  67290. private static Ldexp;
  67291. private static Rgbe2float;
  67292. private static readStringLine;
  67293. /**
  67294. * Reads header information from an RGBE texture stored in a native array.
  67295. * More information on this format are available here:
  67296. * https://en.wikipedia.org/wiki/RGBE_image_format
  67297. *
  67298. * @param uint8array The binary file stored in native array.
  67299. * @return The header information.
  67300. */
  67301. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  67302. /**
  67303. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  67304. * This RGBE texture needs to store the information as a panorama.
  67305. *
  67306. * More information on this format are available here:
  67307. * https://en.wikipedia.org/wiki/RGBE_image_format
  67308. *
  67309. * @param buffer The binary file stored in an array buffer.
  67310. * @param size The expected size of the extracted cubemap.
  67311. * @return The Cube Map information.
  67312. */
  67313. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  67314. /**
  67315. * Returns the pixels data extracted from an RGBE texture.
  67316. * This pixels will be stored left to right up to down in the R G B order in one array.
  67317. *
  67318. * More information on this format are available here:
  67319. * https://en.wikipedia.org/wiki/RGBE_image_format
  67320. *
  67321. * @param uint8array The binary file stored in an array buffer.
  67322. * @param hdrInfo The header information of the file.
  67323. * @return The pixels data in RGB right to left up to down order.
  67324. */
  67325. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  67326. private static RGBE_ReadPixels_RLE;
  67327. private static RGBE_ReadPixels_NOT_RLE;
  67328. }
  67329. }
  67330. declare module "babylonjs/Materials/effectRenderer" {
  67331. import { Nullable } from "babylonjs/types";
  67332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  67333. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67334. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67335. import { Viewport } from "babylonjs/Maths/math.viewport";
  67336. import { Observable } from "babylonjs/Misc/observable";
  67337. import { Effect } from "babylonjs/Materials/effect";
  67338. import "babylonjs/Shaders/postprocess.vertex";
  67339. /**
  67340. * Effect Render Options
  67341. */
  67342. export interface IEffectRendererOptions {
  67343. /**
  67344. * Defines the vertices positions.
  67345. */
  67346. positions?: number[];
  67347. /**
  67348. * Defines the indices.
  67349. */
  67350. indices?: number[];
  67351. }
  67352. /**
  67353. * Helper class to render one or more effects.
  67354. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  67355. */
  67356. export class EffectRenderer {
  67357. private engine;
  67358. private static _DefaultOptions;
  67359. private _vertexBuffers;
  67360. private _indexBuffer;
  67361. private _fullscreenViewport;
  67362. /**
  67363. * Creates an effect renderer
  67364. * @param engine the engine to use for rendering
  67365. * @param options defines the options of the effect renderer
  67366. */
  67367. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  67368. /**
  67369. * Sets the current viewport in normalized coordinates 0-1
  67370. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  67371. */
  67372. setViewport(viewport?: Viewport): void;
  67373. /**
  67374. * Binds the embedded attributes buffer to the effect.
  67375. * @param effect Defines the effect to bind the attributes for
  67376. */
  67377. bindBuffers(effect: Effect): void;
  67378. /**
  67379. * Sets the current effect wrapper to use during draw.
  67380. * The effect needs to be ready before calling this api.
  67381. * This also sets the default full screen position attribute.
  67382. * @param effectWrapper Defines the effect to draw with
  67383. */
  67384. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  67385. /**
  67386. * Restores engine states
  67387. */
  67388. restoreStates(): void;
  67389. /**
  67390. * Draws a full screen quad.
  67391. */
  67392. draw(): void;
  67393. private isRenderTargetTexture;
  67394. /**
  67395. * renders one or more effects to a specified texture
  67396. * @param effectWrapper the effect to renderer
  67397. * @param outputTexture texture to draw to, if null it will render to the screen.
  67398. */
  67399. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  67400. /**
  67401. * Disposes of the effect renderer
  67402. */
  67403. dispose(): void;
  67404. }
  67405. /**
  67406. * Options to create an EffectWrapper
  67407. */
  67408. interface EffectWrapperCreationOptions {
  67409. /**
  67410. * Engine to use to create the effect
  67411. */
  67412. engine: ThinEngine;
  67413. /**
  67414. * Fragment shader for the effect
  67415. */
  67416. fragmentShader: string;
  67417. /**
  67418. * Use the shader store instead of direct source code
  67419. */
  67420. useShaderStore?: boolean;
  67421. /**
  67422. * Vertex shader for the effect
  67423. */
  67424. vertexShader?: string;
  67425. /**
  67426. * Attributes to use in the shader
  67427. */
  67428. attributeNames?: Array<string>;
  67429. /**
  67430. * Uniforms to use in the shader
  67431. */
  67432. uniformNames?: Array<string>;
  67433. /**
  67434. * Texture sampler names to use in the shader
  67435. */
  67436. samplerNames?: Array<string>;
  67437. /**
  67438. * Defines to use in the shader
  67439. */
  67440. defines?: Array<string>;
  67441. /**
  67442. * Callback when effect is compiled
  67443. */
  67444. onCompiled?: Nullable<(effect: Effect) => void>;
  67445. /**
  67446. * The friendly name of the effect displayed in Spector.
  67447. */
  67448. name?: string;
  67449. }
  67450. /**
  67451. * Wraps an effect to be used for rendering
  67452. */
  67453. export class EffectWrapper {
  67454. /**
  67455. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  67456. */
  67457. onApplyObservable: Observable<{}>;
  67458. /**
  67459. * The underlying effect
  67460. */
  67461. effect: Effect;
  67462. /**
  67463. * Creates an effect to be renderer
  67464. * @param creationOptions options to create the effect
  67465. */
  67466. constructor(creationOptions: EffectWrapperCreationOptions);
  67467. /**
  67468. * Disposes of the effect wrapper
  67469. */
  67470. dispose(): void;
  67471. }
  67472. }
  67473. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  67474. /** @hidden */
  67475. export var hdrFilteringVertexShader: {
  67476. name: string;
  67477. shader: string;
  67478. };
  67479. }
  67480. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  67481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67482. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  67483. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  67484. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  67485. /** @hidden */
  67486. export var hdrFilteringPixelShader: {
  67487. name: string;
  67488. shader: string;
  67489. };
  67490. }
  67491. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  67492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67493. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67494. import { Nullable } from "babylonjs/types";
  67495. import "babylonjs/Shaders/hdrFiltering.vertex";
  67496. import "babylonjs/Shaders/hdrFiltering.fragment";
  67497. /**
  67498. * Options for texture filtering
  67499. */
  67500. interface IHDRFilteringOptions {
  67501. /**
  67502. * Scales pixel intensity for the input HDR map.
  67503. */
  67504. hdrScale?: number;
  67505. /**
  67506. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  67507. */
  67508. quality?: number;
  67509. }
  67510. /**
  67511. * Filters HDR maps to get correct renderings of PBR reflections
  67512. */
  67513. export class HDRFiltering {
  67514. private _engine;
  67515. private _effectRenderer;
  67516. private _effectWrapper;
  67517. private _lodGenerationOffset;
  67518. private _lodGenerationScale;
  67519. /**
  67520. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  67521. * you care about baking speed.
  67522. */
  67523. quality: number;
  67524. /**
  67525. * Scales pixel intensity for the input HDR map.
  67526. */
  67527. hdrScale: number;
  67528. /**
  67529. * Instantiates HDR filter for reflection maps
  67530. *
  67531. * @param engine Thin engine
  67532. * @param options Options
  67533. */
  67534. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  67535. private _createRenderTarget;
  67536. private _prefilterInternal;
  67537. private _createEffect;
  67538. /**
  67539. * Get a value indicating if the filter is ready to be used
  67540. * @param texture Texture to filter
  67541. * @returns true if the filter is ready
  67542. */
  67543. isReady(texture: BaseTexture): boolean;
  67544. /**
  67545. * Prefilters a cube texture to have mipmap levels representing roughness values.
  67546. * Prefiltering will be invoked at the end of next rendering pass.
  67547. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  67548. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  67549. * @param texture Texture to filter
  67550. * @param onFinished Callback when filtering is done
  67551. * @return Promise called when prefiltering is done
  67552. */
  67553. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  67554. }
  67555. }
  67556. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  67557. import { Nullable } from "babylonjs/types";
  67558. import { Scene } from "babylonjs/scene";
  67559. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67561. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67562. import "babylonjs/Engines/Extensions/engine.rawTexture";
  67563. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  67564. /**
  67565. * This represents a texture coming from an HDR input.
  67566. *
  67567. * The only supported format is currently panorama picture stored in RGBE format.
  67568. * Example of such files can be found on HDRLib: http://hdrlib.com/
  67569. */
  67570. export class HDRCubeTexture extends BaseTexture {
  67571. private static _facesMapping;
  67572. private _generateHarmonics;
  67573. private _noMipmap;
  67574. private _prefilterOnLoad;
  67575. private _textureMatrix;
  67576. private _size;
  67577. private _onLoad;
  67578. private _onError;
  67579. /**
  67580. * The texture URL.
  67581. */
  67582. url: string;
  67583. protected _isBlocking: boolean;
  67584. /**
  67585. * Sets wether or not the texture is blocking during loading.
  67586. */
  67587. set isBlocking(value: boolean);
  67588. /**
  67589. * Gets wether or not the texture is blocking during loading.
  67590. */
  67591. get isBlocking(): boolean;
  67592. protected _rotationY: number;
  67593. /**
  67594. * Sets texture matrix rotation angle around Y axis in radians.
  67595. */
  67596. set rotationY(value: number);
  67597. /**
  67598. * Gets texture matrix rotation angle around Y axis radians.
  67599. */
  67600. get rotationY(): number;
  67601. /**
  67602. * Gets or sets the center of the bounding box associated with the cube texture
  67603. * It must define where the camera used to render the texture was set
  67604. */
  67605. boundingBoxPosition: Vector3;
  67606. private _boundingBoxSize;
  67607. /**
  67608. * Gets or sets the size of the bounding box associated with the cube texture
  67609. * When defined, the cubemap will switch to local mode
  67610. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67611. * @example https://www.babylonjs-playground.com/#RNASML
  67612. */
  67613. set boundingBoxSize(value: Vector3);
  67614. get boundingBoxSize(): Vector3;
  67615. /**
  67616. * Instantiates an HDRTexture from the following parameters.
  67617. *
  67618. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  67619. * @param sceneOrEngine The scene or engine the texture will be used in
  67620. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  67621. * @param noMipmap Forces to not generate the mipmap if true
  67622. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  67623. * @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)
  67624. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  67625. */
  67626. 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>);
  67627. /**
  67628. * Get the current class name of the texture useful for serialization or dynamic coding.
  67629. * @returns "HDRCubeTexture"
  67630. */
  67631. getClassName(): string;
  67632. /**
  67633. * Occurs when the file is raw .hdr file.
  67634. */
  67635. private loadTexture;
  67636. clone(): HDRCubeTexture;
  67637. delayLoad(): void;
  67638. /**
  67639. * Get the texture reflection matrix used to rotate/transform the reflection.
  67640. * @returns the reflection matrix
  67641. */
  67642. getReflectionTextureMatrix(): Matrix;
  67643. /**
  67644. * Set the texture reflection matrix used to rotate/transform the reflection.
  67645. * @param value Define the reflection matrix to set
  67646. */
  67647. setReflectionTextureMatrix(value: Matrix): void;
  67648. /**
  67649. * Parses a JSON representation of an HDR Texture in order to create the texture
  67650. * @param parsedTexture Define the JSON representation
  67651. * @param scene Define the scene the texture should be created in
  67652. * @param rootUrl Define the root url in case we need to load relative dependencies
  67653. * @returns the newly created texture after parsing
  67654. */
  67655. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  67656. serialize(): any;
  67657. }
  67658. }
  67659. declare module "babylonjs/Physics/physicsEngine" {
  67660. import { Nullable } from "babylonjs/types";
  67661. import { Vector3 } from "babylonjs/Maths/math.vector";
  67662. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67663. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  67664. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  67665. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67666. /**
  67667. * Class used to control physics engine
  67668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67669. */
  67670. export class PhysicsEngine implements IPhysicsEngine {
  67671. private _physicsPlugin;
  67672. /**
  67673. * Global value used to control the smallest number supported by the simulation
  67674. */
  67675. static Epsilon: number;
  67676. private _impostors;
  67677. private _joints;
  67678. private _subTimeStep;
  67679. /**
  67680. * Gets the gravity vector used by the simulation
  67681. */
  67682. gravity: Vector3;
  67683. /**
  67684. * Factory used to create the default physics plugin.
  67685. * @returns The default physics plugin
  67686. */
  67687. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  67688. /**
  67689. * Creates a new Physics Engine
  67690. * @param gravity defines the gravity vector used by the simulation
  67691. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  67692. */
  67693. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  67694. /**
  67695. * Sets the gravity vector used by the simulation
  67696. * @param gravity defines the gravity vector to use
  67697. */
  67698. setGravity(gravity: Vector3): void;
  67699. /**
  67700. * Set the time step of the physics engine.
  67701. * Default is 1/60.
  67702. * To slow it down, enter 1/600 for example.
  67703. * To speed it up, 1/30
  67704. * @param newTimeStep defines the new timestep to apply to this world.
  67705. */
  67706. setTimeStep(newTimeStep?: number): void;
  67707. /**
  67708. * Get the time step of the physics engine.
  67709. * @returns the current time step
  67710. */
  67711. getTimeStep(): number;
  67712. /**
  67713. * Set the sub time step of the physics engine.
  67714. * Default is 0 meaning there is no sub steps
  67715. * To increase physics resolution precision, set a small value (like 1 ms)
  67716. * @param subTimeStep defines the new sub timestep used for physics resolution.
  67717. */
  67718. setSubTimeStep(subTimeStep?: number): void;
  67719. /**
  67720. * Get the sub time step of the physics engine.
  67721. * @returns the current sub time step
  67722. */
  67723. getSubTimeStep(): number;
  67724. /**
  67725. * Release all resources
  67726. */
  67727. dispose(): void;
  67728. /**
  67729. * Gets the name of the current physics plugin
  67730. * @returns the name of the plugin
  67731. */
  67732. getPhysicsPluginName(): string;
  67733. /**
  67734. * Adding a new impostor for the impostor tracking.
  67735. * This will be done by the impostor itself.
  67736. * @param impostor the impostor to add
  67737. */
  67738. addImpostor(impostor: PhysicsImpostor): void;
  67739. /**
  67740. * Remove an impostor from the engine.
  67741. * This impostor and its mesh will not longer be updated by the physics engine.
  67742. * @param impostor the impostor to remove
  67743. */
  67744. removeImpostor(impostor: PhysicsImpostor): void;
  67745. /**
  67746. * Add a joint to the physics engine
  67747. * @param mainImpostor defines the main impostor to which the joint is added.
  67748. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  67749. * @param joint defines the joint that will connect both impostors.
  67750. */
  67751. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  67752. /**
  67753. * Removes a joint from the simulation
  67754. * @param mainImpostor defines the impostor used with the joint
  67755. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  67756. * @param joint defines the joint to remove
  67757. */
  67758. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  67759. /**
  67760. * Called by the scene. No need to call it.
  67761. * @param delta defines the timespam between frames
  67762. */
  67763. _step(delta: number): void;
  67764. /**
  67765. * Gets the current plugin used to run the simulation
  67766. * @returns current plugin
  67767. */
  67768. getPhysicsPlugin(): IPhysicsEnginePlugin;
  67769. /**
  67770. * Gets the list of physic impostors
  67771. * @returns an array of PhysicsImpostor
  67772. */
  67773. getImpostors(): Array<PhysicsImpostor>;
  67774. /**
  67775. * Gets the impostor for a physics enabled object
  67776. * @param object defines the object impersonated by the impostor
  67777. * @returns the PhysicsImpostor or null if not found
  67778. */
  67779. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  67780. /**
  67781. * Gets the impostor for a physics body object
  67782. * @param body defines physics body used by the impostor
  67783. * @returns the PhysicsImpostor or null if not found
  67784. */
  67785. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  67786. /**
  67787. * Does a raycast in the physics world
  67788. * @param from when should the ray start?
  67789. * @param to when should the ray end?
  67790. * @returns PhysicsRaycastResult
  67791. */
  67792. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  67793. }
  67794. }
  67795. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  67796. import { Nullable } from "babylonjs/types";
  67797. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  67798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67799. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  67800. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67801. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  67802. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67803. /** @hidden */
  67804. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  67805. private _useDeltaForWorldStep;
  67806. world: any;
  67807. name: string;
  67808. private _physicsMaterials;
  67809. private _fixedTimeStep;
  67810. private _cannonRaycastResult;
  67811. private _raycastResult;
  67812. private _physicsBodysToRemoveAfterStep;
  67813. private _firstFrame;
  67814. BJSCANNON: any;
  67815. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  67816. setGravity(gravity: Vector3): void;
  67817. setTimeStep(timeStep: number): void;
  67818. getTimeStep(): number;
  67819. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  67820. private _removeMarkedPhysicsBodiesFromWorld;
  67821. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67822. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67823. generatePhysicsBody(impostor: PhysicsImpostor): void;
  67824. private _processChildMeshes;
  67825. removePhysicsBody(impostor: PhysicsImpostor): void;
  67826. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  67827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  67828. private _addMaterial;
  67829. private _checkWithEpsilon;
  67830. private _createShape;
  67831. private _createHeightmap;
  67832. private _minus90X;
  67833. private _plus90X;
  67834. private _tmpPosition;
  67835. private _tmpDeltaPosition;
  67836. private _tmpUnityRotation;
  67837. private _updatePhysicsBodyTransformation;
  67838. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  67839. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  67840. isSupported(): boolean;
  67841. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67842. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67843. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67844. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67845. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  67846. getBodyMass(impostor: PhysicsImpostor): number;
  67847. getBodyFriction(impostor: PhysicsImpostor): number;
  67848. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  67849. getBodyRestitution(impostor: PhysicsImpostor): number;
  67850. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  67851. sleepBody(impostor: PhysicsImpostor): void;
  67852. wakeUpBody(impostor: PhysicsImpostor): void;
  67853. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  67854. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  67855. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  67856. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  67857. getRadius(impostor: PhysicsImpostor): number;
  67858. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  67859. dispose(): void;
  67860. private _extendNamespace;
  67861. /**
  67862. * Does a raycast in the physics world
  67863. * @param from when should the ray start?
  67864. * @param to when should the ray end?
  67865. * @returns PhysicsRaycastResult
  67866. */
  67867. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  67868. }
  67869. }
  67870. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  67871. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  67872. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67873. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  67874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67875. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  67876. import { Nullable } from "babylonjs/types";
  67877. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67878. /** @hidden */
  67879. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  67880. private _useDeltaForWorldStep;
  67881. world: any;
  67882. name: string;
  67883. BJSOIMO: any;
  67884. private _raycastResult;
  67885. private _fixedTimeStep;
  67886. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  67887. setGravity(gravity: Vector3): void;
  67888. setTimeStep(timeStep: number): void;
  67889. getTimeStep(): number;
  67890. private _tmpImpostorsArray;
  67891. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  67892. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67893. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67894. generatePhysicsBody(impostor: PhysicsImpostor): void;
  67895. private _tmpPositionVector;
  67896. removePhysicsBody(impostor: PhysicsImpostor): void;
  67897. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  67898. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  67899. isSupported(): boolean;
  67900. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  67901. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  67902. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67903. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67904. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67905. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67906. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  67907. getBodyMass(impostor: PhysicsImpostor): number;
  67908. getBodyFriction(impostor: PhysicsImpostor): number;
  67909. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  67910. getBodyRestitution(impostor: PhysicsImpostor): number;
  67911. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  67912. sleepBody(impostor: PhysicsImpostor): void;
  67913. wakeUpBody(impostor: PhysicsImpostor): void;
  67914. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  67915. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  67916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  67917. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  67918. getRadius(impostor: PhysicsImpostor): number;
  67919. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  67920. dispose(): void;
  67921. /**
  67922. * Does a raycast in the physics world
  67923. * @param from when should the ray start?
  67924. * @param to when should the ray end?
  67925. * @returns PhysicsRaycastResult
  67926. */
  67927. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  67928. }
  67929. }
  67930. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  67931. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  67932. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  67933. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67934. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  67935. import { Nullable } from "babylonjs/types";
  67936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67937. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67938. /**
  67939. * AmmoJS Physics plugin
  67940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67941. * @see https://github.com/kripken/ammo.js/
  67942. */
  67943. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  67944. private _useDeltaForWorldStep;
  67945. /**
  67946. * Reference to the Ammo library
  67947. */
  67948. bjsAMMO: any;
  67949. /**
  67950. * Created ammoJS world which physics bodies are added to
  67951. */
  67952. world: any;
  67953. /**
  67954. * Name of the plugin
  67955. */
  67956. name: string;
  67957. private _timeStep;
  67958. private _fixedTimeStep;
  67959. private _maxSteps;
  67960. private _tmpQuaternion;
  67961. private _tmpAmmoTransform;
  67962. private _tmpAmmoQuaternion;
  67963. private _tmpAmmoConcreteContactResultCallback;
  67964. private _collisionConfiguration;
  67965. private _dispatcher;
  67966. private _overlappingPairCache;
  67967. private _solver;
  67968. private _softBodySolver;
  67969. private _tmpAmmoVectorA;
  67970. private _tmpAmmoVectorB;
  67971. private _tmpAmmoVectorC;
  67972. private _tmpAmmoVectorD;
  67973. private _tmpContactCallbackResult;
  67974. private _tmpAmmoVectorRCA;
  67975. private _tmpAmmoVectorRCB;
  67976. private _raycastResult;
  67977. private _tmpContactPoint;
  67978. private static readonly DISABLE_COLLISION_FLAG;
  67979. private static readonly KINEMATIC_FLAG;
  67980. private static readonly DISABLE_DEACTIVATION_FLAG;
  67981. /**
  67982. * Initializes the ammoJS plugin
  67983. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  67984. * @param ammoInjection can be used to inject your own ammo reference
  67985. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  67986. */
  67987. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  67988. /**
  67989. * Sets the gravity of the physics world (m/(s^2))
  67990. * @param gravity Gravity to set
  67991. */
  67992. setGravity(gravity: Vector3): void;
  67993. /**
  67994. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  67995. * @param timeStep timestep to use in seconds
  67996. */
  67997. setTimeStep(timeStep: number): void;
  67998. /**
  67999. * 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)
  68000. * @param fixedTimeStep fixedTimeStep to use in seconds
  68001. */
  68002. setFixedTimeStep(fixedTimeStep: number): void;
  68003. /**
  68004. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  68005. * @param maxSteps the maximum number of steps by the physics engine per frame
  68006. */
  68007. setMaxSteps(maxSteps: number): void;
  68008. /**
  68009. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  68010. * @returns the current timestep in seconds
  68011. */
  68012. getTimeStep(): number;
  68013. /**
  68014. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  68015. */
  68016. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  68017. private _isImpostorInContact;
  68018. private _isImpostorPairInContact;
  68019. private _stepSimulation;
  68020. /**
  68021. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  68022. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  68023. * After the step the babylon meshes are set to the position of the physics imposters
  68024. * @param delta amount of time to step forward
  68025. * @param impostors array of imposters to update before/after the step
  68026. */
  68027. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68028. /**
  68029. * Update babylon mesh to match physics world object
  68030. * @param impostor imposter to match
  68031. */
  68032. private _afterSoftStep;
  68033. /**
  68034. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68035. * @param impostor imposter to match
  68036. */
  68037. private _ropeStep;
  68038. /**
  68039. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68040. * @param impostor imposter to match
  68041. */
  68042. private _softbodyOrClothStep;
  68043. private _tmpMatrix;
  68044. /**
  68045. * Applies an impulse on the imposter
  68046. * @param impostor imposter to apply impulse to
  68047. * @param force amount of force to be applied to the imposter
  68048. * @param contactPoint the location to apply the impulse on the imposter
  68049. */
  68050. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68051. /**
  68052. * Applies a force on the imposter
  68053. * @param impostor imposter to apply force
  68054. * @param force amount of force to be applied to the imposter
  68055. * @param contactPoint the location to apply the force on the imposter
  68056. */
  68057. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68058. /**
  68059. * Creates a physics body using the plugin
  68060. * @param impostor the imposter to create the physics body on
  68061. */
  68062. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68063. /**
  68064. * Removes the physics body from the imposter and disposes of the body's memory
  68065. * @param impostor imposter to remove the physics body from
  68066. */
  68067. removePhysicsBody(impostor: PhysicsImpostor): void;
  68068. /**
  68069. * Generates a joint
  68070. * @param impostorJoint the imposter joint to create the joint with
  68071. */
  68072. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68073. /**
  68074. * Removes a joint
  68075. * @param impostorJoint the imposter joint to remove the joint from
  68076. */
  68077. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68078. private _addMeshVerts;
  68079. /**
  68080. * Initialise the soft body vertices to match its object's (mesh) vertices
  68081. * Softbody vertices (nodes) are in world space and to match this
  68082. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  68083. * @param impostor to create the softbody for
  68084. */
  68085. private _softVertexData;
  68086. /**
  68087. * Create an impostor's soft body
  68088. * @param impostor to create the softbody for
  68089. */
  68090. private _createSoftbody;
  68091. /**
  68092. * Create cloth for an impostor
  68093. * @param impostor to create the softbody for
  68094. */
  68095. private _createCloth;
  68096. /**
  68097. * Create rope for an impostor
  68098. * @param impostor to create the softbody for
  68099. */
  68100. private _createRope;
  68101. /**
  68102. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  68103. * @param impostor to create the custom physics shape for
  68104. */
  68105. private _createCustom;
  68106. private _addHullVerts;
  68107. private _createShape;
  68108. /**
  68109. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  68110. * @param impostor imposter containing the physics body and babylon object
  68111. */
  68112. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68113. /**
  68114. * Sets the babylon object's position/rotation from the physics body's position/rotation
  68115. * @param impostor imposter containing the physics body and babylon object
  68116. * @param newPosition new position
  68117. * @param newRotation new rotation
  68118. */
  68119. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68120. /**
  68121. * If this plugin is supported
  68122. * @returns true if its supported
  68123. */
  68124. isSupported(): boolean;
  68125. /**
  68126. * Sets the linear velocity of the physics body
  68127. * @param impostor imposter to set the velocity on
  68128. * @param velocity velocity to set
  68129. */
  68130. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68131. /**
  68132. * Sets the angular velocity of the physics body
  68133. * @param impostor imposter to set the velocity on
  68134. * @param velocity velocity to set
  68135. */
  68136. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68137. /**
  68138. * gets the linear velocity
  68139. * @param impostor imposter to get linear velocity from
  68140. * @returns linear velocity
  68141. */
  68142. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68143. /**
  68144. * gets the angular velocity
  68145. * @param impostor imposter to get angular velocity from
  68146. * @returns angular velocity
  68147. */
  68148. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68149. /**
  68150. * Sets the mass of physics body
  68151. * @param impostor imposter to set the mass on
  68152. * @param mass mass to set
  68153. */
  68154. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68155. /**
  68156. * Gets the mass of the physics body
  68157. * @param impostor imposter to get the mass from
  68158. * @returns mass
  68159. */
  68160. getBodyMass(impostor: PhysicsImpostor): number;
  68161. /**
  68162. * Gets friction of the impostor
  68163. * @param impostor impostor to get friction from
  68164. * @returns friction value
  68165. */
  68166. getBodyFriction(impostor: PhysicsImpostor): number;
  68167. /**
  68168. * Sets friction of the impostor
  68169. * @param impostor impostor to set friction on
  68170. * @param friction friction value
  68171. */
  68172. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68173. /**
  68174. * Gets restitution of the impostor
  68175. * @param impostor impostor to get restitution from
  68176. * @returns restitution value
  68177. */
  68178. getBodyRestitution(impostor: PhysicsImpostor): number;
  68179. /**
  68180. * Sets resitution of the impostor
  68181. * @param impostor impostor to set resitution on
  68182. * @param restitution resitution value
  68183. */
  68184. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68185. /**
  68186. * Gets pressure inside the impostor
  68187. * @param impostor impostor to get pressure from
  68188. * @returns pressure value
  68189. */
  68190. getBodyPressure(impostor: PhysicsImpostor): number;
  68191. /**
  68192. * Sets pressure inside a soft body impostor
  68193. * Cloth and rope must remain 0 pressure
  68194. * @param impostor impostor to set pressure on
  68195. * @param pressure pressure value
  68196. */
  68197. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  68198. /**
  68199. * Gets stiffness of the impostor
  68200. * @param impostor impostor to get stiffness from
  68201. * @returns pressure value
  68202. */
  68203. getBodyStiffness(impostor: PhysicsImpostor): number;
  68204. /**
  68205. * Sets stiffness of the impostor
  68206. * @param impostor impostor to set stiffness on
  68207. * @param stiffness stiffness value from 0 to 1
  68208. */
  68209. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  68210. /**
  68211. * Gets velocityIterations of the impostor
  68212. * @param impostor impostor to get velocity iterations from
  68213. * @returns velocityIterations value
  68214. */
  68215. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  68216. /**
  68217. * Sets velocityIterations of the impostor
  68218. * @param impostor impostor to set velocity iterations on
  68219. * @param velocityIterations velocityIterations value
  68220. */
  68221. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  68222. /**
  68223. * Gets positionIterations of the impostor
  68224. * @param impostor impostor to get position iterations from
  68225. * @returns positionIterations value
  68226. */
  68227. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  68228. /**
  68229. * Sets positionIterations of the impostor
  68230. * @param impostor impostor to set position on
  68231. * @param positionIterations positionIterations value
  68232. */
  68233. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  68234. /**
  68235. * Append an anchor to a cloth object
  68236. * @param impostor is the cloth impostor to add anchor to
  68237. * @param otherImpostor is the rigid impostor to anchor to
  68238. * @param width ratio across width from 0 to 1
  68239. * @param height ratio up height from 0 to 1
  68240. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  68241. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68242. */
  68243. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68244. /**
  68245. * Append an hook to a rope object
  68246. * @param impostor is the rope impostor to add hook to
  68247. * @param otherImpostor is the rigid impostor to hook to
  68248. * @param length ratio along the rope from 0 to 1
  68249. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  68250. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68251. */
  68252. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68253. /**
  68254. * Sleeps the physics body and stops it from being active
  68255. * @param impostor impostor to sleep
  68256. */
  68257. sleepBody(impostor: PhysicsImpostor): void;
  68258. /**
  68259. * Activates the physics body
  68260. * @param impostor impostor to activate
  68261. */
  68262. wakeUpBody(impostor: PhysicsImpostor): void;
  68263. /**
  68264. * Updates the distance parameters of the joint
  68265. * @param joint joint to update
  68266. * @param maxDistance maximum distance of the joint
  68267. * @param minDistance minimum distance of the joint
  68268. */
  68269. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68270. /**
  68271. * Sets a motor on the joint
  68272. * @param joint joint to set motor on
  68273. * @param speed speed of the motor
  68274. * @param maxForce maximum force of the motor
  68275. * @param motorIndex index of the motor
  68276. */
  68277. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68278. /**
  68279. * Sets the motors limit
  68280. * @param joint joint to set limit on
  68281. * @param upperLimit upper limit
  68282. * @param lowerLimit lower limit
  68283. */
  68284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68285. /**
  68286. * Syncs the position and rotation of a mesh with the impostor
  68287. * @param mesh mesh to sync
  68288. * @param impostor impostor to update the mesh with
  68289. */
  68290. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68291. /**
  68292. * Gets the radius of the impostor
  68293. * @param impostor impostor to get radius from
  68294. * @returns the radius
  68295. */
  68296. getRadius(impostor: PhysicsImpostor): number;
  68297. /**
  68298. * Gets the box size of the impostor
  68299. * @param impostor impostor to get box size from
  68300. * @param result the resulting box size
  68301. */
  68302. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68303. /**
  68304. * Disposes of the impostor
  68305. */
  68306. dispose(): void;
  68307. /**
  68308. * Does a raycast in the physics world
  68309. * @param from when should the ray start?
  68310. * @param to when should the ray end?
  68311. * @returns PhysicsRaycastResult
  68312. */
  68313. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68314. }
  68315. }
  68316. declare module "babylonjs/Probes/reflectionProbe" {
  68317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68318. import { Vector3 } from "babylonjs/Maths/math.vector";
  68319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68320. import { Nullable } from "babylonjs/types";
  68321. import { Scene } from "babylonjs/scene";
  68322. module "babylonjs/abstractScene" {
  68323. interface AbstractScene {
  68324. /**
  68325. * The list of reflection probes added to the scene
  68326. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68327. */
  68328. reflectionProbes: Array<ReflectionProbe>;
  68329. /**
  68330. * Removes the given reflection probe from this scene.
  68331. * @param toRemove The reflection probe to remove
  68332. * @returns The index of the removed reflection probe
  68333. */
  68334. removeReflectionProbe(toRemove: ReflectionProbe): number;
  68335. /**
  68336. * Adds the given reflection probe to this scene.
  68337. * @param newReflectionProbe The reflection probe to add
  68338. */
  68339. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  68340. }
  68341. }
  68342. /**
  68343. * Class used to generate realtime reflection / refraction cube textures
  68344. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68345. */
  68346. export class ReflectionProbe {
  68347. /** defines the name of the probe */
  68348. name: string;
  68349. private _scene;
  68350. private _renderTargetTexture;
  68351. private _projectionMatrix;
  68352. private _viewMatrix;
  68353. private _target;
  68354. private _add;
  68355. private _attachedMesh;
  68356. private _invertYAxis;
  68357. /** Gets or sets probe position (center of the cube map) */
  68358. position: Vector3;
  68359. /**
  68360. * Creates a new reflection probe
  68361. * @param name defines the name of the probe
  68362. * @param size defines the texture resolution (for each face)
  68363. * @param scene defines the hosting scene
  68364. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  68365. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  68366. */
  68367. constructor(
  68368. /** defines the name of the probe */
  68369. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  68370. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  68371. get samples(): number;
  68372. set samples(value: number);
  68373. /** Gets or sets the refresh rate to use (on every frame by default) */
  68374. get refreshRate(): number;
  68375. set refreshRate(value: number);
  68376. /**
  68377. * Gets the hosting scene
  68378. * @returns a Scene
  68379. */
  68380. getScene(): Scene;
  68381. /** Gets the internal CubeTexture used to render to */
  68382. get cubeTexture(): RenderTargetTexture;
  68383. /** Gets the list of meshes to render */
  68384. get renderList(): Nullable<AbstractMesh[]>;
  68385. /**
  68386. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  68387. * @param mesh defines the mesh to attach to
  68388. */
  68389. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  68390. /**
  68391. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  68392. * @param renderingGroupId The rendering group id corresponding to its index
  68393. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  68394. */
  68395. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  68396. /**
  68397. * Clean all associated resources
  68398. */
  68399. dispose(): void;
  68400. /**
  68401. * Converts the reflection probe information to a readable string for debug purpose.
  68402. * @param fullDetails Supports for multiple levels of logging within scene loading
  68403. * @returns the human readable reflection probe info
  68404. */
  68405. toString(fullDetails?: boolean): string;
  68406. /**
  68407. * Get the class name of the relfection probe.
  68408. * @returns "ReflectionProbe"
  68409. */
  68410. getClassName(): string;
  68411. /**
  68412. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  68413. * @returns The JSON representation of the texture
  68414. */
  68415. serialize(): any;
  68416. /**
  68417. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  68418. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  68419. * @param scene Define the scene the parsed reflection probe should be instantiated in
  68420. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68421. * @returns The parsed reflection probe if successful
  68422. */
  68423. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  68424. }
  68425. }
  68426. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  68427. /** @hidden */
  68428. export var _BabylonLoaderRegistered: boolean;
  68429. /**
  68430. * Helps setting up some configuration for the babylon file loader.
  68431. */
  68432. export class BabylonFileLoaderConfiguration {
  68433. /**
  68434. * The loader does not allow injecting custom physix engine into the plugins.
  68435. * Unfortunately in ES6, we need to manually inject them into the plugin.
  68436. * So you could set this variable to your engine import to make it work.
  68437. */
  68438. static LoaderInjectedPhysicsEngine: any;
  68439. }
  68440. }
  68441. declare module "babylonjs/Loading/Plugins/index" {
  68442. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  68443. }
  68444. declare module "babylonjs/Loading/index" {
  68445. export * from "babylonjs/Loading/loadingScreen";
  68446. export * from "babylonjs/Loading/Plugins/index";
  68447. export * from "babylonjs/Loading/sceneLoader";
  68448. export * from "babylonjs/Loading/sceneLoaderFlags";
  68449. }
  68450. declare module "babylonjs/Materials/Background/index" {
  68451. export * from "babylonjs/Materials/Background/backgroundMaterial";
  68452. }
  68453. declare module "babylonjs/Materials/Occlusion/occlusionMaterial" {
  68454. import { Scene } from "babylonjs/scene";
  68455. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  68456. import "babylonjs/Shaders/color.fragment";
  68457. import "babylonjs/Shaders/color.vertex";
  68458. /**
  68459. * A material to use for fast depth-only rendering.
  68460. */
  68461. export class OcclusionMaterial extends ShaderMaterial {
  68462. constructor(name: string, scene: Scene);
  68463. }
  68464. }
  68465. declare module "babylonjs/Materials/Occlusion/index" {
  68466. export * from "babylonjs/Materials/Occlusion/occlusionMaterial";
  68467. }
  68468. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  68469. import { Scene } from "babylonjs/scene";
  68470. import { Color3 } from "babylonjs/Maths/math.color";
  68471. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68473. /**
  68474. * The Physically based simple base material of BJS.
  68475. *
  68476. * This enables better naming and convention enforcements on top of the pbrMaterial.
  68477. * It is used as the base class for both the specGloss and metalRough conventions.
  68478. */
  68479. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  68480. /**
  68481. * Number of Simultaneous lights allowed on the material.
  68482. */
  68483. maxSimultaneousLights: number;
  68484. /**
  68485. * If sets to true, disables all the lights affecting the material.
  68486. */
  68487. disableLighting: boolean;
  68488. /**
  68489. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  68490. */
  68491. environmentTexture: BaseTexture;
  68492. /**
  68493. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  68494. */
  68495. invertNormalMapX: boolean;
  68496. /**
  68497. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  68498. */
  68499. invertNormalMapY: boolean;
  68500. /**
  68501. * Normal map used in the model.
  68502. */
  68503. normalTexture: BaseTexture;
  68504. /**
  68505. * Emissivie color used to self-illuminate the model.
  68506. */
  68507. emissiveColor: Color3;
  68508. /**
  68509. * Emissivie texture used to self-illuminate the model.
  68510. */
  68511. emissiveTexture: BaseTexture;
  68512. /**
  68513. * Occlusion Channel Strenght.
  68514. */
  68515. occlusionStrength: number;
  68516. /**
  68517. * Occlusion Texture of the material (adding extra occlusion effects).
  68518. */
  68519. occlusionTexture: BaseTexture;
  68520. /**
  68521. * Defines the alpha limits in alpha test mode.
  68522. */
  68523. alphaCutOff: number;
  68524. /**
  68525. * Gets the current double sided mode.
  68526. */
  68527. get doubleSided(): boolean;
  68528. /**
  68529. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  68530. */
  68531. set doubleSided(value: boolean);
  68532. /**
  68533. * Stores the pre-calculated light information of a mesh in a texture.
  68534. */
  68535. lightmapTexture: BaseTexture;
  68536. /**
  68537. * If true, the light map contains occlusion information instead of lighting info.
  68538. */
  68539. useLightmapAsShadowmap: boolean;
  68540. /**
  68541. * Instantiates a new PBRMaterial instance.
  68542. *
  68543. * @param name The material name
  68544. * @param scene The scene the material will be use in.
  68545. */
  68546. constructor(name: string, scene: Scene);
  68547. getClassName(): string;
  68548. }
  68549. }
  68550. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  68551. import { Scene } from "babylonjs/scene";
  68552. import { Color3 } from "babylonjs/Maths/math.color";
  68553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68554. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68555. /**
  68556. * The PBR material of BJS following the metal roughness convention.
  68557. *
  68558. * This fits to the PBR convention in the GLTF definition:
  68559. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  68560. */
  68561. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  68562. /**
  68563. * The base color has two different interpretations depending on the value of metalness.
  68564. * When the material is a metal, the base color is the specific measured reflectance value
  68565. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  68566. * of the material.
  68567. */
  68568. baseColor: Color3;
  68569. /**
  68570. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  68571. * well as opacity information in the alpha channel.
  68572. */
  68573. baseTexture: BaseTexture;
  68574. /**
  68575. * Specifies the metallic scalar value of the material.
  68576. * Can also be used to scale the metalness values of the metallic texture.
  68577. */
  68578. metallic: number;
  68579. /**
  68580. * Specifies the roughness scalar value of the material.
  68581. * Can also be used to scale the roughness values of the metallic texture.
  68582. */
  68583. roughness: number;
  68584. /**
  68585. * Texture containing both the metallic value in the B channel and the
  68586. * roughness value in the G channel to keep better precision.
  68587. */
  68588. metallicRoughnessTexture: BaseTexture;
  68589. /**
  68590. * Instantiates a new PBRMetalRoughnessMaterial instance.
  68591. *
  68592. * @param name The material name
  68593. * @param scene The scene the material will be use in.
  68594. */
  68595. constructor(name: string, scene: Scene);
  68596. /**
  68597. * Return the currrent class name of the material.
  68598. */
  68599. getClassName(): string;
  68600. /**
  68601. * Makes a duplicate of the current material.
  68602. * @param name - name to use for the new material.
  68603. */
  68604. clone(name: string): PBRMetallicRoughnessMaterial;
  68605. /**
  68606. * Serialize the material to a parsable JSON object.
  68607. */
  68608. serialize(): any;
  68609. /**
  68610. * Parses a JSON object correponding to the serialize function.
  68611. */
  68612. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  68613. }
  68614. }
  68615. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  68616. import { Scene } from "babylonjs/scene";
  68617. import { Color3 } from "babylonjs/Maths/math.color";
  68618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68619. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68620. /**
  68621. * The PBR material of BJS following the specular glossiness convention.
  68622. *
  68623. * This fits to the PBR convention in the GLTF definition:
  68624. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  68625. */
  68626. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  68627. /**
  68628. * Specifies the diffuse color of the material.
  68629. */
  68630. diffuseColor: Color3;
  68631. /**
  68632. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  68633. * channel.
  68634. */
  68635. diffuseTexture: BaseTexture;
  68636. /**
  68637. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  68638. */
  68639. specularColor: Color3;
  68640. /**
  68641. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  68642. */
  68643. glossiness: number;
  68644. /**
  68645. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  68646. */
  68647. specularGlossinessTexture: BaseTexture;
  68648. /**
  68649. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  68650. */
  68651. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  68652. /**
  68653. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  68654. *
  68655. * @param name The material name
  68656. * @param scene The scene the material will be use in.
  68657. */
  68658. constructor(name: string, scene: Scene);
  68659. /**
  68660. * Return the currrent class name of the material.
  68661. */
  68662. getClassName(): string;
  68663. /**
  68664. * Makes a duplicate of the current material.
  68665. * @param name - name to use for the new material.
  68666. */
  68667. clone(name: string): PBRSpecularGlossinessMaterial;
  68668. /**
  68669. * Serialize the material to a parsable JSON object.
  68670. */
  68671. serialize(): any;
  68672. /**
  68673. * Parses a JSON object correponding to the serialize function.
  68674. */
  68675. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  68676. }
  68677. }
  68678. declare module "babylonjs/Materials/PBR/index" {
  68679. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68680. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68681. export * from "babylonjs/Materials/PBR/pbrMaterial";
  68682. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  68683. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  68684. }
  68685. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  68686. import { Nullable } from "babylonjs/types";
  68687. import { Scene } from "babylonjs/scene";
  68688. import { Matrix } from "babylonjs/Maths/math.vector";
  68689. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68690. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68691. import "babylonjs/Engines/Extensions/engine.rawTexture";
  68692. /**
  68693. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  68694. * It can help converting any input color in a desired output one. This can then be used to create effects
  68695. * from sepia, black and white to sixties or futuristic rendering...
  68696. *
  68697. * The only supported format is currently 3dl.
  68698. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  68699. */
  68700. export class ColorGradingTexture extends BaseTexture {
  68701. /**
  68702. * The texture URL.
  68703. */
  68704. url: string;
  68705. /**
  68706. * Empty line regex stored for GC.
  68707. */
  68708. private static _noneEmptyLineRegex;
  68709. private _textureMatrix;
  68710. private _onLoad;
  68711. /**
  68712. * Instantiates a ColorGradingTexture from the following parameters.
  68713. *
  68714. * @param url The location of the color gradind data (currently only supporting 3dl)
  68715. * @param sceneOrEngine The scene or engine the texture will be used in
  68716. * @param onLoad defines a callback triggered when the texture has been loaded
  68717. */
  68718. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  68719. /**
  68720. * Fires the onload event from the constructor if requested.
  68721. */
  68722. private _triggerOnLoad;
  68723. /**
  68724. * Returns the texture matrix used in most of the material.
  68725. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  68726. */
  68727. getTextureMatrix(): Matrix;
  68728. /**
  68729. * Occurs when the file being loaded is a .3dl LUT file.
  68730. */
  68731. private load3dlTexture;
  68732. /**
  68733. * Starts the loading process of the texture.
  68734. */
  68735. private loadTexture;
  68736. /**
  68737. * Clones the color gradind texture.
  68738. */
  68739. clone(): ColorGradingTexture;
  68740. /**
  68741. * Called during delayed load for textures.
  68742. */
  68743. delayLoad(): void;
  68744. /**
  68745. * Parses a color grading texture serialized by Babylon.
  68746. * @param parsedTexture The texture information being parsedTexture
  68747. * @param scene The scene to load the texture in
  68748. * @param rootUrl The root url of the data assets to load
  68749. * @return A color gradind texture
  68750. */
  68751. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  68752. /**
  68753. * Serializes the LUT texture to json format.
  68754. */
  68755. serialize(): any;
  68756. }
  68757. }
  68758. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  68759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68760. import { Scene } from "babylonjs/scene";
  68761. import { Nullable } from "babylonjs/types";
  68762. import "babylonjs/Engines/Extensions/engine.rawTexture";
  68763. /**
  68764. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  68765. */
  68766. export class EquiRectangularCubeTexture extends BaseTexture {
  68767. /** The six faces of the cube. */
  68768. private static _FacesMapping;
  68769. private _noMipmap;
  68770. private _onLoad;
  68771. private _onError;
  68772. /** The size of the cubemap. */
  68773. private _size;
  68774. /** The buffer of the image. */
  68775. private _buffer;
  68776. /** The width of the input image. */
  68777. private _width;
  68778. /** The height of the input image. */
  68779. private _height;
  68780. /** The URL to the image. */
  68781. url: string;
  68782. /**
  68783. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  68784. * @param url The location of the image
  68785. * @param scene The scene the texture will be used in
  68786. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  68787. * @param noMipmap Forces to not generate the mipmap if true
  68788. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68789. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68790. * @param onLoad — defines a callback called when texture is loaded
  68791. * @param onError — defines a callback called if there is an error
  68792. */
  68793. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  68794. /**
  68795. * Load the image data, by putting the image on a canvas and extracting its buffer.
  68796. */
  68797. private loadImage;
  68798. /**
  68799. * Convert the image buffer into a cubemap and create a CubeTexture.
  68800. */
  68801. private loadTexture;
  68802. /**
  68803. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  68804. * @param buffer The ArrayBuffer that should be converted.
  68805. * @returns The buffer as Float32Array.
  68806. */
  68807. private getFloat32ArrayFromArrayBuffer;
  68808. /**
  68809. * Get the current class name of the texture useful for serialization or dynamic coding.
  68810. * @returns "EquiRectangularCubeTexture"
  68811. */
  68812. getClassName(): string;
  68813. /**
  68814. * Create a clone of the current EquiRectangularCubeTexture and return it.
  68815. * @returns A clone of the current EquiRectangularCubeTexture.
  68816. */
  68817. clone(): EquiRectangularCubeTexture;
  68818. }
  68819. }
  68820. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  68821. import { Nullable } from "babylonjs/types";
  68822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68823. import { Matrix } from "babylonjs/Maths/math.vector";
  68824. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  68825. import "babylonjs/Engines/Extensions/engine.videoTexture";
  68826. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68827. import { Scene } from "babylonjs/scene";
  68828. /**
  68829. * Defines the options related to the creation of an HtmlElementTexture
  68830. */
  68831. export interface IHtmlElementTextureOptions {
  68832. /**
  68833. * Defines wether mip maps should be created or not.
  68834. */
  68835. generateMipMaps?: boolean;
  68836. /**
  68837. * Defines the sampling mode of the texture.
  68838. */
  68839. samplingMode?: number;
  68840. /**
  68841. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  68842. */
  68843. engine: Nullable<ThinEngine>;
  68844. /**
  68845. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  68846. */
  68847. scene: Nullable<Scene>;
  68848. }
  68849. /**
  68850. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  68851. * To be as efficient as possible depending on your constraints nothing aside the first upload
  68852. * is automatically managed.
  68853. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  68854. * in your application.
  68855. *
  68856. * As the update is not automatic, you need to call them manually.
  68857. */
  68858. export class HtmlElementTexture extends BaseTexture {
  68859. /**
  68860. * The texture URL.
  68861. */
  68862. element: HTMLVideoElement | HTMLCanvasElement;
  68863. private static readonly DefaultOptions;
  68864. private _textureMatrix;
  68865. private _isVideo;
  68866. private _generateMipMaps;
  68867. private _samplingMode;
  68868. /**
  68869. * Instantiates a HtmlElementTexture from the following parameters.
  68870. *
  68871. * @param name Defines the name of the texture
  68872. * @param element Defines the video or canvas the texture is filled with
  68873. * @param options Defines the other none mandatory texture creation options
  68874. */
  68875. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  68876. private _createInternalTexture;
  68877. /**
  68878. * Returns the texture matrix used in most of the material.
  68879. */
  68880. getTextureMatrix(): Matrix;
  68881. /**
  68882. * Updates the content of the texture.
  68883. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  68884. */
  68885. update(invertY?: Nullable<boolean>): void;
  68886. }
  68887. }
  68888. declare module "babylonjs/Misc/tga" {
  68889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68890. /**
  68891. * Based on jsTGALoader - Javascript loader for TGA file
  68892. * By Vincent Thibault
  68893. * @see http://blog.robrowser.com/javascript-tga-loader.html
  68894. */
  68895. export class TGATools {
  68896. private static _TYPE_INDEXED;
  68897. private static _TYPE_RGB;
  68898. private static _TYPE_GREY;
  68899. private static _TYPE_RLE_INDEXED;
  68900. private static _TYPE_RLE_RGB;
  68901. private static _TYPE_RLE_GREY;
  68902. private static _ORIGIN_MASK;
  68903. private static _ORIGIN_SHIFT;
  68904. private static _ORIGIN_BL;
  68905. private static _ORIGIN_BR;
  68906. private static _ORIGIN_UL;
  68907. private static _ORIGIN_UR;
  68908. /**
  68909. * Gets the header of a TGA file
  68910. * @param data defines the TGA data
  68911. * @returns the header
  68912. */
  68913. static GetTGAHeader(data: Uint8Array): any;
  68914. /**
  68915. * Uploads TGA content to a Babylon Texture
  68916. * @hidden
  68917. */
  68918. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  68919. /** @hidden */
  68920. 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;
  68921. /** @hidden */
  68922. 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;
  68923. /** @hidden */
  68924. 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;
  68925. /** @hidden */
  68926. 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;
  68927. /** @hidden */
  68928. 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;
  68929. /** @hidden */
  68930. 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;
  68931. }
  68932. }
  68933. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  68934. import { Nullable } from "babylonjs/types";
  68935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68936. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  68937. /**
  68938. * Implementation of the TGA Texture Loader.
  68939. * @hidden
  68940. */
  68941. export class _TGATextureLoader implements IInternalTextureLoader {
  68942. /**
  68943. * Defines wether the loader supports cascade loading the different faces.
  68944. */
  68945. readonly supportCascades: boolean;
  68946. /**
  68947. * This returns if the loader support the current file information.
  68948. * @param extension defines the file extension of the file being loaded
  68949. * @returns true if the loader can load the specified file
  68950. */
  68951. canLoad(extension: string): boolean;
  68952. /**
  68953. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  68954. * @param data contains the texture data
  68955. * @param texture defines the BabylonJS internal texture
  68956. * @param createPolynomials will be true if polynomials have been requested
  68957. * @param onLoad defines the callback to trigger once the texture is ready
  68958. * @param onError defines the callback to trigger in case of error
  68959. */
  68960. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68961. /**
  68962. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  68963. * @param data contains the texture data
  68964. * @param texture defines the BabylonJS internal texture
  68965. * @param callback defines the method to call once ready to upload
  68966. */
  68967. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  68968. }
  68969. }
  68970. declare module "babylonjs/Misc/basis" {
  68971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68972. /**
  68973. * Info about the .basis files
  68974. */
  68975. class BasisFileInfo {
  68976. /**
  68977. * If the file has alpha
  68978. */
  68979. hasAlpha: boolean;
  68980. /**
  68981. * Info about each image of the basis file
  68982. */
  68983. images: Array<{
  68984. levels: Array<{
  68985. width: number;
  68986. height: number;
  68987. transcodedPixels: ArrayBufferView;
  68988. }>;
  68989. }>;
  68990. }
  68991. /**
  68992. * Result of transcoding a basis file
  68993. */
  68994. class TranscodeResult {
  68995. /**
  68996. * Info about the .basis file
  68997. */
  68998. fileInfo: BasisFileInfo;
  68999. /**
  69000. * Format to use when loading the file
  69001. */
  69002. format: number;
  69003. }
  69004. /**
  69005. * Configuration options for the Basis transcoder
  69006. */
  69007. export class BasisTranscodeConfiguration {
  69008. /**
  69009. * Supported compression formats used to determine the supported output format of the transcoder
  69010. */
  69011. supportedCompressionFormats?: {
  69012. /**
  69013. * etc1 compression format
  69014. */
  69015. etc1?: boolean;
  69016. /**
  69017. * s3tc compression format
  69018. */
  69019. s3tc?: boolean;
  69020. /**
  69021. * pvrtc compression format
  69022. */
  69023. pvrtc?: boolean;
  69024. /**
  69025. * etc2 compression format
  69026. */
  69027. etc2?: boolean;
  69028. };
  69029. /**
  69030. * If mipmap levels should be loaded for transcoded images (Default: true)
  69031. */
  69032. loadMipmapLevels?: boolean;
  69033. /**
  69034. * Index of a single image to load (Default: all images)
  69035. */
  69036. loadSingleImage?: number;
  69037. }
  69038. /**
  69039. * Used to load .Basis files
  69040. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  69041. */
  69042. export class BasisTools {
  69043. private static _IgnoreSupportedFormats;
  69044. /**
  69045. * URL to use when loading the basis transcoder
  69046. */
  69047. static JSModuleURL: string;
  69048. /**
  69049. * URL to use when loading the wasm module for the transcoder
  69050. */
  69051. static WasmModuleURL: string;
  69052. /**
  69053. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  69054. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  69055. * @returns internal format corresponding to the Basis format
  69056. */
  69057. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  69058. private static _WorkerPromise;
  69059. private static _Worker;
  69060. private static _actionId;
  69061. private static _CreateWorkerAsync;
  69062. /**
  69063. * Transcodes a loaded image file to compressed pixel data
  69064. * @param data image data to transcode
  69065. * @param config configuration options for the transcoding
  69066. * @returns a promise resulting in the transcoded image
  69067. */
  69068. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  69069. /**
  69070. * Loads a texture from the transcode result
  69071. * @param texture texture load to
  69072. * @param transcodeResult the result of transcoding the basis file to load from
  69073. */
  69074. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  69075. }
  69076. }
  69077. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  69078. import { Nullable } from "babylonjs/types";
  69079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69080. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69081. /**
  69082. * Loader for .basis file format
  69083. */
  69084. export class _BasisTextureLoader implements IInternalTextureLoader {
  69085. /**
  69086. * Defines whether the loader supports cascade loading the different faces.
  69087. */
  69088. readonly supportCascades: boolean;
  69089. /**
  69090. * This returns if the loader support the current file information.
  69091. * @param extension defines the file extension of the file being loaded
  69092. * @returns true if the loader can load the specified file
  69093. */
  69094. canLoad(extension: string): boolean;
  69095. /**
  69096. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69097. * @param data contains the texture data
  69098. * @param texture defines the BabylonJS internal texture
  69099. * @param createPolynomials will be true if polynomials have been requested
  69100. * @param onLoad defines the callback to trigger once the texture is ready
  69101. * @param onError defines the callback to trigger in case of error
  69102. */
  69103. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69104. /**
  69105. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69106. * @param data contains the texture data
  69107. * @param texture defines the BabylonJS internal texture
  69108. * @param callback defines the method to call once ready to upload
  69109. */
  69110. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69111. }
  69112. }
  69113. declare module "babylonjs/Materials/Textures/Loaders/index" {
  69114. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  69115. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  69116. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  69117. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  69118. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  69119. }
  69120. declare module "babylonjs/Materials/Textures/Packer/frame" {
  69121. import { Vector2 } from "babylonjs/Maths/math.vector";
  69122. /**
  69123. * Defines the basic options interface of a TexturePacker Frame
  69124. */
  69125. export interface ITexturePackerFrame {
  69126. /**
  69127. * The frame ID
  69128. */
  69129. id: number;
  69130. /**
  69131. * The frames Scale
  69132. */
  69133. scale: Vector2;
  69134. /**
  69135. * The Frames offset
  69136. */
  69137. offset: Vector2;
  69138. }
  69139. /**
  69140. * This is a support class for frame Data on texture packer sets.
  69141. */
  69142. export class TexturePackerFrame implements ITexturePackerFrame {
  69143. /**
  69144. * The frame ID
  69145. */
  69146. id: number;
  69147. /**
  69148. * The frames Scale
  69149. */
  69150. scale: Vector2;
  69151. /**
  69152. * The Frames offset
  69153. */
  69154. offset: Vector2;
  69155. /**
  69156. * Initializes a texture package frame.
  69157. * @param id The numerical frame identifier
  69158. * @param scale Scalar Vector2 for UV frame
  69159. * @param offset Vector2 for the frame position in UV units.
  69160. * @returns TexturePackerFrame
  69161. */
  69162. constructor(id: number, scale: Vector2, offset: Vector2);
  69163. }
  69164. }
  69165. declare module "babylonjs/Materials/Textures/Packer/packer" {
  69166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69167. import { Scene } from "babylonjs/scene";
  69168. import { Nullable } from "babylonjs/types";
  69169. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  69170. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  69171. /**
  69172. * Defines the basic options interface of a TexturePacker
  69173. */
  69174. export interface ITexturePackerOptions {
  69175. /**
  69176. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  69177. */
  69178. map?: string[];
  69179. /**
  69180. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69181. */
  69182. uvsIn?: string;
  69183. /**
  69184. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69185. */
  69186. uvsOut?: string;
  69187. /**
  69188. * number representing the layout style. Defaults to LAYOUT_STRIP
  69189. */
  69190. layout?: number;
  69191. /**
  69192. * number of columns if using custom column count layout(2). This defaults to 4.
  69193. */
  69194. colnum?: number;
  69195. /**
  69196. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  69197. */
  69198. updateInputMeshes?: boolean;
  69199. /**
  69200. * boolean flag to dispose all the source textures. Defaults to true.
  69201. */
  69202. disposeSources?: boolean;
  69203. /**
  69204. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  69205. */
  69206. fillBlanks?: boolean;
  69207. /**
  69208. * string value representing the context fill style color. Defaults to 'black'.
  69209. */
  69210. customFillColor?: string;
  69211. /**
  69212. * Width and Height Value of each Frame in the TexturePacker Sets
  69213. */
  69214. frameSize?: number;
  69215. /**
  69216. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  69217. */
  69218. paddingRatio?: number;
  69219. /**
  69220. * Number that declares the fill method for the padding gutter.
  69221. */
  69222. paddingMode?: number;
  69223. /**
  69224. * If in SUBUV_COLOR padding mode what color to use.
  69225. */
  69226. paddingColor?: Color3 | Color4;
  69227. }
  69228. /**
  69229. * Defines the basic interface of a TexturePacker JSON File
  69230. */
  69231. export interface ITexturePackerJSON {
  69232. /**
  69233. * The frame ID
  69234. */
  69235. name: string;
  69236. /**
  69237. * The base64 channel data
  69238. */
  69239. sets: any;
  69240. /**
  69241. * The options of the Packer
  69242. */
  69243. options: ITexturePackerOptions;
  69244. /**
  69245. * The frame data of the Packer
  69246. */
  69247. frames: Array<number>;
  69248. }
  69249. /**
  69250. * This is a support class that generates a series of packed texture sets.
  69251. * @see https://doc.babylonjs.com/babylon101/materials
  69252. */
  69253. export class TexturePacker {
  69254. /** Packer Layout Constant 0 */
  69255. static readonly LAYOUT_STRIP: number;
  69256. /** Packer Layout Constant 1 */
  69257. static readonly LAYOUT_POWER2: number;
  69258. /** Packer Layout Constant 2 */
  69259. static readonly LAYOUT_COLNUM: number;
  69260. /** Packer Layout Constant 0 */
  69261. static readonly SUBUV_WRAP: number;
  69262. /** Packer Layout Constant 1 */
  69263. static readonly SUBUV_EXTEND: number;
  69264. /** Packer Layout Constant 2 */
  69265. static readonly SUBUV_COLOR: number;
  69266. /** The Name of the Texture Package */
  69267. name: string;
  69268. /** The scene scope of the TexturePacker */
  69269. scene: Scene;
  69270. /** The Meshes to target */
  69271. meshes: AbstractMesh[];
  69272. /** Arguments passed with the Constructor */
  69273. options: ITexturePackerOptions;
  69274. /** The promise that is started upon initialization */
  69275. promise: Nullable<Promise<TexturePacker | string>>;
  69276. /** The Container object for the channel sets that are generated */
  69277. sets: object;
  69278. /** The Container array for the frames that are generated */
  69279. frames: TexturePackerFrame[];
  69280. /** The expected number of textures the system is parsing. */
  69281. private _expecting;
  69282. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  69283. private _paddingValue;
  69284. /**
  69285. * Initializes a texture package series from an array of meshes or a single mesh.
  69286. * @param name The name of the package
  69287. * @param meshes The target meshes to compose the package from
  69288. * @param options The arguments that texture packer should follow while building.
  69289. * @param scene The scene which the textures are scoped to.
  69290. * @returns TexturePacker
  69291. */
  69292. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  69293. /**
  69294. * Starts the package process
  69295. * @param resolve The promises resolution function
  69296. * @returns TexturePacker
  69297. */
  69298. private _createFrames;
  69299. /**
  69300. * Calculates the Size of the Channel Sets
  69301. * @returns Vector2
  69302. */
  69303. private _calculateSize;
  69304. /**
  69305. * Calculates the UV data for the frames.
  69306. * @param baseSize the base frameSize
  69307. * @param padding the base frame padding
  69308. * @param dtSize size of the Dynamic Texture for that channel
  69309. * @param dtUnits is 1/dtSize
  69310. * @param update flag to update the input meshes
  69311. */
  69312. private _calculateMeshUVFrames;
  69313. /**
  69314. * Calculates the frames Offset.
  69315. * @param index of the frame
  69316. * @returns Vector2
  69317. */
  69318. private _getFrameOffset;
  69319. /**
  69320. * Updates a Mesh to the frame data
  69321. * @param mesh that is the target
  69322. * @param frameID or the frame index
  69323. */
  69324. private _updateMeshUV;
  69325. /**
  69326. * Updates a Meshes materials to use the texture packer channels
  69327. * @param m is the mesh to target
  69328. * @param force all channels on the packer to be set.
  69329. */
  69330. private _updateTextureReferences;
  69331. /**
  69332. * Public method to set a Mesh to a frame
  69333. * @param m that is the target
  69334. * @param frameID or the frame index
  69335. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  69336. */
  69337. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  69338. /**
  69339. * Starts the async promise to compile the texture packer.
  69340. * @returns Promise<void>
  69341. */
  69342. processAsync(): Promise<void>;
  69343. /**
  69344. * Disposes all textures associated with this packer
  69345. */
  69346. dispose(): void;
  69347. /**
  69348. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  69349. * @param imageType is the image type to use.
  69350. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  69351. */
  69352. download(imageType?: string, quality?: number): void;
  69353. /**
  69354. * Public method to load a texturePacker JSON file.
  69355. * @param data of the JSON file in string format.
  69356. */
  69357. updateFromJSON(data: string): void;
  69358. }
  69359. }
  69360. declare module "babylonjs/Materials/Textures/Packer/index" {
  69361. export * from "babylonjs/Materials/Textures/Packer/packer";
  69362. export * from "babylonjs/Materials/Textures/Packer/frame";
  69363. }
  69364. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  69365. import { Scene } from "babylonjs/scene";
  69366. import { Texture } from "babylonjs/Materials/Textures/texture";
  69367. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69368. /**
  69369. * 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.
  69370. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69371. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69372. */
  69373. export class CustomProceduralTexture extends ProceduralTexture {
  69374. private _animate;
  69375. private _time;
  69376. private _config;
  69377. private _texturePath;
  69378. /**
  69379. * Instantiates a new Custom Procedural Texture.
  69380. * 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.
  69381. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69382. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69383. * @param name Define the name of the texture
  69384. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  69385. * @param size Define the size of the texture to create
  69386. * @param scene Define the scene the texture belongs to
  69387. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69388. * @param generateMipMaps Define if the texture should creates mip maps or not
  69389. */
  69390. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69391. private _loadJson;
  69392. /**
  69393. * Is the texture ready to be used ? (rendered at least once)
  69394. * @returns true if ready, otherwise, false.
  69395. */
  69396. isReady(): boolean;
  69397. /**
  69398. * Render the texture to its associated render target.
  69399. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69400. */
  69401. render(useCameraPostProcess?: boolean): void;
  69402. /**
  69403. * Update the list of dependant textures samplers in the shader.
  69404. */
  69405. updateTextures(): void;
  69406. /**
  69407. * Update the uniform values of the procedural texture in the shader.
  69408. */
  69409. updateShaderUniforms(): void;
  69410. /**
  69411. * Define if the texture animates or not.
  69412. */
  69413. get animate(): boolean;
  69414. set animate(value: boolean);
  69415. }
  69416. }
  69417. declare module "babylonjs/Shaders/noise.fragment" {
  69418. /** @hidden */
  69419. export var noisePixelShader: {
  69420. name: string;
  69421. shader: string;
  69422. };
  69423. }
  69424. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  69425. import { Nullable } from "babylonjs/types";
  69426. import { Scene } from "babylonjs/scene";
  69427. import { Texture } from "babylonjs/Materials/Textures/texture";
  69428. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69429. import "babylonjs/Shaders/noise.fragment";
  69430. /**
  69431. * Class used to generate noise procedural textures
  69432. */
  69433. export class NoiseProceduralTexture extends ProceduralTexture {
  69434. /** Gets or sets the start time (default is 0) */
  69435. time: number;
  69436. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  69437. brightness: number;
  69438. /** Defines the number of octaves to process */
  69439. octaves: number;
  69440. /** Defines the level of persistence (0.8 by default) */
  69441. persistence: number;
  69442. /** Gets or sets animation speed factor (default is 1) */
  69443. animationSpeedFactor: number;
  69444. /**
  69445. * Creates a new NoiseProceduralTexture
  69446. * @param name defines the name fo the texture
  69447. * @param size defines the size of the texture (default is 256)
  69448. * @param scene defines the hosting scene
  69449. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  69450. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  69451. */
  69452. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69453. private _updateShaderUniforms;
  69454. protected _getDefines(): string;
  69455. /** Generate the current state of the procedural texture */
  69456. render(useCameraPostProcess?: boolean): void;
  69457. /**
  69458. * Serializes this noise procedural texture
  69459. * @returns a serialized noise procedural texture object
  69460. */
  69461. serialize(): any;
  69462. /**
  69463. * Clone the texture.
  69464. * @returns the cloned texture
  69465. */
  69466. clone(): NoiseProceduralTexture;
  69467. /**
  69468. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  69469. * @param parsedTexture defines parsed texture data
  69470. * @param scene defines the current scene
  69471. * @param rootUrl defines the root URL containing noise procedural texture information
  69472. * @returns a parsed NoiseProceduralTexture
  69473. */
  69474. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  69475. }
  69476. }
  69477. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  69478. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  69479. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  69480. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69481. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  69482. }
  69483. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  69484. import { Nullable } from "babylonjs/types";
  69485. import { Scene } from "babylonjs/scene";
  69486. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  69487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69488. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69489. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69490. /**
  69491. * Raw cube texture where the raw buffers are passed in
  69492. */
  69493. export class RawCubeTexture extends CubeTexture {
  69494. /**
  69495. * Creates a cube texture where the raw buffers are passed in.
  69496. * @param scene defines the scene the texture is attached to
  69497. * @param data defines the array of data to use to create each face
  69498. * @param size defines the size of the textures
  69499. * @param format defines the format of the data
  69500. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  69501. * @param generateMipMaps defines if the engine should generate the mip levels
  69502. * @param invertY defines if data must be stored with Y axis inverted
  69503. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  69504. * @param compression defines the compression used (null by default)
  69505. */
  69506. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  69507. /**
  69508. * Updates the raw cube texture.
  69509. * @param data defines the data to store
  69510. * @param format defines the data format
  69511. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69512. * @param invertY defines if data must be stored with Y axis inverted
  69513. * @param compression defines the compression used (null by default)
  69514. * @param level defines which level of the texture to update
  69515. */
  69516. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  69517. /**
  69518. * Updates a raw cube texture with RGBD encoded data.
  69519. * @param data defines the array of data [mipmap][face] to use to create each face
  69520. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  69521. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  69522. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  69523. * @returns a promsie that resolves when the operation is complete
  69524. */
  69525. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  69526. /**
  69527. * Clones the raw cube texture.
  69528. * @return a new cube texture
  69529. */
  69530. clone(): CubeTexture;
  69531. /** @hidden */
  69532. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  69533. }
  69534. }
  69535. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  69536. import { Scene } from "babylonjs/scene";
  69537. import { Texture } from "babylonjs/Materials/Textures/texture";
  69538. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69539. /**
  69540. * Class used to store 2D array textures containing user data
  69541. */
  69542. export class RawTexture2DArray extends Texture {
  69543. /** Gets or sets the texture format to use */
  69544. format: number;
  69545. /**
  69546. * Create a new RawTexture2DArray
  69547. * @param data defines the data of the texture
  69548. * @param width defines the width of the texture
  69549. * @param height defines the height of the texture
  69550. * @param depth defines the number of layers of the texture
  69551. * @param format defines the texture format to use
  69552. * @param scene defines the hosting scene
  69553. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69554. * @param invertY defines if texture must be stored with Y axis inverted
  69555. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69556. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69557. */
  69558. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69559. /** Gets or sets the texture format to use */
  69560. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69561. /**
  69562. * Update the texture with new data
  69563. * @param data defines the data to store in the texture
  69564. */
  69565. update(data: ArrayBufferView): void;
  69566. }
  69567. }
  69568. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  69569. import { Scene } from "babylonjs/scene";
  69570. import { Texture } from "babylonjs/Materials/Textures/texture";
  69571. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69572. /**
  69573. * Class used to store 3D textures containing user data
  69574. */
  69575. export class RawTexture3D extends Texture {
  69576. /** Gets or sets the texture format to use */
  69577. format: number;
  69578. /**
  69579. * Create a new RawTexture3D
  69580. * @param data defines the data of the texture
  69581. * @param width defines the width of the texture
  69582. * @param height defines the height of the texture
  69583. * @param depth defines the depth of the texture
  69584. * @param format defines the texture format to use
  69585. * @param scene defines the hosting scene
  69586. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69587. * @param invertY defines if texture must be stored with Y axis inverted
  69588. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69589. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69590. */
  69591. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69592. /** Gets or sets the texture format to use */
  69593. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69594. /**
  69595. * Update the texture with new data
  69596. * @param data defines the data to store in the texture
  69597. */
  69598. update(data: ArrayBufferView): void;
  69599. }
  69600. }
  69601. declare module "babylonjs/Materials/Textures/refractionTexture" {
  69602. import { Scene } from "babylonjs/scene";
  69603. import { Plane } from "babylonjs/Maths/math.plane";
  69604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69605. /**
  69606. * Creates a refraction texture used by refraction channel of the standard material.
  69607. * It is like a mirror but to see through a material.
  69608. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69609. */
  69610. export class RefractionTexture extends RenderTargetTexture {
  69611. /**
  69612. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  69613. * 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.
  69614. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69615. */
  69616. refractionPlane: Plane;
  69617. /**
  69618. * Define how deep under the surface we should see.
  69619. */
  69620. depth: number;
  69621. /**
  69622. * Creates a refraction texture used by refraction channel of the standard material.
  69623. * It is like a mirror but to see through a material.
  69624. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69625. * @param name Define the texture name
  69626. * @param size Define the size of the underlying texture
  69627. * @param scene Define the scene the refraction belongs to
  69628. * @param generateMipMaps Define if we need to generate mips level for the refraction
  69629. */
  69630. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  69631. /**
  69632. * Clone the refraction texture.
  69633. * @returns the cloned texture
  69634. */
  69635. clone(): RefractionTexture;
  69636. /**
  69637. * Serialize the texture to a JSON representation you could use in Parse later on
  69638. * @returns the serialized JSON representation
  69639. */
  69640. serialize(): any;
  69641. }
  69642. }
  69643. declare module "babylonjs/Materials/Textures/index" {
  69644. export * from "babylonjs/Materials/Textures/baseTexture";
  69645. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  69646. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  69647. export * from "babylonjs/Materials/Textures/cubeTexture";
  69648. export * from "babylonjs/Materials/Textures/dynamicTexture";
  69649. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  69650. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  69651. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  69652. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  69653. export * from "babylonjs/Materials/Textures/internalTexture";
  69654. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  69655. export * from "babylonjs/Materials/Textures/Loaders/index";
  69656. export * from "babylonjs/Materials/Textures/mirrorTexture";
  69657. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  69658. export * from "babylonjs/Materials/Textures/Packer/index";
  69659. export * from "babylonjs/Materials/Textures/Procedurals/index";
  69660. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  69661. export * from "babylonjs/Materials/Textures/rawTexture";
  69662. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  69663. export * from "babylonjs/Materials/Textures/rawTexture3D";
  69664. export * from "babylonjs/Materials/Textures/refractionTexture";
  69665. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  69666. export * from "babylonjs/Materials/Textures/texture";
  69667. export * from "babylonjs/Materials/Textures/videoTexture";
  69668. }
  69669. declare module "babylonjs/Materials/Node/Enums/index" {
  69670. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  69671. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  69672. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  69673. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  69674. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  69675. }
  69676. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  69677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69680. import { Mesh } from "babylonjs/Meshes/mesh";
  69681. import { Effect } from "babylonjs/Materials/effect";
  69682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69683. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69684. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69685. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69686. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69687. /**
  69688. * Block used to add support for vertex skinning (bones)
  69689. */
  69690. export class BonesBlock extends NodeMaterialBlock {
  69691. /**
  69692. * Creates a new BonesBlock
  69693. * @param name defines the block name
  69694. */
  69695. constructor(name: string);
  69696. /**
  69697. * Initialize the block and prepare the context for build
  69698. * @param state defines the state that will be used for the build
  69699. */
  69700. initialize(state: NodeMaterialBuildState): void;
  69701. /**
  69702. * Gets the current class name
  69703. * @returns the class name
  69704. */
  69705. getClassName(): string;
  69706. /**
  69707. * Gets the matrix indices input component
  69708. */
  69709. get matricesIndices(): NodeMaterialConnectionPoint;
  69710. /**
  69711. * Gets the matrix weights input component
  69712. */
  69713. get matricesWeights(): NodeMaterialConnectionPoint;
  69714. /**
  69715. * Gets the extra matrix indices input component
  69716. */
  69717. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  69718. /**
  69719. * Gets the extra matrix weights input component
  69720. */
  69721. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  69722. /**
  69723. * Gets the world input component
  69724. */
  69725. get world(): NodeMaterialConnectionPoint;
  69726. /**
  69727. * Gets the output component
  69728. */
  69729. get output(): NodeMaterialConnectionPoint;
  69730. autoConfigure(material: NodeMaterial): void;
  69731. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  69732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69734. protected _buildBlock(state: NodeMaterialBuildState): this;
  69735. }
  69736. }
  69737. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  69738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69743. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69744. /**
  69745. * Block used to add support for instances
  69746. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  69747. */
  69748. export class InstancesBlock extends NodeMaterialBlock {
  69749. /**
  69750. * Creates a new InstancesBlock
  69751. * @param name defines the block name
  69752. */
  69753. constructor(name: string);
  69754. /**
  69755. * Gets the current class name
  69756. * @returns the class name
  69757. */
  69758. getClassName(): string;
  69759. /**
  69760. * Gets the first world row input component
  69761. */
  69762. get world0(): NodeMaterialConnectionPoint;
  69763. /**
  69764. * Gets the second world row input component
  69765. */
  69766. get world1(): NodeMaterialConnectionPoint;
  69767. /**
  69768. * Gets the third world row input component
  69769. */
  69770. get world2(): NodeMaterialConnectionPoint;
  69771. /**
  69772. * Gets the forth world row input component
  69773. */
  69774. get world3(): NodeMaterialConnectionPoint;
  69775. /**
  69776. * Gets the world input component
  69777. */
  69778. get world(): NodeMaterialConnectionPoint;
  69779. /**
  69780. * Gets the output component
  69781. */
  69782. get output(): NodeMaterialConnectionPoint;
  69783. /**
  69784. * Gets the isntanceID component
  69785. */
  69786. get instanceID(): NodeMaterialConnectionPoint;
  69787. autoConfigure(material: NodeMaterial): void;
  69788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  69789. protected _buildBlock(state: NodeMaterialBuildState): this;
  69790. }
  69791. }
  69792. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  69793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69797. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69798. import { Effect } from "babylonjs/Materials/effect";
  69799. import { Mesh } from "babylonjs/Meshes/mesh";
  69800. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69801. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69802. /**
  69803. * Block used to add morph targets support to vertex shader
  69804. */
  69805. export class MorphTargetsBlock extends NodeMaterialBlock {
  69806. private _repeatableContentAnchor;
  69807. /**
  69808. * Create a new MorphTargetsBlock
  69809. * @param name defines the block name
  69810. */
  69811. constructor(name: string);
  69812. /**
  69813. * Gets the current class name
  69814. * @returns the class name
  69815. */
  69816. getClassName(): string;
  69817. /**
  69818. * Gets the position input component
  69819. */
  69820. get position(): NodeMaterialConnectionPoint;
  69821. /**
  69822. * Gets the normal input component
  69823. */
  69824. get normal(): NodeMaterialConnectionPoint;
  69825. /**
  69826. * Gets the tangent input component
  69827. */
  69828. get tangent(): NodeMaterialConnectionPoint;
  69829. /**
  69830. * Gets the tangent input component
  69831. */
  69832. get uv(): NodeMaterialConnectionPoint;
  69833. /**
  69834. * Gets the position output component
  69835. */
  69836. get positionOutput(): NodeMaterialConnectionPoint;
  69837. /**
  69838. * Gets the normal output component
  69839. */
  69840. get normalOutput(): NodeMaterialConnectionPoint;
  69841. /**
  69842. * Gets the tangent output component
  69843. */
  69844. get tangentOutput(): NodeMaterialConnectionPoint;
  69845. /**
  69846. * Gets the tangent output component
  69847. */
  69848. get uvOutput(): NodeMaterialConnectionPoint;
  69849. initialize(state: NodeMaterialBuildState): void;
  69850. autoConfigure(material: NodeMaterial): void;
  69851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69853. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  69854. protected _buildBlock(state: NodeMaterialBuildState): this;
  69855. }
  69856. }
  69857. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  69858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69861. import { Nullable } from "babylonjs/types";
  69862. import { Scene } from "babylonjs/scene";
  69863. import { Effect } from "babylonjs/Materials/effect";
  69864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69865. import { Mesh } from "babylonjs/Meshes/mesh";
  69866. import { Light } from "babylonjs/Lights/light";
  69867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69868. /**
  69869. * Block used to get data information from a light
  69870. */
  69871. export class LightInformationBlock extends NodeMaterialBlock {
  69872. private _lightDataUniformName;
  69873. private _lightColorUniformName;
  69874. private _lightTypeDefineName;
  69875. /**
  69876. * Gets or sets the light associated with this block
  69877. */
  69878. light: Nullable<Light>;
  69879. /**
  69880. * Creates a new LightInformationBlock
  69881. * @param name defines the block name
  69882. */
  69883. constructor(name: string);
  69884. /**
  69885. * Gets the current class name
  69886. * @returns the class name
  69887. */
  69888. getClassName(): string;
  69889. /**
  69890. * Gets the world position input component
  69891. */
  69892. get worldPosition(): NodeMaterialConnectionPoint;
  69893. /**
  69894. * Gets the direction output component
  69895. */
  69896. get direction(): NodeMaterialConnectionPoint;
  69897. /**
  69898. * Gets the direction output component
  69899. */
  69900. get color(): NodeMaterialConnectionPoint;
  69901. /**
  69902. * Gets the direction output component
  69903. */
  69904. get intensity(): NodeMaterialConnectionPoint;
  69905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69907. protected _buildBlock(state: NodeMaterialBuildState): this;
  69908. serialize(): any;
  69909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69910. }
  69911. }
  69912. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  69913. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  69914. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  69915. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  69916. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  69917. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  69918. }
  69919. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  69920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69925. import { Effect } from "babylonjs/Materials/effect";
  69926. import { Mesh } from "babylonjs/Meshes/mesh";
  69927. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69928. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69929. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69930. /**
  69931. * Block used to add image processing support to fragment shader
  69932. */
  69933. export class ImageProcessingBlock extends NodeMaterialBlock {
  69934. /**
  69935. * Create a new ImageProcessingBlock
  69936. * @param name defines the block name
  69937. */
  69938. constructor(name: string);
  69939. /**
  69940. * Gets the current class name
  69941. * @returns the class name
  69942. */
  69943. getClassName(): string;
  69944. /**
  69945. * Gets the color input component
  69946. */
  69947. get color(): NodeMaterialConnectionPoint;
  69948. /**
  69949. * Gets the output component
  69950. */
  69951. get output(): NodeMaterialConnectionPoint;
  69952. /**
  69953. * Initialize the block and prepare the context for build
  69954. * @param state defines the state that will be used for the build
  69955. */
  69956. initialize(state: NodeMaterialBuildState): void;
  69957. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  69958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69960. protected _buildBlock(state: NodeMaterialBuildState): this;
  69961. }
  69962. }
  69963. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  69964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69967. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69969. import { Effect } from "babylonjs/Materials/effect";
  69970. import { Mesh } from "babylonjs/Meshes/mesh";
  69971. import { Scene } from "babylonjs/scene";
  69972. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  69973. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  69974. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  69975. /**
  69976. * Block used to pertub normals based on a normal map
  69977. */
  69978. export class PerturbNormalBlock extends NodeMaterialBlock {
  69979. private _tangentSpaceParameterName;
  69980. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  69981. invertX: boolean;
  69982. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  69983. invertY: boolean;
  69984. /**
  69985. * Create a new PerturbNormalBlock
  69986. * @param name defines the block name
  69987. */
  69988. constructor(name: string);
  69989. /**
  69990. * Gets the current class name
  69991. * @returns the class name
  69992. */
  69993. getClassName(): string;
  69994. /**
  69995. * Gets the world position input component
  69996. */
  69997. get worldPosition(): NodeMaterialConnectionPoint;
  69998. /**
  69999. * Gets the world normal input component
  70000. */
  70001. get worldNormal(): NodeMaterialConnectionPoint;
  70002. /**
  70003. * Gets the world tangent input component
  70004. */
  70005. get worldTangent(): NodeMaterialConnectionPoint;
  70006. /**
  70007. * Gets the uv input component
  70008. */
  70009. get uv(): NodeMaterialConnectionPoint;
  70010. /**
  70011. * Gets the normal map color input component
  70012. */
  70013. get normalMapColor(): NodeMaterialConnectionPoint;
  70014. /**
  70015. * Gets the strength input component
  70016. */
  70017. get strength(): NodeMaterialConnectionPoint;
  70018. /**
  70019. * Gets the output component
  70020. */
  70021. get output(): NodeMaterialConnectionPoint;
  70022. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70023. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70024. autoConfigure(material: NodeMaterial): void;
  70025. protected _buildBlock(state: NodeMaterialBuildState): this;
  70026. protected _dumpPropertiesCode(): string;
  70027. serialize(): any;
  70028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70029. }
  70030. }
  70031. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  70032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70035. /**
  70036. * Block used to discard a pixel if a value is smaller than a cutoff
  70037. */
  70038. export class DiscardBlock extends NodeMaterialBlock {
  70039. /**
  70040. * Create a new DiscardBlock
  70041. * @param name defines the block name
  70042. */
  70043. constructor(name: string);
  70044. /**
  70045. * Gets the current class name
  70046. * @returns the class name
  70047. */
  70048. getClassName(): string;
  70049. /**
  70050. * Gets the color input component
  70051. */
  70052. get value(): NodeMaterialConnectionPoint;
  70053. /**
  70054. * Gets the cutoff input component
  70055. */
  70056. get cutoff(): NodeMaterialConnectionPoint;
  70057. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70058. }
  70059. }
  70060. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  70061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70064. /**
  70065. * Block used to test if the fragment shader is front facing
  70066. */
  70067. export class FrontFacingBlock extends NodeMaterialBlock {
  70068. /**
  70069. * Creates a new FrontFacingBlock
  70070. * @param name defines the block name
  70071. */
  70072. constructor(name: string);
  70073. /**
  70074. * Gets the current class name
  70075. * @returns the class name
  70076. */
  70077. getClassName(): string;
  70078. /**
  70079. * Gets the output component
  70080. */
  70081. get output(): NodeMaterialConnectionPoint;
  70082. protected _buildBlock(state: NodeMaterialBuildState): this;
  70083. }
  70084. }
  70085. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  70086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70089. /**
  70090. * Block used to get the derivative value on x and y of a given input
  70091. */
  70092. export class DerivativeBlock extends NodeMaterialBlock {
  70093. /**
  70094. * Create a new DerivativeBlock
  70095. * @param name defines the block name
  70096. */
  70097. constructor(name: string);
  70098. /**
  70099. * Gets the current class name
  70100. * @returns the class name
  70101. */
  70102. getClassName(): string;
  70103. /**
  70104. * Gets the input component
  70105. */
  70106. get input(): NodeMaterialConnectionPoint;
  70107. /**
  70108. * Gets the derivative output on x
  70109. */
  70110. get dx(): NodeMaterialConnectionPoint;
  70111. /**
  70112. * Gets the derivative output on y
  70113. */
  70114. get dy(): NodeMaterialConnectionPoint;
  70115. protected _buildBlock(state: NodeMaterialBuildState): this;
  70116. }
  70117. }
  70118. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  70119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70122. /**
  70123. * Block used to make gl_FragCoord available
  70124. */
  70125. export class FragCoordBlock extends NodeMaterialBlock {
  70126. /**
  70127. * Creates a new FragCoordBlock
  70128. * @param name defines the block name
  70129. */
  70130. constructor(name: string);
  70131. /**
  70132. * Gets the current class name
  70133. * @returns the class name
  70134. */
  70135. getClassName(): string;
  70136. /**
  70137. * Gets the xy component
  70138. */
  70139. get xy(): NodeMaterialConnectionPoint;
  70140. /**
  70141. * Gets the xyz component
  70142. */
  70143. get xyz(): NodeMaterialConnectionPoint;
  70144. /**
  70145. * Gets the xyzw component
  70146. */
  70147. get xyzw(): NodeMaterialConnectionPoint;
  70148. /**
  70149. * Gets the x component
  70150. */
  70151. get x(): NodeMaterialConnectionPoint;
  70152. /**
  70153. * Gets the y component
  70154. */
  70155. get y(): NodeMaterialConnectionPoint;
  70156. /**
  70157. * Gets the z component
  70158. */
  70159. get z(): NodeMaterialConnectionPoint;
  70160. /**
  70161. * Gets the w component
  70162. */
  70163. get output(): NodeMaterialConnectionPoint;
  70164. protected writeOutputs(state: NodeMaterialBuildState): string;
  70165. protected _buildBlock(state: NodeMaterialBuildState): this;
  70166. }
  70167. }
  70168. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  70169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70172. import { Effect } from "babylonjs/Materials/effect";
  70173. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70174. import { Mesh } from "babylonjs/Meshes/mesh";
  70175. /**
  70176. * Block used to get the screen sizes
  70177. */
  70178. export class ScreenSizeBlock extends NodeMaterialBlock {
  70179. private _varName;
  70180. private _scene;
  70181. /**
  70182. * Creates a new ScreenSizeBlock
  70183. * @param name defines the block name
  70184. */
  70185. constructor(name: string);
  70186. /**
  70187. * Gets the current class name
  70188. * @returns the class name
  70189. */
  70190. getClassName(): string;
  70191. /**
  70192. * Gets the xy component
  70193. */
  70194. get xy(): NodeMaterialConnectionPoint;
  70195. /**
  70196. * Gets the x component
  70197. */
  70198. get x(): NodeMaterialConnectionPoint;
  70199. /**
  70200. * Gets the y component
  70201. */
  70202. get y(): NodeMaterialConnectionPoint;
  70203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70204. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  70205. protected _buildBlock(state: NodeMaterialBuildState): this;
  70206. }
  70207. }
  70208. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  70209. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  70210. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  70211. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  70212. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  70213. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  70214. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  70215. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  70216. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  70217. }
  70218. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  70219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70221. import { Mesh } from "babylonjs/Meshes/mesh";
  70222. import { Effect } from "babylonjs/Materials/effect";
  70223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70226. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  70227. /**
  70228. * Block used to add support for scene fog
  70229. */
  70230. export class FogBlock extends NodeMaterialBlock {
  70231. private _fogDistanceName;
  70232. private _fogParameters;
  70233. /**
  70234. * Create a new FogBlock
  70235. * @param name defines the block name
  70236. */
  70237. constructor(name: string);
  70238. /**
  70239. * Gets the current class name
  70240. * @returns the class name
  70241. */
  70242. getClassName(): string;
  70243. /**
  70244. * Gets the world position input component
  70245. */
  70246. get worldPosition(): NodeMaterialConnectionPoint;
  70247. /**
  70248. * Gets the view input component
  70249. */
  70250. get view(): NodeMaterialConnectionPoint;
  70251. /**
  70252. * Gets the color input component
  70253. */
  70254. get input(): NodeMaterialConnectionPoint;
  70255. /**
  70256. * Gets the fog color input component
  70257. */
  70258. get fogColor(): NodeMaterialConnectionPoint;
  70259. /**
  70260. * Gets the output component
  70261. */
  70262. get output(): NodeMaterialConnectionPoint;
  70263. autoConfigure(material: NodeMaterial): void;
  70264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70266. protected _buildBlock(state: NodeMaterialBuildState): this;
  70267. }
  70268. }
  70269. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  70270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70274. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70275. import { Effect } from "babylonjs/Materials/effect";
  70276. import { Mesh } from "babylonjs/Meshes/mesh";
  70277. import { Light } from "babylonjs/Lights/light";
  70278. import { Nullable } from "babylonjs/types";
  70279. import { Scene } from "babylonjs/scene";
  70280. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  70281. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  70282. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  70283. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  70284. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  70285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70286. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  70287. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  70288. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  70289. /**
  70290. * Block used to add light in the fragment shader
  70291. */
  70292. export class LightBlock extends NodeMaterialBlock {
  70293. private _lightId;
  70294. /**
  70295. * Gets or sets the light associated with this block
  70296. */
  70297. light: Nullable<Light>;
  70298. /**
  70299. * Create a new LightBlock
  70300. * @param name defines the block name
  70301. */
  70302. constructor(name: string);
  70303. /**
  70304. * Gets the current class name
  70305. * @returns the class name
  70306. */
  70307. getClassName(): string;
  70308. /**
  70309. * Gets the world position input component
  70310. */
  70311. get worldPosition(): NodeMaterialConnectionPoint;
  70312. /**
  70313. * Gets the world normal input component
  70314. */
  70315. get worldNormal(): NodeMaterialConnectionPoint;
  70316. /**
  70317. * Gets the camera (or eye) position component
  70318. */
  70319. get cameraPosition(): NodeMaterialConnectionPoint;
  70320. /**
  70321. * Gets the glossiness component
  70322. */
  70323. get glossiness(): NodeMaterialConnectionPoint;
  70324. /**
  70325. * Gets the glossinness power component
  70326. */
  70327. get glossPower(): NodeMaterialConnectionPoint;
  70328. /**
  70329. * Gets the diffuse color component
  70330. */
  70331. get diffuseColor(): NodeMaterialConnectionPoint;
  70332. /**
  70333. * Gets the specular color component
  70334. */
  70335. get specularColor(): NodeMaterialConnectionPoint;
  70336. /**
  70337. * Gets the view matrix component
  70338. */
  70339. get view(): NodeMaterialConnectionPoint;
  70340. /**
  70341. * Gets the diffuse output component
  70342. */
  70343. get diffuseOutput(): NodeMaterialConnectionPoint;
  70344. /**
  70345. * Gets the specular output component
  70346. */
  70347. get specularOutput(): NodeMaterialConnectionPoint;
  70348. /**
  70349. * Gets the shadow output component
  70350. */
  70351. get shadow(): NodeMaterialConnectionPoint;
  70352. autoConfigure(material: NodeMaterial): void;
  70353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70354. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70356. private _injectVertexCode;
  70357. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70358. serialize(): any;
  70359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70360. }
  70361. }
  70362. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  70363. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70364. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70365. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70366. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  70367. /**
  70368. * Block used to read a reflection texture from a sampler
  70369. */
  70370. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  70371. /**
  70372. * Create a new ReflectionTextureBlock
  70373. * @param name defines the block name
  70374. */
  70375. constructor(name: string);
  70376. /**
  70377. * Gets the current class name
  70378. * @returns the class name
  70379. */
  70380. getClassName(): string;
  70381. /**
  70382. * Gets the world position input component
  70383. */
  70384. get position(): NodeMaterialConnectionPoint;
  70385. /**
  70386. * Gets the world position input component
  70387. */
  70388. get worldPosition(): NodeMaterialConnectionPoint;
  70389. /**
  70390. * Gets the world normal input component
  70391. */
  70392. get worldNormal(): NodeMaterialConnectionPoint;
  70393. /**
  70394. * Gets the world input component
  70395. */
  70396. get world(): NodeMaterialConnectionPoint;
  70397. /**
  70398. * Gets the camera (or eye) position component
  70399. */
  70400. get cameraPosition(): NodeMaterialConnectionPoint;
  70401. /**
  70402. * Gets the view input component
  70403. */
  70404. get view(): NodeMaterialConnectionPoint;
  70405. /**
  70406. * Gets the rgb output component
  70407. */
  70408. get rgb(): NodeMaterialConnectionPoint;
  70409. /**
  70410. * Gets the rgba output component
  70411. */
  70412. get rgba(): NodeMaterialConnectionPoint;
  70413. /**
  70414. * Gets the r output component
  70415. */
  70416. get r(): NodeMaterialConnectionPoint;
  70417. /**
  70418. * Gets the g output component
  70419. */
  70420. get g(): NodeMaterialConnectionPoint;
  70421. /**
  70422. * Gets the b output component
  70423. */
  70424. get b(): NodeMaterialConnectionPoint;
  70425. /**
  70426. * Gets the a output component
  70427. */
  70428. get a(): NodeMaterialConnectionPoint;
  70429. autoConfigure(material: NodeMaterial): void;
  70430. protected _buildBlock(state: NodeMaterialBuildState): this;
  70431. }
  70432. }
  70433. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  70434. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  70435. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  70436. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  70437. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  70438. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  70439. }
  70440. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  70441. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  70442. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  70443. }
  70444. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  70445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70448. /**
  70449. * Block used to add 2 vectors
  70450. */
  70451. export class AddBlock extends NodeMaterialBlock {
  70452. /**
  70453. * Creates a new AddBlock
  70454. * @param name defines the block name
  70455. */
  70456. constructor(name: string);
  70457. /**
  70458. * Gets the current class name
  70459. * @returns the class name
  70460. */
  70461. getClassName(): string;
  70462. /**
  70463. * Gets the left operand input component
  70464. */
  70465. get left(): NodeMaterialConnectionPoint;
  70466. /**
  70467. * Gets the right operand input component
  70468. */
  70469. get right(): NodeMaterialConnectionPoint;
  70470. /**
  70471. * Gets the output component
  70472. */
  70473. get output(): NodeMaterialConnectionPoint;
  70474. protected _buildBlock(state: NodeMaterialBuildState): this;
  70475. }
  70476. }
  70477. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  70478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70481. /**
  70482. * Block used to scale a vector by a float
  70483. */
  70484. export class ScaleBlock extends NodeMaterialBlock {
  70485. /**
  70486. * Creates a new ScaleBlock
  70487. * @param name defines the block name
  70488. */
  70489. constructor(name: string);
  70490. /**
  70491. * Gets the current class name
  70492. * @returns the class name
  70493. */
  70494. getClassName(): string;
  70495. /**
  70496. * Gets the input component
  70497. */
  70498. get input(): NodeMaterialConnectionPoint;
  70499. /**
  70500. * Gets the factor input component
  70501. */
  70502. get factor(): NodeMaterialConnectionPoint;
  70503. /**
  70504. * Gets the output component
  70505. */
  70506. get output(): NodeMaterialConnectionPoint;
  70507. protected _buildBlock(state: NodeMaterialBuildState): this;
  70508. }
  70509. }
  70510. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  70511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70514. import { Scene } from "babylonjs/scene";
  70515. /**
  70516. * Block used to clamp a float
  70517. */
  70518. export class ClampBlock extends NodeMaterialBlock {
  70519. /** Gets or sets the minimum range */
  70520. minimum: number;
  70521. /** Gets or sets the maximum range */
  70522. maximum: number;
  70523. /**
  70524. * Creates a new ClampBlock
  70525. * @param name defines the block name
  70526. */
  70527. constructor(name: string);
  70528. /**
  70529. * Gets the current class name
  70530. * @returns the class name
  70531. */
  70532. getClassName(): string;
  70533. /**
  70534. * Gets the value input component
  70535. */
  70536. get value(): NodeMaterialConnectionPoint;
  70537. /**
  70538. * Gets the output component
  70539. */
  70540. get output(): NodeMaterialConnectionPoint;
  70541. protected _buildBlock(state: NodeMaterialBuildState): this;
  70542. protected _dumpPropertiesCode(): string;
  70543. serialize(): any;
  70544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70545. }
  70546. }
  70547. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  70548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70551. /**
  70552. * Block used to apply a cross product between 2 vectors
  70553. */
  70554. export class CrossBlock extends NodeMaterialBlock {
  70555. /**
  70556. * Creates a new CrossBlock
  70557. * @param name defines the block name
  70558. */
  70559. constructor(name: string);
  70560. /**
  70561. * Gets the current class name
  70562. * @returns the class name
  70563. */
  70564. getClassName(): string;
  70565. /**
  70566. * Gets the left operand input component
  70567. */
  70568. get left(): NodeMaterialConnectionPoint;
  70569. /**
  70570. * Gets the right operand input component
  70571. */
  70572. get right(): NodeMaterialConnectionPoint;
  70573. /**
  70574. * Gets the output component
  70575. */
  70576. get output(): NodeMaterialConnectionPoint;
  70577. protected _buildBlock(state: NodeMaterialBuildState): this;
  70578. }
  70579. }
  70580. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  70581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70584. /**
  70585. * Block used to apply a dot product between 2 vectors
  70586. */
  70587. export class DotBlock extends NodeMaterialBlock {
  70588. /**
  70589. * Creates a new DotBlock
  70590. * @param name defines the block name
  70591. */
  70592. constructor(name: string);
  70593. /**
  70594. * Gets the current class name
  70595. * @returns the class name
  70596. */
  70597. getClassName(): string;
  70598. /**
  70599. * Gets the left operand input component
  70600. */
  70601. get left(): NodeMaterialConnectionPoint;
  70602. /**
  70603. * Gets the right operand input component
  70604. */
  70605. get right(): NodeMaterialConnectionPoint;
  70606. /**
  70607. * Gets the output component
  70608. */
  70609. get output(): NodeMaterialConnectionPoint;
  70610. protected _buildBlock(state: NodeMaterialBuildState): this;
  70611. }
  70612. }
  70613. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  70614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70617. /**
  70618. * Block used to normalize a vector
  70619. */
  70620. export class NormalizeBlock extends NodeMaterialBlock {
  70621. /**
  70622. * Creates a new NormalizeBlock
  70623. * @param name defines the block name
  70624. */
  70625. constructor(name: string);
  70626. /**
  70627. * Gets the current class name
  70628. * @returns the class name
  70629. */
  70630. getClassName(): string;
  70631. /**
  70632. * Gets the input component
  70633. */
  70634. get input(): NodeMaterialConnectionPoint;
  70635. /**
  70636. * Gets the output component
  70637. */
  70638. get output(): NodeMaterialConnectionPoint;
  70639. protected _buildBlock(state: NodeMaterialBuildState): this;
  70640. }
  70641. }
  70642. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  70643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70646. /**
  70647. * Block used to create a Color3/4 out of individual inputs (one for each component)
  70648. */
  70649. export class ColorMergerBlock extends NodeMaterialBlock {
  70650. /**
  70651. * Create a new ColorMergerBlock
  70652. * @param name defines the block name
  70653. */
  70654. constructor(name: string);
  70655. /**
  70656. * Gets the current class name
  70657. * @returns the class name
  70658. */
  70659. getClassName(): string;
  70660. /**
  70661. * Gets the rgb component (input)
  70662. */
  70663. get rgbIn(): NodeMaterialConnectionPoint;
  70664. /**
  70665. * Gets the r component (input)
  70666. */
  70667. get r(): NodeMaterialConnectionPoint;
  70668. /**
  70669. * Gets the g component (input)
  70670. */
  70671. get g(): NodeMaterialConnectionPoint;
  70672. /**
  70673. * Gets the b component (input)
  70674. */
  70675. get b(): NodeMaterialConnectionPoint;
  70676. /**
  70677. * Gets the a component (input)
  70678. */
  70679. get a(): NodeMaterialConnectionPoint;
  70680. /**
  70681. * Gets the rgba component (output)
  70682. */
  70683. get rgba(): NodeMaterialConnectionPoint;
  70684. /**
  70685. * Gets the rgb component (output)
  70686. */
  70687. get rgbOut(): NodeMaterialConnectionPoint;
  70688. /**
  70689. * Gets the rgb component (output)
  70690. * @deprecated Please use rgbOut instead.
  70691. */
  70692. get rgb(): NodeMaterialConnectionPoint;
  70693. protected _buildBlock(state: NodeMaterialBuildState): this;
  70694. }
  70695. }
  70696. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  70697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70700. /**
  70701. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  70702. */
  70703. export class VectorSplitterBlock extends NodeMaterialBlock {
  70704. /**
  70705. * Create a new VectorSplitterBlock
  70706. * @param name defines the block name
  70707. */
  70708. constructor(name: string);
  70709. /**
  70710. * Gets the current class name
  70711. * @returns the class name
  70712. */
  70713. getClassName(): string;
  70714. /**
  70715. * Gets the xyzw component (input)
  70716. */
  70717. get xyzw(): NodeMaterialConnectionPoint;
  70718. /**
  70719. * Gets the xyz component (input)
  70720. */
  70721. get xyzIn(): NodeMaterialConnectionPoint;
  70722. /**
  70723. * Gets the xy component (input)
  70724. */
  70725. get xyIn(): NodeMaterialConnectionPoint;
  70726. /**
  70727. * Gets the xyz component (output)
  70728. */
  70729. get xyzOut(): NodeMaterialConnectionPoint;
  70730. /**
  70731. * Gets the xy component (output)
  70732. */
  70733. get xyOut(): NodeMaterialConnectionPoint;
  70734. /**
  70735. * Gets the x component (output)
  70736. */
  70737. get x(): NodeMaterialConnectionPoint;
  70738. /**
  70739. * Gets the y component (output)
  70740. */
  70741. get y(): NodeMaterialConnectionPoint;
  70742. /**
  70743. * Gets the z component (output)
  70744. */
  70745. get z(): NodeMaterialConnectionPoint;
  70746. /**
  70747. * Gets the w component (output)
  70748. */
  70749. get w(): NodeMaterialConnectionPoint;
  70750. protected _inputRename(name: string): string;
  70751. protected _outputRename(name: string): string;
  70752. protected _buildBlock(state: NodeMaterialBuildState): this;
  70753. }
  70754. }
  70755. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  70756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70759. /**
  70760. * Block used to lerp between 2 values
  70761. */
  70762. export class LerpBlock extends NodeMaterialBlock {
  70763. /**
  70764. * Creates a new LerpBlock
  70765. * @param name defines the block name
  70766. */
  70767. constructor(name: string);
  70768. /**
  70769. * Gets the current class name
  70770. * @returns the class name
  70771. */
  70772. getClassName(): string;
  70773. /**
  70774. * Gets the left operand input component
  70775. */
  70776. get left(): NodeMaterialConnectionPoint;
  70777. /**
  70778. * Gets the right operand input component
  70779. */
  70780. get right(): NodeMaterialConnectionPoint;
  70781. /**
  70782. * Gets the gradient operand input component
  70783. */
  70784. get gradient(): NodeMaterialConnectionPoint;
  70785. /**
  70786. * Gets the output component
  70787. */
  70788. get output(): NodeMaterialConnectionPoint;
  70789. protected _buildBlock(state: NodeMaterialBuildState): this;
  70790. }
  70791. }
  70792. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  70793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70796. /**
  70797. * Block used to divide 2 vectors
  70798. */
  70799. export class DivideBlock extends NodeMaterialBlock {
  70800. /**
  70801. * Creates a new DivideBlock
  70802. * @param name defines the block name
  70803. */
  70804. constructor(name: string);
  70805. /**
  70806. * Gets the current class name
  70807. * @returns the class name
  70808. */
  70809. getClassName(): string;
  70810. /**
  70811. * Gets the left operand input component
  70812. */
  70813. get left(): NodeMaterialConnectionPoint;
  70814. /**
  70815. * Gets the right operand input component
  70816. */
  70817. get right(): NodeMaterialConnectionPoint;
  70818. /**
  70819. * Gets the output component
  70820. */
  70821. get output(): NodeMaterialConnectionPoint;
  70822. protected _buildBlock(state: NodeMaterialBuildState): this;
  70823. }
  70824. }
  70825. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  70826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70829. /**
  70830. * Block used to subtract 2 vectors
  70831. */
  70832. export class SubtractBlock extends NodeMaterialBlock {
  70833. /**
  70834. * Creates a new SubtractBlock
  70835. * @param name defines the block name
  70836. */
  70837. constructor(name: string);
  70838. /**
  70839. * Gets the current class name
  70840. * @returns the class name
  70841. */
  70842. getClassName(): string;
  70843. /**
  70844. * Gets the left operand input component
  70845. */
  70846. get left(): NodeMaterialConnectionPoint;
  70847. /**
  70848. * Gets the right operand input component
  70849. */
  70850. get right(): NodeMaterialConnectionPoint;
  70851. /**
  70852. * Gets the output component
  70853. */
  70854. get output(): NodeMaterialConnectionPoint;
  70855. protected _buildBlock(state: NodeMaterialBuildState): this;
  70856. }
  70857. }
  70858. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  70859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70862. /**
  70863. * Block used to step a value
  70864. */
  70865. export class StepBlock extends NodeMaterialBlock {
  70866. /**
  70867. * Creates a new StepBlock
  70868. * @param name defines the block name
  70869. */
  70870. constructor(name: string);
  70871. /**
  70872. * Gets the current class name
  70873. * @returns the class name
  70874. */
  70875. getClassName(): string;
  70876. /**
  70877. * Gets the value operand input component
  70878. */
  70879. get value(): NodeMaterialConnectionPoint;
  70880. /**
  70881. * Gets the edge operand input component
  70882. */
  70883. get edge(): NodeMaterialConnectionPoint;
  70884. /**
  70885. * Gets the output component
  70886. */
  70887. get output(): NodeMaterialConnectionPoint;
  70888. protected _buildBlock(state: NodeMaterialBuildState): this;
  70889. }
  70890. }
  70891. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  70892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70895. /**
  70896. * Block used to get the opposite (1 - x) of a value
  70897. */
  70898. export class OneMinusBlock extends NodeMaterialBlock {
  70899. /**
  70900. * Creates a new OneMinusBlock
  70901. * @param name defines the block name
  70902. */
  70903. constructor(name: string);
  70904. /**
  70905. * Gets the current class name
  70906. * @returns the class name
  70907. */
  70908. getClassName(): string;
  70909. /**
  70910. * Gets the input component
  70911. */
  70912. get input(): NodeMaterialConnectionPoint;
  70913. /**
  70914. * Gets the output component
  70915. */
  70916. get output(): NodeMaterialConnectionPoint;
  70917. protected _buildBlock(state: NodeMaterialBuildState): this;
  70918. }
  70919. }
  70920. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  70921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70924. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70925. /**
  70926. * Block used to get the view direction
  70927. */
  70928. export class ViewDirectionBlock extends NodeMaterialBlock {
  70929. /**
  70930. * Creates a new ViewDirectionBlock
  70931. * @param name defines the block name
  70932. */
  70933. constructor(name: string);
  70934. /**
  70935. * Gets the current class name
  70936. * @returns the class name
  70937. */
  70938. getClassName(): string;
  70939. /**
  70940. * Gets the world position component
  70941. */
  70942. get worldPosition(): NodeMaterialConnectionPoint;
  70943. /**
  70944. * Gets the camera position component
  70945. */
  70946. get cameraPosition(): NodeMaterialConnectionPoint;
  70947. /**
  70948. * Gets the output component
  70949. */
  70950. get output(): NodeMaterialConnectionPoint;
  70951. autoConfigure(material: NodeMaterial): void;
  70952. protected _buildBlock(state: NodeMaterialBuildState): this;
  70953. }
  70954. }
  70955. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  70956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70959. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70960. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  70961. /**
  70962. * Block used to compute fresnel value
  70963. */
  70964. export class FresnelBlock extends NodeMaterialBlock {
  70965. /**
  70966. * Create a new FresnelBlock
  70967. * @param name defines the block name
  70968. */
  70969. constructor(name: string);
  70970. /**
  70971. * Gets the current class name
  70972. * @returns the class name
  70973. */
  70974. getClassName(): string;
  70975. /**
  70976. * Gets the world normal input component
  70977. */
  70978. get worldNormal(): NodeMaterialConnectionPoint;
  70979. /**
  70980. * Gets the view direction input component
  70981. */
  70982. get viewDirection(): NodeMaterialConnectionPoint;
  70983. /**
  70984. * Gets the bias input component
  70985. */
  70986. get bias(): NodeMaterialConnectionPoint;
  70987. /**
  70988. * Gets the camera (or eye) position component
  70989. */
  70990. get power(): NodeMaterialConnectionPoint;
  70991. /**
  70992. * Gets the fresnel output component
  70993. */
  70994. get fresnel(): NodeMaterialConnectionPoint;
  70995. autoConfigure(material: NodeMaterial): void;
  70996. protected _buildBlock(state: NodeMaterialBuildState): this;
  70997. }
  70998. }
  70999. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  71000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71003. /**
  71004. * Block used to get the max of 2 values
  71005. */
  71006. export class MaxBlock extends NodeMaterialBlock {
  71007. /**
  71008. * Creates a new MaxBlock
  71009. * @param name defines the block name
  71010. */
  71011. constructor(name: string);
  71012. /**
  71013. * Gets the current class name
  71014. * @returns the class name
  71015. */
  71016. getClassName(): string;
  71017. /**
  71018. * Gets the left operand input component
  71019. */
  71020. get left(): NodeMaterialConnectionPoint;
  71021. /**
  71022. * Gets the right operand input component
  71023. */
  71024. get right(): NodeMaterialConnectionPoint;
  71025. /**
  71026. * Gets the output component
  71027. */
  71028. get output(): NodeMaterialConnectionPoint;
  71029. protected _buildBlock(state: NodeMaterialBuildState): this;
  71030. }
  71031. }
  71032. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  71033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71036. /**
  71037. * Block used to get the min of 2 values
  71038. */
  71039. export class MinBlock extends NodeMaterialBlock {
  71040. /**
  71041. * Creates a new MinBlock
  71042. * @param name defines the block name
  71043. */
  71044. constructor(name: string);
  71045. /**
  71046. * Gets the current class name
  71047. * @returns the class name
  71048. */
  71049. getClassName(): string;
  71050. /**
  71051. * Gets the left operand input component
  71052. */
  71053. get left(): NodeMaterialConnectionPoint;
  71054. /**
  71055. * Gets the right operand input component
  71056. */
  71057. get right(): NodeMaterialConnectionPoint;
  71058. /**
  71059. * Gets the output component
  71060. */
  71061. get output(): NodeMaterialConnectionPoint;
  71062. protected _buildBlock(state: NodeMaterialBuildState): this;
  71063. }
  71064. }
  71065. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  71066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71069. /**
  71070. * Block used to get the distance between 2 values
  71071. */
  71072. export class DistanceBlock extends NodeMaterialBlock {
  71073. /**
  71074. * Creates a new DistanceBlock
  71075. * @param name defines the block name
  71076. */
  71077. constructor(name: string);
  71078. /**
  71079. * Gets the current class name
  71080. * @returns the class name
  71081. */
  71082. getClassName(): string;
  71083. /**
  71084. * Gets the left operand input component
  71085. */
  71086. get left(): NodeMaterialConnectionPoint;
  71087. /**
  71088. * Gets the right operand input component
  71089. */
  71090. get right(): NodeMaterialConnectionPoint;
  71091. /**
  71092. * Gets the output component
  71093. */
  71094. get output(): NodeMaterialConnectionPoint;
  71095. protected _buildBlock(state: NodeMaterialBuildState): this;
  71096. }
  71097. }
  71098. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  71099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71102. /**
  71103. * Block used to get the length of a vector
  71104. */
  71105. export class LengthBlock extends NodeMaterialBlock {
  71106. /**
  71107. * Creates a new LengthBlock
  71108. * @param name defines the block name
  71109. */
  71110. constructor(name: string);
  71111. /**
  71112. * Gets the current class name
  71113. * @returns the class name
  71114. */
  71115. getClassName(): string;
  71116. /**
  71117. * Gets the value input component
  71118. */
  71119. get value(): NodeMaterialConnectionPoint;
  71120. /**
  71121. * Gets the output component
  71122. */
  71123. get output(): NodeMaterialConnectionPoint;
  71124. protected _buildBlock(state: NodeMaterialBuildState): this;
  71125. }
  71126. }
  71127. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  71128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71131. /**
  71132. * Block used to get negative version of a value (i.e. x * -1)
  71133. */
  71134. export class NegateBlock extends NodeMaterialBlock {
  71135. /**
  71136. * Creates a new NegateBlock
  71137. * @param name defines the block name
  71138. */
  71139. constructor(name: string);
  71140. /**
  71141. * Gets the current class name
  71142. * @returns the class name
  71143. */
  71144. getClassName(): string;
  71145. /**
  71146. * Gets the value input component
  71147. */
  71148. get value(): NodeMaterialConnectionPoint;
  71149. /**
  71150. * Gets the output component
  71151. */
  71152. get output(): NodeMaterialConnectionPoint;
  71153. protected _buildBlock(state: NodeMaterialBuildState): this;
  71154. }
  71155. }
  71156. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  71157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71160. /**
  71161. * Block used to get the value of the first parameter raised to the power of the second
  71162. */
  71163. export class PowBlock extends NodeMaterialBlock {
  71164. /**
  71165. * Creates a new PowBlock
  71166. * @param name defines the block name
  71167. */
  71168. constructor(name: string);
  71169. /**
  71170. * Gets the current class name
  71171. * @returns the class name
  71172. */
  71173. getClassName(): string;
  71174. /**
  71175. * Gets the value operand input component
  71176. */
  71177. get value(): NodeMaterialConnectionPoint;
  71178. /**
  71179. * Gets the power operand input component
  71180. */
  71181. get power(): NodeMaterialConnectionPoint;
  71182. /**
  71183. * Gets the output component
  71184. */
  71185. get output(): NodeMaterialConnectionPoint;
  71186. protected _buildBlock(state: NodeMaterialBuildState): this;
  71187. }
  71188. }
  71189. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  71190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71193. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71194. /**
  71195. * Block used to get a random number
  71196. */
  71197. export class RandomNumberBlock extends NodeMaterialBlock {
  71198. /**
  71199. * Creates a new RandomNumberBlock
  71200. * @param name defines the block name
  71201. */
  71202. constructor(name: string);
  71203. /**
  71204. * Gets the current class name
  71205. * @returns the class name
  71206. */
  71207. getClassName(): string;
  71208. /**
  71209. * Gets the seed input component
  71210. */
  71211. get seed(): NodeMaterialConnectionPoint;
  71212. /**
  71213. * Gets the output component
  71214. */
  71215. get output(): NodeMaterialConnectionPoint;
  71216. protected _buildBlock(state: NodeMaterialBuildState): this;
  71217. }
  71218. }
  71219. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  71220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71222. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71223. /**
  71224. * Block used to compute arc tangent of 2 values
  71225. */
  71226. export class ArcTan2Block extends NodeMaterialBlock {
  71227. /**
  71228. * Creates a new ArcTan2Block
  71229. * @param name defines the block name
  71230. */
  71231. constructor(name: string);
  71232. /**
  71233. * Gets the current class name
  71234. * @returns the class name
  71235. */
  71236. getClassName(): string;
  71237. /**
  71238. * Gets the x operand input component
  71239. */
  71240. get x(): NodeMaterialConnectionPoint;
  71241. /**
  71242. * Gets the y operand input component
  71243. */
  71244. get y(): NodeMaterialConnectionPoint;
  71245. /**
  71246. * Gets the output component
  71247. */
  71248. get output(): NodeMaterialConnectionPoint;
  71249. protected _buildBlock(state: NodeMaterialBuildState): this;
  71250. }
  71251. }
  71252. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  71253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71256. /**
  71257. * Block used to smooth step a value
  71258. */
  71259. export class SmoothStepBlock extends NodeMaterialBlock {
  71260. /**
  71261. * Creates a new SmoothStepBlock
  71262. * @param name defines the block name
  71263. */
  71264. constructor(name: string);
  71265. /**
  71266. * Gets the current class name
  71267. * @returns the class name
  71268. */
  71269. getClassName(): string;
  71270. /**
  71271. * Gets the value operand input component
  71272. */
  71273. get value(): NodeMaterialConnectionPoint;
  71274. /**
  71275. * Gets the first edge operand input component
  71276. */
  71277. get edge0(): NodeMaterialConnectionPoint;
  71278. /**
  71279. * Gets the second edge operand input component
  71280. */
  71281. get edge1(): NodeMaterialConnectionPoint;
  71282. /**
  71283. * Gets the output component
  71284. */
  71285. get output(): NodeMaterialConnectionPoint;
  71286. protected _buildBlock(state: NodeMaterialBuildState): this;
  71287. }
  71288. }
  71289. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  71290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71293. /**
  71294. * Block used to get the reciprocal (1 / x) of a value
  71295. */
  71296. export class ReciprocalBlock extends NodeMaterialBlock {
  71297. /**
  71298. * Creates a new ReciprocalBlock
  71299. * @param name defines the block name
  71300. */
  71301. constructor(name: string);
  71302. /**
  71303. * Gets the current class name
  71304. * @returns the class name
  71305. */
  71306. getClassName(): string;
  71307. /**
  71308. * Gets the input component
  71309. */
  71310. get input(): NodeMaterialConnectionPoint;
  71311. /**
  71312. * Gets the output component
  71313. */
  71314. get output(): NodeMaterialConnectionPoint;
  71315. protected _buildBlock(state: NodeMaterialBuildState): this;
  71316. }
  71317. }
  71318. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  71319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71322. /**
  71323. * Block used to replace a color by another one
  71324. */
  71325. export class ReplaceColorBlock extends NodeMaterialBlock {
  71326. /**
  71327. * Creates a new ReplaceColorBlock
  71328. * @param name defines the block name
  71329. */
  71330. constructor(name: string);
  71331. /**
  71332. * Gets the current class name
  71333. * @returns the class name
  71334. */
  71335. getClassName(): string;
  71336. /**
  71337. * Gets the value input component
  71338. */
  71339. get value(): NodeMaterialConnectionPoint;
  71340. /**
  71341. * Gets the reference input component
  71342. */
  71343. get reference(): NodeMaterialConnectionPoint;
  71344. /**
  71345. * Gets the distance input component
  71346. */
  71347. get distance(): NodeMaterialConnectionPoint;
  71348. /**
  71349. * Gets the replacement input component
  71350. */
  71351. get replacement(): NodeMaterialConnectionPoint;
  71352. /**
  71353. * Gets the output component
  71354. */
  71355. get output(): NodeMaterialConnectionPoint;
  71356. protected _buildBlock(state: NodeMaterialBuildState): this;
  71357. }
  71358. }
  71359. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  71360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71363. /**
  71364. * Block used to posterize a value
  71365. * @see https://en.wikipedia.org/wiki/Posterization
  71366. */
  71367. export class PosterizeBlock extends NodeMaterialBlock {
  71368. /**
  71369. * Creates a new PosterizeBlock
  71370. * @param name defines the block name
  71371. */
  71372. constructor(name: string);
  71373. /**
  71374. * Gets the current class name
  71375. * @returns the class name
  71376. */
  71377. getClassName(): string;
  71378. /**
  71379. * Gets the value input component
  71380. */
  71381. get value(): NodeMaterialConnectionPoint;
  71382. /**
  71383. * Gets the steps input component
  71384. */
  71385. get steps(): NodeMaterialConnectionPoint;
  71386. /**
  71387. * Gets the output component
  71388. */
  71389. get output(): NodeMaterialConnectionPoint;
  71390. protected _buildBlock(state: NodeMaterialBuildState): this;
  71391. }
  71392. }
  71393. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  71394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71397. import { Scene } from "babylonjs/scene";
  71398. /**
  71399. * Operations supported by the Wave block
  71400. */
  71401. export enum WaveBlockKind {
  71402. /** SawTooth */
  71403. SawTooth = 0,
  71404. /** Square */
  71405. Square = 1,
  71406. /** Triangle */
  71407. Triangle = 2
  71408. }
  71409. /**
  71410. * Block used to apply wave operation to floats
  71411. */
  71412. export class WaveBlock extends NodeMaterialBlock {
  71413. /**
  71414. * Gets or sets the kibnd of wave to be applied by the block
  71415. */
  71416. kind: WaveBlockKind;
  71417. /**
  71418. * Creates a new WaveBlock
  71419. * @param name defines the block name
  71420. */
  71421. constructor(name: string);
  71422. /**
  71423. * Gets the current class name
  71424. * @returns the class name
  71425. */
  71426. getClassName(): string;
  71427. /**
  71428. * Gets the input component
  71429. */
  71430. get input(): NodeMaterialConnectionPoint;
  71431. /**
  71432. * Gets the output component
  71433. */
  71434. get output(): NodeMaterialConnectionPoint;
  71435. protected _buildBlock(state: NodeMaterialBuildState): this;
  71436. serialize(): any;
  71437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71438. }
  71439. }
  71440. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  71441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71444. import { Color3 } from "babylonjs/Maths/math.color";
  71445. import { Scene } from "babylonjs/scene";
  71446. import { Observable } from "babylonjs/Misc/observable";
  71447. /**
  71448. * Class used to store a color step for the GradientBlock
  71449. */
  71450. export class GradientBlockColorStep {
  71451. private _step;
  71452. /**
  71453. * Gets value indicating which step this color is associated with (between 0 and 1)
  71454. */
  71455. get step(): number;
  71456. /**
  71457. * Sets a value indicating which step this color is associated with (between 0 and 1)
  71458. */
  71459. set step(val: number);
  71460. private _color;
  71461. /**
  71462. * Gets the color associated with this step
  71463. */
  71464. get color(): Color3;
  71465. /**
  71466. * Sets the color associated with this step
  71467. */
  71468. set color(val: Color3);
  71469. /**
  71470. * Creates a new GradientBlockColorStep
  71471. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  71472. * @param color defines the color associated with this step
  71473. */
  71474. constructor(step: number, color: Color3);
  71475. }
  71476. /**
  71477. * Block used to return a color from a gradient based on an input value between 0 and 1
  71478. */
  71479. export class GradientBlock extends NodeMaterialBlock {
  71480. /**
  71481. * Gets or sets the list of color steps
  71482. */
  71483. colorSteps: GradientBlockColorStep[];
  71484. /** Gets an observable raised when the value is changed */
  71485. onValueChangedObservable: Observable<GradientBlock>;
  71486. /** calls observable when the value is changed*/
  71487. colorStepsUpdated(): void;
  71488. /**
  71489. * Creates a new GradientBlock
  71490. * @param name defines the block name
  71491. */
  71492. constructor(name: string);
  71493. /**
  71494. * Gets the current class name
  71495. * @returns the class name
  71496. */
  71497. getClassName(): string;
  71498. /**
  71499. * Gets the gradient input component
  71500. */
  71501. get gradient(): NodeMaterialConnectionPoint;
  71502. /**
  71503. * Gets the output component
  71504. */
  71505. get output(): NodeMaterialConnectionPoint;
  71506. private _writeColorConstant;
  71507. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71508. serialize(): any;
  71509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71510. protected _dumpPropertiesCode(): string;
  71511. }
  71512. }
  71513. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  71514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71517. /**
  71518. * Block used to normalize lerp between 2 values
  71519. */
  71520. export class NLerpBlock extends NodeMaterialBlock {
  71521. /**
  71522. * Creates a new NLerpBlock
  71523. * @param name defines the block name
  71524. */
  71525. constructor(name: string);
  71526. /**
  71527. * Gets the current class name
  71528. * @returns the class name
  71529. */
  71530. getClassName(): string;
  71531. /**
  71532. * Gets the left operand input component
  71533. */
  71534. get left(): NodeMaterialConnectionPoint;
  71535. /**
  71536. * Gets the right operand input component
  71537. */
  71538. get right(): NodeMaterialConnectionPoint;
  71539. /**
  71540. * Gets the gradient operand input component
  71541. */
  71542. get gradient(): NodeMaterialConnectionPoint;
  71543. /**
  71544. * Gets the output component
  71545. */
  71546. get output(): NodeMaterialConnectionPoint;
  71547. protected _buildBlock(state: NodeMaterialBuildState): this;
  71548. }
  71549. }
  71550. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  71551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71554. import { Scene } from "babylonjs/scene";
  71555. /**
  71556. * block used to Generate a Worley Noise 3D Noise Pattern
  71557. */
  71558. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  71559. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  71560. manhattanDistance: boolean;
  71561. /**
  71562. * Creates a new WorleyNoise3DBlock
  71563. * @param name defines the block name
  71564. */
  71565. constructor(name: string);
  71566. /**
  71567. * Gets the current class name
  71568. * @returns the class name
  71569. */
  71570. getClassName(): string;
  71571. /**
  71572. * Gets the seed input component
  71573. */
  71574. get seed(): NodeMaterialConnectionPoint;
  71575. /**
  71576. * Gets the jitter input component
  71577. */
  71578. get jitter(): NodeMaterialConnectionPoint;
  71579. /**
  71580. * Gets the output component
  71581. */
  71582. get output(): NodeMaterialConnectionPoint;
  71583. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71584. /**
  71585. * Exposes the properties to the UI?
  71586. */
  71587. protected _dumpPropertiesCode(): string;
  71588. /**
  71589. * Exposes the properties to the Seralize?
  71590. */
  71591. serialize(): any;
  71592. /**
  71593. * Exposes the properties to the deseralize?
  71594. */
  71595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71596. }
  71597. }
  71598. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  71599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71602. /**
  71603. * block used to Generate a Simplex Perlin 3d Noise Pattern
  71604. */
  71605. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  71606. /**
  71607. * Creates a new SimplexPerlin3DBlock
  71608. * @param name defines the block name
  71609. */
  71610. constructor(name: string);
  71611. /**
  71612. * Gets the current class name
  71613. * @returns the class name
  71614. */
  71615. getClassName(): string;
  71616. /**
  71617. * Gets the seed operand input component
  71618. */
  71619. get seed(): NodeMaterialConnectionPoint;
  71620. /**
  71621. * Gets the output component
  71622. */
  71623. get output(): NodeMaterialConnectionPoint;
  71624. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71625. }
  71626. }
  71627. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  71628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71631. /**
  71632. * Block used to blend normals
  71633. */
  71634. export class NormalBlendBlock extends NodeMaterialBlock {
  71635. /**
  71636. * Creates a new NormalBlendBlock
  71637. * @param name defines the block name
  71638. */
  71639. constructor(name: string);
  71640. /**
  71641. * Gets the current class name
  71642. * @returns the class name
  71643. */
  71644. getClassName(): string;
  71645. /**
  71646. * Gets the first input component
  71647. */
  71648. get normalMap0(): NodeMaterialConnectionPoint;
  71649. /**
  71650. * Gets the second input component
  71651. */
  71652. get normalMap1(): NodeMaterialConnectionPoint;
  71653. /**
  71654. * Gets the output component
  71655. */
  71656. get output(): NodeMaterialConnectionPoint;
  71657. protected _buildBlock(state: NodeMaterialBuildState): this;
  71658. }
  71659. }
  71660. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  71661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71664. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71665. /**
  71666. * Block used to rotate a 2d vector by a given angle
  71667. */
  71668. export class Rotate2dBlock extends NodeMaterialBlock {
  71669. /**
  71670. * Creates a new Rotate2dBlock
  71671. * @param name defines the block name
  71672. */
  71673. constructor(name: string);
  71674. /**
  71675. * Gets the current class name
  71676. * @returns the class name
  71677. */
  71678. getClassName(): string;
  71679. /**
  71680. * Gets the input vector
  71681. */
  71682. get input(): NodeMaterialConnectionPoint;
  71683. /**
  71684. * Gets the input angle
  71685. */
  71686. get angle(): NodeMaterialConnectionPoint;
  71687. /**
  71688. * Gets the output component
  71689. */
  71690. get output(): NodeMaterialConnectionPoint;
  71691. autoConfigure(material: NodeMaterial): void;
  71692. protected _buildBlock(state: NodeMaterialBuildState): this;
  71693. }
  71694. }
  71695. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  71696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71699. /**
  71700. * Block used to get the reflected vector from a direction and a normal
  71701. */
  71702. export class ReflectBlock extends NodeMaterialBlock {
  71703. /**
  71704. * Creates a new ReflectBlock
  71705. * @param name defines the block name
  71706. */
  71707. constructor(name: string);
  71708. /**
  71709. * Gets the current class name
  71710. * @returns the class name
  71711. */
  71712. getClassName(): string;
  71713. /**
  71714. * Gets the incident component
  71715. */
  71716. get incident(): NodeMaterialConnectionPoint;
  71717. /**
  71718. * Gets the normal component
  71719. */
  71720. get normal(): NodeMaterialConnectionPoint;
  71721. /**
  71722. * Gets the output component
  71723. */
  71724. get output(): NodeMaterialConnectionPoint;
  71725. protected _buildBlock(state: NodeMaterialBuildState): this;
  71726. }
  71727. }
  71728. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  71729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71732. /**
  71733. * Block used to get the refracted vector from a direction and a normal
  71734. */
  71735. export class RefractBlock extends NodeMaterialBlock {
  71736. /**
  71737. * Creates a new RefractBlock
  71738. * @param name defines the block name
  71739. */
  71740. constructor(name: string);
  71741. /**
  71742. * Gets the current class name
  71743. * @returns the class name
  71744. */
  71745. getClassName(): string;
  71746. /**
  71747. * Gets the incident component
  71748. */
  71749. get incident(): NodeMaterialConnectionPoint;
  71750. /**
  71751. * Gets the normal component
  71752. */
  71753. get normal(): NodeMaterialConnectionPoint;
  71754. /**
  71755. * Gets the index of refraction component
  71756. */
  71757. get ior(): NodeMaterialConnectionPoint;
  71758. /**
  71759. * Gets the output component
  71760. */
  71761. get output(): NodeMaterialConnectionPoint;
  71762. protected _buildBlock(state: NodeMaterialBuildState): this;
  71763. }
  71764. }
  71765. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  71766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71769. /**
  71770. * Block used to desaturate a color
  71771. */
  71772. export class DesaturateBlock extends NodeMaterialBlock {
  71773. /**
  71774. * Creates a new DesaturateBlock
  71775. * @param name defines the block name
  71776. */
  71777. constructor(name: string);
  71778. /**
  71779. * Gets the current class name
  71780. * @returns the class name
  71781. */
  71782. getClassName(): string;
  71783. /**
  71784. * Gets the color operand input component
  71785. */
  71786. get color(): NodeMaterialConnectionPoint;
  71787. /**
  71788. * Gets the level operand input component
  71789. */
  71790. get level(): NodeMaterialConnectionPoint;
  71791. /**
  71792. * Gets the output component
  71793. */
  71794. get output(): NodeMaterialConnectionPoint;
  71795. protected _buildBlock(state: NodeMaterialBuildState): this;
  71796. }
  71797. }
  71798. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  71799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71801. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71802. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  71803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71804. import { Nullable } from "babylonjs/types";
  71805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71806. import { Mesh } from "babylonjs/Meshes/mesh";
  71807. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71808. import { Effect } from "babylonjs/Materials/effect";
  71809. import { Scene } from "babylonjs/scene";
  71810. /**
  71811. * Block used to implement the reflection module of the PBR material
  71812. */
  71813. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  71814. /** @hidden */
  71815. _defineLODReflectionAlpha: string;
  71816. /** @hidden */
  71817. _defineLinearSpecularReflection: string;
  71818. private _vEnvironmentIrradianceName;
  71819. /** @hidden */
  71820. _vReflectionMicrosurfaceInfosName: string;
  71821. /** @hidden */
  71822. _vReflectionInfosName: string;
  71823. /** @hidden */
  71824. _vReflectionFilteringInfoName: string;
  71825. private _scene;
  71826. /**
  71827. * The properties below are set by the main PBR block prior to calling methods of this class.
  71828. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  71829. * It's less burden on the user side in the editor part.
  71830. */
  71831. /** @hidden */
  71832. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  71833. /** @hidden */
  71834. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  71835. /** @hidden */
  71836. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  71837. /** @hidden */
  71838. viewConnectionPoint: NodeMaterialConnectionPoint;
  71839. /**
  71840. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  71841. * diffuse part of the IBL.
  71842. */
  71843. useSphericalHarmonics: boolean;
  71844. /**
  71845. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  71846. */
  71847. forceIrradianceInFragment: boolean;
  71848. /**
  71849. * Create a new ReflectionBlock
  71850. * @param name defines the block name
  71851. */
  71852. constructor(name: string);
  71853. /**
  71854. * Gets the current class name
  71855. * @returns the class name
  71856. */
  71857. getClassName(): string;
  71858. /**
  71859. * Gets the position input component
  71860. */
  71861. get position(): NodeMaterialConnectionPoint;
  71862. /**
  71863. * Gets the world position input component
  71864. */
  71865. get worldPosition(): NodeMaterialConnectionPoint;
  71866. /**
  71867. * Gets the world normal input component
  71868. */
  71869. get worldNormal(): NodeMaterialConnectionPoint;
  71870. /**
  71871. * Gets the world input component
  71872. */
  71873. get world(): NodeMaterialConnectionPoint;
  71874. /**
  71875. * Gets the camera (or eye) position component
  71876. */
  71877. get cameraPosition(): NodeMaterialConnectionPoint;
  71878. /**
  71879. * Gets the view input component
  71880. */
  71881. get view(): NodeMaterialConnectionPoint;
  71882. /**
  71883. * Gets the color input component
  71884. */
  71885. get color(): NodeMaterialConnectionPoint;
  71886. /**
  71887. * Gets the reflection object output component
  71888. */
  71889. get reflection(): NodeMaterialConnectionPoint;
  71890. /**
  71891. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  71892. */
  71893. get hasTexture(): boolean;
  71894. /**
  71895. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  71896. */
  71897. get reflectionColor(): string;
  71898. protected _getTexture(): Nullable<BaseTexture>;
  71899. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  71900. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  71901. /**
  71902. * Gets the code to inject in the vertex shader
  71903. * @param state current state of the node material building
  71904. * @returns the shader code
  71905. */
  71906. handleVertexSide(state: NodeMaterialBuildState): string;
  71907. /**
  71908. * Gets the main code of the block (fragment side)
  71909. * @param state current state of the node material building
  71910. * @param normalVarName name of the existing variable corresponding to the normal
  71911. * @returns the shader code
  71912. */
  71913. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  71914. protected _buildBlock(state: NodeMaterialBuildState): this;
  71915. protected _dumpPropertiesCode(): string;
  71916. serialize(): any;
  71917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71918. }
  71919. }
  71920. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  71921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71926. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  71927. import { Scene } from "babylonjs/scene";
  71928. import { Nullable } from "babylonjs/types";
  71929. /**
  71930. * Block used to implement the sheen module of the PBR material
  71931. */
  71932. export class SheenBlock extends NodeMaterialBlock {
  71933. /**
  71934. * Create a new SheenBlock
  71935. * @param name defines the block name
  71936. */
  71937. constructor(name: string);
  71938. /**
  71939. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  71940. * It allows the strength of the sheen effect to not depend on the base color of the material,
  71941. * making it easier to setup and tweak the effect
  71942. */
  71943. albedoScaling: boolean;
  71944. /**
  71945. * Defines if the sheen is linked to the sheen color.
  71946. */
  71947. linkSheenWithAlbedo: boolean;
  71948. /**
  71949. * Initialize the block and prepare the context for build
  71950. * @param state defines the state that will be used for the build
  71951. */
  71952. initialize(state: NodeMaterialBuildState): void;
  71953. /**
  71954. * Gets the current class name
  71955. * @returns the class name
  71956. */
  71957. getClassName(): string;
  71958. /**
  71959. * Gets the intensity input component
  71960. */
  71961. get intensity(): NodeMaterialConnectionPoint;
  71962. /**
  71963. * Gets the color input component
  71964. */
  71965. get color(): NodeMaterialConnectionPoint;
  71966. /**
  71967. * Gets the roughness input component
  71968. */
  71969. get roughness(): NodeMaterialConnectionPoint;
  71970. /**
  71971. * Gets the sheen object output component
  71972. */
  71973. get sheen(): NodeMaterialConnectionPoint;
  71974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  71975. /**
  71976. * Gets the main code of the block (fragment side)
  71977. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  71978. * @returns the shader code
  71979. */
  71980. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  71981. protected _buildBlock(state: NodeMaterialBuildState): this;
  71982. protected _dumpPropertiesCode(): string;
  71983. serialize(): any;
  71984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71985. }
  71986. }
  71987. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  71988. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71993. /**
  71994. * Block used to implement the anisotropy module of the PBR material
  71995. */
  71996. export class AnisotropyBlock extends NodeMaterialBlock {
  71997. /**
  71998. * The two properties below are set by the main PBR block prior to calling methods of this class.
  71999. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72000. * It's less burden on the user side in the editor part.
  72001. */
  72002. /** @hidden */
  72003. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72004. /** @hidden */
  72005. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72006. /**
  72007. * Create a new AnisotropyBlock
  72008. * @param name defines the block name
  72009. */
  72010. constructor(name: string);
  72011. /**
  72012. * Initialize the block and prepare the context for build
  72013. * @param state defines the state that will be used for the build
  72014. */
  72015. initialize(state: NodeMaterialBuildState): void;
  72016. /**
  72017. * Gets the current class name
  72018. * @returns the class name
  72019. */
  72020. getClassName(): string;
  72021. /**
  72022. * Gets the intensity input component
  72023. */
  72024. get intensity(): NodeMaterialConnectionPoint;
  72025. /**
  72026. * Gets the direction input component
  72027. */
  72028. get direction(): NodeMaterialConnectionPoint;
  72029. /**
  72030. * Gets the uv input component
  72031. */
  72032. get uv(): NodeMaterialConnectionPoint;
  72033. /**
  72034. * Gets the worldTangent input component
  72035. */
  72036. get worldTangent(): NodeMaterialConnectionPoint;
  72037. /**
  72038. * Gets the anisotropy object output component
  72039. */
  72040. get anisotropy(): NodeMaterialConnectionPoint;
  72041. private _generateTBNSpace;
  72042. /**
  72043. * Gets the main code of the block (fragment side)
  72044. * @param state current state of the node material building
  72045. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72046. * @returns the shader code
  72047. */
  72048. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  72049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72050. protected _buildBlock(state: NodeMaterialBuildState): this;
  72051. }
  72052. }
  72053. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  72054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72057. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72059. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72060. import { Scene } from "babylonjs/scene";
  72061. import { Nullable } from "babylonjs/types";
  72062. import { Mesh } from "babylonjs/Meshes/mesh";
  72063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72064. import { Effect } from "babylonjs/Materials/effect";
  72065. /**
  72066. * Block used to implement the clear coat module of the PBR material
  72067. */
  72068. export class ClearCoatBlock extends NodeMaterialBlock {
  72069. private _scene;
  72070. /**
  72071. * Create a new ClearCoatBlock
  72072. * @param name defines the block name
  72073. */
  72074. constructor(name: string);
  72075. /**
  72076. * Defines if the F0 value should be remapped to account for the interface change in the material.
  72077. */
  72078. remapF0OnInterfaceChange: boolean;
  72079. /**
  72080. * Initialize the block and prepare the context for build
  72081. * @param state defines the state that will be used for the build
  72082. */
  72083. initialize(state: NodeMaterialBuildState): void;
  72084. /**
  72085. * Gets the current class name
  72086. * @returns the class name
  72087. */
  72088. getClassName(): string;
  72089. /**
  72090. * Gets the intensity input component
  72091. */
  72092. get intensity(): NodeMaterialConnectionPoint;
  72093. /**
  72094. * Gets the roughness input component
  72095. */
  72096. get roughness(): NodeMaterialConnectionPoint;
  72097. /**
  72098. * Gets the ior input component
  72099. */
  72100. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72101. /**
  72102. * Gets the bump texture input component
  72103. */
  72104. get normalMapColor(): NodeMaterialConnectionPoint;
  72105. /**
  72106. * Gets the uv input component
  72107. */
  72108. get uv(): NodeMaterialConnectionPoint;
  72109. /**
  72110. * Gets the tint color input component
  72111. */
  72112. get tintColor(): NodeMaterialConnectionPoint;
  72113. /**
  72114. * Gets the tint "at distance" input component
  72115. */
  72116. get tintAtDistance(): NodeMaterialConnectionPoint;
  72117. /**
  72118. * Gets the tint thickness input component
  72119. */
  72120. get tintThickness(): NodeMaterialConnectionPoint;
  72121. /**
  72122. * Gets the world tangent input component
  72123. */
  72124. get worldTangent(): NodeMaterialConnectionPoint;
  72125. /**
  72126. * Gets the clear coat object output component
  72127. */
  72128. get clearcoat(): NodeMaterialConnectionPoint;
  72129. autoConfigure(material: NodeMaterial): void;
  72130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72132. private _generateTBNSpace;
  72133. /**
  72134. * Gets the main code of the block (fragment side)
  72135. * @param state current state of the node material building
  72136. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  72137. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72138. * @param worldPosVarName name of the variable holding the world position
  72139. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72140. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  72141. * @param worldNormalVarName name of the variable holding the world normal
  72142. * @returns the shader code
  72143. */
  72144. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  72145. protected _buildBlock(state: NodeMaterialBuildState): this;
  72146. protected _dumpPropertiesCode(): string;
  72147. serialize(): any;
  72148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72149. }
  72150. }
  72151. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  72152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72155. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72157. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72158. import { Nullable } from "babylonjs/types";
  72159. /**
  72160. * Block used to implement the sub surface module of the PBR material
  72161. */
  72162. export class SubSurfaceBlock extends NodeMaterialBlock {
  72163. /**
  72164. * Create a new SubSurfaceBlock
  72165. * @param name defines the block name
  72166. */
  72167. constructor(name: string);
  72168. /**
  72169. * Initialize the block and prepare the context for build
  72170. * @param state defines the state that will be used for the build
  72171. */
  72172. initialize(state: NodeMaterialBuildState): void;
  72173. /**
  72174. * Gets the current class name
  72175. * @returns the class name
  72176. */
  72177. getClassName(): string;
  72178. /**
  72179. * Gets the thickness component
  72180. */
  72181. get thickness(): NodeMaterialConnectionPoint;
  72182. /**
  72183. * Gets the tint color input component
  72184. */
  72185. get tintColor(): NodeMaterialConnectionPoint;
  72186. /**
  72187. * Gets the translucency intensity input component
  72188. */
  72189. get translucencyIntensity(): NodeMaterialConnectionPoint;
  72190. /**
  72191. * Gets the translucency diffusion distance input component
  72192. */
  72193. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  72194. /**
  72195. * Gets the refraction object parameters
  72196. */
  72197. get refraction(): NodeMaterialConnectionPoint;
  72198. /**
  72199. * Gets the sub surface object output component
  72200. */
  72201. get subsurface(): NodeMaterialConnectionPoint;
  72202. autoConfigure(material: NodeMaterial): void;
  72203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72204. /**
  72205. * Gets the main code of the block (fragment side)
  72206. * @param state current state of the node material building
  72207. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  72208. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72209. * @param worldPosVarName name of the variable holding the world position
  72210. * @returns the shader code
  72211. */
  72212. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  72213. protected _buildBlock(state: NodeMaterialBuildState): this;
  72214. }
  72215. }
  72216. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  72217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72220. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72221. import { Light } from "babylonjs/Lights/light";
  72222. import { Nullable } from "babylonjs/types";
  72223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72224. import { Effect } from "babylonjs/Materials/effect";
  72225. import { Mesh } from "babylonjs/Meshes/mesh";
  72226. import { Scene } from "babylonjs/scene";
  72227. /**
  72228. * Block used to implement the PBR metallic/roughness model
  72229. */
  72230. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  72231. /**
  72232. * Gets or sets the light associated with this block
  72233. */
  72234. light: Nullable<Light>;
  72235. private _lightId;
  72236. private _scene;
  72237. private _environmentBRDFTexture;
  72238. private _environmentBrdfSamplerName;
  72239. private _vNormalWName;
  72240. private _invertNormalName;
  72241. private _metallicReflectanceColor;
  72242. private _metallicF0Factor;
  72243. private _vMetallicReflectanceFactorsName;
  72244. /**
  72245. * Create a new ReflectionBlock
  72246. * @param name defines the block name
  72247. */
  72248. constructor(name: string);
  72249. /**
  72250. * Intensity of the direct lights e.g. the four lights available in your scene.
  72251. * This impacts both the direct diffuse and specular highlights.
  72252. */
  72253. directIntensity: number;
  72254. /**
  72255. * Intensity of the environment e.g. how much the environment will light the object
  72256. * either through harmonics for rough material or through the refelction for shiny ones.
  72257. */
  72258. environmentIntensity: number;
  72259. /**
  72260. * This is a special control allowing the reduction of the specular highlights coming from the
  72261. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  72262. */
  72263. specularIntensity: number;
  72264. /**
  72265. * Defines the falloff type used in this material.
  72266. * It by default is Physical.
  72267. */
  72268. lightFalloff: number;
  72269. /**
  72270. * Specifies that alpha test should be used
  72271. */
  72272. useAlphaTest: boolean;
  72273. /**
  72274. * Defines the alpha limits in alpha test mode.
  72275. */
  72276. alphaTestCutoff: number;
  72277. /**
  72278. * Specifies that alpha blending should be used
  72279. */
  72280. useAlphaBlending: boolean;
  72281. /**
  72282. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  72283. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  72284. */
  72285. useRadianceOverAlpha: boolean;
  72286. /**
  72287. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  72288. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  72289. */
  72290. useSpecularOverAlpha: boolean;
  72291. /**
  72292. * Enables specular anti aliasing in the PBR shader.
  72293. * It will both interacts on the Geometry for analytical and IBL lighting.
  72294. * It also prefilter the roughness map based on the bump values.
  72295. */
  72296. enableSpecularAntiAliasing: boolean;
  72297. /**
  72298. * Enables realtime filtering on the texture.
  72299. */
  72300. realTimeFiltering: boolean;
  72301. /**
  72302. * Quality switch for realtime filtering
  72303. */
  72304. realTimeFilteringQuality: number;
  72305. /**
  72306. * Defines if the material uses energy conservation.
  72307. */
  72308. useEnergyConservation: boolean;
  72309. /**
  72310. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  72311. * too much the area relying on ambient texture to define their ambient occlusion.
  72312. */
  72313. useRadianceOcclusion: boolean;
  72314. /**
  72315. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  72316. * makes the reflect vector face the model (under horizon).
  72317. */
  72318. useHorizonOcclusion: boolean;
  72319. /**
  72320. * If set to true, no lighting calculations will be applied.
  72321. */
  72322. unlit: boolean;
  72323. /**
  72324. * Force normal to face away from face.
  72325. */
  72326. forceNormalForward: boolean;
  72327. /**
  72328. * Defines the material debug mode.
  72329. * It helps seeing only some components of the material while troubleshooting.
  72330. */
  72331. debugMode: number;
  72332. /**
  72333. * Specify from where on screen the debug mode should start.
  72334. * The value goes from -1 (full screen) to 1 (not visible)
  72335. * It helps with side by side comparison against the final render
  72336. * This defaults to 0
  72337. */
  72338. debugLimit: number;
  72339. /**
  72340. * As the default viewing range might not be enough (if the ambient is really small for instance)
  72341. * You can use the factor to better multiply the final value.
  72342. */
  72343. debugFactor: number;
  72344. /**
  72345. * Initialize the block and prepare the context for build
  72346. * @param state defines the state that will be used for the build
  72347. */
  72348. initialize(state: NodeMaterialBuildState): void;
  72349. /**
  72350. * Gets the current class name
  72351. * @returns the class name
  72352. */
  72353. getClassName(): string;
  72354. /**
  72355. * Gets the world position input component
  72356. */
  72357. get worldPosition(): NodeMaterialConnectionPoint;
  72358. /**
  72359. * Gets the world normal input component
  72360. */
  72361. get worldNormal(): NodeMaterialConnectionPoint;
  72362. /**
  72363. * Gets the view matrix parameter
  72364. */
  72365. get view(): NodeMaterialConnectionPoint;
  72366. /**
  72367. * Gets the camera position input component
  72368. */
  72369. get cameraPosition(): NodeMaterialConnectionPoint;
  72370. /**
  72371. * Gets the perturbed normal input component
  72372. */
  72373. get perturbedNormal(): NodeMaterialConnectionPoint;
  72374. /**
  72375. * Gets the base color input component
  72376. */
  72377. get baseColor(): NodeMaterialConnectionPoint;
  72378. /**
  72379. * Gets the metallic input component
  72380. */
  72381. get metallic(): NodeMaterialConnectionPoint;
  72382. /**
  72383. * Gets the roughness input component
  72384. */
  72385. get roughness(): NodeMaterialConnectionPoint;
  72386. /**
  72387. * Gets the ambient occlusion input component
  72388. */
  72389. get ambientOcc(): NodeMaterialConnectionPoint;
  72390. /**
  72391. * Gets the opacity input component
  72392. */
  72393. get opacity(): NodeMaterialConnectionPoint;
  72394. /**
  72395. * Gets the index of refraction input component
  72396. */
  72397. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72398. /**
  72399. * Gets the ambient color input component
  72400. */
  72401. get ambientColor(): NodeMaterialConnectionPoint;
  72402. /**
  72403. * Gets the reflection object parameters
  72404. */
  72405. get reflection(): NodeMaterialConnectionPoint;
  72406. /**
  72407. * Gets the clear coat object parameters
  72408. */
  72409. get clearcoat(): NodeMaterialConnectionPoint;
  72410. /**
  72411. * Gets the sheen object parameters
  72412. */
  72413. get sheen(): NodeMaterialConnectionPoint;
  72414. /**
  72415. * Gets the sub surface object parameters
  72416. */
  72417. get subsurface(): NodeMaterialConnectionPoint;
  72418. /**
  72419. * Gets the anisotropy object parameters
  72420. */
  72421. get anisotropy(): NodeMaterialConnectionPoint;
  72422. /**
  72423. * Gets the ambient output component
  72424. */
  72425. get ambientClr(): NodeMaterialConnectionPoint;
  72426. /**
  72427. * Gets the diffuse output component
  72428. */
  72429. get diffuseDir(): NodeMaterialConnectionPoint;
  72430. /**
  72431. * Gets the specular output component
  72432. */
  72433. get specularDir(): NodeMaterialConnectionPoint;
  72434. /**
  72435. * Gets the clear coat output component
  72436. */
  72437. get clearcoatDir(): NodeMaterialConnectionPoint;
  72438. /**
  72439. * Gets the sheen output component
  72440. */
  72441. get sheenDir(): NodeMaterialConnectionPoint;
  72442. /**
  72443. * Gets the indirect diffuse output component
  72444. */
  72445. get diffuseIndirect(): NodeMaterialConnectionPoint;
  72446. /**
  72447. * Gets the indirect specular output component
  72448. */
  72449. get specularIndirect(): NodeMaterialConnectionPoint;
  72450. /**
  72451. * Gets the indirect clear coat output component
  72452. */
  72453. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  72454. /**
  72455. * Gets the indirect sheen output component
  72456. */
  72457. get sheenIndirect(): NodeMaterialConnectionPoint;
  72458. /**
  72459. * Gets the refraction output component
  72460. */
  72461. get refraction(): NodeMaterialConnectionPoint;
  72462. /**
  72463. * Gets the global lighting output component
  72464. */
  72465. get lighting(): NodeMaterialConnectionPoint;
  72466. /**
  72467. * Gets the shadow output component
  72468. */
  72469. get shadow(): NodeMaterialConnectionPoint;
  72470. /**
  72471. * Gets the alpha output component
  72472. */
  72473. get alpha(): NodeMaterialConnectionPoint;
  72474. autoConfigure(material: NodeMaterial): void;
  72475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72476. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  72477. isReady(): boolean;
  72478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  72479. private _injectVertexCode;
  72480. private _getAlbedoOpacityCode;
  72481. private _getAmbientOcclusionCode;
  72482. private _getReflectivityCode;
  72483. protected _buildBlock(state: NodeMaterialBuildState): this;
  72484. protected _dumpPropertiesCode(): string;
  72485. serialize(): any;
  72486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72487. }
  72488. }
  72489. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  72490. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  72491. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  72492. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  72493. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72494. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  72495. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  72496. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  72497. }
  72498. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  72499. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  72500. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  72501. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  72502. }
  72503. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  72504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72507. /**
  72508. * Block used to compute value of one parameter modulo another
  72509. */
  72510. export class ModBlock extends NodeMaterialBlock {
  72511. /**
  72512. * Creates a new ModBlock
  72513. * @param name defines the block name
  72514. */
  72515. constructor(name: string);
  72516. /**
  72517. * Gets the current class name
  72518. * @returns the class name
  72519. */
  72520. getClassName(): string;
  72521. /**
  72522. * Gets the left operand input component
  72523. */
  72524. get left(): NodeMaterialConnectionPoint;
  72525. /**
  72526. * Gets the right operand input component
  72527. */
  72528. get right(): NodeMaterialConnectionPoint;
  72529. /**
  72530. * Gets the output component
  72531. */
  72532. get output(): NodeMaterialConnectionPoint;
  72533. protected _buildBlock(state: NodeMaterialBuildState): this;
  72534. }
  72535. }
  72536. declare module "babylonjs/Materials/Node/Blocks/index" {
  72537. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  72538. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  72539. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  72540. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  72541. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  72542. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  72543. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  72544. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  72545. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  72546. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  72547. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  72548. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  72549. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  72550. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  72551. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  72552. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  72553. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  72554. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  72555. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  72556. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  72557. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  72558. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  72559. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  72560. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  72561. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  72562. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  72563. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  72564. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  72565. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  72566. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  72567. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  72568. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  72569. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  72570. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  72571. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  72572. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  72573. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  72574. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  72575. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  72576. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  72577. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  72578. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  72579. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  72580. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  72581. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  72582. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  72583. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  72584. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  72585. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  72586. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  72587. }
  72588. declare module "babylonjs/Materials/Node/Optimizers/index" {
  72589. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  72590. }
  72591. declare module "babylonjs/Materials/Node/index" {
  72592. export * from "babylonjs/Materials/Node/Enums/index";
  72593. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72594. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  72595. export * from "babylonjs/Materials/Node/nodeMaterial";
  72596. export * from "babylonjs/Materials/Node/Blocks/index";
  72597. export * from "babylonjs/Materials/Node/Optimizers/index";
  72598. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  72599. }
  72600. declare module "babylonjs/Materials/index" {
  72601. export * from "babylonjs/Materials/Background/index";
  72602. export * from "babylonjs/Materials/colorCurves";
  72603. export * from "babylonjs/Materials/iEffectFallbacks";
  72604. export * from "babylonjs/Materials/effectFallbacks";
  72605. export * from "babylonjs/Materials/effect";
  72606. export * from "babylonjs/Materials/fresnelParameters";
  72607. export * from "babylonjs/Materials/imageProcessingConfiguration";
  72608. export * from "babylonjs/Materials/material";
  72609. export * from "babylonjs/Materials/materialDefines";
  72610. export * from "babylonjs/Materials/thinMaterialHelper";
  72611. export * from "babylonjs/Materials/materialHelper";
  72612. export * from "babylonjs/Materials/multiMaterial";
  72613. export * from "babylonjs/Materials/Occlusion/index";
  72614. export * from "babylonjs/Materials/PBR/index";
  72615. export * from "babylonjs/Materials/pushMaterial";
  72616. export * from "babylonjs/Materials/shaderMaterial";
  72617. export * from "babylonjs/Materials/standardMaterial";
  72618. export * from "babylonjs/Materials/Textures/index";
  72619. export * from "babylonjs/Materials/uniformBuffer";
  72620. export * from "babylonjs/Materials/materialFlags";
  72621. export * from "babylonjs/Materials/Node/index";
  72622. export * from "babylonjs/Materials/effectRenderer";
  72623. export * from "babylonjs/Materials/shadowDepthWrapper";
  72624. }
  72625. declare module "babylonjs/Maths/index" {
  72626. export * from "babylonjs/Maths/math.scalar";
  72627. export * from "babylonjs/Maths/math.functions";
  72628. export * from "babylonjs/Maths/math";
  72629. export * from "babylonjs/Maths/sphericalPolynomial";
  72630. }
  72631. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  72632. import { IDisposable } from "babylonjs/scene";
  72633. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  72634. /**
  72635. * Configuration for Draco compression
  72636. */
  72637. export interface IDracoCompressionConfiguration {
  72638. /**
  72639. * Configuration for the decoder.
  72640. */
  72641. decoder: {
  72642. /**
  72643. * The url to the WebAssembly module.
  72644. */
  72645. wasmUrl?: string;
  72646. /**
  72647. * The url to the WebAssembly binary.
  72648. */
  72649. wasmBinaryUrl?: string;
  72650. /**
  72651. * The url to the fallback JavaScript module.
  72652. */
  72653. fallbackUrl?: string;
  72654. };
  72655. }
  72656. /**
  72657. * Draco compression (https://google.github.io/draco/)
  72658. *
  72659. * This class wraps the Draco module.
  72660. *
  72661. * **Encoder**
  72662. *
  72663. * The encoder is not currently implemented.
  72664. *
  72665. * **Decoder**
  72666. *
  72667. * 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.
  72668. *
  72669. * To update the configuration, use the following code:
  72670. * ```javascript
  72671. * DracoCompression.Configuration = {
  72672. * decoder: {
  72673. * wasmUrl: "<url to the WebAssembly library>",
  72674. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  72675. * fallbackUrl: "<url to the fallback JavaScript library>",
  72676. * }
  72677. * };
  72678. * ```
  72679. *
  72680. * 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.
  72681. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  72682. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  72683. *
  72684. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  72685. * ```javascript
  72686. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  72687. * ```
  72688. *
  72689. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  72690. */
  72691. export class DracoCompression implements IDisposable {
  72692. private _workerPoolPromise?;
  72693. private _decoderModulePromise?;
  72694. /**
  72695. * The configuration. Defaults to the following urls:
  72696. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  72697. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  72698. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  72699. */
  72700. static Configuration: IDracoCompressionConfiguration;
  72701. /**
  72702. * Returns true if the decoder configuration is available.
  72703. */
  72704. static get DecoderAvailable(): boolean;
  72705. /**
  72706. * Default number of workers to create when creating the draco compression object.
  72707. */
  72708. static DefaultNumWorkers: number;
  72709. private static GetDefaultNumWorkers;
  72710. private static _Default;
  72711. /**
  72712. * Default instance for the draco compression object.
  72713. */
  72714. static get Default(): DracoCompression;
  72715. /**
  72716. * Constructor
  72717. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  72718. */
  72719. constructor(numWorkers?: number);
  72720. /**
  72721. * Stop all async operations and release resources.
  72722. */
  72723. dispose(): void;
  72724. /**
  72725. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  72726. * @returns a promise that resolves when ready
  72727. */
  72728. whenReadyAsync(): Promise<void>;
  72729. /**
  72730. * Decode Draco compressed mesh data to vertex data.
  72731. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  72732. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  72733. * @returns A promise that resolves with the decoded vertex data
  72734. */
  72735. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  72736. [kind: string]: number;
  72737. }): Promise<VertexData>;
  72738. }
  72739. }
  72740. declare module "babylonjs/Meshes/Compression/index" {
  72741. export * from "babylonjs/Meshes/Compression/dracoCompression";
  72742. }
  72743. declare module "babylonjs/Meshes/csg" {
  72744. import { Nullable } from "babylonjs/types";
  72745. import { Scene } from "babylonjs/scene";
  72746. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  72747. import { Mesh } from "babylonjs/Meshes/mesh";
  72748. import { Material } from "babylonjs/Materials/material";
  72749. /**
  72750. * Class for building Constructive Solid Geometry
  72751. */
  72752. export class CSG {
  72753. private polygons;
  72754. /**
  72755. * The world matrix
  72756. */
  72757. matrix: Matrix;
  72758. /**
  72759. * Stores the position
  72760. */
  72761. position: Vector3;
  72762. /**
  72763. * Stores the rotation
  72764. */
  72765. rotation: Vector3;
  72766. /**
  72767. * Stores the rotation quaternion
  72768. */
  72769. rotationQuaternion: Nullable<Quaternion>;
  72770. /**
  72771. * Stores the scaling vector
  72772. */
  72773. scaling: Vector3;
  72774. /**
  72775. * Convert the Mesh to CSG
  72776. * @param mesh The Mesh to convert to CSG
  72777. * @returns A new CSG from the Mesh
  72778. */
  72779. static FromMesh(mesh: Mesh): CSG;
  72780. /**
  72781. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  72782. * @param polygons Polygons used to construct a CSG solid
  72783. */
  72784. private static FromPolygons;
  72785. /**
  72786. * Clones, or makes a deep copy, of the CSG
  72787. * @returns A new CSG
  72788. */
  72789. clone(): CSG;
  72790. /**
  72791. * Unions this CSG with another CSG
  72792. * @param csg The CSG to union against this CSG
  72793. * @returns The unioned CSG
  72794. */
  72795. union(csg: CSG): CSG;
  72796. /**
  72797. * Unions this CSG with another CSG in place
  72798. * @param csg The CSG to union against this CSG
  72799. */
  72800. unionInPlace(csg: CSG): void;
  72801. /**
  72802. * Subtracts this CSG with another CSG
  72803. * @param csg The CSG to subtract against this CSG
  72804. * @returns A new CSG
  72805. */
  72806. subtract(csg: CSG): CSG;
  72807. /**
  72808. * Subtracts this CSG with another CSG in place
  72809. * @param csg The CSG to subtact against this CSG
  72810. */
  72811. subtractInPlace(csg: CSG): void;
  72812. /**
  72813. * Intersect this CSG with another CSG
  72814. * @param csg The CSG to intersect against this CSG
  72815. * @returns A new CSG
  72816. */
  72817. intersect(csg: CSG): CSG;
  72818. /**
  72819. * Intersects this CSG with another CSG in place
  72820. * @param csg The CSG to intersect against this CSG
  72821. */
  72822. intersectInPlace(csg: CSG): void;
  72823. /**
  72824. * Return a new CSG solid with solid and empty space switched. This solid is
  72825. * not modified.
  72826. * @returns A new CSG solid with solid and empty space switched
  72827. */
  72828. inverse(): CSG;
  72829. /**
  72830. * Inverses the CSG in place
  72831. */
  72832. inverseInPlace(): void;
  72833. /**
  72834. * This is used to keep meshes transformations so they can be restored
  72835. * when we build back a Babylon Mesh
  72836. * NB : All CSG operations are performed in world coordinates
  72837. * @param csg The CSG to copy the transform attributes from
  72838. * @returns This CSG
  72839. */
  72840. copyTransformAttributes(csg: CSG): CSG;
  72841. /**
  72842. * Build Raw mesh from CSG
  72843. * Coordinates here are in world space
  72844. * @param name The name of the mesh geometry
  72845. * @param scene The Scene
  72846. * @param keepSubMeshes Specifies if the submeshes should be kept
  72847. * @returns A new Mesh
  72848. */
  72849. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  72850. /**
  72851. * Build Mesh from CSG taking material and transforms into account
  72852. * @param name The name of the Mesh
  72853. * @param material The material of the Mesh
  72854. * @param scene The Scene
  72855. * @param keepSubMeshes Specifies if submeshes should be kept
  72856. * @returns The new Mesh
  72857. */
  72858. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  72859. }
  72860. }
  72861. declare module "babylonjs/Meshes/trailMesh" {
  72862. import { Mesh } from "babylonjs/Meshes/mesh";
  72863. import { Scene } from "babylonjs/scene";
  72864. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72865. /**
  72866. * Class used to create a trail following a mesh
  72867. */
  72868. export class TrailMesh extends Mesh {
  72869. private _generator;
  72870. private _autoStart;
  72871. private _running;
  72872. private _diameter;
  72873. private _length;
  72874. private _sectionPolygonPointsCount;
  72875. private _sectionVectors;
  72876. private _sectionNormalVectors;
  72877. private _beforeRenderObserver;
  72878. /**
  72879. * @constructor
  72880. * @param name The value used by scene.getMeshByName() to do a lookup.
  72881. * @param generator The mesh or transform node to generate a trail.
  72882. * @param scene The scene to add this mesh to.
  72883. * @param diameter Diameter of trailing mesh. Default is 1.
  72884. * @param length Length of trailing mesh. Default is 60.
  72885. * @param autoStart Automatically start trailing mesh. Default true.
  72886. */
  72887. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  72888. /**
  72889. * "TrailMesh"
  72890. * @returns "TrailMesh"
  72891. */
  72892. getClassName(): string;
  72893. private _createMesh;
  72894. /**
  72895. * Start trailing mesh.
  72896. */
  72897. start(): void;
  72898. /**
  72899. * Stop trailing mesh.
  72900. */
  72901. stop(): void;
  72902. /**
  72903. * Update trailing mesh geometry.
  72904. */
  72905. update(): void;
  72906. /**
  72907. * Returns a new TrailMesh object.
  72908. * @param name is a string, the name given to the new mesh
  72909. * @param newGenerator use new generator object for cloned trail mesh
  72910. * @returns a new mesh
  72911. */
  72912. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  72913. /**
  72914. * Serializes this trail mesh
  72915. * @param serializationObject object to write serialization to
  72916. */
  72917. serialize(serializationObject: any): void;
  72918. /**
  72919. * Parses a serialized trail mesh
  72920. * @param parsedMesh the serialized mesh
  72921. * @param scene the scene to create the trail mesh in
  72922. * @returns the created trail mesh
  72923. */
  72924. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  72925. }
  72926. }
  72927. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  72928. import { Nullable } from "babylonjs/types";
  72929. import { Scene } from "babylonjs/scene";
  72930. import { Vector4 } from "babylonjs/Maths/math.vector";
  72931. import { Color4 } from "babylonjs/Maths/math.color";
  72932. import { Mesh } from "babylonjs/Meshes/mesh";
  72933. /**
  72934. * Class containing static functions to help procedurally build meshes
  72935. */
  72936. export class TiledBoxBuilder {
  72937. /**
  72938. * Creates a box mesh
  72939. * 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)
  72940. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  72941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  72942. * * 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
  72943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  72944. * @param name defines the name of the mesh
  72945. * @param options defines the options used to create the mesh
  72946. * @param scene defines the hosting scene
  72947. * @returns the box mesh
  72948. */
  72949. static CreateTiledBox(name: string, options: {
  72950. pattern?: number;
  72951. width?: number;
  72952. height?: number;
  72953. depth?: number;
  72954. tileSize?: number;
  72955. tileWidth?: number;
  72956. tileHeight?: number;
  72957. alignHorizontal?: number;
  72958. alignVertical?: number;
  72959. faceUV?: Vector4[];
  72960. faceColors?: Color4[];
  72961. sideOrientation?: number;
  72962. updatable?: boolean;
  72963. }, scene?: Nullable<Scene>): Mesh;
  72964. }
  72965. }
  72966. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  72967. import { Vector4 } from "babylonjs/Maths/math.vector";
  72968. import { Mesh } from "babylonjs/Meshes/mesh";
  72969. /**
  72970. * Class containing static functions to help procedurally build meshes
  72971. */
  72972. export class TorusKnotBuilder {
  72973. /**
  72974. * Creates a torus knot mesh
  72975. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  72976. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  72977. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  72978. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  72979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  72980. * * 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
  72981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  72982. * @param name defines the name of the mesh
  72983. * @param options defines the options used to create the mesh
  72984. * @param scene defines the hosting scene
  72985. * @returns the torus knot mesh
  72986. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  72987. */
  72988. static CreateTorusKnot(name: string, options: {
  72989. radius?: number;
  72990. tube?: number;
  72991. radialSegments?: number;
  72992. tubularSegments?: number;
  72993. p?: number;
  72994. q?: number;
  72995. updatable?: boolean;
  72996. sideOrientation?: number;
  72997. frontUVs?: Vector4;
  72998. backUVs?: Vector4;
  72999. }, scene: any): Mesh;
  73000. }
  73001. }
  73002. declare module "babylonjs/Meshes/polygonMesh" {
  73003. import { Scene } from "babylonjs/scene";
  73004. import { Vector2 } from "babylonjs/Maths/math.vector";
  73005. import { Mesh } from "babylonjs/Meshes/mesh";
  73006. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73007. import { Path2 } from "babylonjs/Maths/math.path";
  73008. /**
  73009. * Polygon
  73010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  73011. */
  73012. export class Polygon {
  73013. /**
  73014. * Creates a rectangle
  73015. * @param xmin bottom X coord
  73016. * @param ymin bottom Y coord
  73017. * @param xmax top X coord
  73018. * @param ymax top Y coord
  73019. * @returns points that make the resulting rectation
  73020. */
  73021. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  73022. /**
  73023. * Creates a circle
  73024. * @param radius radius of circle
  73025. * @param cx scale in x
  73026. * @param cy scale in y
  73027. * @param numberOfSides number of sides that make up the circle
  73028. * @returns points that make the resulting circle
  73029. */
  73030. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  73031. /**
  73032. * Creates a polygon from input string
  73033. * @param input Input polygon data
  73034. * @returns the parsed points
  73035. */
  73036. static Parse(input: string): Vector2[];
  73037. /**
  73038. * Starts building a polygon from x and y coordinates
  73039. * @param x x coordinate
  73040. * @param y y coordinate
  73041. * @returns the started path2
  73042. */
  73043. static StartingAt(x: number, y: number): Path2;
  73044. }
  73045. /**
  73046. * Builds a polygon
  73047. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  73048. */
  73049. export class PolygonMeshBuilder {
  73050. private _points;
  73051. private _outlinepoints;
  73052. private _holes;
  73053. private _name;
  73054. private _scene;
  73055. private _epoints;
  73056. private _eholes;
  73057. private _addToepoint;
  73058. /**
  73059. * Babylon reference to the earcut plugin.
  73060. */
  73061. bjsEarcut: any;
  73062. /**
  73063. * Creates a PolygonMeshBuilder
  73064. * @param name name of the builder
  73065. * @param contours Path of the polygon
  73066. * @param scene scene to add to when creating the mesh
  73067. * @param earcutInjection can be used to inject your own earcut reference
  73068. */
  73069. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  73070. /**
  73071. * Adds a whole within the polygon
  73072. * @param hole Array of points defining the hole
  73073. * @returns this
  73074. */
  73075. addHole(hole: Vector2[]): PolygonMeshBuilder;
  73076. /**
  73077. * Creates the polygon
  73078. * @param updatable If the mesh should be updatable
  73079. * @param depth The depth of the mesh created
  73080. * @returns the created mesh
  73081. */
  73082. build(updatable?: boolean, depth?: number): Mesh;
  73083. /**
  73084. * Creates the polygon
  73085. * @param depth The depth of the mesh created
  73086. * @returns the created VertexData
  73087. */
  73088. buildVertexData(depth?: number): VertexData;
  73089. /**
  73090. * Adds a side to the polygon
  73091. * @param positions points that make the polygon
  73092. * @param normals normals of the polygon
  73093. * @param uvs uvs of the polygon
  73094. * @param indices indices of the polygon
  73095. * @param bounds bounds of the polygon
  73096. * @param points points of the polygon
  73097. * @param depth depth of the polygon
  73098. * @param flip flip of the polygon
  73099. */
  73100. private addSide;
  73101. }
  73102. }
  73103. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  73104. import { Scene } from "babylonjs/scene";
  73105. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73106. import { Color4 } from "babylonjs/Maths/math.color";
  73107. import { Mesh } from "babylonjs/Meshes/mesh";
  73108. import { Nullable } from "babylonjs/types";
  73109. /**
  73110. * Class containing static functions to help procedurally build meshes
  73111. */
  73112. export class PolygonBuilder {
  73113. /**
  73114. * Creates a polygon mesh
  73115. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73116. * * 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
  73117. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73119. * * 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)
  73120. * * Remember you can only change the shape positions, not their number when updating a polygon
  73121. * @param name defines the name of the mesh
  73122. * @param options defines the options used to create the mesh
  73123. * @param scene defines the hosting scene
  73124. * @param earcutInjection can be used to inject your own earcut reference
  73125. * @returns the polygon mesh
  73126. */
  73127. static CreatePolygon(name: string, options: {
  73128. shape: Vector3[];
  73129. holes?: Vector3[][];
  73130. depth?: number;
  73131. faceUV?: Vector4[];
  73132. faceColors?: Color4[];
  73133. updatable?: boolean;
  73134. sideOrientation?: number;
  73135. frontUVs?: Vector4;
  73136. backUVs?: Vector4;
  73137. wrap?: boolean;
  73138. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73139. /**
  73140. * Creates an extruded polygon mesh, with depth in the Y direction.
  73141. * * 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)
  73142. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73143. * @param name defines the name of the mesh
  73144. * @param options defines the options used to create the mesh
  73145. * @param scene defines the hosting scene
  73146. * @param earcutInjection can be used to inject your own earcut reference
  73147. * @returns the polygon mesh
  73148. */
  73149. static ExtrudePolygon(name: string, options: {
  73150. shape: Vector3[];
  73151. holes?: Vector3[][];
  73152. depth?: number;
  73153. faceUV?: Vector4[];
  73154. faceColors?: Color4[];
  73155. updatable?: boolean;
  73156. sideOrientation?: number;
  73157. frontUVs?: Vector4;
  73158. backUVs?: Vector4;
  73159. wrap?: boolean;
  73160. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73161. }
  73162. }
  73163. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  73164. import { Scene } from "babylonjs/scene";
  73165. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73166. import { Mesh } from "babylonjs/Meshes/mesh";
  73167. import { Nullable } from "babylonjs/types";
  73168. /**
  73169. * Class containing static functions to help procedurally build meshes
  73170. */
  73171. export class LatheBuilder {
  73172. /**
  73173. * Creates lathe mesh.
  73174. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  73175. * * 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
  73176. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  73177. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  73178. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  73179. * * 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
  73180. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  73181. * * 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
  73182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73183. * * 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
  73184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73186. * @param name defines the name of the mesh
  73187. * @param options defines the options used to create the mesh
  73188. * @param scene defines the hosting scene
  73189. * @returns the lathe mesh
  73190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  73191. */
  73192. static CreateLathe(name: string, options: {
  73193. shape: Vector3[];
  73194. radius?: number;
  73195. tessellation?: number;
  73196. clip?: number;
  73197. arc?: number;
  73198. closed?: boolean;
  73199. updatable?: boolean;
  73200. sideOrientation?: number;
  73201. frontUVs?: Vector4;
  73202. backUVs?: Vector4;
  73203. cap?: number;
  73204. invertUV?: boolean;
  73205. }, scene?: Nullable<Scene>): Mesh;
  73206. }
  73207. }
  73208. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  73209. import { Nullable } from "babylonjs/types";
  73210. import { Scene } from "babylonjs/scene";
  73211. import { Vector4 } from "babylonjs/Maths/math.vector";
  73212. import { Mesh } from "babylonjs/Meshes/mesh";
  73213. /**
  73214. * Class containing static functions to help procedurally build meshes
  73215. */
  73216. export class TiledPlaneBuilder {
  73217. /**
  73218. * Creates a tiled plane mesh
  73219. * * The parameter `pattern` will, depending on value, do nothing or
  73220. * * * flip (reflect about central vertical) alternate tiles across and up
  73221. * * * flip every tile on alternate rows
  73222. * * * rotate (180 degs) alternate tiles across and up
  73223. * * * rotate every tile on alternate rows
  73224. * * * flip and rotate alternate tiles across and up
  73225. * * * flip and rotate every tile on alternate rows
  73226. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  73227. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  73228. * * 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
  73229. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73230. * * 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)
  73231. * * 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)
  73232. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73233. * @param name defines the name of the mesh
  73234. * @param options defines the options used to create the mesh
  73235. * @param scene defines the hosting scene
  73236. * @returns the box mesh
  73237. */
  73238. static CreateTiledPlane(name: string, options: {
  73239. pattern?: number;
  73240. tileSize?: number;
  73241. tileWidth?: number;
  73242. tileHeight?: number;
  73243. size?: number;
  73244. width?: number;
  73245. height?: number;
  73246. alignHorizontal?: number;
  73247. alignVertical?: number;
  73248. sideOrientation?: number;
  73249. frontUVs?: Vector4;
  73250. backUVs?: Vector4;
  73251. updatable?: boolean;
  73252. }, scene?: Nullable<Scene>): Mesh;
  73253. }
  73254. }
  73255. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  73256. import { Nullable } from "babylonjs/types";
  73257. import { Scene } from "babylonjs/scene";
  73258. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73259. import { Mesh } from "babylonjs/Meshes/mesh";
  73260. /**
  73261. * Class containing static functions to help procedurally build meshes
  73262. */
  73263. export class TubeBuilder {
  73264. /**
  73265. * Creates a tube mesh.
  73266. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73267. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  73268. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  73269. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  73270. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  73271. * * 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)
  73272. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  73273. * * 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
  73274. * * 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
  73275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73276. * * 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
  73277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73279. * @param name defines the name of the mesh
  73280. * @param options defines the options used to create the mesh
  73281. * @param scene defines the hosting scene
  73282. * @returns the tube mesh
  73283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73284. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  73285. */
  73286. static CreateTube(name: string, options: {
  73287. path: Vector3[];
  73288. radius?: number;
  73289. tessellation?: number;
  73290. radiusFunction?: {
  73291. (i: number, distance: number): number;
  73292. };
  73293. cap?: number;
  73294. arc?: number;
  73295. updatable?: boolean;
  73296. sideOrientation?: number;
  73297. frontUVs?: Vector4;
  73298. backUVs?: Vector4;
  73299. instance?: Mesh;
  73300. invertUV?: boolean;
  73301. }, scene?: Nullable<Scene>): Mesh;
  73302. }
  73303. }
  73304. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  73305. import { Scene } from "babylonjs/scene";
  73306. import { Vector4 } from "babylonjs/Maths/math.vector";
  73307. import { Mesh } from "babylonjs/Meshes/mesh";
  73308. import { Nullable } from "babylonjs/types";
  73309. /**
  73310. * Class containing static functions to help procedurally build meshes
  73311. */
  73312. export class IcoSphereBuilder {
  73313. /**
  73314. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73315. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73316. * * 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`)
  73317. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73318. * * 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
  73319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73320. * * 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
  73321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73322. * @param name defines the name of the mesh
  73323. * @param options defines the options used to create the mesh
  73324. * @param scene defines the hosting scene
  73325. * @returns the icosahedron mesh
  73326. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73327. */
  73328. static CreateIcoSphere(name: string, options: {
  73329. radius?: number;
  73330. radiusX?: number;
  73331. radiusY?: number;
  73332. radiusZ?: number;
  73333. flat?: boolean;
  73334. subdivisions?: number;
  73335. sideOrientation?: number;
  73336. frontUVs?: Vector4;
  73337. backUVs?: Vector4;
  73338. updatable?: boolean;
  73339. }, scene?: Nullable<Scene>): Mesh;
  73340. }
  73341. }
  73342. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  73343. import { Vector3 } from "babylonjs/Maths/math.vector";
  73344. import { Mesh } from "babylonjs/Meshes/mesh";
  73345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73346. /**
  73347. * Class containing static functions to help procedurally build meshes
  73348. */
  73349. export class DecalBuilder {
  73350. /**
  73351. * Creates a decal mesh.
  73352. * 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
  73353. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  73354. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  73355. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  73356. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  73357. * @param name defines the name of the mesh
  73358. * @param sourceMesh defines the mesh where the decal must be applied
  73359. * @param options defines the options used to create the mesh
  73360. * @param scene defines the hosting scene
  73361. * @returns the decal mesh
  73362. * @see https://doc.babylonjs.com/how_to/decals
  73363. */
  73364. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  73365. position?: Vector3;
  73366. normal?: Vector3;
  73367. size?: Vector3;
  73368. angle?: number;
  73369. }): Mesh;
  73370. }
  73371. }
  73372. declare module "babylonjs/Meshes/meshBuilder" {
  73373. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  73374. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  73375. import { Nullable } from "babylonjs/types";
  73376. import { Scene } from "babylonjs/scene";
  73377. import { Mesh } from "babylonjs/Meshes/mesh";
  73378. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  73379. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  73380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73381. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  73382. import { Plane } from "babylonjs/Maths/math.plane";
  73383. /**
  73384. * Class containing static functions to help procedurally build meshes
  73385. */
  73386. export class MeshBuilder {
  73387. /**
  73388. * Creates a box mesh
  73389. * * The parameter `size` sets the size (float) of each box side (default 1)
  73390. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  73391. * * 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)
  73392. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73394. * * 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
  73395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73396. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73397. * @param name defines the name of the mesh
  73398. * @param options defines the options used to create the mesh
  73399. * @param scene defines the hosting scene
  73400. * @returns the box mesh
  73401. */
  73402. static CreateBox(name: string, options: {
  73403. size?: number;
  73404. width?: number;
  73405. height?: number;
  73406. depth?: number;
  73407. faceUV?: Vector4[];
  73408. faceColors?: Color4[];
  73409. sideOrientation?: number;
  73410. frontUVs?: Vector4;
  73411. backUVs?: Vector4;
  73412. wrap?: boolean;
  73413. topBaseAt?: number;
  73414. bottomBaseAt?: number;
  73415. updatable?: boolean;
  73416. }, scene?: Nullable<Scene>): Mesh;
  73417. /**
  73418. * Creates a tiled box mesh
  73419. * * faceTiles sets the pattern, tile size and number of tiles for a face
  73420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73421. * @param name defines the name of the mesh
  73422. * @param options defines the options used to create the mesh
  73423. * @param scene defines the hosting scene
  73424. * @returns the tiled box mesh
  73425. */
  73426. static CreateTiledBox(name: string, options: {
  73427. pattern?: number;
  73428. size?: number;
  73429. width?: number;
  73430. height?: number;
  73431. depth: number;
  73432. tileSize?: number;
  73433. tileWidth?: number;
  73434. tileHeight?: number;
  73435. faceUV?: Vector4[];
  73436. faceColors?: Color4[];
  73437. alignHorizontal?: number;
  73438. alignVertical?: number;
  73439. sideOrientation?: number;
  73440. updatable?: boolean;
  73441. }, scene?: Nullable<Scene>): Mesh;
  73442. /**
  73443. * Creates a sphere mesh
  73444. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  73445. * * 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`)
  73446. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  73447. * * 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
  73448. * * 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)
  73449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73450. * * 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
  73451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73452. * @param name defines the name of the mesh
  73453. * @param options defines the options used to create the mesh
  73454. * @param scene defines the hosting scene
  73455. * @returns the sphere mesh
  73456. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  73457. */
  73458. static CreateSphere(name: string, options: {
  73459. segments?: number;
  73460. diameter?: number;
  73461. diameterX?: number;
  73462. diameterY?: number;
  73463. diameterZ?: number;
  73464. arc?: number;
  73465. slice?: number;
  73466. sideOrientation?: number;
  73467. frontUVs?: Vector4;
  73468. backUVs?: Vector4;
  73469. updatable?: boolean;
  73470. }, scene?: Nullable<Scene>): Mesh;
  73471. /**
  73472. * Creates a plane polygonal mesh. By default, this is a disc
  73473. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  73474. * * 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
  73475. * * 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
  73476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73477. * * 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
  73478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73479. * @param name defines the name of the mesh
  73480. * @param options defines the options used to create the mesh
  73481. * @param scene defines the hosting scene
  73482. * @returns the plane polygonal mesh
  73483. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  73484. */
  73485. static CreateDisc(name: string, options: {
  73486. radius?: number;
  73487. tessellation?: number;
  73488. arc?: number;
  73489. updatable?: boolean;
  73490. sideOrientation?: number;
  73491. frontUVs?: Vector4;
  73492. backUVs?: Vector4;
  73493. }, scene?: Nullable<Scene>): Mesh;
  73494. /**
  73495. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73496. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73497. * * 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`)
  73498. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73499. * * 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
  73500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73501. * * 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
  73502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73503. * @param name defines the name of the mesh
  73504. * @param options defines the options used to create the mesh
  73505. * @param scene defines the hosting scene
  73506. * @returns the icosahedron mesh
  73507. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73508. */
  73509. static CreateIcoSphere(name: string, options: {
  73510. radius?: number;
  73511. radiusX?: number;
  73512. radiusY?: number;
  73513. radiusZ?: number;
  73514. flat?: boolean;
  73515. subdivisions?: number;
  73516. sideOrientation?: number;
  73517. frontUVs?: Vector4;
  73518. backUVs?: Vector4;
  73519. updatable?: boolean;
  73520. }, scene?: Nullable<Scene>): Mesh;
  73521. /**
  73522. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73523. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  73524. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  73525. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  73526. * * 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
  73527. * * 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
  73528. * * 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
  73529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73530. * * 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
  73531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73532. * * 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
  73533. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  73534. * * 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
  73535. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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. * @param name defines the name of the mesh
  73538. * @param options defines the options used to create the mesh
  73539. * @param scene defines the hosting scene
  73540. * @returns the ribbon mesh
  73541. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  73542. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73543. */
  73544. static CreateRibbon(name: string, options: {
  73545. pathArray: Vector3[][];
  73546. closeArray?: boolean;
  73547. closePath?: boolean;
  73548. offset?: number;
  73549. updatable?: boolean;
  73550. sideOrientation?: number;
  73551. frontUVs?: Vector4;
  73552. backUVs?: Vector4;
  73553. instance?: Mesh;
  73554. invertUV?: boolean;
  73555. uvs?: Vector2[];
  73556. colors?: Color4[];
  73557. }, scene?: Nullable<Scene>): Mesh;
  73558. /**
  73559. * Creates a cylinder or a cone mesh
  73560. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  73561. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  73562. * * 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.
  73563. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  73564. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  73565. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  73566. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  73567. * * 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).
  73568. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  73569. * * 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).
  73570. * * 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
  73571. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  73572. * * 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
  73573. * * 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.
  73574. * * If `enclose` is false, a ring surface is one element.
  73575. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  73576. * * 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
  73577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73578. * * 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
  73579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73580. * @param name defines the name of the mesh
  73581. * @param options defines the options used to create the mesh
  73582. * @param scene defines the hosting scene
  73583. * @returns the cylinder mesh
  73584. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  73585. */
  73586. static CreateCylinder(name: string, options: {
  73587. height?: number;
  73588. diameterTop?: number;
  73589. diameterBottom?: number;
  73590. diameter?: number;
  73591. tessellation?: number;
  73592. subdivisions?: number;
  73593. arc?: number;
  73594. faceColors?: Color4[];
  73595. faceUV?: Vector4[];
  73596. updatable?: boolean;
  73597. hasRings?: boolean;
  73598. enclose?: boolean;
  73599. cap?: number;
  73600. sideOrientation?: number;
  73601. frontUVs?: Vector4;
  73602. backUVs?: Vector4;
  73603. }, scene?: Nullable<Scene>): Mesh;
  73604. /**
  73605. * Creates a torus mesh
  73606. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  73607. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  73608. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  73609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73610. * * 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
  73611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73612. * @param name defines the name of the mesh
  73613. * @param options defines the options used to create the mesh
  73614. * @param scene defines the hosting scene
  73615. * @returns the torus mesh
  73616. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  73617. */
  73618. static CreateTorus(name: string, options: {
  73619. diameter?: number;
  73620. thickness?: number;
  73621. tessellation?: number;
  73622. updatable?: boolean;
  73623. sideOrientation?: number;
  73624. frontUVs?: Vector4;
  73625. backUVs?: Vector4;
  73626. }, scene?: Nullable<Scene>): Mesh;
  73627. /**
  73628. * Creates a torus knot mesh
  73629. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  73630. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  73631. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  73632. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  73633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73634. * * 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
  73635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73636. * @param name defines the name of the mesh
  73637. * @param options defines the options used to create the mesh
  73638. * @param scene defines the hosting scene
  73639. * @returns the torus knot mesh
  73640. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73641. */
  73642. static CreateTorusKnot(name: string, options: {
  73643. radius?: number;
  73644. tube?: number;
  73645. radialSegments?: number;
  73646. tubularSegments?: number;
  73647. p?: number;
  73648. q?: number;
  73649. updatable?: boolean;
  73650. sideOrientation?: number;
  73651. frontUVs?: Vector4;
  73652. backUVs?: Vector4;
  73653. }, scene?: Nullable<Scene>): Mesh;
  73654. /**
  73655. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  73656. * * 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
  73657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  73658. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  73659. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  73660. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  73661. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  73662. * * 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
  73663. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  73664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  73666. * @param name defines the name of the new line system
  73667. * @param options defines the options used to create the line system
  73668. * @param scene defines the hosting scene
  73669. * @returns a new line system mesh
  73670. */
  73671. static CreateLineSystem(name: string, options: {
  73672. lines: Vector3[][];
  73673. updatable?: boolean;
  73674. instance?: Nullable<LinesMesh>;
  73675. colors?: Nullable<Color4[][]>;
  73676. useVertexAlpha?: boolean;
  73677. }, scene: Nullable<Scene>): LinesMesh;
  73678. /**
  73679. * Creates a line mesh
  73680. * 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
  73681. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  73682. * * The parameter `points` is an array successive Vector3
  73683. * * 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
  73684. * * The optional parameter `colors` is an array of successive Color4, one per line point
  73685. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  73686. * * When updating an instance, remember that only point positions can change, not the number of points
  73687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  73689. * @param name defines the name of the new line system
  73690. * @param options defines the options used to create the line system
  73691. * @param scene defines the hosting scene
  73692. * @returns a new line mesh
  73693. */
  73694. static CreateLines(name: string, options: {
  73695. points: Vector3[];
  73696. updatable?: boolean;
  73697. instance?: Nullable<LinesMesh>;
  73698. colors?: Color4[];
  73699. useVertexAlpha?: boolean;
  73700. }, scene?: Nullable<Scene>): LinesMesh;
  73701. /**
  73702. * Creates a dashed line mesh
  73703. * * 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
  73704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  73705. * * The parameter `points` is an array successive Vector3
  73706. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  73707. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  73708. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  73709. * * 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
  73710. * * When updating an instance, remember that only point positions can change, not the number of points
  73711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73712. * @param name defines the name of the mesh
  73713. * @param options defines the options used to create the mesh
  73714. * @param scene defines the hosting scene
  73715. * @returns the dashed line mesh
  73716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  73717. */
  73718. static CreateDashedLines(name: string, options: {
  73719. points: Vector3[];
  73720. dashSize?: number;
  73721. gapSize?: number;
  73722. dashNb?: number;
  73723. updatable?: boolean;
  73724. instance?: LinesMesh;
  73725. }, scene?: Nullable<Scene>): LinesMesh;
  73726. /**
  73727. * 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.
  73728. * * 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.
  73729. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  73730. * * 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.
  73731. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  73732. * * 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
  73733. * * 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
  73734. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  73735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73736. * * 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
  73737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  73738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73739. * @param name defines the name of the mesh
  73740. * @param options defines the options used to create the mesh
  73741. * @param scene defines the hosting scene
  73742. * @returns the extruded shape mesh
  73743. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  73745. */
  73746. static ExtrudeShape(name: string, options: {
  73747. shape: Vector3[];
  73748. path: Vector3[];
  73749. scale?: number;
  73750. rotation?: number;
  73751. cap?: number;
  73752. updatable?: boolean;
  73753. sideOrientation?: number;
  73754. frontUVs?: Vector4;
  73755. backUVs?: Vector4;
  73756. instance?: Mesh;
  73757. invertUV?: boolean;
  73758. }, scene?: Nullable<Scene>): Mesh;
  73759. /**
  73760. * Creates an custom extruded shape mesh.
  73761. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  73762. * * 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.
  73763. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  73764. * * 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
  73765. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  73766. * * 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
  73767. * * It must returns a float value that will be the scale value applied to the shape on each path point
  73768. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  73769. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  73770. * * 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
  73771. * * 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
  73772. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  73773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73774. * * 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
  73775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73777. * @param name defines the name of the mesh
  73778. * @param options defines the options used to create the mesh
  73779. * @param scene defines the hosting scene
  73780. * @returns the custom extruded shape mesh
  73781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  73782. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  73784. */
  73785. static ExtrudeShapeCustom(name: string, options: {
  73786. shape: Vector3[];
  73787. path: Vector3[];
  73788. scaleFunction?: any;
  73789. rotationFunction?: any;
  73790. ribbonCloseArray?: boolean;
  73791. ribbonClosePath?: boolean;
  73792. cap?: number;
  73793. updatable?: boolean;
  73794. sideOrientation?: number;
  73795. frontUVs?: Vector4;
  73796. backUVs?: Vector4;
  73797. instance?: Mesh;
  73798. invertUV?: boolean;
  73799. }, scene?: Nullable<Scene>): Mesh;
  73800. /**
  73801. * Creates lathe mesh.
  73802. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  73803. * * 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
  73804. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  73805. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  73806. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  73807. * * 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
  73808. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  73809. * * 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
  73810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73811. * * 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
  73812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73814. * @param name defines the name of the mesh
  73815. * @param options defines the options used to create the mesh
  73816. * @param scene defines the hosting scene
  73817. * @returns the lathe mesh
  73818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  73819. */
  73820. static CreateLathe(name: string, options: {
  73821. shape: Vector3[];
  73822. radius?: number;
  73823. tessellation?: number;
  73824. clip?: number;
  73825. arc?: number;
  73826. closed?: boolean;
  73827. updatable?: boolean;
  73828. sideOrientation?: number;
  73829. frontUVs?: Vector4;
  73830. backUVs?: Vector4;
  73831. cap?: number;
  73832. invertUV?: boolean;
  73833. }, scene?: Nullable<Scene>): Mesh;
  73834. /**
  73835. * Creates a tiled plane mesh
  73836. * * You can set a limited pattern arrangement with the tiles
  73837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73838. * * 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
  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 plane mesh
  73844. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  73845. */
  73846. static CreateTiledPlane(name: string, options: {
  73847. pattern?: number;
  73848. tileSize?: number;
  73849. tileWidth?: number;
  73850. tileHeight?: number;
  73851. size?: number;
  73852. width?: number;
  73853. height?: number;
  73854. alignHorizontal?: number;
  73855. alignVertical?: number;
  73856. sideOrientation?: number;
  73857. frontUVs?: Vector4;
  73858. backUVs?: Vector4;
  73859. updatable?: boolean;
  73860. }, scene?: Nullable<Scene>): Mesh;
  73861. /**
  73862. * Creates a plane mesh
  73863. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  73864. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  73865. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  73866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73867. * * 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
  73868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73869. * @param name defines the name of the mesh
  73870. * @param options defines the options used to create the mesh
  73871. * @param scene defines the hosting scene
  73872. * @returns the plane mesh
  73873. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  73874. */
  73875. static CreatePlane(name: string, options: {
  73876. size?: number;
  73877. width?: number;
  73878. height?: number;
  73879. sideOrientation?: number;
  73880. frontUVs?: Vector4;
  73881. backUVs?: Vector4;
  73882. updatable?: boolean;
  73883. sourcePlane?: Plane;
  73884. }, scene?: Nullable<Scene>): Mesh;
  73885. /**
  73886. * Creates a ground mesh
  73887. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  73888. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  73889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73890. * @param name defines the name of the mesh
  73891. * @param options defines the options used to create the mesh
  73892. * @param scene defines the hosting scene
  73893. * @returns the ground mesh
  73894. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  73895. */
  73896. static CreateGround(name: string, options: {
  73897. width?: number;
  73898. height?: number;
  73899. subdivisions?: number;
  73900. subdivisionsX?: number;
  73901. subdivisionsY?: number;
  73902. updatable?: boolean;
  73903. }, scene?: Nullable<Scene>): Mesh;
  73904. /**
  73905. * Creates a tiled ground mesh
  73906. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  73907. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  73908. * * 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
  73909. * * 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
  73910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73911. * @param name defines the name of the mesh
  73912. * @param options defines the options used to create the mesh
  73913. * @param scene defines the hosting scene
  73914. * @returns the tiled ground mesh
  73915. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  73916. */
  73917. static CreateTiledGround(name: string, options: {
  73918. xmin: number;
  73919. zmin: number;
  73920. xmax: number;
  73921. zmax: number;
  73922. subdivisions?: {
  73923. w: number;
  73924. h: number;
  73925. };
  73926. precision?: {
  73927. w: number;
  73928. h: number;
  73929. };
  73930. updatable?: boolean;
  73931. }, scene?: Nullable<Scene>): Mesh;
  73932. /**
  73933. * Creates a ground mesh from a height map
  73934. * * The parameter `url` sets the URL of the height map image resource.
  73935. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  73936. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  73937. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  73938. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  73939. * * 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.
  73940. * * 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).
  73941. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  73942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73943. * @param name defines the name of the mesh
  73944. * @param url defines the url to the height map
  73945. * @param options defines the options used to create the mesh
  73946. * @param scene defines the hosting scene
  73947. * @returns the ground mesh
  73948. * @see https://doc.babylonjs.com/babylon101/height_map
  73949. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  73950. */
  73951. static CreateGroundFromHeightMap(name: string, url: string, options: {
  73952. width?: number;
  73953. height?: number;
  73954. subdivisions?: number;
  73955. minHeight?: number;
  73956. maxHeight?: number;
  73957. colorFilter?: Color3;
  73958. alphaFilter?: number;
  73959. updatable?: boolean;
  73960. onReady?: (mesh: GroundMesh) => void;
  73961. }, scene?: Nullable<Scene>): GroundMesh;
  73962. /**
  73963. * Creates a polygon mesh
  73964. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73965. * * 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
  73966. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73968. * * 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)
  73969. * * Remember you can only change the shape positions, not their number when updating a polygon
  73970. * @param name defines the name of the mesh
  73971. * @param options defines the options used to create the mesh
  73972. * @param scene defines the hosting scene
  73973. * @param earcutInjection can be used to inject your own earcut reference
  73974. * @returns the polygon mesh
  73975. */
  73976. static CreatePolygon(name: string, options: {
  73977. shape: Vector3[];
  73978. holes?: Vector3[][];
  73979. depth?: number;
  73980. faceUV?: Vector4[];
  73981. faceColors?: Color4[];
  73982. updatable?: boolean;
  73983. sideOrientation?: number;
  73984. frontUVs?: Vector4;
  73985. backUVs?: Vector4;
  73986. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73987. /**
  73988. * Creates an extruded polygon mesh, with depth in the Y direction.
  73989. * * 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)
  73990. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73991. * @param name defines the name of the mesh
  73992. * @param options defines the options used to create the mesh
  73993. * @param scene defines the hosting scene
  73994. * @param earcutInjection can be used to inject your own earcut reference
  73995. * @returns the polygon mesh
  73996. */
  73997. static ExtrudePolygon(name: string, options: {
  73998. shape: Vector3[];
  73999. holes?: Vector3[][];
  74000. depth?: number;
  74001. faceUV?: Vector4[];
  74002. faceColors?: Color4[];
  74003. updatable?: boolean;
  74004. sideOrientation?: number;
  74005. frontUVs?: Vector4;
  74006. backUVs?: Vector4;
  74007. wrap?: boolean;
  74008. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74009. /**
  74010. * Creates a tube mesh.
  74011. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74012. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  74013. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  74014. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  74015. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  74016. * * 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)
  74017. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  74018. * * 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
  74019. * * 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
  74020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74021. * * 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
  74022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74024. * @param name defines the name of the mesh
  74025. * @param options defines the options used to create the mesh
  74026. * @param scene defines the hosting scene
  74027. * @returns the tube mesh
  74028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74029. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  74030. */
  74031. static CreateTube(name: string, options: {
  74032. path: Vector3[];
  74033. radius?: number;
  74034. tessellation?: number;
  74035. radiusFunction?: {
  74036. (i: number, distance: number): number;
  74037. };
  74038. cap?: number;
  74039. arc?: number;
  74040. updatable?: boolean;
  74041. sideOrientation?: number;
  74042. frontUVs?: Vector4;
  74043. backUVs?: Vector4;
  74044. instance?: Mesh;
  74045. invertUV?: boolean;
  74046. }, scene?: Nullable<Scene>): Mesh;
  74047. /**
  74048. * Creates a polyhedron mesh
  74049. * * 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
  74050. * * The parameter `size` (positive float, default 1) sets the polygon size
  74051. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  74052. * * 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`
  74053. * * 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
  74054. * * 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)`)
  74055. * * 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
  74056. * * 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
  74057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74058. * * 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
  74059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74060. * @param name defines the name of the mesh
  74061. * @param options defines the options used to create the mesh
  74062. * @param scene defines the hosting scene
  74063. * @returns the polyhedron mesh
  74064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  74065. */
  74066. static CreatePolyhedron(name: string, options: {
  74067. type?: number;
  74068. size?: number;
  74069. sizeX?: number;
  74070. sizeY?: number;
  74071. sizeZ?: number;
  74072. custom?: any;
  74073. faceUV?: Vector4[];
  74074. faceColors?: Color4[];
  74075. flat?: boolean;
  74076. updatable?: boolean;
  74077. sideOrientation?: number;
  74078. frontUVs?: Vector4;
  74079. backUVs?: Vector4;
  74080. }, scene?: Nullable<Scene>): Mesh;
  74081. /**
  74082. * Creates a decal mesh.
  74083. * 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
  74084. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74085. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74086. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74087. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74088. * @param name defines the name of the mesh
  74089. * @param sourceMesh defines the mesh where the decal must be applied
  74090. * @param options defines the options used to create the mesh
  74091. * @param scene defines the hosting scene
  74092. * @returns the decal mesh
  74093. * @see https://doc.babylonjs.com/how_to/decals
  74094. */
  74095. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  74096. position?: Vector3;
  74097. normal?: Vector3;
  74098. size?: Vector3;
  74099. angle?: number;
  74100. }): Mesh;
  74101. /**
  74102. * Creates a Capsule Mesh
  74103. * @param name defines the name of the mesh.
  74104. * @param options the constructors options used to shape the mesh.
  74105. * @param scene defines the scene the mesh is scoped to.
  74106. * @returns the capsule mesh
  74107. * @see https://doc.babylonjs.com/how_to/capsule_shape
  74108. */
  74109. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  74110. }
  74111. }
  74112. declare module "babylonjs/Meshes/meshSimplification" {
  74113. import { Mesh } from "babylonjs/Meshes/mesh";
  74114. /**
  74115. * A simplifier interface for future simplification implementations
  74116. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74117. */
  74118. export interface ISimplifier {
  74119. /**
  74120. * Simplification of a given mesh according to the given settings.
  74121. * Since this requires computation, it is assumed that the function runs async.
  74122. * @param settings The settings of the simplification, including quality and distance
  74123. * @param successCallback A callback that will be called after the mesh was simplified.
  74124. * @param errorCallback in case of an error, this callback will be called. optional.
  74125. */
  74126. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  74127. }
  74128. /**
  74129. * Expected simplification settings.
  74130. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  74131. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74132. */
  74133. export interface ISimplificationSettings {
  74134. /**
  74135. * Gets or sets the expected quality
  74136. */
  74137. quality: number;
  74138. /**
  74139. * Gets or sets the distance when this optimized version should be used
  74140. */
  74141. distance: number;
  74142. /**
  74143. * Gets an already optimized mesh
  74144. */
  74145. optimizeMesh?: boolean;
  74146. }
  74147. /**
  74148. * Class used to specify simplification options
  74149. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74150. */
  74151. export class SimplificationSettings implements ISimplificationSettings {
  74152. /** expected quality */
  74153. quality: number;
  74154. /** distance when this optimized version should be used */
  74155. distance: number;
  74156. /** already optimized mesh */
  74157. optimizeMesh?: boolean | undefined;
  74158. /**
  74159. * Creates a SimplificationSettings
  74160. * @param quality expected quality
  74161. * @param distance distance when this optimized version should be used
  74162. * @param optimizeMesh already optimized mesh
  74163. */
  74164. constructor(
  74165. /** expected quality */
  74166. quality: number,
  74167. /** distance when this optimized version should be used */
  74168. distance: number,
  74169. /** already optimized mesh */
  74170. optimizeMesh?: boolean | undefined);
  74171. }
  74172. /**
  74173. * Interface used to define a simplification task
  74174. */
  74175. export interface ISimplificationTask {
  74176. /**
  74177. * Array of settings
  74178. */
  74179. settings: Array<ISimplificationSettings>;
  74180. /**
  74181. * Simplification type
  74182. */
  74183. simplificationType: SimplificationType;
  74184. /**
  74185. * Mesh to simplify
  74186. */
  74187. mesh: Mesh;
  74188. /**
  74189. * Callback called on success
  74190. */
  74191. successCallback?: () => void;
  74192. /**
  74193. * Defines if parallel processing can be used
  74194. */
  74195. parallelProcessing: boolean;
  74196. }
  74197. /**
  74198. * Queue used to order the simplification tasks
  74199. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74200. */
  74201. export class SimplificationQueue {
  74202. private _simplificationArray;
  74203. /**
  74204. * Gets a boolean indicating that the process is still running
  74205. */
  74206. running: boolean;
  74207. /**
  74208. * Creates a new queue
  74209. */
  74210. constructor();
  74211. /**
  74212. * Adds a new simplification task
  74213. * @param task defines a task to add
  74214. */
  74215. addTask(task: ISimplificationTask): void;
  74216. /**
  74217. * Execute next task
  74218. */
  74219. executeNext(): void;
  74220. /**
  74221. * Execute a simplification task
  74222. * @param task defines the task to run
  74223. */
  74224. runSimplification(task: ISimplificationTask): void;
  74225. private getSimplifier;
  74226. }
  74227. /**
  74228. * The implemented types of simplification
  74229. * At the moment only Quadratic Error Decimation is implemented
  74230. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74231. */
  74232. export enum SimplificationType {
  74233. /** Quadratic error decimation */
  74234. QUADRATIC = 0
  74235. }
  74236. /**
  74237. * An implementation of the Quadratic Error simplification algorithm.
  74238. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  74239. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  74240. * @author RaananW
  74241. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74242. */
  74243. export class QuadraticErrorSimplification implements ISimplifier {
  74244. private _mesh;
  74245. private triangles;
  74246. private vertices;
  74247. private references;
  74248. private _reconstructedMesh;
  74249. /** Gets or sets the number pf sync interations */
  74250. syncIterations: number;
  74251. /** Gets or sets the aggressiveness of the simplifier */
  74252. aggressiveness: number;
  74253. /** Gets or sets the number of allowed iterations for decimation */
  74254. decimationIterations: number;
  74255. /** Gets or sets the espilon to use for bounding box computation */
  74256. boundingBoxEpsilon: number;
  74257. /**
  74258. * Creates a new QuadraticErrorSimplification
  74259. * @param _mesh defines the target mesh
  74260. */
  74261. constructor(_mesh: Mesh);
  74262. /**
  74263. * Simplification of a given mesh according to the given settings.
  74264. * Since this requires computation, it is assumed that the function runs async.
  74265. * @param settings The settings of the simplification, including quality and distance
  74266. * @param successCallback A callback that will be called after the mesh was simplified.
  74267. */
  74268. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  74269. private runDecimation;
  74270. private initWithMesh;
  74271. private init;
  74272. private reconstructMesh;
  74273. private initDecimatedMesh;
  74274. private isFlipped;
  74275. private updateTriangles;
  74276. private identifyBorder;
  74277. private updateMesh;
  74278. private vertexError;
  74279. private calculateError;
  74280. }
  74281. }
  74282. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  74283. import { Scene } from "babylonjs/scene";
  74284. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  74285. import { ISceneComponent } from "babylonjs/sceneComponent";
  74286. module "babylonjs/scene" {
  74287. interface Scene {
  74288. /** @hidden (Backing field) */
  74289. _simplificationQueue: SimplificationQueue;
  74290. /**
  74291. * Gets or sets the simplification queue attached to the scene
  74292. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74293. */
  74294. simplificationQueue: SimplificationQueue;
  74295. }
  74296. }
  74297. module "babylonjs/Meshes/mesh" {
  74298. interface Mesh {
  74299. /**
  74300. * Simplify the mesh according to the given array of settings.
  74301. * Function will return immediately and will simplify async
  74302. * @param settings a collection of simplification settings
  74303. * @param parallelProcessing should all levels calculate parallel or one after the other
  74304. * @param simplificationType the type of simplification to run
  74305. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  74306. * @returns the current mesh
  74307. */
  74308. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  74309. }
  74310. }
  74311. /**
  74312. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  74313. * created in a scene
  74314. */
  74315. export class SimplicationQueueSceneComponent implements ISceneComponent {
  74316. /**
  74317. * The component name helpfull to identify the component in the list of scene components.
  74318. */
  74319. readonly name: string;
  74320. /**
  74321. * The scene the component belongs to.
  74322. */
  74323. scene: Scene;
  74324. /**
  74325. * Creates a new instance of the component for the given scene
  74326. * @param scene Defines the scene to register the component in
  74327. */
  74328. constructor(scene: Scene);
  74329. /**
  74330. * Registers the component in a given scene
  74331. */
  74332. register(): void;
  74333. /**
  74334. * Rebuilds the elements related to this component in case of
  74335. * context lost for instance.
  74336. */
  74337. rebuild(): void;
  74338. /**
  74339. * Disposes the component and the associated ressources
  74340. */
  74341. dispose(): void;
  74342. private _beforeCameraUpdate;
  74343. }
  74344. }
  74345. declare module "babylonjs/Meshes/Builders/index" {
  74346. export * from "babylonjs/Meshes/Builders/boxBuilder";
  74347. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  74348. export * from "babylonjs/Meshes/Builders/discBuilder";
  74349. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  74350. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  74351. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  74352. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  74353. export * from "babylonjs/Meshes/Builders/torusBuilder";
  74354. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  74355. export * from "babylonjs/Meshes/Builders/linesBuilder";
  74356. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  74357. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  74358. export * from "babylonjs/Meshes/Builders/latheBuilder";
  74359. export * from "babylonjs/Meshes/Builders/planeBuilder";
  74360. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  74361. export * from "babylonjs/Meshes/Builders/groundBuilder";
  74362. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  74363. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  74364. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74365. export * from "babylonjs/Meshes/Builders/decalBuilder";
  74366. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74367. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  74368. }
  74369. declare module "babylonjs/Meshes/thinInstanceMesh" {
  74370. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  74371. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  74372. import { Matrix } from "babylonjs/Maths/math.vector";
  74373. module "babylonjs/Meshes/mesh" {
  74374. interface Mesh {
  74375. /**
  74376. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  74377. */
  74378. thinInstanceEnablePicking: boolean;
  74379. /**
  74380. * Creates a new thin instance
  74381. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  74382. * @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
  74383. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  74384. */
  74385. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  74386. /**
  74387. * Adds the transformation (matrix) of the current mesh as a thin instance
  74388. * @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
  74389. * @returns the thin instance index number
  74390. */
  74391. thinInstanceAddSelf(refresh: boolean): number;
  74392. /**
  74393. * Registers a custom attribute to be used with thin instances
  74394. * @param kind name of the attribute
  74395. * @param stride size in floats of the attribute
  74396. */
  74397. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  74398. /**
  74399. * Sets the matrix of a thin instance
  74400. * @param index index of the thin instance
  74401. * @param matrix matrix to set
  74402. * @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
  74403. */
  74404. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  74405. /**
  74406. * Sets the value of a custom attribute for a thin instance
  74407. * @param kind name of the attribute
  74408. * @param index index of the thin instance
  74409. * @param value value to set
  74410. * @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
  74411. */
  74412. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  74413. /**
  74414. * 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.
  74415. */
  74416. thinInstanceCount: number;
  74417. /**
  74418. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  74419. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  74420. * @param buffer buffer to set
  74421. * @param stride size in floats of each value of the buffer
  74422. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  74423. */
  74424. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  74425. /**
  74426. * Gets the list of world matrices
  74427. * @return an array containing all the world matrices from the thin instances
  74428. */
  74429. thinInstanceGetWorldMatrices(): Matrix[];
  74430. /**
  74431. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  74432. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74433. */
  74434. thinInstanceBufferUpdated(kind: string): void;
  74435. /**
  74436. * Applies a partial update to a buffer directly on the GPU
  74437. * 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
  74438. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74439. * @param data the data to set in the GPU buffer
  74440. * @param offset the offset in the GPU buffer where to update the data
  74441. */
  74442. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  74443. /**
  74444. * Refreshes the bounding info, taking into account all the thin instances defined
  74445. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  74446. */
  74447. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  74448. /** @hidden */
  74449. _thinInstanceInitializeUserStorage(): void;
  74450. /** @hidden */
  74451. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  74452. /** @hidden */
  74453. _userThinInstanceBuffersStorage: {
  74454. data: {
  74455. [key: string]: Float32Array;
  74456. };
  74457. sizes: {
  74458. [key: string]: number;
  74459. };
  74460. vertexBuffers: {
  74461. [key: string]: Nullable<VertexBuffer>;
  74462. };
  74463. strides: {
  74464. [key: string]: number;
  74465. };
  74466. };
  74467. }
  74468. }
  74469. }
  74470. declare module "babylonjs/Meshes/index" {
  74471. export * from "babylonjs/Meshes/abstractMesh";
  74472. export * from "babylonjs/Meshes/buffer";
  74473. export * from "babylonjs/Meshes/Compression/index";
  74474. export * from "babylonjs/Meshes/csg";
  74475. export * from "babylonjs/Meshes/geometry";
  74476. export * from "babylonjs/Meshes/groundMesh";
  74477. export * from "babylonjs/Meshes/trailMesh";
  74478. export * from "babylonjs/Meshes/instancedMesh";
  74479. export * from "babylonjs/Meshes/linesMesh";
  74480. export * from "babylonjs/Meshes/mesh";
  74481. export * from "babylonjs/Meshes/mesh.vertexData";
  74482. export * from "babylonjs/Meshes/meshBuilder";
  74483. export * from "babylonjs/Meshes/meshSimplification";
  74484. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  74485. export * from "babylonjs/Meshes/polygonMesh";
  74486. export * from "babylonjs/Meshes/subMesh";
  74487. export * from "babylonjs/Meshes/meshLODLevel";
  74488. export * from "babylonjs/Meshes/transformNode";
  74489. export * from "babylonjs/Meshes/Builders/index";
  74490. export * from "babylonjs/Meshes/dataBuffer";
  74491. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  74492. export * from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  74493. import "babylonjs/Meshes/thinInstanceMesh";
  74494. export * from "babylonjs/Meshes/thinInstanceMesh";
  74495. }
  74496. declare module "babylonjs/Morph/index" {
  74497. export * from "babylonjs/Morph/morphTarget";
  74498. export * from "babylonjs/Morph/morphTargetManager";
  74499. }
  74500. declare module "babylonjs/Navigation/INavigationEngine" {
  74501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74502. import { Vector3 } from "babylonjs/Maths/math";
  74503. import { Mesh } from "babylonjs/Meshes/mesh";
  74504. import { Scene } from "babylonjs/scene";
  74505. /**
  74506. * Navigation plugin interface to add navigation constrained by a navigation mesh
  74507. */
  74508. export interface INavigationEnginePlugin {
  74509. /**
  74510. * plugin name
  74511. */
  74512. name: string;
  74513. /**
  74514. * Creates a navigation mesh
  74515. * @param meshes array of all the geometry used to compute the navigatio mesh
  74516. * @param parameters bunch of parameters used to filter geometry
  74517. */
  74518. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  74519. /**
  74520. * Create a navigation mesh debug mesh
  74521. * @param scene is where the mesh will be added
  74522. * @returns debug display mesh
  74523. */
  74524. createDebugNavMesh(scene: Scene): Mesh;
  74525. /**
  74526. * Get a navigation mesh constrained position, closest to the parameter position
  74527. * @param position world position
  74528. * @returns the closest point to position constrained by the navigation mesh
  74529. */
  74530. getClosestPoint(position: Vector3): Vector3;
  74531. /**
  74532. * Get a navigation mesh constrained position, closest to the parameter position
  74533. * @param position world position
  74534. * @param result output the closest point to position constrained by the navigation mesh
  74535. */
  74536. getClosestPointToRef(position: Vector3, result: Vector3): void;
  74537. /**
  74538. * Get a navigation mesh constrained position, within a particular radius
  74539. * @param position world position
  74540. * @param maxRadius the maximum distance to the constrained world position
  74541. * @returns the closest point to position constrained by the navigation mesh
  74542. */
  74543. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  74544. /**
  74545. * Get a navigation mesh constrained position, within a particular radius
  74546. * @param position world position
  74547. * @param maxRadius the maximum distance to the constrained world position
  74548. * @param result output the closest point to position constrained by the navigation mesh
  74549. */
  74550. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  74551. /**
  74552. * Compute the final position from a segment made of destination-position
  74553. * @param position world position
  74554. * @param destination world position
  74555. * @returns the resulting point along the navmesh
  74556. */
  74557. moveAlong(position: Vector3, destination: Vector3): Vector3;
  74558. /**
  74559. * Compute the final position from a segment made of destination-position
  74560. * @param position world position
  74561. * @param destination world position
  74562. * @param result output the resulting point along the navmesh
  74563. */
  74564. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  74565. /**
  74566. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  74567. * @param start world position
  74568. * @param end world position
  74569. * @returns array containing world position composing the path
  74570. */
  74571. computePath(start: Vector3, end: Vector3): Vector3[];
  74572. /**
  74573. * If this plugin is supported
  74574. * @returns true if plugin is supported
  74575. */
  74576. isSupported(): boolean;
  74577. /**
  74578. * Create a new Crowd so you can add agents
  74579. * @param maxAgents the maximum agent count in the crowd
  74580. * @param maxAgentRadius the maximum radius an agent can have
  74581. * @param scene to attach the crowd to
  74582. * @returns the crowd you can add agents to
  74583. */
  74584. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  74585. /**
  74586. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74587. * The queries will try to find a solution within those bounds
  74588. * default is (1,1,1)
  74589. * @param extent x,y,z value that define the extent around the queries point of reference
  74590. */
  74591. setDefaultQueryExtent(extent: Vector3): void;
  74592. /**
  74593. * Get the Bounding box extent specified by setDefaultQueryExtent
  74594. * @returns the box extent values
  74595. */
  74596. getDefaultQueryExtent(): Vector3;
  74597. /**
  74598. * build the navmesh from a previously saved state using getNavmeshData
  74599. * @param data the Uint8Array returned by getNavmeshData
  74600. */
  74601. buildFromNavmeshData(data: Uint8Array): void;
  74602. /**
  74603. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  74604. * @returns data the Uint8Array that can be saved and reused
  74605. */
  74606. getNavmeshData(): Uint8Array;
  74607. /**
  74608. * Get the Bounding box extent result specified by setDefaultQueryExtent
  74609. * @param result output the box extent values
  74610. */
  74611. getDefaultQueryExtentToRef(result: Vector3): void;
  74612. /**
  74613. * Set the time step of the navigation tick update.
  74614. * Default is 1/60.
  74615. * A value of 0 will disable fixed time update
  74616. * @param newTimeStep the new timestep to apply to this world.
  74617. */
  74618. setTimeStep(newTimeStep: number): void;
  74619. /**
  74620. * Get the time step of the navigation tick update.
  74621. * @returns the current time step
  74622. */
  74623. getTimeStep(): number;
  74624. /**
  74625. * If delta time in navigation tick update is greater than the time step
  74626. * a number of sub iterations are done. If more iterations are need to reach deltatime
  74627. * they will be discarded.
  74628. * A value of 0 will set to no maximum and update will use as many substeps as needed
  74629. * @param newStepCount the maximum number of iterations
  74630. */
  74631. setMaximumSubStepCount(newStepCount: number): void;
  74632. /**
  74633. * Get the maximum number of iterations per navigation tick update
  74634. * @returns the maximum number of iterations
  74635. */
  74636. getMaximumSubStepCount(): number;
  74637. /**
  74638. * Release all resources
  74639. */
  74640. dispose(): void;
  74641. }
  74642. /**
  74643. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  74644. */
  74645. export interface ICrowd {
  74646. /**
  74647. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  74648. * You can attach anything to that node. The node position is updated in the scene update tick.
  74649. * @param pos world position that will be constrained by the navigation mesh
  74650. * @param parameters agent parameters
  74651. * @param transform hooked to the agent that will be update by the scene
  74652. * @returns agent index
  74653. */
  74654. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  74655. /**
  74656. * Returns the agent position in world space
  74657. * @param index agent index returned by addAgent
  74658. * @returns world space position
  74659. */
  74660. getAgentPosition(index: number): Vector3;
  74661. /**
  74662. * Gets the agent position result in world space
  74663. * @param index agent index returned by addAgent
  74664. * @param result output world space position
  74665. */
  74666. getAgentPositionToRef(index: number, result: Vector3): void;
  74667. /**
  74668. * Gets the agent velocity in world space
  74669. * @param index agent index returned by addAgent
  74670. * @returns world space velocity
  74671. */
  74672. getAgentVelocity(index: number): Vector3;
  74673. /**
  74674. * Gets the agent velocity result in world space
  74675. * @param index agent index returned by addAgent
  74676. * @param result output world space velocity
  74677. */
  74678. getAgentVelocityToRef(index: number, result: Vector3): void;
  74679. /**
  74680. * Gets the agent next target point on the path
  74681. * @param index agent index returned by addAgent
  74682. * @returns world space position
  74683. */
  74684. getAgentNextTargetPath(index: number): Vector3;
  74685. /**
  74686. * Gets the agent state
  74687. * @param index agent index returned by addAgent
  74688. * @returns agent state
  74689. */
  74690. getAgentState(index: number): number;
  74691. /**
  74692. * returns true if the agent in over an off mesh link connection
  74693. * @param index agent index returned by addAgent
  74694. * @returns true if over an off mesh link connection
  74695. */
  74696. overOffmeshConnection(index: number): boolean;
  74697. /**
  74698. * Gets the agent next target point on the path
  74699. * @param index agent index returned by addAgent
  74700. * @param result output world space position
  74701. */
  74702. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  74703. /**
  74704. * remove a particular agent previously created
  74705. * @param index agent index returned by addAgent
  74706. */
  74707. removeAgent(index: number): void;
  74708. /**
  74709. * get the list of all agents attached to this crowd
  74710. * @returns list of agent indices
  74711. */
  74712. getAgents(): number[];
  74713. /**
  74714. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  74715. * @param deltaTime in seconds
  74716. */
  74717. update(deltaTime: number): void;
  74718. /**
  74719. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  74720. * @param index agent index returned by addAgent
  74721. * @param destination targeted world position
  74722. */
  74723. agentGoto(index: number, destination: Vector3): void;
  74724. /**
  74725. * Teleport the agent to a new position
  74726. * @param index agent index returned by addAgent
  74727. * @param destination targeted world position
  74728. */
  74729. agentTeleport(index: number, destination: Vector3): void;
  74730. /**
  74731. * Update agent parameters
  74732. * @param index agent index returned by addAgent
  74733. * @param parameters agent parameters
  74734. */
  74735. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  74736. /**
  74737. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74738. * The queries will try to find a solution within those bounds
  74739. * default is (1,1,1)
  74740. * @param extent x,y,z value that define the extent around the queries point of reference
  74741. */
  74742. setDefaultQueryExtent(extent: Vector3): void;
  74743. /**
  74744. * Get the Bounding box extent specified by setDefaultQueryExtent
  74745. * @returns the box extent values
  74746. */
  74747. getDefaultQueryExtent(): Vector3;
  74748. /**
  74749. * Get the Bounding box extent result specified by setDefaultQueryExtent
  74750. * @param result output the box extent values
  74751. */
  74752. getDefaultQueryExtentToRef(result: Vector3): void;
  74753. /**
  74754. * Release all resources
  74755. */
  74756. dispose(): void;
  74757. }
  74758. /**
  74759. * Configures an agent
  74760. */
  74761. export interface IAgentParameters {
  74762. /**
  74763. * Agent radius. [Limit: >= 0]
  74764. */
  74765. radius: number;
  74766. /**
  74767. * Agent height. [Limit: > 0]
  74768. */
  74769. height: number;
  74770. /**
  74771. * Maximum allowed acceleration. [Limit: >= 0]
  74772. */
  74773. maxAcceleration: number;
  74774. /**
  74775. * Maximum allowed speed. [Limit: >= 0]
  74776. */
  74777. maxSpeed: number;
  74778. /**
  74779. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  74780. */
  74781. collisionQueryRange: number;
  74782. /**
  74783. * The path visibility optimization range. [Limit: > 0]
  74784. */
  74785. pathOptimizationRange: number;
  74786. /**
  74787. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  74788. */
  74789. separationWeight: number;
  74790. }
  74791. /**
  74792. * Configures the navigation mesh creation
  74793. */
  74794. export interface INavMeshParameters {
  74795. /**
  74796. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  74797. */
  74798. cs: number;
  74799. /**
  74800. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  74801. */
  74802. ch: number;
  74803. /**
  74804. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  74805. */
  74806. walkableSlopeAngle: number;
  74807. /**
  74808. * Minimum floor to 'ceiling' height that will still allow the floor area to
  74809. * be considered walkable. [Limit: >= 3] [Units: vx]
  74810. */
  74811. walkableHeight: number;
  74812. /**
  74813. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  74814. */
  74815. walkableClimb: number;
  74816. /**
  74817. * The distance to erode/shrink the walkable area of the heightfield away from
  74818. * obstructions. [Limit: >=0] [Units: vx]
  74819. */
  74820. walkableRadius: number;
  74821. /**
  74822. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  74823. */
  74824. maxEdgeLen: number;
  74825. /**
  74826. * The maximum distance a simplfied contour's border edges should deviate
  74827. * the original raw contour. [Limit: >=0] [Units: vx]
  74828. */
  74829. maxSimplificationError: number;
  74830. /**
  74831. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  74832. */
  74833. minRegionArea: number;
  74834. /**
  74835. * Any regions with a span count smaller than this value will, if possible,
  74836. * be merged with larger regions. [Limit: >=0] [Units: vx]
  74837. */
  74838. mergeRegionArea: number;
  74839. /**
  74840. * The maximum number of vertices allowed for polygons generated during the
  74841. * contour to polygon conversion process. [Limit: >= 3]
  74842. */
  74843. maxVertsPerPoly: number;
  74844. /**
  74845. * Sets the sampling distance to use when generating the detail mesh.
  74846. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  74847. */
  74848. detailSampleDist: number;
  74849. /**
  74850. * The maximum distance the detail mesh surface should deviate from heightfield
  74851. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  74852. */
  74853. detailSampleMaxError: number;
  74854. }
  74855. }
  74856. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  74857. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  74858. import { Mesh } from "babylonjs/Meshes/mesh";
  74859. import { Scene } from "babylonjs/scene";
  74860. import { Vector3 } from "babylonjs/Maths/math";
  74861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74862. /**
  74863. * RecastJS navigation plugin
  74864. */
  74865. export class RecastJSPlugin implements INavigationEnginePlugin {
  74866. /**
  74867. * Reference to the Recast library
  74868. */
  74869. bjsRECAST: any;
  74870. /**
  74871. * plugin name
  74872. */
  74873. name: string;
  74874. /**
  74875. * the first navmesh created. We might extend this to support multiple navmeshes
  74876. */
  74877. navMesh: any;
  74878. private _maximumSubStepCount;
  74879. private _timeStep;
  74880. /**
  74881. * Initializes the recastJS plugin
  74882. * @param recastInjection can be used to inject your own recast reference
  74883. */
  74884. constructor(recastInjection?: any);
  74885. /**
  74886. * Set the time step of the navigation tick update.
  74887. * Default is 1/60.
  74888. * A value of 0 will disable fixed time update
  74889. * @param newTimeStep the new timestep to apply to this world.
  74890. */
  74891. setTimeStep(newTimeStep?: number): void;
  74892. /**
  74893. * Get the time step of the navigation tick update.
  74894. * @returns the current time step
  74895. */
  74896. getTimeStep(): number;
  74897. /**
  74898. * If delta time in navigation tick update is greater than the time step
  74899. * a number of sub iterations are done. If more iterations are need to reach deltatime
  74900. * they will be discarded.
  74901. * A value of 0 will set to no maximum and update will use as many substeps as needed
  74902. * @param newStepCount the maximum number of iterations
  74903. */
  74904. setMaximumSubStepCount(newStepCount?: number): void;
  74905. /**
  74906. * Get the maximum number of iterations per navigation tick update
  74907. * @returns the maximum number of iterations
  74908. */
  74909. getMaximumSubStepCount(): number;
  74910. /**
  74911. * Creates a navigation mesh
  74912. * @param meshes array of all the geometry used to compute the navigatio mesh
  74913. * @param parameters bunch of parameters used to filter geometry
  74914. */
  74915. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  74916. /**
  74917. * Create a navigation mesh debug mesh
  74918. * @param scene is where the mesh will be added
  74919. * @returns debug display mesh
  74920. */
  74921. createDebugNavMesh(scene: Scene): Mesh;
  74922. /**
  74923. * Get a navigation mesh constrained position, closest to the parameter position
  74924. * @param position world position
  74925. * @returns the closest point to position constrained by the navigation mesh
  74926. */
  74927. getClosestPoint(position: Vector3): Vector3;
  74928. /**
  74929. * Get a navigation mesh constrained position, closest to the parameter position
  74930. * @param position world position
  74931. * @param result output the closest point to position constrained by the navigation mesh
  74932. */
  74933. getClosestPointToRef(position: Vector3, result: Vector3): void;
  74934. /**
  74935. * Get a navigation mesh constrained position, within a particular radius
  74936. * @param position world position
  74937. * @param maxRadius the maximum distance to the constrained world position
  74938. * @returns the closest point to position constrained by the navigation mesh
  74939. */
  74940. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  74941. /**
  74942. * Get a navigation mesh constrained position, within a particular radius
  74943. * @param position world position
  74944. * @param maxRadius the maximum distance to the constrained world position
  74945. * @param result output the closest point to position constrained by the navigation mesh
  74946. */
  74947. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  74948. /**
  74949. * Compute the final position from a segment made of destination-position
  74950. * @param position world position
  74951. * @param destination world position
  74952. * @returns the resulting point along the navmesh
  74953. */
  74954. moveAlong(position: Vector3, destination: Vector3): Vector3;
  74955. /**
  74956. * Compute the final position from a segment made of destination-position
  74957. * @param position world position
  74958. * @param destination world position
  74959. * @param result output the resulting point along the navmesh
  74960. */
  74961. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  74962. /**
  74963. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  74964. * @param start world position
  74965. * @param end world position
  74966. * @returns array containing world position composing the path
  74967. */
  74968. computePath(start: Vector3, end: Vector3): Vector3[];
  74969. /**
  74970. * Create a new Crowd so you can add agents
  74971. * @param maxAgents the maximum agent count in the crowd
  74972. * @param maxAgentRadius the maximum radius an agent can have
  74973. * @param scene to attach the crowd to
  74974. * @returns the crowd you can add agents to
  74975. */
  74976. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  74977. /**
  74978. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74979. * The queries will try to find a solution within those bounds
  74980. * default is (1,1,1)
  74981. * @param extent x,y,z value that define the extent around the queries point of reference
  74982. */
  74983. setDefaultQueryExtent(extent: Vector3): void;
  74984. /**
  74985. * Get the Bounding box extent specified by setDefaultQueryExtent
  74986. * @returns the box extent values
  74987. */
  74988. getDefaultQueryExtent(): Vector3;
  74989. /**
  74990. * build the navmesh from a previously saved state using getNavmeshData
  74991. * @param data the Uint8Array returned by getNavmeshData
  74992. */
  74993. buildFromNavmeshData(data: Uint8Array): void;
  74994. /**
  74995. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  74996. * @returns data the Uint8Array that can be saved and reused
  74997. */
  74998. getNavmeshData(): Uint8Array;
  74999. /**
  75000. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75001. * @param result output the box extent values
  75002. */
  75003. getDefaultQueryExtentToRef(result: Vector3): void;
  75004. /**
  75005. * Disposes
  75006. */
  75007. dispose(): void;
  75008. /**
  75009. * If this plugin is supported
  75010. * @returns true if plugin is supported
  75011. */
  75012. isSupported(): boolean;
  75013. }
  75014. /**
  75015. * Recast detour crowd implementation
  75016. */
  75017. export class RecastJSCrowd implements ICrowd {
  75018. /**
  75019. * Recast/detour plugin
  75020. */
  75021. bjsRECASTPlugin: RecastJSPlugin;
  75022. /**
  75023. * Link to the detour crowd
  75024. */
  75025. recastCrowd: any;
  75026. /**
  75027. * One transform per agent
  75028. */
  75029. transforms: TransformNode[];
  75030. /**
  75031. * All agents created
  75032. */
  75033. agents: number[];
  75034. /**
  75035. * Link to the scene is kept to unregister the crowd from the scene
  75036. */
  75037. private _scene;
  75038. /**
  75039. * Observer for crowd updates
  75040. */
  75041. private _onBeforeAnimationsObserver;
  75042. /**
  75043. * Constructor
  75044. * @param plugin recastJS plugin
  75045. * @param maxAgents the maximum agent count in the crowd
  75046. * @param maxAgentRadius the maximum radius an agent can have
  75047. * @param scene to attach the crowd to
  75048. * @returns the crowd you can add agents to
  75049. */
  75050. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  75051. /**
  75052. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75053. * You can attach anything to that node. The node position is updated in the scene update tick.
  75054. * @param pos world position that will be constrained by the navigation mesh
  75055. * @param parameters agent parameters
  75056. * @param transform hooked to the agent that will be update by the scene
  75057. * @returns agent index
  75058. */
  75059. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75060. /**
  75061. * Returns the agent position in world space
  75062. * @param index agent index returned by addAgent
  75063. * @returns world space position
  75064. */
  75065. getAgentPosition(index: number): Vector3;
  75066. /**
  75067. * Returns the agent position result in world space
  75068. * @param index agent index returned by addAgent
  75069. * @param result output world space position
  75070. */
  75071. getAgentPositionToRef(index: number, result: Vector3): void;
  75072. /**
  75073. * Returns the agent velocity in world space
  75074. * @param index agent index returned by addAgent
  75075. * @returns world space velocity
  75076. */
  75077. getAgentVelocity(index: number): Vector3;
  75078. /**
  75079. * Returns the agent velocity result in world space
  75080. * @param index agent index returned by addAgent
  75081. * @param result output world space velocity
  75082. */
  75083. getAgentVelocityToRef(index: number, result: Vector3): void;
  75084. /**
  75085. * Returns the agent next target point on the path
  75086. * @param index agent index returned by addAgent
  75087. * @returns world space position
  75088. */
  75089. getAgentNextTargetPath(index: number): Vector3;
  75090. /**
  75091. * Returns the agent next target point on the path
  75092. * @param index agent index returned by addAgent
  75093. * @param result output world space position
  75094. */
  75095. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75096. /**
  75097. * Gets the agent state
  75098. * @param index agent index returned by addAgent
  75099. * @returns agent state
  75100. */
  75101. getAgentState(index: number): number;
  75102. /**
  75103. * returns true if the agent in over an off mesh link connection
  75104. * @param index agent index returned by addAgent
  75105. * @returns true if over an off mesh link connection
  75106. */
  75107. overOffmeshConnection(index: number): boolean;
  75108. /**
  75109. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75110. * @param index agent index returned by addAgent
  75111. * @param destination targeted world position
  75112. */
  75113. agentGoto(index: number, destination: Vector3): void;
  75114. /**
  75115. * Teleport the agent to a new position
  75116. * @param index agent index returned by addAgent
  75117. * @param destination targeted world position
  75118. */
  75119. agentTeleport(index: number, destination: Vector3): void;
  75120. /**
  75121. * Update agent parameters
  75122. * @param index agent index returned by addAgent
  75123. * @param parameters agent parameters
  75124. */
  75125. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75126. /**
  75127. * remove a particular agent previously created
  75128. * @param index agent index returned by addAgent
  75129. */
  75130. removeAgent(index: number): void;
  75131. /**
  75132. * get the list of all agents attached to this crowd
  75133. * @returns list of agent indices
  75134. */
  75135. getAgents(): number[];
  75136. /**
  75137. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75138. * @param deltaTime in seconds
  75139. */
  75140. update(deltaTime: number): void;
  75141. /**
  75142. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75143. * The queries will try to find a solution within those bounds
  75144. * default is (1,1,1)
  75145. * @param extent x,y,z value that define the extent around the queries point of reference
  75146. */
  75147. setDefaultQueryExtent(extent: Vector3): void;
  75148. /**
  75149. * Get the Bounding box extent specified by setDefaultQueryExtent
  75150. * @returns the box extent values
  75151. */
  75152. getDefaultQueryExtent(): Vector3;
  75153. /**
  75154. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75155. * @param result output the box extent values
  75156. */
  75157. getDefaultQueryExtentToRef(result: Vector3): void;
  75158. /**
  75159. * Release all resources
  75160. */
  75161. dispose(): void;
  75162. }
  75163. }
  75164. declare module "babylonjs/Navigation/Plugins/index" {
  75165. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  75166. }
  75167. declare module "babylonjs/Navigation/index" {
  75168. export * from "babylonjs/Navigation/INavigationEngine";
  75169. export * from "babylonjs/Navigation/Plugins/index";
  75170. }
  75171. declare module "babylonjs/Offline/database" {
  75172. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  75173. /**
  75174. * Class used to enable access to IndexedDB
  75175. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75176. */
  75177. export class Database implements IOfflineProvider {
  75178. private _callbackManifestChecked;
  75179. private _currentSceneUrl;
  75180. private _db;
  75181. private _enableSceneOffline;
  75182. private _enableTexturesOffline;
  75183. private _manifestVersionFound;
  75184. private _mustUpdateRessources;
  75185. private _hasReachedQuota;
  75186. private _isSupported;
  75187. private _idbFactory;
  75188. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  75189. private static IsUASupportingBlobStorage;
  75190. /**
  75191. * Gets a boolean indicating if Database storate is enabled (off by default)
  75192. */
  75193. static IDBStorageEnabled: boolean;
  75194. /**
  75195. * Gets a boolean indicating if scene must be saved in the database
  75196. */
  75197. get enableSceneOffline(): boolean;
  75198. /**
  75199. * Gets a boolean indicating if textures must be saved in the database
  75200. */
  75201. get enableTexturesOffline(): boolean;
  75202. /**
  75203. * Creates a new Database
  75204. * @param urlToScene defines the url to load the scene
  75205. * @param callbackManifestChecked defines the callback to use when manifest is checked
  75206. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  75207. */
  75208. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  75209. private static _ParseURL;
  75210. private static _ReturnFullUrlLocation;
  75211. private _checkManifestFile;
  75212. /**
  75213. * Open the database and make it available
  75214. * @param successCallback defines the callback to call on success
  75215. * @param errorCallback defines the callback to call on error
  75216. */
  75217. open(successCallback: () => void, errorCallback: () => void): void;
  75218. /**
  75219. * Loads an image from the database
  75220. * @param url defines the url to load from
  75221. * @param image defines the target DOM image
  75222. */
  75223. loadImage(url: string, image: HTMLImageElement): void;
  75224. private _loadImageFromDBAsync;
  75225. private _saveImageIntoDBAsync;
  75226. private _checkVersionFromDB;
  75227. private _loadVersionFromDBAsync;
  75228. private _saveVersionIntoDBAsync;
  75229. /**
  75230. * Loads a file from database
  75231. * @param url defines the URL to load from
  75232. * @param sceneLoaded defines a callback to call on success
  75233. * @param progressCallBack defines a callback to call when progress changed
  75234. * @param errorCallback defines a callback to call on error
  75235. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75236. */
  75237. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75238. private _loadFileAsync;
  75239. private _saveFileAsync;
  75240. /**
  75241. * Validates if xhr data is correct
  75242. * @param xhr defines the request to validate
  75243. * @param dataType defines the expected data type
  75244. * @returns true if data is correct
  75245. */
  75246. private static _ValidateXHRData;
  75247. }
  75248. }
  75249. declare module "babylonjs/Offline/index" {
  75250. export * from "babylonjs/Offline/database";
  75251. export * from "babylonjs/Offline/IOfflineProvider";
  75252. }
  75253. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  75254. /** @hidden */
  75255. export var gpuUpdateParticlesPixelShader: {
  75256. name: string;
  75257. shader: string;
  75258. };
  75259. }
  75260. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  75261. /** @hidden */
  75262. export var gpuUpdateParticlesVertexShader: {
  75263. name: string;
  75264. shader: string;
  75265. };
  75266. }
  75267. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  75268. /** @hidden */
  75269. export var clipPlaneFragmentDeclaration2: {
  75270. name: string;
  75271. shader: string;
  75272. };
  75273. }
  75274. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  75275. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  75276. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  75277. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  75278. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  75279. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  75280. /** @hidden */
  75281. export var gpuRenderParticlesPixelShader: {
  75282. name: string;
  75283. shader: string;
  75284. };
  75285. }
  75286. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  75287. /** @hidden */
  75288. export var clipPlaneVertexDeclaration2: {
  75289. name: string;
  75290. shader: string;
  75291. };
  75292. }
  75293. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  75294. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  75295. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  75296. /** @hidden */
  75297. export var gpuRenderParticlesVertexShader: {
  75298. name: string;
  75299. shader: string;
  75300. };
  75301. }
  75302. declare module "babylonjs/Particles/gpuParticleSystem" {
  75303. import { Nullable } from "babylonjs/types";
  75304. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  75305. import { Observable } from "babylonjs/Misc/observable";
  75306. import { Matrix } from "babylonjs/Maths/math.vector";
  75307. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  75308. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75309. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  75310. import { IDisposable } from "babylonjs/scene";
  75311. import { Effect } from "babylonjs/Materials/effect";
  75312. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75313. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75314. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  75315. import { Scene } from "babylonjs/scene";
  75316. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  75317. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  75318. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  75319. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  75320. /**
  75321. * This represents a GPU particle system in Babylon
  75322. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  75323. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  75324. */
  75325. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  75326. /**
  75327. * The layer mask we are rendering the particles through.
  75328. */
  75329. layerMask: number;
  75330. private _capacity;
  75331. private _activeCount;
  75332. private _currentActiveCount;
  75333. private _accumulatedCount;
  75334. private _renderEffect;
  75335. private _updateEffect;
  75336. private _buffer0;
  75337. private _buffer1;
  75338. private _spriteBuffer;
  75339. private _updateVAO;
  75340. private _renderVAO;
  75341. private _targetIndex;
  75342. private _sourceBuffer;
  75343. private _targetBuffer;
  75344. private _currentRenderId;
  75345. private _started;
  75346. private _stopped;
  75347. private _timeDelta;
  75348. private _randomTexture;
  75349. private _randomTexture2;
  75350. private _attributesStrideSize;
  75351. private _updateEffectOptions;
  75352. private _randomTextureSize;
  75353. private _actualFrame;
  75354. private _customEffect;
  75355. private readonly _rawTextureWidth;
  75356. /**
  75357. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  75358. */
  75359. static get IsSupported(): boolean;
  75360. /**
  75361. * An event triggered when the system is disposed.
  75362. */
  75363. onDisposeObservable: Observable<IParticleSystem>;
  75364. /**
  75365. * An event triggered when the system is stopped
  75366. */
  75367. onStoppedObservable: Observable<IParticleSystem>;
  75368. /**
  75369. * Gets the maximum number of particles active at the same time.
  75370. * @returns The max number of active particles.
  75371. */
  75372. getCapacity(): number;
  75373. /**
  75374. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  75375. * to override the particles.
  75376. */
  75377. forceDepthWrite: boolean;
  75378. /**
  75379. * Gets or set the number of active particles
  75380. */
  75381. get activeParticleCount(): number;
  75382. set activeParticleCount(value: number);
  75383. private _preWarmDone;
  75384. /**
  75385. * Specifies if the particles are updated in emitter local space or world space.
  75386. */
  75387. isLocal: boolean;
  75388. /** Gets or sets a matrix to use to compute projection */
  75389. defaultProjectionMatrix: Matrix;
  75390. /**
  75391. * Is this system ready to be used/rendered
  75392. * @return true if the system is ready
  75393. */
  75394. isReady(): boolean;
  75395. /**
  75396. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75397. * @returns True if it has been started, otherwise false.
  75398. */
  75399. isStarted(): boolean;
  75400. /**
  75401. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  75402. * @returns True if it has been stopped, otherwise false.
  75403. */
  75404. isStopped(): boolean;
  75405. /**
  75406. * Gets a boolean indicating that the system is stopping
  75407. * @returns true if the system is currently stopping
  75408. */
  75409. isStopping(): boolean;
  75410. /**
  75411. * Gets the number of particles active at the same time.
  75412. * @returns The number of active particles.
  75413. */
  75414. getActiveCount(): number;
  75415. /**
  75416. * Starts the particle system and begins to emit
  75417. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75418. */
  75419. start(delay?: number): void;
  75420. /**
  75421. * Stops the particle system.
  75422. */
  75423. stop(): void;
  75424. /**
  75425. * Remove all active particles
  75426. */
  75427. reset(): void;
  75428. /**
  75429. * Returns the string "GPUParticleSystem"
  75430. * @returns a string containing the class name
  75431. */
  75432. getClassName(): string;
  75433. /**
  75434. * Gets the custom effect used to render the particles
  75435. * @param blendMode Blend mode for which the effect should be retrieved
  75436. * @returns The effect
  75437. */
  75438. getCustomEffect(blendMode?: number): Nullable<Effect>;
  75439. /**
  75440. * Sets the custom effect used to render the particles
  75441. * @param effect The effect to set
  75442. * @param blendMode Blend mode for which the effect should be set
  75443. */
  75444. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  75445. /** @hidden */
  75446. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  75447. /**
  75448. * Observable that will be called just before the particles are drawn
  75449. */
  75450. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  75451. /**
  75452. * Gets the name of the particle vertex shader
  75453. */
  75454. get vertexShaderName(): string;
  75455. private _colorGradientsTexture;
  75456. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  75457. /**
  75458. * Adds a new color gradient
  75459. * @param gradient defines the gradient to use (between 0 and 1)
  75460. * @param color1 defines the color to affect to the specified gradient
  75461. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75462. * @returns the current particle system
  75463. */
  75464. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  75465. private _refreshColorGradient;
  75466. /** Force the system to rebuild all gradients that need to be resync */
  75467. forceRefreshGradients(): void;
  75468. /**
  75469. * Remove a specific color gradient
  75470. * @param gradient defines the gradient to remove
  75471. * @returns the current particle system
  75472. */
  75473. removeColorGradient(gradient: number): GPUParticleSystem;
  75474. private _angularSpeedGradientsTexture;
  75475. private _sizeGradientsTexture;
  75476. private _velocityGradientsTexture;
  75477. private _limitVelocityGradientsTexture;
  75478. private _dragGradientsTexture;
  75479. private _addFactorGradient;
  75480. /**
  75481. * Adds a new size gradient
  75482. * @param gradient defines the gradient to use (between 0 and 1)
  75483. * @param factor defines the size factor to affect to the specified gradient
  75484. * @returns the current particle system
  75485. */
  75486. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  75487. /**
  75488. * Remove a specific size gradient
  75489. * @param gradient defines the gradient to remove
  75490. * @returns the current particle system
  75491. */
  75492. removeSizeGradient(gradient: number): GPUParticleSystem;
  75493. private _refreshFactorGradient;
  75494. /**
  75495. * Adds a new angular speed gradient
  75496. * @param gradient defines the gradient to use (between 0 and 1)
  75497. * @param factor defines the angular speed to affect to the specified gradient
  75498. * @returns the current particle system
  75499. */
  75500. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  75501. /**
  75502. * Remove a specific angular speed gradient
  75503. * @param gradient defines the gradient to remove
  75504. * @returns the current particle system
  75505. */
  75506. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  75507. /**
  75508. * Adds a new velocity gradient
  75509. * @param gradient defines the gradient to use (between 0 and 1)
  75510. * @param factor defines the velocity to affect to the specified gradient
  75511. * @returns the current particle system
  75512. */
  75513. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75514. /**
  75515. * Remove a specific velocity gradient
  75516. * @param gradient defines the gradient to remove
  75517. * @returns the current particle system
  75518. */
  75519. removeVelocityGradient(gradient: number): GPUParticleSystem;
  75520. /**
  75521. * Adds a new limit velocity gradient
  75522. * @param gradient defines the gradient to use (between 0 and 1)
  75523. * @param factor defines the limit velocity value to affect to the specified gradient
  75524. * @returns the current particle system
  75525. */
  75526. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75527. /**
  75528. * Remove a specific limit velocity gradient
  75529. * @param gradient defines the gradient to remove
  75530. * @returns the current particle system
  75531. */
  75532. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  75533. /**
  75534. * Adds a new drag gradient
  75535. * @param gradient defines the gradient to use (between 0 and 1)
  75536. * @param factor defines the drag value to affect to the specified gradient
  75537. * @returns the current particle system
  75538. */
  75539. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  75540. /**
  75541. * Remove a specific drag gradient
  75542. * @param gradient defines the gradient to remove
  75543. * @returns the current particle system
  75544. */
  75545. removeDragGradient(gradient: number): GPUParticleSystem;
  75546. /**
  75547. * Not supported by GPUParticleSystem
  75548. * @param gradient defines the gradient to use (between 0 and 1)
  75549. * @param factor defines the emit rate value to affect to the specified gradient
  75550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75551. * @returns the current particle system
  75552. */
  75553. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75554. /**
  75555. * Not supported by GPUParticleSystem
  75556. * @param gradient defines the gradient to remove
  75557. * @returns the current particle system
  75558. */
  75559. removeEmitRateGradient(gradient: number): IParticleSystem;
  75560. /**
  75561. * Not supported by GPUParticleSystem
  75562. * @param gradient defines the gradient to use (between 0 and 1)
  75563. * @param factor defines the start size value to affect to the specified gradient
  75564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75565. * @returns the current particle system
  75566. */
  75567. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75568. /**
  75569. * Not supported by GPUParticleSystem
  75570. * @param gradient defines the gradient to remove
  75571. * @returns the current particle system
  75572. */
  75573. removeStartSizeGradient(gradient: number): IParticleSystem;
  75574. /**
  75575. * Not supported by GPUParticleSystem
  75576. * @param gradient defines the gradient to use (between 0 and 1)
  75577. * @param min defines the color remap minimal range
  75578. * @param max defines the color remap maximal range
  75579. * @returns the current particle system
  75580. */
  75581. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75582. /**
  75583. * Not supported by GPUParticleSystem
  75584. * @param gradient defines the gradient to remove
  75585. * @returns the current particle system
  75586. */
  75587. removeColorRemapGradient(): IParticleSystem;
  75588. /**
  75589. * Not supported by GPUParticleSystem
  75590. * @param gradient defines the gradient to use (between 0 and 1)
  75591. * @param min defines the alpha remap minimal range
  75592. * @param max defines the alpha remap maximal range
  75593. * @returns the current particle system
  75594. */
  75595. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75596. /**
  75597. * Not supported by GPUParticleSystem
  75598. * @param gradient defines the gradient to remove
  75599. * @returns the current particle system
  75600. */
  75601. removeAlphaRemapGradient(): IParticleSystem;
  75602. /**
  75603. * Not supported by GPUParticleSystem
  75604. * @param gradient defines the gradient to use (between 0 and 1)
  75605. * @param color defines the color to affect to the specified gradient
  75606. * @returns the current particle system
  75607. */
  75608. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75609. /**
  75610. * Not supported by GPUParticleSystem
  75611. * @param gradient defines the gradient to remove
  75612. * @returns the current particle system
  75613. */
  75614. removeRampGradient(): IParticleSystem;
  75615. /**
  75616. * Not supported by GPUParticleSystem
  75617. * @returns the list of ramp gradients
  75618. */
  75619. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75620. /**
  75621. * Not supported by GPUParticleSystem
  75622. * Gets or sets a boolean indicating that ramp gradients must be used
  75623. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75624. */
  75625. get useRampGradients(): boolean;
  75626. set useRampGradients(value: boolean);
  75627. /**
  75628. * Not supported by GPUParticleSystem
  75629. * @param gradient defines the gradient to use (between 0 and 1)
  75630. * @param factor defines the life time factor to affect to the specified gradient
  75631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75632. * @returns the current particle system
  75633. */
  75634. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75635. /**
  75636. * Not supported by GPUParticleSystem
  75637. * @param gradient defines the gradient to remove
  75638. * @returns the current particle system
  75639. */
  75640. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75641. /**
  75642. * Instantiates a GPU particle system.
  75643. * 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.
  75644. * @param name The name of the particle system
  75645. * @param options The options used to create the system
  75646. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  75647. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75648. * @param customEffect a custom effect used to change the way particles are rendered by default
  75649. */
  75650. constructor(name: string, options: Partial<{
  75651. capacity: number;
  75652. randomTextureSize: number;
  75653. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  75654. protected _reset(): void;
  75655. private _createUpdateVAO;
  75656. private _createRenderVAO;
  75657. private _initialize;
  75658. /** @hidden */
  75659. _recreateUpdateEffect(): void;
  75660. private _getEffect;
  75661. /**
  75662. * Fill the defines array according to the current settings of the particle system
  75663. * @param defines Array to be updated
  75664. * @param blendMode blend mode to take into account when updating the array
  75665. */
  75666. fillDefines(defines: Array<string>, blendMode?: number): void;
  75667. /**
  75668. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  75669. * @param uniforms Uniforms array to fill
  75670. * @param attributes Attributes array to fill
  75671. * @param samplers Samplers array to fill
  75672. */
  75673. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  75674. /** @hidden */
  75675. _recreateRenderEffect(): Effect;
  75676. /**
  75677. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75678. * @param preWarm defines if we are in the pre-warmimg phase
  75679. */
  75680. animate(preWarm?: boolean): void;
  75681. private _createFactorGradientTexture;
  75682. private _createSizeGradientTexture;
  75683. private _createAngularSpeedGradientTexture;
  75684. private _createVelocityGradientTexture;
  75685. private _createLimitVelocityGradientTexture;
  75686. private _createDragGradientTexture;
  75687. private _createColorGradientTexture;
  75688. /**
  75689. * Renders the particle system in its current state
  75690. * @param preWarm defines if the system should only update the particles but not render them
  75691. * @returns the current number of particles
  75692. */
  75693. render(preWarm?: boolean): number;
  75694. /**
  75695. * Rebuilds the particle system
  75696. */
  75697. rebuild(): void;
  75698. private _releaseBuffers;
  75699. private _releaseVAOs;
  75700. /**
  75701. * Disposes the particle system and free the associated resources
  75702. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75703. */
  75704. dispose(disposeTexture?: boolean): void;
  75705. /**
  75706. * Clones the particle system.
  75707. * @param name The name of the cloned object
  75708. * @param newEmitter The new emitter to use
  75709. * @returns the cloned particle system
  75710. */
  75711. clone(name: string, newEmitter: any): GPUParticleSystem;
  75712. /**
  75713. * Serializes the particle system to a JSON object
  75714. * @param serializeTexture defines if the texture must be serialized as well
  75715. * @returns the JSON object
  75716. */
  75717. serialize(serializeTexture?: boolean): any;
  75718. /**
  75719. * Parses a JSON object to create a GPU particle system.
  75720. * @param parsedParticleSystem The JSON object to parse
  75721. * @param sceneOrEngine The scene or the engine to create the particle system in
  75722. * @param rootUrl The root url to use to load external dependencies like texture
  75723. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75724. * @returns the parsed GPU particle system
  75725. */
  75726. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  75727. }
  75728. }
  75729. declare module "babylonjs/Particles/particleSystemSet" {
  75730. import { Nullable } from "babylonjs/types";
  75731. import { Color3 } from "babylonjs/Maths/math.color";
  75732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75734. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75735. import { Scene, IDisposable } from "babylonjs/scene";
  75736. /**
  75737. * Represents a set of particle systems working together to create a specific effect
  75738. */
  75739. export class ParticleSystemSet implements IDisposable {
  75740. /**
  75741. * Gets or sets base Assets URL
  75742. */
  75743. static BaseAssetsUrl: string;
  75744. private _emitterCreationOptions;
  75745. private _emitterNode;
  75746. /**
  75747. * Gets the particle system list
  75748. */
  75749. systems: IParticleSystem[];
  75750. /**
  75751. * Gets the emitter node used with this set
  75752. */
  75753. get emitterNode(): Nullable<TransformNode>;
  75754. /**
  75755. * Creates a new emitter mesh as a sphere
  75756. * @param options defines the options used to create the sphere
  75757. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  75758. * @param scene defines the hosting scene
  75759. */
  75760. setEmitterAsSphere(options: {
  75761. diameter: number;
  75762. segments: number;
  75763. color: Color3;
  75764. }, renderingGroupId: number, scene: Scene): void;
  75765. /**
  75766. * Starts all particle systems of the set
  75767. * @param emitter defines an optional mesh to use as emitter for the particle systems
  75768. */
  75769. start(emitter?: AbstractMesh): void;
  75770. /**
  75771. * Release all associated resources
  75772. */
  75773. dispose(): void;
  75774. /**
  75775. * Serialize the set into a JSON compatible object
  75776. * @param serializeTexture defines if the texture must be serialized as well
  75777. * @returns a JSON compatible representation of the set
  75778. */
  75779. serialize(serializeTexture?: boolean): any;
  75780. /**
  75781. * Parse a new ParticleSystemSet from a serialized source
  75782. * @param data defines a JSON compatible representation of the set
  75783. * @param scene defines the hosting scene
  75784. * @param gpu defines if we want GPU particles or CPU particles
  75785. * @returns a new ParticleSystemSet
  75786. */
  75787. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  75788. }
  75789. }
  75790. declare module "babylonjs/Particles/particleHelper" {
  75791. import { Nullable } from "babylonjs/types";
  75792. import { Scene } from "babylonjs/scene";
  75793. import { Vector3 } from "babylonjs/Maths/math.vector";
  75794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75796. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  75797. /**
  75798. * This class is made for on one-liner static method to help creating particle system set.
  75799. */
  75800. export class ParticleHelper {
  75801. /**
  75802. * Gets or sets base Assets URL
  75803. */
  75804. static BaseAssetsUrl: string;
  75805. /** Define the Url to load snippets */
  75806. static SnippetUrl: string;
  75807. /**
  75808. * Create a default particle system that you can tweak
  75809. * @param emitter defines the emitter to use
  75810. * @param capacity defines the system capacity (default is 500 particles)
  75811. * @param scene defines the hosting scene
  75812. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  75813. * @returns the new Particle system
  75814. */
  75815. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  75816. /**
  75817. * This is the main static method (one-liner) of this helper to create different particle systems
  75818. * @param type This string represents the type to the particle system to create
  75819. * @param scene The scene where the particle system should live
  75820. * @param gpu If the system will use gpu
  75821. * @returns the ParticleSystemSet created
  75822. */
  75823. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  75824. /**
  75825. * Static function used to export a particle system to a ParticleSystemSet variable.
  75826. * Please note that the emitter shape is not exported
  75827. * @param systems defines the particle systems to export
  75828. * @returns the created particle system set
  75829. */
  75830. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  75831. /**
  75832. * Creates a particle system from a snippet saved in a remote file
  75833. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  75834. * @param url defines the url to load from
  75835. * @param scene defines the hosting scene
  75836. * @param gpu If the system will use gpu
  75837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75838. * @returns a promise that will resolve to the new particle system
  75839. */
  75840. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  75841. /**
  75842. * Creates a particle system from a snippet saved by the particle system editor
  75843. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  75844. * @param scene defines the hosting scene
  75845. * @param gpu If the system will use gpu
  75846. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75847. * @returns a promise that will resolve to the new particle system
  75848. */
  75849. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  75850. }
  75851. }
  75852. declare module "babylonjs/Particles/particleSystemComponent" {
  75853. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75854. import { Effect } from "babylonjs/Materials/effect";
  75855. import "babylonjs/Shaders/particles.vertex";
  75856. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  75857. module "babylonjs/Engines/engine" {
  75858. interface Engine {
  75859. /**
  75860. * Create an effect to use with particle systems.
  75861. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  75862. * the particle system for which you want to create a custom effect in the last parameter
  75863. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  75864. * @param uniformsNames defines a list of attribute names
  75865. * @param samplers defines an array of string used to represent textures
  75866. * @param defines defines the string containing the defines to use to compile the shaders
  75867. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  75868. * @param onCompiled defines a function to call when the effect creation is successful
  75869. * @param onError defines a function to call when the effect creation has failed
  75870. * @param particleSystem the particle system you want to create the effect for
  75871. * @returns the new Effect
  75872. */
  75873. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  75874. }
  75875. }
  75876. module "babylonjs/Meshes/mesh" {
  75877. interface Mesh {
  75878. /**
  75879. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  75880. * @returns an array of IParticleSystem
  75881. */
  75882. getEmittedParticleSystems(): IParticleSystem[];
  75883. /**
  75884. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  75885. * @returns an array of IParticleSystem
  75886. */
  75887. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  75888. }
  75889. }
  75890. }
  75891. declare module "babylonjs/Particles/pointsCloudSystem" {
  75892. import { Color4 } from "babylonjs/Maths/math";
  75893. import { Mesh } from "babylonjs/Meshes/mesh";
  75894. import { Scene, IDisposable } from "babylonjs/scene";
  75895. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  75896. /** Defines the 4 color options */
  75897. export enum PointColor {
  75898. /** color value */
  75899. Color = 2,
  75900. /** uv value */
  75901. UV = 1,
  75902. /** random value */
  75903. Random = 0,
  75904. /** stated value */
  75905. Stated = 3
  75906. }
  75907. /**
  75908. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  75909. * 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.
  75910. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  75911. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  75912. *
  75913. * Full documentation here : TO BE ENTERED
  75914. */
  75915. export class PointsCloudSystem implements IDisposable {
  75916. /**
  75917. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  75918. * Example : var p = SPS.particles[i];
  75919. */
  75920. particles: CloudPoint[];
  75921. /**
  75922. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  75923. */
  75924. nbParticles: number;
  75925. /**
  75926. * This a counter for your own usage. It's not set by any SPS functions.
  75927. */
  75928. counter: number;
  75929. /**
  75930. * The PCS name. This name is also given to the underlying mesh.
  75931. */
  75932. name: string;
  75933. /**
  75934. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  75935. */
  75936. mesh: Mesh;
  75937. /**
  75938. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  75939. * Please read :
  75940. */
  75941. vars: any;
  75942. /**
  75943. * @hidden
  75944. */
  75945. _size: number;
  75946. private _scene;
  75947. private _promises;
  75948. private _positions;
  75949. private _indices;
  75950. private _normals;
  75951. private _colors;
  75952. private _uvs;
  75953. private _indices32;
  75954. private _positions32;
  75955. private _colors32;
  75956. private _uvs32;
  75957. private _updatable;
  75958. private _isVisibilityBoxLocked;
  75959. private _alwaysVisible;
  75960. private _groups;
  75961. private _groupCounter;
  75962. private _computeParticleColor;
  75963. private _computeParticleTexture;
  75964. private _computeParticleRotation;
  75965. private _computeBoundingBox;
  75966. private _isReady;
  75967. /**
  75968. * Creates a PCS (Points Cloud System) object
  75969. * @param name (String) is the PCS name, this will be the underlying mesh name
  75970. * @param pointSize (number) is the size for each point
  75971. * @param scene (Scene) is the scene in which the PCS is added
  75972. * @param options defines the options of the PCS e.g.
  75973. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  75974. */
  75975. constructor(name: string, pointSize: number, scene: Scene, options?: {
  75976. updatable?: boolean;
  75977. });
  75978. /**
  75979. * Builds the PCS underlying mesh. Returns a standard Mesh.
  75980. * If no points were added to the PCS, the returned mesh is just a single point.
  75981. * @returns a promise for the created mesh
  75982. */
  75983. buildMeshAsync(): Promise<Mesh>;
  75984. /**
  75985. * @hidden
  75986. */
  75987. private _buildMesh;
  75988. private _addParticle;
  75989. private _randomUnitVector;
  75990. private _getColorIndicesForCoord;
  75991. private _setPointsColorOrUV;
  75992. private _colorFromTexture;
  75993. private _calculateDensity;
  75994. /**
  75995. * Adds points to the PCS in random positions within a unit sphere
  75996. * @param nb (positive integer) the number of particles to be created from this model
  75997. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  75998. * @returns the number of groups in the system
  75999. */
  76000. addPoints(nb: number, pointFunction?: any): number;
  76001. /**
  76002. * Adds points to the PCS from the surface of the model shape
  76003. * @param mesh is any Mesh object that will be used as a surface model for the points
  76004. * @param nb (positive integer) the number of particles to be created from this model
  76005. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76006. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76007. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76008. * @returns the number of groups in the system
  76009. */
  76010. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76011. /**
  76012. * Adds points to the PCS inside the model shape
  76013. * @param mesh is any Mesh object that will be used as a surface model for the points
  76014. * @param nb (positive integer) the number of particles to be created from this model
  76015. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76016. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76017. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76018. * @returns the number of groups in the system
  76019. */
  76020. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76021. /**
  76022. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  76023. * This method calls `updateParticle()` for each particle of the SPS.
  76024. * For an animated SPS, it is usually called within the render loop.
  76025. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  76026. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  76027. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  76028. * @returns the PCS.
  76029. */
  76030. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  76031. /**
  76032. * Disposes the PCS.
  76033. */
  76034. dispose(): void;
  76035. /**
  76036. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  76037. * doc :
  76038. * @returns the PCS.
  76039. */
  76040. refreshVisibleSize(): PointsCloudSystem;
  76041. /**
  76042. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  76043. * @param size the size (float) of the visibility box
  76044. * note : this doesn't lock the PCS mesh bounding box.
  76045. * doc :
  76046. */
  76047. setVisibilityBox(size: number): void;
  76048. /**
  76049. * Gets whether the PCS is always visible or not
  76050. * doc :
  76051. */
  76052. get isAlwaysVisible(): boolean;
  76053. /**
  76054. * Sets the PCS as always visible or not
  76055. * doc :
  76056. */
  76057. set isAlwaysVisible(val: boolean);
  76058. /**
  76059. * Tells to `setParticles()` to compute the particle rotations or not
  76060. * Default value : false. The PCS is faster when it's set to false
  76061. * Note : particle rotations are only applied to parent particles
  76062. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  76063. */
  76064. set computeParticleRotation(val: boolean);
  76065. /**
  76066. * Tells to `setParticles()` to compute the particle colors or not.
  76067. * Default value : true. The PCS is faster when it's set to false.
  76068. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76069. */
  76070. set computeParticleColor(val: boolean);
  76071. set computeParticleTexture(val: boolean);
  76072. /**
  76073. * Gets if `setParticles()` computes the particle colors or not.
  76074. * Default value : false. The PCS is faster when it's set to false.
  76075. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76076. */
  76077. get computeParticleColor(): boolean;
  76078. /**
  76079. * Gets if `setParticles()` computes the particle textures or not.
  76080. * Default value : false. The PCS is faster when it's set to false.
  76081. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  76082. */
  76083. get computeParticleTexture(): boolean;
  76084. /**
  76085. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  76086. */
  76087. set computeBoundingBox(val: boolean);
  76088. /**
  76089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  76090. */
  76091. get computeBoundingBox(): boolean;
  76092. /**
  76093. * This function does nothing. It may be overwritten to set all the particle first values.
  76094. * The PCS doesn't call this function, you may have to call it by your own.
  76095. * doc :
  76096. */
  76097. initParticles(): void;
  76098. /**
  76099. * This function does nothing. It may be overwritten to recycle a particle
  76100. * The PCS doesn't call this function, you can to call it
  76101. * doc :
  76102. * @param particle The particle to recycle
  76103. * @returns the recycled particle
  76104. */
  76105. recycleParticle(particle: CloudPoint): CloudPoint;
  76106. /**
  76107. * Updates a particle : this function should be overwritten by the user.
  76108. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  76109. * doc :
  76110. * @example : just set a particle position or velocity and recycle conditions
  76111. * @param particle The particle to update
  76112. * @returns the updated particle
  76113. */
  76114. updateParticle(particle: CloudPoint): CloudPoint;
  76115. /**
  76116. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  76117. * This does nothing and may be overwritten by the user.
  76118. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76120. * @param update the boolean update value actually passed to setParticles()
  76121. */
  76122. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76123. /**
  76124. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  76125. * This will be passed three parameters.
  76126. * This does nothing and may be overwritten by the user.
  76127. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76128. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76129. * @param update the boolean update value actually passed to setParticles()
  76130. */
  76131. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76132. }
  76133. }
  76134. declare module "babylonjs/Particles/cloudPoint" {
  76135. import { Nullable } from "babylonjs/types";
  76136. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  76137. import { Mesh } from "babylonjs/Meshes/mesh";
  76138. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  76139. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  76140. /**
  76141. * Represents one particle of a points cloud system.
  76142. */
  76143. export class CloudPoint {
  76144. /**
  76145. * particle global index
  76146. */
  76147. idx: number;
  76148. /**
  76149. * The color of the particle
  76150. */
  76151. color: Nullable<Color4>;
  76152. /**
  76153. * The world space position of the particle.
  76154. */
  76155. position: Vector3;
  76156. /**
  76157. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  76158. */
  76159. rotation: Vector3;
  76160. /**
  76161. * The world space rotation quaternion of the particle.
  76162. */
  76163. rotationQuaternion: Nullable<Quaternion>;
  76164. /**
  76165. * The uv of the particle.
  76166. */
  76167. uv: Nullable<Vector2>;
  76168. /**
  76169. * The current speed of the particle.
  76170. */
  76171. velocity: Vector3;
  76172. /**
  76173. * The pivot point in the particle local space.
  76174. */
  76175. pivot: Vector3;
  76176. /**
  76177. * Must the particle be translated from its pivot point in its local space ?
  76178. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  76179. * Default : false
  76180. */
  76181. translateFromPivot: boolean;
  76182. /**
  76183. * Index of this particle in the global "positions" array (Internal use)
  76184. * @hidden
  76185. */
  76186. _pos: number;
  76187. /**
  76188. * @hidden Index of this particle in the global "indices" array (Internal use)
  76189. */
  76190. _ind: number;
  76191. /**
  76192. * Group this particle belongs to
  76193. */
  76194. _group: PointsGroup;
  76195. /**
  76196. * Group id of this particle
  76197. */
  76198. groupId: number;
  76199. /**
  76200. * Index of the particle in its group id (Internal use)
  76201. */
  76202. idxInGroup: number;
  76203. /**
  76204. * @hidden Particle BoundingInfo object (Internal use)
  76205. */
  76206. _boundingInfo: BoundingInfo;
  76207. /**
  76208. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  76209. */
  76210. _pcs: PointsCloudSystem;
  76211. /**
  76212. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  76213. */
  76214. _stillInvisible: boolean;
  76215. /**
  76216. * @hidden Last computed particle rotation matrix
  76217. */
  76218. _rotationMatrix: number[];
  76219. /**
  76220. * Parent particle Id, if any.
  76221. * Default null.
  76222. */
  76223. parentId: Nullable<number>;
  76224. /**
  76225. * @hidden Internal global position in the PCS.
  76226. */
  76227. _globalPosition: Vector3;
  76228. /**
  76229. * Creates a Point Cloud object.
  76230. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  76231. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  76232. * @param group (PointsGroup) is the group the particle belongs to
  76233. * @param groupId (integer) is the group identifier in the PCS.
  76234. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  76235. * @param pcs defines the PCS it is associated to
  76236. */
  76237. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  76238. /**
  76239. * get point size
  76240. */
  76241. get size(): Vector3;
  76242. /**
  76243. * Set point size
  76244. */
  76245. set size(scale: Vector3);
  76246. /**
  76247. * Legacy support, changed quaternion to rotationQuaternion
  76248. */
  76249. get quaternion(): Nullable<Quaternion>;
  76250. /**
  76251. * Legacy support, changed quaternion to rotationQuaternion
  76252. */
  76253. set quaternion(q: Nullable<Quaternion>);
  76254. /**
  76255. * Returns a boolean. True if the particle intersects a mesh, else false
  76256. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  76257. * @param target is the object (point or mesh) what the intersection is computed against
  76258. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  76259. * @returns true if it intersects
  76260. */
  76261. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  76262. /**
  76263. * get the rotation matrix of the particle
  76264. * @hidden
  76265. */
  76266. getRotationMatrix(m: Matrix): void;
  76267. }
  76268. /**
  76269. * Represents a group of points in a points cloud system
  76270. * * PCS internal tool, don't use it manually.
  76271. */
  76272. export class PointsGroup {
  76273. /**
  76274. * The group id
  76275. * @hidden
  76276. */
  76277. groupID: number;
  76278. /**
  76279. * image data for group (internal use)
  76280. * @hidden
  76281. */
  76282. _groupImageData: Nullable<ArrayBufferView>;
  76283. /**
  76284. * Image Width (internal use)
  76285. * @hidden
  76286. */
  76287. _groupImgWidth: number;
  76288. /**
  76289. * Image Height (internal use)
  76290. * @hidden
  76291. */
  76292. _groupImgHeight: number;
  76293. /**
  76294. * Custom position function (internal use)
  76295. * @hidden
  76296. */
  76297. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  76298. /**
  76299. * density per facet for surface points
  76300. * @hidden
  76301. */
  76302. _groupDensity: number[];
  76303. /**
  76304. * Only when points are colored by texture carries pointer to texture list array
  76305. * @hidden
  76306. */
  76307. _textureNb: number;
  76308. /**
  76309. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  76310. * PCS internal tool, don't use it manually.
  76311. * @hidden
  76312. */
  76313. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  76314. }
  76315. }
  76316. declare module "babylonjs/Particles/index" {
  76317. export * from "babylonjs/Particles/baseParticleSystem";
  76318. export * from "babylonjs/Particles/EmitterTypes/index";
  76319. export * from "babylonjs/Particles/gpuParticleSystem";
  76320. export * from "babylonjs/Particles/IParticleSystem";
  76321. export * from "babylonjs/Particles/particle";
  76322. export * from "babylonjs/Particles/particleHelper";
  76323. export * from "babylonjs/Particles/particleSystem";
  76324. import "babylonjs/Particles/particleSystemComponent";
  76325. export * from "babylonjs/Particles/particleSystemComponent";
  76326. export * from "babylonjs/Particles/particleSystemSet";
  76327. export * from "babylonjs/Particles/solidParticle";
  76328. export * from "babylonjs/Particles/solidParticleSystem";
  76329. export * from "babylonjs/Particles/cloudPoint";
  76330. export * from "babylonjs/Particles/pointsCloudSystem";
  76331. export * from "babylonjs/Particles/subEmitter";
  76332. }
  76333. declare module "babylonjs/Physics/physicsEngineComponent" {
  76334. import { Nullable } from "babylonjs/types";
  76335. import { Observable, Observer } from "babylonjs/Misc/observable";
  76336. import { Vector3 } from "babylonjs/Maths/math.vector";
  76337. import { Mesh } from "babylonjs/Meshes/mesh";
  76338. import { ISceneComponent } from "babylonjs/sceneComponent";
  76339. import { Scene } from "babylonjs/scene";
  76340. import { Node } from "babylonjs/node";
  76341. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  76342. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76343. module "babylonjs/scene" {
  76344. interface Scene {
  76345. /** @hidden (Backing field) */
  76346. _physicsEngine: Nullable<IPhysicsEngine>;
  76347. /** @hidden */
  76348. _physicsTimeAccumulator: number;
  76349. /**
  76350. * Gets the current physics engine
  76351. * @returns a IPhysicsEngine or null if none attached
  76352. */
  76353. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  76354. /**
  76355. * Enables physics to the current scene
  76356. * @param gravity defines the scene's gravity for the physics engine
  76357. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  76358. * @return a boolean indicating if the physics engine was initialized
  76359. */
  76360. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  76361. /**
  76362. * Disables and disposes the physics engine associated with the scene
  76363. */
  76364. disablePhysicsEngine(): void;
  76365. /**
  76366. * Gets a boolean indicating if there is an active physics engine
  76367. * @returns a boolean indicating if there is an active physics engine
  76368. */
  76369. isPhysicsEnabled(): boolean;
  76370. /**
  76371. * Deletes a physics compound impostor
  76372. * @param compound defines the compound to delete
  76373. */
  76374. deleteCompoundImpostor(compound: any): void;
  76375. /**
  76376. * An event triggered when physic simulation is about to be run
  76377. */
  76378. onBeforePhysicsObservable: Observable<Scene>;
  76379. /**
  76380. * An event triggered when physic simulation has been done
  76381. */
  76382. onAfterPhysicsObservable: Observable<Scene>;
  76383. }
  76384. }
  76385. module "babylonjs/Meshes/abstractMesh" {
  76386. interface AbstractMesh {
  76387. /** @hidden */
  76388. _physicsImpostor: Nullable<PhysicsImpostor>;
  76389. /**
  76390. * Gets or sets impostor used for physic simulation
  76391. * @see https://doc.babylonjs.com/features/physics_engine
  76392. */
  76393. physicsImpostor: Nullable<PhysicsImpostor>;
  76394. /**
  76395. * Gets the current physics impostor
  76396. * @see https://doc.babylonjs.com/features/physics_engine
  76397. * @returns a physics impostor or null
  76398. */
  76399. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  76400. /** Apply a physic impulse to the mesh
  76401. * @param force defines the force to apply
  76402. * @param contactPoint defines where to apply the force
  76403. * @returns the current mesh
  76404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76405. */
  76406. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  76407. /**
  76408. * Creates a physic joint between two meshes
  76409. * @param otherMesh defines the other mesh to use
  76410. * @param pivot1 defines the pivot to use on this mesh
  76411. * @param pivot2 defines the pivot to use on the other mesh
  76412. * @param options defines additional options (can be plugin dependent)
  76413. * @returns the current mesh
  76414. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  76415. */
  76416. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  76417. /** @hidden */
  76418. _disposePhysicsObserver: Nullable<Observer<Node>>;
  76419. }
  76420. }
  76421. /**
  76422. * Defines the physics engine scene component responsible to manage a physics engine
  76423. */
  76424. export class PhysicsEngineSceneComponent implements ISceneComponent {
  76425. /**
  76426. * The component name helpful to identify the component in the list of scene components.
  76427. */
  76428. readonly name: string;
  76429. /**
  76430. * The scene the component belongs to.
  76431. */
  76432. scene: Scene;
  76433. /**
  76434. * Creates a new instance of the component for the given scene
  76435. * @param scene Defines the scene to register the component in
  76436. */
  76437. constructor(scene: Scene);
  76438. /**
  76439. * Registers the component in a given scene
  76440. */
  76441. register(): void;
  76442. /**
  76443. * Rebuilds the elements related to this component in case of
  76444. * context lost for instance.
  76445. */
  76446. rebuild(): void;
  76447. /**
  76448. * Disposes the component and the associated ressources
  76449. */
  76450. dispose(): void;
  76451. }
  76452. }
  76453. declare module "babylonjs/Physics/physicsHelper" {
  76454. import { Nullable } from "babylonjs/types";
  76455. import { Vector3 } from "babylonjs/Maths/math.vector";
  76456. import { Mesh } from "babylonjs/Meshes/mesh";
  76457. import { Scene } from "babylonjs/scene";
  76458. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76459. /**
  76460. * A helper for physics simulations
  76461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76462. */
  76463. export class PhysicsHelper {
  76464. private _scene;
  76465. private _physicsEngine;
  76466. /**
  76467. * Initializes the Physics helper
  76468. * @param scene Babylon.js scene
  76469. */
  76470. constructor(scene: Scene);
  76471. /**
  76472. * Applies a radial explosion impulse
  76473. * @param origin the origin of the explosion
  76474. * @param radiusOrEventOptions the radius or the options of radial explosion
  76475. * @param strength the explosion strength
  76476. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76477. * @returns A physics radial explosion event, or null
  76478. */
  76479. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76480. /**
  76481. * Applies a radial explosion force
  76482. * @param origin the origin of the explosion
  76483. * @param radiusOrEventOptions the radius or the options of radial explosion
  76484. * @param strength the explosion strength
  76485. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76486. * @returns A physics radial explosion event, or null
  76487. */
  76488. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76489. /**
  76490. * Creates a gravitational field
  76491. * @param origin the origin of the explosion
  76492. * @param radiusOrEventOptions the radius or the options of radial explosion
  76493. * @param strength the explosion strength
  76494. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76495. * @returns A physics gravitational field event, or null
  76496. */
  76497. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  76498. /**
  76499. * Creates a physics updraft event
  76500. * @param origin the origin of the updraft
  76501. * @param radiusOrEventOptions the radius or the options of the updraft
  76502. * @param strength the strength of the updraft
  76503. * @param height the height of the updraft
  76504. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  76505. * @returns A physics updraft event, or null
  76506. */
  76507. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  76508. /**
  76509. * Creates a physics vortex event
  76510. * @param origin the of the vortex
  76511. * @param radiusOrEventOptions the radius or the options of the vortex
  76512. * @param strength the strength of the vortex
  76513. * @param height the height of the vortex
  76514. * @returns a Physics vortex event, or null
  76515. * A physics vortex event or null
  76516. */
  76517. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  76518. }
  76519. /**
  76520. * Represents a physics radial explosion event
  76521. */
  76522. class PhysicsRadialExplosionEvent {
  76523. private _scene;
  76524. private _options;
  76525. private _sphere;
  76526. private _dataFetched;
  76527. /**
  76528. * Initializes a radial explosioin event
  76529. * @param _scene BabylonJS scene
  76530. * @param _options The options for the vortex event
  76531. */
  76532. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  76533. /**
  76534. * Returns the data related to the radial explosion event (sphere).
  76535. * @returns The radial explosion event data
  76536. */
  76537. getData(): PhysicsRadialExplosionEventData;
  76538. /**
  76539. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  76540. * @param impostor A physics imposter
  76541. * @param origin the origin of the explosion
  76542. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  76543. */
  76544. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  76545. /**
  76546. * Triggers affecterd impostors callbacks
  76547. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  76548. */
  76549. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  76550. /**
  76551. * Disposes the sphere.
  76552. * @param force Specifies if the sphere should be disposed by force
  76553. */
  76554. dispose(force?: boolean): void;
  76555. /*** Helpers ***/
  76556. private _prepareSphere;
  76557. private _intersectsWithSphere;
  76558. }
  76559. /**
  76560. * Represents a gravitational field event
  76561. */
  76562. class PhysicsGravitationalFieldEvent {
  76563. private _physicsHelper;
  76564. private _scene;
  76565. private _origin;
  76566. private _options;
  76567. private _tickCallback;
  76568. private _sphere;
  76569. private _dataFetched;
  76570. /**
  76571. * Initializes the physics gravitational field event
  76572. * @param _physicsHelper A physics helper
  76573. * @param _scene BabylonJS scene
  76574. * @param _origin The origin position of the gravitational field event
  76575. * @param _options The options for the vortex event
  76576. */
  76577. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  76578. /**
  76579. * Returns the data related to the gravitational field event (sphere).
  76580. * @returns A gravitational field event
  76581. */
  76582. getData(): PhysicsGravitationalFieldEventData;
  76583. /**
  76584. * Enables the gravitational field.
  76585. */
  76586. enable(): void;
  76587. /**
  76588. * Disables the gravitational field.
  76589. */
  76590. disable(): void;
  76591. /**
  76592. * Disposes the sphere.
  76593. * @param force The force to dispose from the gravitational field event
  76594. */
  76595. dispose(force?: boolean): void;
  76596. private _tick;
  76597. }
  76598. /**
  76599. * Represents a physics updraft event
  76600. */
  76601. class PhysicsUpdraftEvent {
  76602. private _scene;
  76603. private _origin;
  76604. private _options;
  76605. private _physicsEngine;
  76606. private _originTop;
  76607. private _originDirection;
  76608. private _tickCallback;
  76609. private _cylinder;
  76610. private _cylinderPosition;
  76611. private _dataFetched;
  76612. /**
  76613. * Initializes the physics updraft event
  76614. * @param _scene BabylonJS scene
  76615. * @param _origin The origin position of the updraft
  76616. * @param _options The options for the updraft event
  76617. */
  76618. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  76619. /**
  76620. * Returns the data related to the updraft event (cylinder).
  76621. * @returns A physics updraft event
  76622. */
  76623. getData(): PhysicsUpdraftEventData;
  76624. /**
  76625. * Enables the updraft.
  76626. */
  76627. enable(): void;
  76628. /**
  76629. * Disables the updraft.
  76630. */
  76631. disable(): void;
  76632. /**
  76633. * Disposes the cylinder.
  76634. * @param force Specifies if the updraft should be disposed by force
  76635. */
  76636. dispose(force?: boolean): void;
  76637. private getImpostorHitData;
  76638. private _tick;
  76639. /*** Helpers ***/
  76640. private _prepareCylinder;
  76641. private _intersectsWithCylinder;
  76642. }
  76643. /**
  76644. * Represents a physics vortex event
  76645. */
  76646. class PhysicsVortexEvent {
  76647. private _scene;
  76648. private _origin;
  76649. private _options;
  76650. private _physicsEngine;
  76651. private _originTop;
  76652. private _tickCallback;
  76653. private _cylinder;
  76654. private _cylinderPosition;
  76655. private _dataFetched;
  76656. /**
  76657. * Initializes the physics vortex event
  76658. * @param _scene The BabylonJS scene
  76659. * @param _origin The origin position of the vortex
  76660. * @param _options The options for the vortex event
  76661. */
  76662. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  76663. /**
  76664. * Returns the data related to the vortex event (cylinder).
  76665. * @returns The physics vortex event data
  76666. */
  76667. getData(): PhysicsVortexEventData;
  76668. /**
  76669. * Enables the vortex.
  76670. */
  76671. enable(): void;
  76672. /**
  76673. * Disables the cortex.
  76674. */
  76675. disable(): void;
  76676. /**
  76677. * Disposes the sphere.
  76678. * @param force
  76679. */
  76680. dispose(force?: boolean): void;
  76681. private getImpostorHitData;
  76682. private _tick;
  76683. /*** Helpers ***/
  76684. private _prepareCylinder;
  76685. private _intersectsWithCylinder;
  76686. }
  76687. /**
  76688. * Options fot the radial explosion event
  76689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76690. */
  76691. export class PhysicsRadialExplosionEventOptions {
  76692. /**
  76693. * The radius of the sphere for the radial explosion.
  76694. */
  76695. radius: number;
  76696. /**
  76697. * The strenth of the explosion.
  76698. */
  76699. strength: number;
  76700. /**
  76701. * The strenght of the force in correspondence to the distance of the affected object
  76702. */
  76703. falloff: PhysicsRadialImpulseFalloff;
  76704. /**
  76705. * Sphere options for the radial explosion.
  76706. */
  76707. sphere: {
  76708. segments: number;
  76709. diameter: number;
  76710. };
  76711. /**
  76712. * Sphere options for the radial explosion.
  76713. */
  76714. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  76715. }
  76716. /**
  76717. * Options fot the updraft event
  76718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76719. */
  76720. export class PhysicsUpdraftEventOptions {
  76721. /**
  76722. * The radius of the cylinder for the vortex
  76723. */
  76724. radius: number;
  76725. /**
  76726. * The strenth of the updraft.
  76727. */
  76728. strength: number;
  76729. /**
  76730. * The height of the cylinder for the updraft.
  76731. */
  76732. height: number;
  76733. /**
  76734. * The mode for the the updraft.
  76735. */
  76736. updraftMode: PhysicsUpdraftMode;
  76737. }
  76738. /**
  76739. * Options fot the vortex event
  76740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76741. */
  76742. export class PhysicsVortexEventOptions {
  76743. /**
  76744. * The radius of the cylinder for the vortex
  76745. */
  76746. radius: number;
  76747. /**
  76748. * The strenth of the vortex.
  76749. */
  76750. strength: number;
  76751. /**
  76752. * The height of the cylinder for the vortex.
  76753. */
  76754. height: number;
  76755. /**
  76756. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  76757. */
  76758. centripetalForceThreshold: number;
  76759. /**
  76760. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  76761. */
  76762. centripetalForceMultiplier: number;
  76763. /**
  76764. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  76765. */
  76766. centrifugalForceMultiplier: number;
  76767. /**
  76768. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  76769. */
  76770. updraftForceMultiplier: number;
  76771. }
  76772. /**
  76773. * The strenght of the force in correspondence to the distance of the affected object
  76774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76775. */
  76776. export enum PhysicsRadialImpulseFalloff {
  76777. /** Defines that impulse is constant in strength across it's whole radius */
  76778. Constant = 0,
  76779. /** Defines that impulse gets weaker if it's further from the origin */
  76780. Linear = 1
  76781. }
  76782. /**
  76783. * The strength of the force in correspondence to the distance of the affected object
  76784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76785. */
  76786. export enum PhysicsUpdraftMode {
  76787. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  76788. Center = 0,
  76789. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  76790. Perpendicular = 1
  76791. }
  76792. /**
  76793. * Interface for a physics hit data
  76794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76795. */
  76796. export interface PhysicsHitData {
  76797. /**
  76798. * The force applied at the contact point
  76799. */
  76800. force: Vector3;
  76801. /**
  76802. * The contact point
  76803. */
  76804. contactPoint: Vector3;
  76805. /**
  76806. * The distance from the origin to the contact point
  76807. */
  76808. distanceFromOrigin: number;
  76809. }
  76810. /**
  76811. * Interface for radial explosion event data
  76812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76813. */
  76814. export interface PhysicsRadialExplosionEventData {
  76815. /**
  76816. * A sphere used for the radial explosion event
  76817. */
  76818. sphere: Mesh;
  76819. }
  76820. /**
  76821. * Interface for gravitational field event data
  76822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76823. */
  76824. export interface PhysicsGravitationalFieldEventData {
  76825. /**
  76826. * A sphere mesh used for the gravitational field event
  76827. */
  76828. sphere: Mesh;
  76829. }
  76830. /**
  76831. * Interface for updraft event data
  76832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76833. */
  76834. export interface PhysicsUpdraftEventData {
  76835. /**
  76836. * A cylinder used for the updraft event
  76837. */
  76838. cylinder: Mesh;
  76839. }
  76840. /**
  76841. * Interface for vortex event data
  76842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76843. */
  76844. export interface PhysicsVortexEventData {
  76845. /**
  76846. * A cylinder used for the vortex event
  76847. */
  76848. cylinder: Mesh;
  76849. }
  76850. /**
  76851. * Interface for an affected physics impostor
  76852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76853. */
  76854. export interface PhysicsAffectedImpostorWithData {
  76855. /**
  76856. * The impostor affected by the effect
  76857. */
  76858. impostor: PhysicsImpostor;
  76859. /**
  76860. * The data about the hit/horce from the explosion
  76861. */
  76862. hitData: PhysicsHitData;
  76863. }
  76864. }
  76865. declare module "babylonjs/Physics/Plugins/index" {
  76866. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  76867. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  76868. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  76869. }
  76870. declare module "babylonjs/Physics/index" {
  76871. export * from "babylonjs/Physics/IPhysicsEngine";
  76872. export * from "babylonjs/Physics/physicsEngine";
  76873. export * from "babylonjs/Physics/physicsEngineComponent";
  76874. export * from "babylonjs/Physics/physicsHelper";
  76875. export * from "babylonjs/Physics/physicsImpostor";
  76876. export * from "babylonjs/Physics/physicsJoint";
  76877. export * from "babylonjs/Physics/Plugins/index";
  76878. }
  76879. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  76880. /** @hidden */
  76881. export var blackAndWhitePixelShader: {
  76882. name: string;
  76883. shader: string;
  76884. };
  76885. }
  76886. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  76887. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76888. import { Camera } from "babylonjs/Cameras/camera";
  76889. import { Engine } from "babylonjs/Engines/engine";
  76890. import "babylonjs/Shaders/blackAndWhite.fragment";
  76891. import { Nullable } from "babylonjs/types";
  76892. import { Scene } from "babylonjs/scene";
  76893. /**
  76894. * Post process used to render in black and white
  76895. */
  76896. export class BlackAndWhitePostProcess extends PostProcess {
  76897. /**
  76898. * Linear about to convert he result to black and white (default: 1)
  76899. */
  76900. degree: number;
  76901. /**
  76902. * Gets a string identifying the name of the class
  76903. * @returns "BlackAndWhitePostProcess" string
  76904. */
  76905. getClassName(): string;
  76906. /**
  76907. * Creates a black and white post process
  76908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  76909. * @param name The name of the effect.
  76910. * @param options The required width/height ratio to downsize to before computing the render pass.
  76911. * @param camera The camera to apply the render pass to.
  76912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76913. * @param engine The engine which the post process will be applied. (default: current engine)
  76914. * @param reusable If the post process can be reused on the same frame. (default: false)
  76915. */
  76916. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76917. /** @hidden */
  76918. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  76919. }
  76920. }
  76921. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  76922. import { Nullable } from "babylonjs/types";
  76923. import { Camera } from "babylonjs/Cameras/camera";
  76924. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76925. import { Engine } from "babylonjs/Engines/engine";
  76926. /**
  76927. * This represents a set of one or more post processes in Babylon.
  76928. * A post process can be used to apply a shader to a texture after it is rendered.
  76929. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  76930. */
  76931. export class PostProcessRenderEffect {
  76932. private _postProcesses;
  76933. private _getPostProcesses;
  76934. private _singleInstance;
  76935. private _cameras;
  76936. private _indicesForCamera;
  76937. /**
  76938. * Name of the effect
  76939. * @hidden
  76940. */
  76941. _name: string;
  76942. /**
  76943. * Instantiates a post process render effect.
  76944. * A post process can be used to apply a shader to a texture after it is rendered.
  76945. * @param engine The engine the effect is tied to
  76946. * @param name The name of the effect
  76947. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  76948. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  76949. */
  76950. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  76951. /**
  76952. * Checks if all the post processes in the effect are supported.
  76953. */
  76954. get isSupported(): boolean;
  76955. /**
  76956. * Updates the current state of the effect
  76957. * @hidden
  76958. */
  76959. _update(): void;
  76960. /**
  76961. * Attaches the effect on cameras
  76962. * @param cameras The camera to attach to.
  76963. * @hidden
  76964. */
  76965. _attachCameras(cameras: Camera): void;
  76966. /**
  76967. * Attaches the effect on cameras
  76968. * @param cameras The camera to attach to.
  76969. * @hidden
  76970. */
  76971. _attachCameras(cameras: Camera[]): void;
  76972. /**
  76973. * Detaches the effect on cameras
  76974. * @param cameras The camera to detatch from.
  76975. * @hidden
  76976. */
  76977. _detachCameras(cameras: Camera): void;
  76978. /**
  76979. * Detatches the effect on cameras
  76980. * @param cameras The camera to detatch from.
  76981. * @hidden
  76982. */
  76983. _detachCameras(cameras: Camera[]): void;
  76984. /**
  76985. * Enables the effect on given cameras
  76986. * @param cameras The camera to enable.
  76987. * @hidden
  76988. */
  76989. _enable(cameras: Camera): void;
  76990. /**
  76991. * Enables the effect on given cameras
  76992. * @param cameras The camera to enable.
  76993. * @hidden
  76994. */
  76995. _enable(cameras: Nullable<Camera[]>): void;
  76996. /**
  76997. * Disables the effect on the given cameras
  76998. * @param cameras The camera to disable.
  76999. * @hidden
  77000. */
  77001. _disable(cameras: Camera): void;
  77002. /**
  77003. * Disables the effect on the given cameras
  77004. * @param cameras The camera to disable.
  77005. * @hidden
  77006. */
  77007. _disable(cameras: Nullable<Camera[]>): void;
  77008. /**
  77009. * Gets a list of the post processes contained in the effect.
  77010. * @param camera The camera to get the post processes on.
  77011. * @returns The list of the post processes in the effect.
  77012. */
  77013. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  77014. }
  77015. }
  77016. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  77017. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77018. /** @hidden */
  77019. export var extractHighlightsPixelShader: {
  77020. name: string;
  77021. shader: string;
  77022. };
  77023. }
  77024. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  77025. import { Nullable } from "babylonjs/types";
  77026. import { Camera } from "babylonjs/Cameras/camera";
  77027. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77028. import { Engine } from "babylonjs/Engines/engine";
  77029. import "babylonjs/Shaders/extractHighlights.fragment";
  77030. /**
  77031. * 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.
  77032. */
  77033. export class ExtractHighlightsPostProcess extends PostProcess {
  77034. /**
  77035. * The luminance threshold, pixels below this value will be set to black.
  77036. */
  77037. threshold: number;
  77038. /** @hidden */
  77039. _exposure: number;
  77040. /**
  77041. * Post process which has the input texture to be used when performing highlight extraction
  77042. * @hidden
  77043. */
  77044. _inputPostProcess: Nullable<PostProcess>;
  77045. /**
  77046. * Gets a string identifying the name of the class
  77047. * @returns "ExtractHighlightsPostProcess" string
  77048. */
  77049. getClassName(): string;
  77050. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77051. }
  77052. }
  77053. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  77054. /** @hidden */
  77055. export var bloomMergePixelShader: {
  77056. name: string;
  77057. shader: string;
  77058. };
  77059. }
  77060. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  77061. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77062. import { Nullable } from "babylonjs/types";
  77063. import { Engine } from "babylonjs/Engines/engine";
  77064. import { Camera } from "babylonjs/Cameras/camera";
  77065. import "babylonjs/Shaders/bloomMerge.fragment";
  77066. /**
  77067. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77068. */
  77069. export class BloomMergePostProcess extends PostProcess {
  77070. /** Weight of the bloom to be added to the original input. */
  77071. weight: number;
  77072. /**
  77073. * Gets a string identifying the name of the class
  77074. * @returns "BloomMergePostProcess" string
  77075. */
  77076. getClassName(): string;
  77077. /**
  77078. * Creates a new instance of @see BloomMergePostProcess
  77079. * @param name The name of the effect.
  77080. * @param originalFromInput Post process which's input will be used for the merge.
  77081. * @param blurred Blurred highlights post process which's output will be used.
  77082. * @param weight Weight of the bloom to be added to the original input.
  77083. * @param options The required width/height ratio to downsize to before computing the render pass.
  77084. * @param camera The camera to apply the render pass to.
  77085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77086. * @param engine The engine which the post process will be applied. (default: current engine)
  77087. * @param reusable If the post process can be reused on the same frame. (default: false)
  77088. * @param textureType Type of textures used when performing the post process. (default: 0)
  77089. * @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)
  77090. */
  77091. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  77092. /** Weight of the bloom to be added to the original input. */
  77093. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77094. }
  77095. }
  77096. declare module "babylonjs/PostProcesses/bloomEffect" {
  77097. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77098. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77099. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77100. import { Camera } from "babylonjs/Cameras/camera";
  77101. import { Scene } from "babylonjs/scene";
  77102. /**
  77103. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  77104. */
  77105. export class BloomEffect extends PostProcessRenderEffect {
  77106. private bloomScale;
  77107. /**
  77108. * @hidden Internal
  77109. */
  77110. _effects: Array<PostProcess>;
  77111. /**
  77112. * @hidden Internal
  77113. */
  77114. _downscale: ExtractHighlightsPostProcess;
  77115. private _blurX;
  77116. private _blurY;
  77117. private _merge;
  77118. /**
  77119. * The luminance threshold to find bright areas of the image to bloom.
  77120. */
  77121. get threshold(): number;
  77122. set threshold(value: number);
  77123. /**
  77124. * The strength of the bloom.
  77125. */
  77126. get weight(): number;
  77127. set weight(value: number);
  77128. /**
  77129. * Specifies the size of the bloom blur kernel, relative to the final output size
  77130. */
  77131. get kernel(): number;
  77132. set kernel(value: number);
  77133. /**
  77134. * Creates a new instance of @see BloomEffect
  77135. * @param scene The scene the effect belongs to.
  77136. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  77137. * @param bloomKernel The size of the kernel to be used when applying the blur.
  77138. * @param bloomWeight The the strength of bloom.
  77139. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77140. * @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)
  77141. */
  77142. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  77143. /**
  77144. * Disposes each of the internal effects for a given camera.
  77145. * @param camera The camera to dispose the effect on.
  77146. */
  77147. disposeEffects(camera: Camera): void;
  77148. /**
  77149. * @hidden Internal
  77150. */
  77151. _updateEffects(): void;
  77152. /**
  77153. * Internal
  77154. * @returns if all the contained post processes are ready.
  77155. * @hidden
  77156. */
  77157. _isReady(): boolean;
  77158. }
  77159. }
  77160. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  77161. /** @hidden */
  77162. export var chromaticAberrationPixelShader: {
  77163. name: string;
  77164. shader: string;
  77165. };
  77166. }
  77167. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  77168. import { Vector2 } from "babylonjs/Maths/math.vector";
  77169. import { Nullable } from "babylonjs/types";
  77170. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77171. import { Camera } from "babylonjs/Cameras/camera";
  77172. import { Engine } from "babylonjs/Engines/engine";
  77173. import "babylonjs/Shaders/chromaticAberration.fragment";
  77174. import { Scene } from "babylonjs/scene";
  77175. /**
  77176. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  77177. */
  77178. export class ChromaticAberrationPostProcess extends PostProcess {
  77179. /**
  77180. * The amount of seperation of rgb channels (default: 30)
  77181. */
  77182. aberrationAmount: number;
  77183. /**
  77184. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  77185. */
  77186. radialIntensity: number;
  77187. /**
  77188. * 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))
  77189. */
  77190. direction: Vector2;
  77191. /**
  77192. * 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))
  77193. */
  77194. centerPosition: Vector2;
  77195. /** The width of the screen to apply the effect on */
  77196. screenWidth: number;
  77197. /** The height of the screen to apply the effect on */
  77198. screenHeight: number;
  77199. /**
  77200. * Gets a string identifying the name of the class
  77201. * @returns "ChromaticAberrationPostProcess" string
  77202. */
  77203. getClassName(): string;
  77204. /**
  77205. * Creates a new instance ChromaticAberrationPostProcess
  77206. * @param name The name of the effect.
  77207. * @param screenWidth The width of the screen to apply the effect on.
  77208. * @param screenHeight The height of the screen to apply the effect on.
  77209. * @param options The required width/height ratio to downsize to before computing the render pass.
  77210. * @param camera The camera to apply the render pass to.
  77211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77212. * @param engine The engine which the post process will be applied. (default: current engine)
  77213. * @param reusable If the post process can be reused on the same frame. (default: false)
  77214. * @param textureType Type of textures used when performing the post process. (default: 0)
  77215. * @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)
  77216. */
  77217. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77218. /** @hidden */
  77219. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  77220. }
  77221. }
  77222. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  77223. /** @hidden */
  77224. export var circleOfConfusionPixelShader: {
  77225. name: string;
  77226. shader: string;
  77227. };
  77228. }
  77229. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  77230. import { Nullable } from "babylonjs/types";
  77231. import { Engine } from "babylonjs/Engines/engine";
  77232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77233. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77234. import { Camera } from "babylonjs/Cameras/camera";
  77235. import "babylonjs/Shaders/circleOfConfusion.fragment";
  77236. /**
  77237. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  77238. */
  77239. export class CircleOfConfusionPostProcess extends PostProcess {
  77240. /**
  77241. * 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.
  77242. */
  77243. lensSize: number;
  77244. /**
  77245. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77246. */
  77247. fStop: number;
  77248. /**
  77249. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77250. */
  77251. focusDistance: number;
  77252. /**
  77253. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  77254. */
  77255. focalLength: number;
  77256. /**
  77257. * Gets a string identifying the name of the class
  77258. * @returns "CircleOfConfusionPostProcess" string
  77259. */
  77260. getClassName(): string;
  77261. private _depthTexture;
  77262. /**
  77263. * Creates a new instance CircleOfConfusionPostProcess
  77264. * @param name The name of the effect.
  77265. * @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.
  77266. * @param options The required width/height ratio to downsize to before computing the render pass.
  77267. * @param camera The camera to apply the render pass to.
  77268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77269. * @param engine The engine which the post process will be applied. (default: current engine)
  77270. * @param reusable If the post process can be reused on the same frame. (default: false)
  77271. * @param textureType Type of textures used when performing the post process. (default: 0)
  77272. * @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)
  77273. */
  77274. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77275. /**
  77276. * 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.
  77277. */
  77278. set depthTexture(value: RenderTargetTexture);
  77279. }
  77280. }
  77281. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  77282. /** @hidden */
  77283. export var colorCorrectionPixelShader: {
  77284. name: string;
  77285. shader: string;
  77286. };
  77287. }
  77288. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  77289. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77290. import { Engine } from "babylonjs/Engines/engine";
  77291. import { Camera } from "babylonjs/Cameras/camera";
  77292. import "babylonjs/Shaders/colorCorrection.fragment";
  77293. import { Nullable } from "babylonjs/types";
  77294. import { Scene } from "babylonjs/scene";
  77295. /**
  77296. *
  77297. * This post-process allows the modification of rendered colors by using
  77298. * a 'look-up table' (LUT). This effect is also called Color Grading.
  77299. *
  77300. * The object needs to be provided an url to a texture containing the color
  77301. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  77302. * Use an image editing software to tweak the LUT to match your needs.
  77303. *
  77304. * For an example of a color LUT, see here:
  77305. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  77306. * For explanations on color grading, see here:
  77307. * @see http://udn.epicgames.com/Three/ColorGrading.html
  77308. *
  77309. */
  77310. export class ColorCorrectionPostProcess extends PostProcess {
  77311. private _colorTableTexture;
  77312. /**
  77313. * Gets the color table url used to create the LUT texture
  77314. */
  77315. colorTableUrl: string;
  77316. /**
  77317. * Gets a string identifying the name of the class
  77318. * @returns "ColorCorrectionPostProcess" string
  77319. */
  77320. getClassName(): string;
  77321. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77322. /** @hidden */
  77323. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  77324. }
  77325. }
  77326. declare module "babylonjs/Shaders/convolution.fragment" {
  77327. /** @hidden */
  77328. export var convolutionPixelShader: {
  77329. name: string;
  77330. shader: string;
  77331. };
  77332. }
  77333. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  77334. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77335. import { Nullable } from "babylonjs/types";
  77336. import { Camera } from "babylonjs/Cameras/camera";
  77337. import { Engine } from "babylonjs/Engines/engine";
  77338. import "babylonjs/Shaders/convolution.fragment";
  77339. import { Scene } from "babylonjs/scene";
  77340. /**
  77341. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  77342. * input texture to perform effects such as edge detection or sharpening
  77343. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  77344. */
  77345. export class ConvolutionPostProcess extends PostProcess {
  77346. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  77347. kernel: number[];
  77348. /**
  77349. * Gets a string identifying the name of the class
  77350. * @returns "ConvolutionPostProcess" string
  77351. */
  77352. getClassName(): string;
  77353. /**
  77354. * Creates a new instance ConvolutionPostProcess
  77355. * @param name The name of the effect.
  77356. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  77357. * @param options The required width/height ratio to downsize to before computing the render pass.
  77358. * @param camera The camera to apply the render pass to.
  77359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77360. * @param engine The engine which the post process will be applied. (default: current engine)
  77361. * @param reusable If the post process can be reused on the same frame. (default: false)
  77362. * @param textureType Type of textures used when performing the post process. (default: 0)
  77363. */
  77364. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77365. /** @hidden */
  77366. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  77367. /**
  77368. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77369. */
  77370. static EdgeDetect0Kernel: number[];
  77371. /**
  77372. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77373. */
  77374. static EdgeDetect1Kernel: number[];
  77375. /**
  77376. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77377. */
  77378. static EdgeDetect2Kernel: number[];
  77379. /**
  77380. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77381. */
  77382. static SharpenKernel: number[];
  77383. /**
  77384. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77385. */
  77386. static EmbossKernel: number[];
  77387. /**
  77388. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77389. */
  77390. static GaussianKernel: number[];
  77391. }
  77392. }
  77393. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  77394. import { Nullable } from "babylonjs/types";
  77395. import { Vector2 } from "babylonjs/Maths/math.vector";
  77396. import { Camera } from "babylonjs/Cameras/camera";
  77397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77398. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  77399. import { Engine } from "babylonjs/Engines/engine";
  77400. import { Scene } from "babylonjs/scene";
  77401. /**
  77402. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  77403. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  77404. * based on samples that have a large difference in distance than the center pixel.
  77405. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  77406. */
  77407. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  77408. /**
  77409. * The direction the blur should be applied
  77410. */
  77411. direction: Vector2;
  77412. /**
  77413. * Gets a string identifying the name of the class
  77414. * @returns "DepthOfFieldBlurPostProcess" string
  77415. */
  77416. getClassName(): string;
  77417. /**
  77418. * Creates a new instance CircleOfConfusionPostProcess
  77419. * @param name The name of the effect.
  77420. * @param scene The scene the effect belongs to.
  77421. * @param direction The direction the blur should be applied.
  77422. * @param kernel The size of the kernel used to blur.
  77423. * @param options The required width/height ratio to downsize to before computing the render pass.
  77424. * @param camera The camera to apply the render pass to.
  77425. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  77426. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  77427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77428. * @param engine The engine which the post process will be applied. (default: current engine)
  77429. * @param reusable If the post process can be reused on the same frame. (default: false)
  77430. * @param textureType Type of textures used when performing the post process. (default: 0)
  77431. * @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)
  77432. */
  77433. 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);
  77434. }
  77435. }
  77436. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  77437. /** @hidden */
  77438. export var depthOfFieldMergePixelShader: {
  77439. name: string;
  77440. shader: string;
  77441. };
  77442. }
  77443. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  77444. import { Nullable } from "babylonjs/types";
  77445. import { Camera } from "babylonjs/Cameras/camera";
  77446. import { Effect } from "babylonjs/Materials/effect";
  77447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77448. import { Engine } from "babylonjs/Engines/engine";
  77449. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  77450. /**
  77451. * Options to be set when merging outputs from the default pipeline.
  77452. */
  77453. export class DepthOfFieldMergePostProcessOptions {
  77454. /**
  77455. * The original image to merge on top of
  77456. */
  77457. originalFromInput: PostProcess;
  77458. /**
  77459. * Parameters to perform the merge of the depth of field effect
  77460. */
  77461. depthOfField?: {
  77462. circleOfConfusion: PostProcess;
  77463. blurSteps: Array<PostProcess>;
  77464. };
  77465. /**
  77466. * Parameters to perform the merge of bloom effect
  77467. */
  77468. bloom?: {
  77469. blurred: PostProcess;
  77470. weight: number;
  77471. };
  77472. }
  77473. /**
  77474. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77475. */
  77476. export class DepthOfFieldMergePostProcess extends PostProcess {
  77477. private blurSteps;
  77478. /**
  77479. * Gets a string identifying the name of the class
  77480. * @returns "DepthOfFieldMergePostProcess" string
  77481. */
  77482. getClassName(): string;
  77483. /**
  77484. * Creates a new instance of DepthOfFieldMergePostProcess
  77485. * @param name The name of the effect.
  77486. * @param originalFromInput Post process which's input will be used for the merge.
  77487. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  77488. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  77489. * @param options The required width/height ratio to downsize to before computing the render pass.
  77490. * @param camera The camera to apply the render pass to.
  77491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77492. * @param engine The engine which the post process will be applied. (default: current engine)
  77493. * @param reusable If the post process can be reused on the same frame. (default: false)
  77494. * @param textureType Type of textures used when performing the post process. (default: 0)
  77495. * @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)
  77496. */
  77497. 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);
  77498. /**
  77499. * Updates the effect with the current post process compile time values and recompiles the shader.
  77500. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  77501. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  77502. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  77503. * @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
  77504. * @param onCompiled Called when the shader has been compiled.
  77505. * @param onError Called if there is an error when compiling a shader.
  77506. */
  77507. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  77508. }
  77509. }
  77510. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  77511. import { Nullable } from "babylonjs/types";
  77512. import { Camera } from "babylonjs/Cameras/camera";
  77513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77515. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77516. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77517. import { Scene } from "babylonjs/scene";
  77518. /**
  77519. * Specifies the level of max blur that should be applied when using the depth of field effect
  77520. */
  77521. export enum DepthOfFieldEffectBlurLevel {
  77522. /**
  77523. * Subtle blur
  77524. */
  77525. Low = 0,
  77526. /**
  77527. * Medium blur
  77528. */
  77529. Medium = 1,
  77530. /**
  77531. * Large blur
  77532. */
  77533. High = 2
  77534. }
  77535. /**
  77536. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  77537. */
  77538. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  77539. private _circleOfConfusion;
  77540. /**
  77541. * @hidden Internal, blurs from high to low
  77542. */
  77543. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  77544. private _depthOfFieldBlurY;
  77545. private _dofMerge;
  77546. /**
  77547. * @hidden Internal post processes in depth of field effect
  77548. */
  77549. _effects: Array<PostProcess>;
  77550. /**
  77551. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  77552. */
  77553. set focalLength(value: number);
  77554. get focalLength(): number;
  77555. /**
  77556. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77557. */
  77558. set fStop(value: number);
  77559. get fStop(): number;
  77560. /**
  77561. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77562. */
  77563. set focusDistance(value: number);
  77564. get focusDistance(): number;
  77565. /**
  77566. * 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.
  77567. */
  77568. set lensSize(value: number);
  77569. get lensSize(): number;
  77570. /**
  77571. * Creates a new instance DepthOfFieldEffect
  77572. * @param scene The scene the effect belongs to.
  77573. * @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.
  77574. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77575. * @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)
  77576. */
  77577. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  77578. /**
  77579. * Get the current class name of the current effet
  77580. * @returns "DepthOfFieldEffect"
  77581. */
  77582. getClassName(): string;
  77583. /**
  77584. * 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.
  77585. */
  77586. set depthTexture(value: RenderTargetTexture);
  77587. /**
  77588. * Disposes each of the internal effects for a given camera.
  77589. * @param camera The camera to dispose the effect on.
  77590. */
  77591. disposeEffects(camera: Camera): void;
  77592. /**
  77593. * @hidden Internal
  77594. */
  77595. _updateEffects(): void;
  77596. /**
  77597. * Internal
  77598. * @returns if all the contained post processes are ready.
  77599. * @hidden
  77600. */
  77601. _isReady(): boolean;
  77602. }
  77603. }
  77604. declare module "babylonjs/Shaders/displayPass.fragment" {
  77605. /** @hidden */
  77606. export var displayPassPixelShader: {
  77607. name: string;
  77608. shader: string;
  77609. };
  77610. }
  77611. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  77612. import { Nullable } from "babylonjs/types";
  77613. import { Camera } from "babylonjs/Cameras/camera";
  77614. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77615. import { Engine } from "babylonjs/Engines/engine";
  77616. import "babylonjs/Shaders/displayPass.fragment";
  77617. import { Scene } from "babylonjs/scene";
  77618. /**
  77619. * DisplayPassPostProcess which produces an output the same as it's input
  77620. */
  77621. export class DisplayPassPostProcess extends PostProcess {
  77622. /**
  77623. * Gets a string identifying the name of the class
  77624. * @returns "DisplayPassPostProcess" string
  77625. */
  77626. getClassName(): string;
  77627. /**
  77628. * Creates the DisplayPassPostProcess
  77629. * @param name The name of the effect.
  77630. * @param options The required width/height ratio to downsize to before computing the render pass.
  77631. * @param camera The camera to apply the render pass to.
  77632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77633. * @param engine The engine which the post process will be applied. (default: current engine)
  77634. * @param reusable If the post process can be reused on the same frame. (default: false)
  77635. */
  77636. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77637. /** @hidden */
  77638. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  77639. }
  77640. }
  77641. declare module "babylonjs/Shaders/filter.fragment" {
  77642. /** @hidden */
  77643. export var filterPixelShader: {
  77644. name: string;
  77645. shader: string;
  77646. };
  77647. }
  77648. declare module "babylonjs/PostProcesses/filterPostProcess" {
  77649. import { Nullable } from "babylonjs/types";
  77650. import { Matrix } from "babylonjs/Maths/math.vector";
  77651. import { Camera } from "babylonjs/Cameras/camera";
  77652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77653. import { Engine } from "babylonjs/Engines/engine";
  77654. import "babylonjs/Shaders/filter.fragment";
  77655. import { Scene } from "babylonjs/scene";
  77656. /**
  77657. * Applies a kernel filter to the image
  77658. */
  77659. export class FilterPostProcess extends PostProcess {
  77660. /** The matrix to be applied to the image */
  77661. kernelMatrix: Matrix;
  77662. /**
  77663. * Gets a string identifying the name of the class
  77664. * @returns "FilterPostProcess" string
  77665. */
  77666. getClassName(): string;
  77667. /**
  77668. *
  77669. * @param name The name of the effect.
  77670. * @param kernelMatrix The matrix to be applied to the image
  77671. * @param options The required width/height ratio to downsize to before computing the render pass.
  77672. * @param camera The camera to apply the render pass to.
  77673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77674. * @param engine The engine which the post process will be applied. (default: current engine)
  77675. * @param reusable If the post process can be reused on the same frame. (default: false)
  77676. */
  77677. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77678. /** @hidden */
  77679. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  77680. }
  77681. }
  77682. declare module "babylonjs/Shaders/fxaa.fragment" {
  77683. /** @hidden */
  77684. export var fxaaPixelShader: {
  77685. name: string;
  77686. shader: string;
  77687. };
  77688. }
  77689. declare module "babylonjs/Shaders/fxaa.vertex" {
  77690. /** @hidden */
  77691. export var fxaaVertexShader: {
  77692. name: string;
  77693. shader: string;
  77694. };
  77695. }
  77696. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  77697. import { Nullable } from "babylonjs/types";
  77698. import { Camera } from "babylonjs/Cameras/camera";
  77699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77700. import { Engine } from "babylonjs/Engines/engine";
  77701. import "babylonjs/Shaders/fxaa.fragment";
  77702. import "babylonjs/Shaders/fxaa.vertex";
  77703. import { Scene } from "babylonjs/scene";
  77704. /**
  77705. * Fxaa post process
  77706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  77707. */
  77708. export class FxaaPostProcess extends PostProcess {
  77709. /**
  77710. * Gets a string identifying the name of the class
  77711. * @returns "FxaaPostProcess" string
  77712. */
  77713. getClassName(): string;
  77714. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77715. private _getDefines;
  77716. /** @hidden */
  77717. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  77718. }
  77719. }
  77720. declare module "babylonjs/Shaders/grain.fragment" {
  77721. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77722. /** @hidden */
  77723. export var grainPixelShader: {
  77724. name: string;
  77725. shader: string;
  77726. };
  77727. }
  77728. declare module "babylonjs/PostProcesses/grainPostProcess" {
  77729. import { Nullable } from "babylonjs/types";
  77730. import { Camera } from "babylonjs/Cameras/camera";
  77731. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77732. import { Engine } from "babylonjs/Engines/engine";
  77733. import "babylonjs/Shaders/grain.fragment";
  77734. import { Scene } from "babylonjs/scene";
  77735. /**
  77736. * The GrainPostProcess adds noise to the image at mid luminance levels
  77737. */
  77738. export class GrainPostProcess extends PostProcess {
  77739. /**
  77740. * The intensity of the grain added (default: 30)
  77741. */
  77742. intensity: number;
  77743. /**
  77744. * If the grain should be randomized on every frame
  77745. */
  77746. animated: boolean;
  77747. /**
  77748. * Gets a string identifying the name of the class
  77749. * @returns "GrainPostProcess" string
  77750. */
  77751. getClassName(): string;
  77752. /**
  77753. * Creates a new instance of @see GrainPostProcess
  77754. * @param name The name of the effect.
  77755. * @param options The required width/height ratio to downsize to before computing the render pass.
  77756. * @param camera The camera to apply the render pass to.
  77757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77758. * @param engine The engine which the post process will be applied. (default: current engine)
  77759. * @param reusable If the post process can be reused on the same frame. (default: false)
  77760. * @param textureType Type of textures used when performing the post process. (default: 0)
  77761. * @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)
  77762. */
  77763. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77764. /** @hidden */
  77765. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  77766. }
  77767. }
  77768. declare module "babylonjs/Shaders/highlights.fragment" {
  77769. /** @hidden */
  77770. export var highlightsPixelShader: {
  77771. name: string;
  77772. shader: string;
  77773. };
  77774. }
  77775. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  77776. import { Nullable } from "babylonjs/types";
  77777. import { Camera } from "babylonjs/Cameras/camera";
  77778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77779. import { Engine } from "babylonjs/Engines/engine";
  77780. import "babylonjs/Shaders/highlights.fragment";
  77781. /**
  77782. * Extracts highlights from the image
  77783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  77784. */
  77785. export class HighlightsPostProcess extends PostProcess {
  77786. /**
  77787. * Gets a string identifying the name of the class
  77788. * @returns "HighlightsPostProcess" string
  77789. */
  77790. getClassName(): string;
  77791. /**
  77792. * Extracts highlights from the image
  77793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  77794. * @param name The name of the effect.
  77795. * @param options The required width/height ratio to downsize to before computing the render pass.
  77796. * @param camera The camera to apply the render pass to.
  77797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77798. * @param engine The engine which the post process will be applied. (default: current engine)
  77799. * @param reusable If the post process can be reused on the same frame. (default: false)
  77800. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  77801. */
  77802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77803. }
  77804. }
  77805. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  77806. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77807. /**
  77808. * Contains all parameters needed for the prepass to perform
  77809. * motion blur
  77810. */
  77811. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  77812. /**
  77813. * Is motion blur enabled
  77814. */
  77815. enabled: boolean;
  77816. /**
  77817. * Name of the configuration
  77818. */
  77819. name: string;
  77820. /**
  77821. * Textures that should be present in the MRT for this effect to work
  77822. */
  77823. readonly texturesRequired: number[];
  77824. }
  77825. }
  77826. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  77827. import { Nullable } from "babylonjs/types";
  77828. import { Scene } from "babylonjs/scene";
  77829. import { ISceneComponent } from "babylonjs/sceneComponent";
  77830. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  77831. module "babylonjs/scene" {
  77832. interface Scene {
  77833. /** @hidden (Backing field) */
  77834. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  77835. /**
  77836. * Gets or Sets the current geometry buffer associated to the scene.
  77837. */
  77838. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  77839. /**
  77840. * Enables a GeometryBufferRender and associates it with the scene
  77841. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  77842. * @returns the GeometryBufferRenderer
  77843. */
  77844. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  77845. /**
  77846. * Disables the GeometryBufferRender associated with the scene
  77847. */
  77848. disableGeometryBufferRenderer(): void;
  77849. }
  77850. }
  77851. /**
  77852. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77853. * in several rendering techniques.
  77854. */
  77855. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  77856. /**
  77857. * The component name helpful to identify the component in the list of scene components.
  77858. */
  77859. readonly name: string;
  77860. /**
  77861. * The scene the component belongs to.
  77862. */
  77863. scene: Scene;
  77864. /**
  77865. * Creates a new instance of the component for the given scene
  77866. * @param scene Defines the scene to register the component in
  77867. */
  77868. constructor(scene: Scene);
  77869. /**
  77870. * Registers the component in a given scene
  77871. */
  77872. register(): void;
  77873. /**
  77874. * Rebuilds the elements related to this component in case of
  77875. * context lost for instance.
  77876. */
  77877. rebuild(): void;
  77878. /**
  77879. * Disposes the component and the associated ressources
  77880. */
  77881. dispose(): void;
  77882. private _gatherRenderTargets;
  77883. }
  77884. }
  77885. declare module "babylonjs/Shaders/motionBlur.fragment" {
  77886. /** @hidden */
  77887. export var motionBlurPixelShader: {
  77888. name: string;
  77889. shader: string;
  77890. };
  77891. }
  77892. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  77893. import { Nullable } from "babylonjs/types";
  77894. import { Camera } from "babylonjs/Cameras/camera";
  77895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77897. import "babylonjs/Animations/animatable";
  77898. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77899. import "babylonjs/Shaders/motionBlur.fragment";
  77900. import { Engine } from "babylonjs/Engines/engine";
  77901. import { Scene } from "babylonjs/scene";
  77902. /**
  77903. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  77904. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  77905. * As an example, all you have to do is to create the post-process:
  77906. * var mb = new BABYLON.MotionBlurPostProcess(
  77907. * 'mb', // The name of the effect.
  77908. * scene, // The scene containing the objects to blur according to their velocity.
  77909. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  77910. * camera // The camera to apply the render pass to.
  77911. * );
  77912. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  77913. */
  77914. export class MotionBlurPostProcess extends PostProcess {
  77915. /**
  77916. * Defines how much the image is blurred by the movement. Default value is equal to 1
  77917. */
  77918. motionStrength: number;
  77919. /**
  77920. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  77921. */
  77922. get motionBlurSamples(): number;
  77923. /**
  77924. * Sets the number of iterations to be used for motion blur quality
  77925. */
  77926. set motionBlurSamples(samples: number);
  77927. private _motionBlurSamples;
  77928. /**
  77929. * Gets wether or not the motion blur post-process is in object based mode.
  77930. */
  77931. get isObjectBased(): boolean;
  77932. /**
  77933. * Sets wether or not the motion blur post-process is in object based mode.
  77934. */
  77935. set isObjectBased(value: boolean);
  77936. private _isObjectBased;
  77937. private _forceGeometryBuffer;
  77938. private _geometryBufferRenderer;
  77939. private _prePassRenderer;
  77940. private _invViewProjection;
  77941. private _previousViewProjection;
  77942. /**
  77943. * Gets a string identifying the name of the class
  77944. * @returns "MotionBlurPostProcess" string
  77945. */
  77946. getClassName(): string;
  77947. /**
  77948. * Creates a new instance MotionBlurPostProcess
  77949. * @param name The name of the effect.
  77950. * @param scene The scene containing the objects to blur according to their velocity.
  77951. * @param options The required width/height ratio to downsize to before computing the render pass.
  77952. * @param camera The camera to apply the render pass to.
  77953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77954. * @param engine The engine which the post process will be applied. (default: current engine)
  77955. * @param reusable If the post process can be reused on the same frame. (default: false)
  77956. * @param textureType Type of textures used when performing the post process. (default: 0)
  77957. * @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)
  77958. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  77959. */
  77960. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  77961. /**
  77962. * Excludes the given skinned mesh from computing bones velocities.
  77963. * 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.
  77964. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  77965. */
  77966. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  77967. /**
  77968. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  77969. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  77970. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  77971. */
  77972. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  77973. /**
  77974. * Disposes the post process.
  77975. * @param camera The camera to dispose the post process on.
  77976. */
  77977. dispose(camera?: Camera): void;
  77978. /**
  77979. * Called on the mode changed (object based or screen based).
  77980. */
  77981. private _applyMode;
  77982. /**
  77983. * Called on the effect is applied when the motion blur post-process is in object based mode.
  77984. */
  77985. private _onApplyObjectBased;
  77986. /**
  77987. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  77988. */
  77989. private _onApplyScreenBased;
  77990. /**
  77991. * Called on the effect must be updated (changed mode, samples count, etc.).
  77992. */
  77993. private _updateEffect;
  77994. /** @hidden */
  77995. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  77996. }
  77997. }
  77998. declare module "babylonjs/Shaders/refraction.fragment" {
  77999. /** @hidden */
  78000. export var refractionPixelShader: {
  78001. name: string;
  78002. shader: string;
  78003. };
  78004. }
  78005. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  78006. import { Color3 } from "babylonjs/Maths/math.color";
  78007. import { Camera } from "babylonjs/Cameras/camera";
  78008. import { Texture } from "babylonjs/Materials/Textures/texture";
  78009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78010. import { Engine } from "babylonjs/Engines/engine";
  78011. import "babylonjs/Shaders/refraction.fragment";
  78012. import { Scene } from "babylonjs/scene";
  78013. /**
  78014. * Post process which applies a refractin texture
  78015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78016. */
  78017. export class RefractionPostProcess extends PostProcess {
  78018. private _refTexture;
  78019. private _ownRefractionTexture;
  78020. /** the base color of the refraction (used to taint the rendering) */
  78021. color: Color3;
  78022. /** simulated refraction depth */
  78023. depth: number;
  78024. /** the coefficient of the base color (0 to remove base color tainting) */
  78025. colorLevel: number;
  78026. /** Gets the url used to load the refraction texture */
  78027. refractionTextureUrl: string;
  78028. /**
  78029. * Gets or sets the refraction texture
  78030. * Please note that you are responsible for disposing the texture if you set it manually
  78031. */
  78032. get refractionTexture(): Texture;
  78033. set refractionTexture(value: Texture);
  78034. /**
  78035. * Gets a string identifying the name of the class
  78036. * @returns "RefractionPostProcess" string
  78037. */
  78038. getClassName(): string;
  78039. /**
  78040. * Initializes the RefractionPostProcess
  78041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78042. * @param name The name of the effect.
  78043. * @param refractionTextureUrl Url of the refraction texture to use
  78044. * @param color the base color of the refraction (used to taint the rendering)
  78045. * @param depth simulated refraction depth
  78046. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  78047. * @param camera The camera to apply the render pass to.
  78048. * @param options The required width/height ratio to downsize to before computing the render pass.
  78049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78050. * @param engine The engine which the post process will be applied. (default: current engine)
  78051. * @param reusable If the post process can be reused on the same frame. (default: false)
  78052. */
  78053. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78054. /**
  78055. * Disposes of the post process
  78056. * @param camera Camera to dispose post process on
  78057. */
  78058. dispose(camera: Camera): void;
  78059. /** @hidden */
  78060. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  78061. }
  78062. }
  78063. declare module "babylonjs/Shaders/sharpen.fragment" {
  78064. /** @hidden */
  78065. export var sharpenPixelShader: {
  78066. name: string;
  78067. shader: string;
  78068. };
  78069. }
  78070. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  78071. import { Nullable } from "babylonjs/types";
  78072. import { Camera } from "babylonjs/Cameras/camera";
  78073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78074. import "babylonjs/Shaders/sharpen.fragment";
  78075. import { Engine } from "babylonjs/Engines/engine";
  78076. import { Scene } from "babylonjs/scene";
  78077. /**
  78078. * The SharpenPostProcess applies a sharpen kernel to every pixel
  78079. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  78080. */
  78081. export class SharpenPostProcess extends PostProcess {
  78082. /**
  78083. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  78084. */
  78085. colorAmount: number;
  78086. /**
  78087. * How much sharpness should be applied (default: 0.3)
  78088. */
  78089. edgeAmount: number;
  78090. /**
  78091. * Gets a string identifying the name of the class
  78092. * @returns "SharpenPostProcess" string
  78093. */
  78094. getClassName(): string;
  78095. /**
  78096. * Creates a new instance ConvolutionPostProcess
  78097. * @param name The name of the effect.
  78098. * @param options The required width/height ratio to downsize to before computing the render pass.
  78099. * @param camera The camera to apply the render pass to.
  78100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78101. * @param engine The engine which the post process will be applied. (default: current engine)
  78102. * @param reusable If the post process can be reused on the same frame. (default: false)
  78103. * @param textureType Type of textures used when performing the post process. (default: 0)
  78104. * @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)
  78105. */
  78106. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78107. /** @hidden */
  78108. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  78109. }
  78110. }
  78111. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  78112. import { Nullable } from "babylonjs/types";
  78113. import { Camera } from "babylonjs/Cameras/camera";
  78114. import { Engine } from "babylonjs/Engines/engine";
  78115. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  78116. import { IInspectable } from "babylonjs/Misc/iInspectable";
  78117. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  78118. /**
  78119. * PostProcessRenderPipeline
  78120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78121. */
  78122. export class PostProcessRenderPipeline {
  78123. private engine;
  78124. private _renderEffects;
  78125. private _renderEffectsForIsolatedPass;
  78126. /**
  78127. * List of inspectable custom properties (used by the Inspector)
  78128. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78129. */
  78130. inspectableCustomProperties: IInspectable[];
  78131. /**
  78132. * @hidden
  78133. */
  78134. protected _cameras: Camera[];
  78135. /** @hidden */
  78136. _name: string;
  78137. /**
  78138. * Gets pipeline name
  78139. */
  78140. get name(): string;
  78141. /** Gets the list of attached cameras */
  78142. get cameras(): Camera[];
  78143. /**
  78144. * Initializes a PostProcessRenderPipeline
  78145. * @param engine engine to add the pipeline to
  78146. * @param name name of the pipeline
  78147. */
  78148. constructor(engine: Engine, name: string);
  78149. /**
  78150. * Gets the class name
  78151. * @returns "PostProcessRenderPipeline"
  78152. */
  78153. getClassName(): string;
  78154. /**
  78155. * If all the render effects in the pipeline are supported
  78156. */
  78157. get isSupported(): boolean;
  78158. /**
  78159. * Adds an effect to the pipeline
  78160. * @param renderEffect the effect to add
  78161. */
  78162. addEffect(renderEffect: PostProcessRenderEffect): void;
  78163. /** @hidden */
  78164. _rebuild(): void;
  78165. /** @hidden */
  78166. _enableEffect(renderEffectName: string, cameras: Camera): void;
  78167. /** @hidden */
  78168. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  78169. /** @hidden */
  78170. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78171. /** @hidden */
  78172. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78173. /** @hidden */
  78174. _attachCameras(cameras: Camera, unique: boolean): void;
  78175. /** @hidden */
  78176. _attachCameras(cameras: Camera[], unique: boolean): void;
  78177. /** @hidden */
  78178. _detachCameras(cameras: Camera): void;
  78179. /** @hidden */
  78180. _detachCameras(cameras: Nullable<Camera[]>): void;
  78181. /** @hidden */
  78182. _update(): void;
  78183. /** @hidden */
  78184. _reset(): void;
  78185. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  78186. /**
  78187. * Sets the required values to the prepass renderer.
  78188. * @param prePassRenderer defines the prepass renderer to setup.
  78189. * @returns true if the pre pass is needed.
  78190. */
  78191. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  78192. /**
  78193. * Disposes of the pipeline
  78194. */
  78195. dispose(): void;
  78196. }
  78197. }
  78198. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  78199. import { Camera } from "babylonjs/Cameras/camera";
  78200. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78201. /**
  78202. * PostProcessRenderPipelineManager class
  78203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78204. */
  78205. export class PostProcessRenderPipelineManager {
  78206. private _renderPipelines;
  78207. /**
  78208. * Initializes a PostProcessRenderPipelineManager
  78209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78210. */
  78211. constructor();
  78212. /**
  78213. * Gets the list of supported render pipelines
  78214. */
  78215. get supportedPipelines(): PostProcessRenderPipeline[];
  78216. /**
  78217. * Adds a pipeline to the manager
  78218. * @param renderPipeline The pipeline to add
  78219. */
  78220. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  78221. /**
  78222. * Attaches a camera to the pipeline
  78223. * @param renderPipelineName The name of the pipeline to attach to
  78224. * @param cameras the camera to attach
  78225. * @param unique if the camera can be attached multiple times to the pipeline
  78226. */
  78227. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  78228. /**
  78229. * Detaches a camera from the pipeline
  78230. * @param renderPipelineName The name of the pipeline to detach from
  78231. * @param cameras the camera to detach
  78232. */
  78233. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  78234. /**
  78235. * Enables an effect by name on a pipeline
  78236. * @param renderPipelineName the name of the pipeline to enable the effect in
  78237. * @param renderEffectName the name of the effect to enable
  78238. * @param cameras the cameras that the effect should be enabled on
  78239. */
  78240. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78241. /**
  78242. * Disables an effect by name on a pipeline
  78243. * @param renderPipelineName the name of the pipeline to disable the effect in
  78244. * @param renderEffectName the name of the effect to disable
  78245. * @param cameras the cameras that the effect should be disabled on
  78246. */
  78247. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78248. /**
  78249. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  78250. */
  78251. update(): void;
  78252. /** @hidden */
  78253. _rebuild(): void;
  78254. /**
  78255. * Disposes of the manager and pipelines
  78256. */
  78257. dispose(): void;
  78258. }
  78259. }
  78260. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  78261. import { ISceneComponent } from "babylonjs/sceneComponent";
  78262. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  78263. import { Scene } from "babylonjs/scene";
  78264. module "babylonjs/scene" {
  78265. interface Scene {
  78266. /** @hidden (Backing field) */
  78267. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78268. /**
  78269. * Gets the postprocess render pipeline manager
  78270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78271. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78272. */
  78273. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78274. }
  78275. }
  78276. /**
  78277. * Defines the Render Pipeline scene component responsible to rendering pipelines
  78278. */
  78279. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  78280. /**
  78281. * The component name helpfull to identify the component in the list of scene components.
  78282. */
  78283. readonly name: string;
  78284. /**
  78285. * The scene the component belongs to.
  78286. */
  78287. scene: Scene;
  78288. /**
  78289. * Creates a new instance of the component for the given scene
  78290. * @param scene Defines the scene to register the component in
  78291. */
  78292. constructor(scene: Scene);
  78293. /**
  78294. * Registers the component in a given scene
  78295. */
  78296. register(): void;
  78297. /**
  78298. * Rebuilds the elements related to this component in case of
  78299. * context lost for instance.
  78300. */
  78301. rebuild(): void;
  78302. /**
  78303. * Disposes the component and the associated ressources
  78304. */
  78305. dispose(): void;
  78306. private _gatherRenderTargets;
  78307. }
  78308. }
  78309. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  78310. import { Nullable } from "babylonjs/types";
  78311. import { Observable } from "babylonjs/Misc/observable";
  78312. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  78313. import { Camera } from "babylonjs/Cameras/camera";
  78314. import { IDisposable } from "babylonjs/scene";
  78315. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  78316. import { Scene } from "babylonjs/scene";
  78317. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  78318. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  78319. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  78320. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  78321. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  78322. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78323. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  78324. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78325. import { Animation } from "babylonjs/Animations/animation";
  78326. /**
  78327. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  78328. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78329. */
  78330. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  78331. private _scene;
  78332. private _camerasToBeAttached;
  78333. /**
  78334. * ID of the sharpen post process,
  78335. */
  78336. private readonly SharpenPostProcessId;
  78337. /**
  78338. * @ignore
  78339. * ID of the image processing post process;
  78340. */
  78341. readonly ImageProcessingPostProcessId: string;
  78342. /**
  78343. * @ignore
  78344. * ID of the Fast Approximate Anti-Aliasing post process;
  78345. */
  78346. readonly FxaaPostProcessId: string;
  78347. /**
  78348. * ID of the chromatic aberration post process,
  78349. */
  78350. private readonly ChromaticAberrationPostProcessId;
  78351. /**
  78352. * ID of the grain post process
  78353. */
  78354. private readonly GrainPostProcessId;
  78355. /**
  78356. * Sharpen post process which will apply a sharpen convolution to enhance edges
  78357. */
  78358. sharpen: SharpenPostProcess;
  78359. private _sharpenEffect;
  78360. private bloom;
  78361. /**
  78362. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  78363. */
  78364. depthOfField: DepthOfFieldEffect;
  78365. /**
  78366. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  78367. */
  78368. fxaa: FxaaPostProcess;
  78369. /**
  78370. * Image post processing pass used to perform operations such as tone mapping or color grading.
  78371. */
  78372. imageProcessing: ImageProcessingPostProcess;
  78373. /**
  78374. * Chromatic aberration post process which will shift rgb colors in the image
  78375. */
  78376. chromaticAberration: ChromaticAberrationPostProcess;
  78377. private _chromaticAberrationEffect;
  78378. /**
  78379. * Grain post process which add noise to the image
  78380. */
  78381. grain: GrainPostProcess;
  78382. private _grainEffect;
  78383. /**
  78384. * Glow post process which adds a glow to emissive areas of the image
  78385. */
  78386. private _glowLayer;
  78387. /**
  78388. * Animations which can be used to tweak settings over a period of time
  78389. */
  78390. animations: Animation[];
  78391. private _imageProcessingConfigurationObserver;
  78392. private _sharpenEnabled;
  78393. private _bloomEnabled;
  78394. private _depthOfFieldEnabled;
  78395. private _depthOfFieldBlurLevel;
  78396. private _fxaaEnabled;
  78397. private _imageProcessingEnabled;
  78398. private _defaultPipelineTextureType;
  78399. private _bloomScale;
  78400. private _chromaticAberrationEnabled;
  78401. private _grainEnabled;
  78402. private _buildAllowed;
  78403. /**
  78404. * This is triggered each time the pipeline has been built.
  78405. */
  78406. onBuildObservable: Observable<DefaultRenderingPipeline>;
  78407. /**
  78408. * Gets active scene
  78409. */
  78410. get scene(): Scene;
  78411. /**
  78412. * Enable or disable the sharpen process from the pipeline
  78413. */
  78414. set sharpenEnabled(enabled: boolean);
  78415. get sharpenEnabled(): boolean;
  78416. private _resizeObserver;
  78417. private _hardwareScaleLevel;
  78418. private _bloomKernel;
  78419. /**
  78420. * Specifies the size of the bloom blur kernel, relative to the final output size
  78421. */
  78422. get bloomKernel(): number;
  78423. set bloomKernel(value: number);
  78424. /**
  78425. * Specifies the weight of the bloom in the final rendering
  78426. */
  78427. private _bloomWeight;
  78428. /**
  78429. * Specifies the luma threshold for the area that will be blurred by the bloom
  78430. */
  78431. private _bloomThreshold;
  78432. private _hdr;
  78433. /**
  78434. * The strength of the bloom.
  78435. */
  78436. set bloomWeight(value: number);
  78437. get bloomWeight(): number;
  78438. /**
  78439. * The strength of the bloom.
  78440. */
  78441. set bloomThreshold(value: number);
  78442. get bloomThreshold(): number;
  78443. /**
  78444. * The scale of the bloom, lower value will provide better performance.
  78445. */
  78446. set bloomScale(value: number);
  78447. get bloomScale(): number;
  78448. /**
  78449. * Enable or disable the bloom from the pipeline
  78450. */
  78451. set bloomEnabled(enabled: boolean);
  78452. get bloomEnabled(): boolean;
  78453. private _rebuildBloom;
  78454. /**
  78455. * If the depth of field is enabled.
  78456. */
  78457. get depthOfFieldEnabled(): boolean;
  78458. set depthOfFieldEnabled(enabled: boolean);
  78459. /**
  78460. * Blur level of the depth of field effect. (Higher blur will effect performance)
  78461. */
  78462. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  78463. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  78464. /**
  78465. * If the anti aliasing is enabled.
  78466. */
  78467. set fxaaEnabled(enabled: boolean);
  78468. get fxaaEnabled(): boolean;
  78469. private _samples;
  78470. /**
  78471. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  78472. */
  78473. set samples(sampleCount: number);
  78474. get samples(): number;
  78475. /**
  78476. * If image processing is enabled.
  78477. */
  78478. set imageProcessingEnabled(enabled: boolean);
  78479. get imageProcessingEnabled(): boolean;
  78480. /**
  78481. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  78482. */
  78483. set glowLayerEnabled(enabled: boolean);
  78484. get glowLayerEnabled(): boolean;
  78485. /**
  78486. * Gets the glow layer (or null if not defined)
  78487. */
  78488. get glowLayer(): Nullable<GlowLayer>;
  78489. /**
  78490. * Enable or disable the chromaticAberration process from the pipeline
  78491. */
  78492. set chromaticAberrationEnabled(enabled: boolean);
  78493. get chromaticAberrationEnabled(): boolean;
  78494. /**
  78495. * Enable or disable the grain process from the pipeline
  78496. */
  78497. set grainEnabled(enabled: boolean);
  78498. get grainEnabled(): boolean;
  78499. /**
  78500. * @constructor
  78501. * @param name - The rendering pipeline name (default: "")
  78502. * @param hdr - If high dynamic range textures should be used (default: true)
  78503. * @param scene - The scene linked to this pipeline (default: the last created scene)
  78504. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  78505. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  78506. */
  78507. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  78508. /**
  78509. * Get the class name
  78510. * @returns "DefaultRenderingPipeline"
  78511. */
  78512. getClassName(): string;
  78513. /**
  78514. * Force the compilation of the entire pipeline.
  78515. */
  78516. prepare(): void;
  78517. private _hasCleared;
  78518. private _prevPostProcess;
  78519. private _prevPrevPostProcess;
  78520. private _setAutoClearAndTextureSharing;
  78521. private _depthOfFieldSceneObserver;
  78522. private _buildPipeline;
  78523. private _disposePostProcesses;
  78524. /**
  78525. * Adds a camera to the pipeline
  78526. * @param camera the camera to be added
  78527. */
  78528. addCamera(camera: Camera): void;
  78529. /**
  78530. * Removes a camera from the pipeline
  78531. * @param camera the camera to remove
  78532. */
  78533. removeCamera(camera: Camera): void;
  78534. /**
  78535. * Dispose of the pipeline and stop all post processes
  78536. */
  78537. dispose(): void;
  78538. /**
  78539. * Serialize the rendering pipeline (Used when exporting)
  78540. * @returns the serialized object
  78541. */
  78542. serialize(): any;
  78543. /**
  78544. * Parse the serialized pipeline
  78545. * @param source Source pipeline.
  78546. * @param scene The scene to load the pipeline to.
  78547. * @param rootUrl The URL of the serialized pipeline.
  78548. * @returns An instantiated pipeline from the serialized object.
  78549. */
  78550. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  78551. }
  78552. }
  78553. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  78554. /** @hidden */
  78555. export var lensHighlightsPixelShader: {
  78556. name: string;
  78557. shader: string;
  78558. };
  78559. }
  78560. declare module "babylonjs/Shaders/depthOfField.fragment" {
  78561. /** @hidden */
  78562. export var depthOfFieldPixelShader: {
  78563. name: string;
  78564. shader: string;
  78565. };
  78566. }
  78567. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  78568. import { Camera } from "babylonjs/Cameras/camera";
  78569. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78570. import { Scene } from "babylonjs/scene";
  78571. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78572. import "babylonjs/Shaders/chromaticAberration.fragment";
  78573. import "babylonjs/Shaders/lensHighlights.fragment";
  78574. import "babylonjs/Shaders/depthOfField.fragment";
  78575. /**
  78576. * BABYLON.JS Chromatic Aberration GLSL Shader
  78577. * Author: Olivier Guyot
  78578. * Separates very slightly R, G and B colors on the edges of the screen
  78579. * Inspired by Francois Tarlier & Martins Upitis
  78580. */
  78581. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  78582. /**
  78583. * @ignore
  78584. * The chromatic aberration PostProcess id in the pipeline
  78585. */
  78586. LensChromaticAberrationEffect: string;
  78587. /**
  78588. * @ignore
  78589. * The highlights enhancing PostProcess id in the pipeline
  78590. */
  78591. HighlightsEnhancingEffect: string;
  78592. /**
  78593. * @ignore
  78594. * The depth-of-field PostProcess id in the pipeline
  78595. */
  78596. LensDepthOfFieldEffect: string;
  78597. private _scene;
  78598. private _depthTexture;
  78599. private _grainTexture;
  78600. private _chromaticAberrationPostProcess;
  78601. private _highlightsPostProcess;
  78602. private _depthOfFieldPostProcess;
  78603. private _edgeBlur;
  78604. private _grainAmount;
  78605. private _chromaticAberration;
  78606. private _distortion;
  78607. private _highlightsGain;
  78608. private _highlightsThreshold;
  78609. private _dofDistance;
  78610. private _dofAperture;
  78611. private _dofDarken;
  78612. private _dofPentagon;
  78613. private _blurNoise;
  78614. /**
  78615. * @constructor
  78616. *
  78617. * Effect parameters are as follow:
  78618. * {
  78619. * chromatic_aberration: number; // from 0 to x (1 for realism)
  78620. * edge_blur: number; // from 0 to x (1 for realism)
  78621. * distortion: number; // from 0 to x (1 for realism)
  78622. * grain_amount: number; // from 0 to 1
  78623. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  78624. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  78625. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  78626. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  78627. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  78628. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  78629. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  78630. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  78631. * }
  78632. * Note: if an effect parameter is unset, effect is disabled
  78633. *
  78634. * @param name The rendering pipeline name
  78635. * @param parameters - An object containing all parameters (see above)
  78636. * @param scene The scene linked to this pipeline
  78637. * @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)
  78638. * @param cameras The array of cameras that the rendering pipeline will be attached to
  78639. */
  78640. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  78641. /**
  78642. * Get the class name
  78643. * @returns "LensRenderingPipeline"
  78644. */
  78645. getClassName(): string;
  78646. /**
  78647. * Gets associated scene
  78648. */
  78649. get scene(): Scene;
  78650. /**
  78651. * Gets or sets the edge blur
  78652. */
  78653. get edgeBlur(): number;
  78654. set edgeBlur(value: number);
  78655. /**
  78656. * Gets or sets the grain amount
  78657. */
  78658. get grainAmount(): number;
  78659. set grainAmount(value: number);
  78660. /**
  78661. * Gets or sets the chromatic aberration amount
  78662. */
  78663. get chromaticAberration(): number;
  78664. set chromaticAberration(value: number);
  78665. /**
  78666. * Gets or sets the depth of field aperture
  78667. */
  78668. get dofAperture(): number;
  78669. set dofAperture(value: number);
  78670. /**
  78671. * Gets or sets the edge distortion
  78672. */
  78673. get edgeDistortion(): number;
  78674. set edgeDistortion(value: number);
  78675. /**
  78676. * Gets or sets the depth of field distortion
  78677. */
  78678. get dofDistortion(): number;
  78679. set dofDistortion(value: number);
  78680. /**
  78681. * Gets or sets the darken out of focus amount
  78682. */
  78683. get darkenOutOfFocus(): number;
  78684. set darkenOutOfFocus(value: number);
  78685. /**
  78686. * Gets or sets a boolean indicating if blur noise is enabled
  78687. */
  78688. get blurNoise(): boolean;
  78689. set blurNoise(value: boolean);
  78690. /**
  78691. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  78692. */
  78693. get pentagonBokeh(): boolean;
  78694. set pentagonBokeh(value: boolean);
  78695. /**
  78696. * Gets or sets the highlight grain amount
  78697. */
  78698. get highlightsGain(): number;
  78699. set highlightsGain(value: number);
  78700. /**
  78701. * Gets or sets the highlight threshold
  78702. */
  78703. get highlightsThreshold(): number;
  78704. set highlightsThreshold(value: number);
  78705. /**
  78706. * Sets the amount of blur at the edges
  78707. * @param amount blur amount
  78708. */
  78709. setEdgeBlur(amount: number): void;
  78710. /**
  78711. * Sets edge blur to 0
  78712. */
  78713. disableEdgeBlur(): void;
  78714. /**
  78715. * Sets the amout of grain
  78716. * @param amount Amount of grain
  78717. */
  78718. setGrainAmount(amount: number): void;
  78719. /**
  78720. * Set grain amount to 0
  78721. */
  78722. disableGrain(): void;
  78723. /**
  78724. * Sets the chromatic aberration amount
  78725. * @param amount amount of chromatic aberration
  78726. */
  78727. setChromaticAberration(amount: number): void;
  78728. /**
  78729. * Sets chromatic aberration amount to 0
  78730. */
  78731. disableChromaticAberration(): void;
  78732. /**
  78733. * Sets the EdgeDistortion amount
  78734. * @param amount amount of EdgeDistortion
  78735. */
  78736. setEdgeDistortion(amount: number): void;
  78737. /**
  78738. * Sets edge distortion to 0
  78739. */
  78740. disableEdgeDistortion(): void;
  78741. /**
  78742. * Sets the FocusDistance amount
  78743. * @param amount amount of FocusDistance
  78744. */
  78745. setFocusDistance(amount: number): void;
  78746. /**
  78747. * Disables depth of field
  78748. */
  78749. disableDepthOfField(): void;
  78750. /**
  78751. * Sets the Aperture amount
  78752. * @param amount amount of Aperture
  78753. */
  78754. setAperture(amount: number): void;
  78755. /**
  78756. * Sets the DarkenOutOfFocus amount
  78757. * @param amount amount of DarkenOutOfFocus
  78758. */
  78759. setDarkenOutOfFocus(amount: number): void;
  78760. private _pentagonBokehIsEnabled;
  78761. /**
  78762. * Creates a pentagon bokeh effect
  78763. */
  78764. enablePentagonBokeh(): void;
  78765. /**
  78766. * Disables the pentagon bokeh effect
  78767. */
  78768. disablePentagonBokeh(): void;
  78769. /**
  78770. * Enables noise blur
  78771. */
  78772. enableNoiseBlur(): void;
  78773. /**
  78774. * Disables noise blur
  78775. */
  78776. disableNoiseBlur(): void;
  78777. /**
  78778. * Sets the HighlightsGain amount
  78779. * @param amount amount of HighlightsGain
  78780. */
  78781. setHighlightsGain(amount: number): void;
  78782. /**
  78783. * Sets the HighlightsThreshold amount
  78784. * @param amount amount of HighlightsThreshold
  78785. */
  78786. setHighlightsThreshold(amount: number): void;
  78787. /**
  78788. * Disables highlights
  78789. */
  78790. disableHighlights(): void;
  78791. /**
  78792. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  78793. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  78794. */
  78795. dispose(disableDepthRender?: boolean): void;
  78796. private _createChromaticAberrationPostProcess;
  78797. private _createHighlightsPostProcess;
  78798. private _createDepthOfFieldPostProcess;
  78799. private _createGrainTexture;
  78800. }
  78801. }
  78802. declare module "babylonjs/Rendering/ssao2Configuration" {
  78803. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  78804. /**
  78805. * Contains all parameters needed for the prepass to perform
  78806. * screen space subsurface scattering
  78807. */
  78808. export class SSAO2Configuration implements PrePassEffectConfiguration {
  78809. /**
  78810. * Is subsurface enabled
  78811. */
  78812. enabled: boolean;
  78813. /**
  78814. * Name of the configuration
  78815. */
  78816. name: string;
  78817. /**
  78818. * Textures that should be present in the MRT for this effect to work
  78819. */
  78820. readonly texturesRequired: number[];
  78821. }
  78822. }
  78823. declare module "babylonjs/Shaders/ssao2.fragment" {
  78824. /** @hidden */
  78825. export var ssao2PixelShader: {
  78826. name: string;
  78827. shader: string;
  78828. };
  78829. }
  78830. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  78831. /** @hidden */
  78832. export var ssaoCombinePixelShader: {
  78833. name: string;
  78834. shader: string;
  78835. };
  78836. }
  78837. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  78838. import { Camera } from "babylonjs/Cameras/camera";
  78839. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78840. import { Scene } from "babylonjs/scene";
  78841. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78842. import "babylonjs/Shaders/ssao2.fragment";
  78843. import "babylonjs/Shaders/ssaoCombine.fragment";
  78844. /**
  78845. * Render pipeline to produce ssao effect
  78846. */
  78847. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  78848. /**
  78849. * @ignore
  78850. * The PassPostProcess id in the pipeline that contains the original scene color
  78851. */
  78852. SSAOOriginalSceneColorEffect: string;
  78853. /**
  78854. * @ignore
  78855. * The SSAO PostProcess id in the pipeline
  78856. */
  78857. SSAORenderEffect: string;
  78858. /**
  78859. * @ignore
  78860. * The horizontal blur PostProcess id in the pipeline
  78861. */
  78862. SSAOBlurHRenderEffect: string;
  78863. /**
  78864. * @ignore
  78865. * The vertical blur PostProcess id in the pipeline
  78866. */
  78867. SSAOBlurVRenderEffect: string;
  78868. /**
  78869. * @ignore
  78870. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  78871. */
  78872. SSAOCombineRenderEffect: string;
  78873. /**
  78874. * The output strength of the SSAO post-process. Default value is 1.0.
  78875. */
  78876. totalStrength: number;
  78877. /**
  78878. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  78879. */
  78880. maxZ: number;
  78881. /**
  78882. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  78883. */
  78884. minZAspect: number;
  78885. private _samples;
  78886. /**
  78887. * Number of samples used for the SSAO calculations. Default value is 8
  78888. */
  78889. set samples(n: number);
  78890. get samples(): number;
  78891. private _textureSamples;
  78892. /**
  78893. * Number of samples to use for antialiasing
  78894. */
  78895. set textureSamples(n: number);
  78896. get textureSamples(): number;
  78897. /**
  78898. * Force rendering the geometry through geometry buffer
  78899. */
  78900. private _forceGeometryBuffer;
  78901. /**
  78902. * Ratio object used for SSAO ratio and blur ratio
  78903. */
  78904. private _ratio;
  78905. /**
  78906. * Dynamically generated sphere sampler.
  78907. */
  78908. private _sampleSphere;
  78909. /**
  78910. * Blur filter offsets
  78911. */
  78912. private _samplerOffsets;
  78913. private _expensiveBlur;
  78914. /**
  78915. * If bilateral blur should be used
  78916. */
  78917. set expensiveBlur(b: boolean);
  78918. get expensiveBlur(): boolean;
  78919. /**
  78920. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  78921. */
  78922. radius: number;
  78923. /**
  78924. * The base color of the SSAO post-process
  78925. * The final result is "base + ssao" between [0, 1]
  78926. */
  78927. base: number;
  78928. /**
  78929. * Support test.
  78930. */
  78931. static get IsSupported(): boolean;
  78932. private _scene;
  78933. private _randomTexture;
  78934. private _originalColorPostProcess;
  78935. private _ssaoPostProcess;
  78936. private _blurHPostProcess;
  78937. private _blurVPostProcess;
  78938. private _ssaoCombinePostProcess;
  78939. private _prePassRenderer;
  78940. /**
  78941. * Gets active scene
  78942. */
  78943. get scene(): Scene;
  78944. /**
  78945. * @constructor
  78946. * @param name The rendering pipeline name
  78947. * @param scene The scene linked to this pipeline
  78948. * @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 }
  78949. * @param cameras The array of cameras that the rendering pipeline will be attached to
  78950. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  78951. */
  78952. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  78953. /**
  78954. * Get the class name
  78955. * @returns "SSAO2RenderingPipeline"
  78956. */
  78957. getClassName(): string;
  78958. /**
  78959. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  78960. */
  78961. dispose(disableGeometryBufferRenderer?: boolean): void;
  78962. private _createBlurPostProcess;
  78963. /** @hidden */
  78964. _rebuild(): void;
  78965. private _bits;
  78966. private _radicalInverse_VdC;
  78967. private _hammersley;
  78968. private _hemisphereSample_uniform;
  78969. private _generateHemisphere;
  78970. private _getDefinesForSSAO;
  78971. private static readonly ORTHO_DEPTH_PROJECTION;
  78972. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  78973. private _createSSAOPostProcess;
  78974. private _createSSAOCombinePostProcess;
  78975. private _createRandomTexture;
  78976. /**
  78977. * Serialize the rendering pipeline (Used when exporting)
  78978. * @returns the serialized object
  78979. */
  78980. serialize(): any;
  78981. /**
  78982. * Parse the serialized pipeline
  78983. * @param source Source pipeline.
  78984. * @param scene The scene to load the pipeline to.
  78985. * @param rootUrl The URL of the serialized pipeline.
  78986. * @returns An instantiated pipeline from the serialized object.
  78987. */
  78988. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  78989. }
  78990. }
  78991. declare module "babylonjs/Shaders/ssao.fragment" {
  78992. /** @hidden */
  78993. export var ssaoPixelShader: {
  78994. name: string;
  78995. shader: string;
  78996. };
  78997. }
  78998. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  78999. import { Camera } from "babylonjs/Cameras/camera";
  79000. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79001. import { Scene } from "babylonjs/scene";
  79002. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79003. import "babylonjs/Shaders/ssao.fragment";
  79004. import "babylonjs/Shaders/ssaoCombine.fragment";
  79005. /**
  79006. * Render pipeline to produce ssao effect
  79007. */
  79008. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  79009. /**
  79010. * @ignore
  79011. * The PassPostProcess id in the pipeline that contains the original scene color
  79012. */
  79013. SSAOOriginalSceneColorEffect: string;
  79014. /**
  79015. * @ignore
  79016. * The SSAO PostProcess id in the pipeline
  79017. */
  79018. SSAORenderEffect: string;
  79019. /**
  79020. * @ignore
  79021. * The horizontal blur PostProcess id in the pipeline
  79022. */
  79023. SSAOBlurHRenderEffect: string;
  79024. /**
  79025. * @ignore
  79026. * The vertical blur PostProcess id in the pipeline
  79027. */
  79028. SSAOBlurVRenderEffect: string;
  79029. /**
  79030. * @ignore
  79031. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79032. */
  79033. SSAOCombineRenderEffect: string;
  79034. /**
  79035. * The output strength of the SSAO post-process. Default value is 1.0.
  79036. */
  79037. totalStrength: number;
  79038. /**
  79039. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  79040. */
  79041. radius: number;
  79042. /**
  79043. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  79044. * Must not be equal to fallOff and superior to fallOff.
  79045. * Default value is 0.0075
  79046. */
  79047. area: number;
  79048. /**
  79049. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  79050. * Must not be equal to area and inferior to area.
  79051. * Default value is 0.000001
  79052. */
  79053. fallOff: number;
  79054. /**
  79055. * The base color of the SSAO post-process
  79056. * The final result is "base + ssao" between [0, 1]
  79057. */
  79058. base: number;
  79059. private _scene;
  79060. private _depthTexture;
  79061. private _randomTexture;
  79062. private _originalColorPostProcess;
  79063. private _ssaoPostProcess;
  79064. private _blurHPostProcess;
  79065. private _blurVPostProcess;
  79066. private _ssaoCombinePostProcess;
  79067. private _firstUpdate;
  79068. /**
  79069. * Gets active scene
  79070. */
  79071. get scene(): Scene;
  79072. /**
  79073. * @constructor
  79074. * @param name - The rendering pipeline name
  79075. * @param scene - The scene linked to this pipeline
  79076. * @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 }
  79077. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  79078. */
  79079. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  79080. /**
  79081. * Get the class name
  79082. * @returns "SSAORenderingPipeline"
  79083. */
  79084. getClassName(): string;
  79085. /**
  79086. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  79087. */
  79088. dispose(disableDepthRender?: boolean): void;
  79089. private _createBlurPostProcess;
  79090. /** @hidden */
  79091. _rebuild(): void;
  79092. private _createSSAOPostProcess;
  79093. private _createSSAOCombinePostProcess;
  79094. private _createRandomTexture;
  79095. }
  79096. }
  79097. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  79098. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79099. /**
  79100. * Contains all parameters needed for the prepass to perform
  79101. * screen space reflections
  79102. */
  79103. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  79104. /**
  79105. * Is ssr enabled
  79106. */
  79107. enabled: boolean;
  79108. /**
  79109. * Name of the configuration
  79110. */
  79111. name: string;
  79112. /**
  79113. * Textures that should be present in the MRT for this effect to work
  79114. */
  79115. readonly texturesRequired: number[];
  79116. }
  79117. }
  79118. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  79119. /** @hidden */
  79120. export var screenSpaceReflectionPixelShader: {
  79121. name: string;
  79122. shader: string;
  79123. };
  79124. }
  79125. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  79126. import { Nullable } from "babylonjs/types";
  79127. import { Camera } from "babylonjs/Cameras/camera";
  79128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79129. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  79130. import { Engine } from "babylonjs/Engines/engine";
  79131. import { Scene } from "babylonjs/scene";
  79132. /**
  79133. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  79134. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  79135. */
  79136. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  79137. /**
  79138. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  79139. */
  79140. threshold: number;
  79141. /**
  79142. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  79143. */
  79144. strength: number;
  79145. /**
  79146. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  79147. */
  79148. reflectionSpecularFalloffExponent: number;
  79149. /**
  79150. * 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]
  79151. */
  79152. step: number;
  79153. /**
  79154. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  79155. */
  79156. roughnessFactor: number;
  79157. private _forceGeometryBuffer;
  79158. private _geometryBufferRenderer;
  79159. private _prePassRenderer;
  79160. private _enableSmoothReflections;
  79161. private _reflectionSamples;
  79162. private _smoothSteps;
  79163. /**
  79164. * Gets a string identifying the name of the class
  79165. * @returns "ScreenSpaceReflectionPostProcess" string
  79166. */
  79167. getClassName(): string;
  79168. /**
  79169. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  79170. * @param name The name of the effect.
  79171. * @param scene The scene containing the objects to calculate reflections.
  79172. * @param options The required width/height ratio to downsize to before computing the render pass.
  79173. * @param camera The camera to apply the render pass to.
  79174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79175. * @param engine The engine which the post process will be applied. (default: current engine)
  79176. * @param reusable If the post process can be reused on the same frame. (default: false)
  79177. * @param textureType Type of textures used when performing the post process. (default: 0)
  79178. * @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)
  79179. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  79180. */
  79181. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  79182. /**
  79183. * Gets wether or not smoothing reflections is enabled.
  79184. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79185. */
  79186. get enableSmoothReflections(): boolean;
  79187. /**
  79188. * Sets wether or not smoothing reflections is enabled.
  79189. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79190. */
  79191. set enableSmoothReflections(enabled: boolean);
  79192. /**
  79193. * Gets the number of samples taken while computing reflections. More samples count is high,
  79194. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79195. */
  79196. get reflectionSamples(): number;
  79197. /**
  79198. * Sets the number of samples taken while computing reflections. More samples count is high,
  79199. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79200. */
  79201. set reflectionSamples(samples: number);
  79202. /**
  79203. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  79204. * more the post-process will require GPU power and can generate a drop in FPS.
  79205. * Default value (5.0) work pretty well in all cases but can be adjusted.
  79206. */
  79207. get smoothSteps(): number;
  79208. set smoothSteps(steps: number);
  79209. private _updateEffectDefines;
  79210. /** @hidden */
  79211. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  79212. }
  79213. }
  79214. declare module "babylonjs/Shaders/standard.fragment" {
  79215. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  79216. /** @hidden */
  79217. export var standardPixelShader: {
  79218. name: string;
  79219. shader: string;
  79220. };
  79221. }
  79222. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  79223. import { Nullable } from "babylonjs/types";
  79224. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  79225. import { Camera } from "babylonjs/Cameras/camera";
  79226. import { Texture } from "babylonjs/Materials/Textures/texture";
  79227. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79228. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79229. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  79230. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  79231. import { IDisposable } from "babylonjs/scene";
  79232. import { SpotLight } from "babylonjs/Lights/spotLight";
  79233. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  79234. import { Scene } from "babylonjs/scene";
  79235. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  79236. import { Animation } from "babylonjs/Animations/animation";
  79237. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79238. import "babylonjs/Shaders/standard.fragment";
  79239. /**
  79240. * Standard rendering pipeline
  79241. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79242. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  79243. */
  79244. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  79245. /**
  79246. * Public members
  79247. */
  79248. /**
  79249. * Post-process which contains the original scene color before the pipeline applies all the effects
  79250. */
  79251. originalPostProcess: Nullable<PostProcess>;
  79252. /**
  79253. * Post-process used to down scale an image x4
  79254. */
  79255. downSampleX4PostProcess: Nullable<PostProcess>;
  79256. /**
  79257. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  79258. */
  79259. brightPassPostProcess: Nullable<PostProcess>;
  79260. /**
  79261. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  79262. */
  79263. blurHPostProcesses: PostProcess[];
  79264. /**
  79265. * Post-process array storing all the vertical blur post-processes used by the pipeline
  79266. */
  79267. blurVPostProcesses: PostProcess[];
  79268. /**
  79269. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  79270. */
  79271. textureAdderPostProcess: Nullable<PostProcess>;
  79272. /**
  79273. * Post-process used to create volumetric lighting effect
  79274. */
  79275. volumetricLightPostProcess: Nullable<PostProcess>;
  79276. /**
  79277. * Post-process used to smooth the previous volumetric light post-process on the X axis
  79278. */
  79279. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  79280. /**
  79281. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  79282. */
  79283. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  79284. /**
  79285. * Post-process used to merge the volumetric light effect and the real scene color
  79286. */
  79287. volumetricLightMergePostProces: Nullable<PostProcess>;
  79288. /**
  79289. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  79290. */
  79291. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  79292. /**
  79293. * Base post-process used to calculate the average luminance of the final image for HDR
  79294. */
  79295. luminancePostProcess: Nullable<PostProcess>;
  79296. /**
  79297. * Post-processes used to create down sample post-processes in order to get
  79298. * the average luminance of the final image for HDR
  79299. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  79300. */
  79301. luminanceDownSamplePostProcesses: PostProcess[];
  79302. /**
  79303. * Post-process used to create a HDR effect (light adaptation)
  79304. */
  79305. hdrPostProcess: Nullable<PostProcess>;
  79306. /**
  79307. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  79308. */
  79309. textureAdderFinalPostProcess: Nullable<PostProcess>;
  79310. /**
  79311. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  79312. */
  79313. lensFlareFinalPostProcess: Nullable<PostProcess>;
  79314. /**
  79315. * Post-process used to merge the final HDR post-process and the real scene color
  79316. */
  79317. hdrFinalPostProcess: Nullable<PostProcess>;
  79318. /**
  79319. * Post-process used to create a lens flare effect
  79320. */
  79321. lensFlarePostProcess: Nullable<PostProcess>;
  79322. /**
  79323. * Post-process that merges the result of the lens flare post-process and the real scene color
  79324. */
  79325. lensFlareComposePostProcess: Nullable<PostProcess>;
  79326. /**
  79327. * Post-process used to create a motion blur effect
  79328. */
  79329. motionBlurPostProcess: Nullable<PostProcess>;
  79330. /**
  79331. * Post-process used to create a depth of field effect
  79332. */
  79333. depthOfFieldPostProcess: Nullable<PostProcess>;
  79334. /**
  79335. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  79336. */
  79337. fxaaPostProcess: Nullable<FxaaPostProcess>;
  79338. /**
  79339. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  79340. */
  79341. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  79342. /**
  79343. * Represents the brightness threshold in order to configure the illuminated surfaces
  79344. */
  79345. brightThreshold: number;
  79346. /**
  79347. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  79348. */
  79349. blurWidth: number;
  79350. /**
  79351. * Sets if the blur for highlighted surfaces must be only horizontal
  79352. */
  79353. horizontalBlur: boolean;
  79354. /**
  79355. * Gets the overall exposure used by the pipeline
  79356. */
  79357. get exposure(): number;
  79358. /**
  79359. * Sets the overall exposure used by the pipeline
  79360. */
  79361. set exposure(value: number);
  79362. /**
  79363. * Texture used typically to simulate "dirty" on camera lens
  79364. */
  79365. lensTexture: Nullable<Texture>;
  79366. /**
  79367. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  79368. */
  79369. volumetricLightCoefficient: number;
  79370. /**
  79371. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  79372. */
  79373. volumetricLightPower: number;
  79374. /**
  79375. * Used the set the blur intensity to smooth the volumetric lights
  79376. */
  79377. volumetricLightBlurScale: number;
  79378. /**
  79379. * Light (spot or directional) used to generate the volumetric lights rays
  79380. * The source light must have a shadow generate so the pipeline can get its
  79381. * depth map
  79382. */
  79383. sourceLight: Nullable<SpotLight | DirectionalLight>;
  79384. /**
  79385. * For eye adaptation, represents the minimum luminance the eye can see
  79386. */
  79387. hdrMinimumLuminance: number;
  79388. /**
  79389. * For eye adaptation, represents the decrease luminance speed
  79390. */
  79391. hdrDecreaseRate: number;
  79392. /**
  79393. * For eye adaptation, represents the increase luminance speed
  79394. */
  79395. hdrIncreaseRate: number;
  79396. /**
  79397. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79398. */
  79399. get hdrAutoExposure(): boolean;
  79400. /**
  79401. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79402. */
  79403. set hdrAutoExposure(value: boolean);
  79404. /**
  79405. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  79406. */
  79407. lensColorTexture: Nullable<Texture>;
  79408. /**
  79409. * The overall strengh for the lens flare effect
  79410. */
  79411. lensFlareStrength: number;
  79412. /**
  79413. * Dispersion coefficient for lens flare ghosts
  79414. */
  79415. lensFlareGhostDispersal: number;
  79416. /**
  79417. * Main lens flare halo width
  79418. */
  79419. lensFlareHaloWidth: number;
  79420. /**
  79421. * Based on the lens distortion effect, defines how much the lens flare result
  79422. * is distorted
  79423. */
  79424. lensFlareDistortionStrength: number;
  79425. /**
  79426. * Configures the blur intensity used for for lens flare (halo)
  79427. */
  79428. lensFlareBlurWidth: number;
  79429. /**
  79430. * Lens star texture must be used to simulate rays on the flares and is available
  79431. * in the documentation
  79432. */
  79433. lensStarTexture: Nullable<Texture>;
  79434. /**
  79435. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  79436. * flare effect by taking account of the dirt texture
  79437. */
  79438. lensFlareDirtTexture: Nullable<Texture>;
  79439. /**
  79440. * Represents the focal length for the depth of field effect
  79441. */
  79442. depthOfFieldDistance: number;
  79443. /**
  79444. * Represents the blur intensity for the blurred part of the depth of field effect
  79445. */
  79446. depthOfFieldBlurWidth: number;
  79447. /**
  79448. * Gets how much the image is blurred by the movement while using the motion blur post-process
  79449. */
  79450. get motionStrength(): number;
  79451. /**
  79452. * Sets how much the image is blurred by the movement while using the motion blur post-process
  79453. */
  79454. set motionStrength(strength: number);
  79455. /**
  79456. * Gets wether or not the motion blur post-process is object based or screen based.
  79457. */
  79458. get objectBasedMotionBlur(): boolean;
  79459. /**
  79460. * Sets wether or not the motion blur post-process should be object based or screen based
  79461. */
  79462. set objectBasedMotionBlur(value: boolean);
  79463. /**
  79464. * List of animations for the pipeline (IAnimatable implementation)
  79465. */
  79466. animations: Animation[];
  79467. /**
  79468. * Private members
  79469. */
  79470. private _scene;
  79471. private _currentDepthOfFieldSource;
  79472. private _basePostProcess;
  79473. private _fixedExposure;
  79474. private _currentExposure;
  79475. private _hdrAutoExposure;
  79476. private _hdrCurrentLuminance;
  79477. private _motionStrength;
  79478. private _isObjectBasedMotionBlur;
  79479. private _floatTextureType;
  79480. private _camerasToBeAttached;
  79481. private _ratio;
  79482. private _bloomEnabled;
  79483. private _depthOfFieldEnabled;
  79484. private _vlsEnabled;
  79485. private _lensFlareEnabled;
  79486. private _hdrEnabled;
  79487. private _motionBlurEnabled;
  79488. private _fxaaEnabled;
  79489. private _screenSpaceReflectionsEnabled;
  79490. private _motionBlurSamples;
  79491. private _volumetricLightStepsCount;
  79492. private _samples;
  79493. /**
  79494. * @ignore
  79495. * Specifies if the bloom pipeline is enabled
  79496. */
  79497. get BloomEnabled(): boolean;
  79498. set BloomEnabled(enabled: boolean);
  79499. /**
  79500. * @ignore
  79501. * Specifies if the depth of field pipeline is enabed
  79502. */
  79503. get DepthOfFieldEnabled(): boolean;
  79504. set DepthOfFieldEnabled(enabled: boolean);
  79505. /**
  79506. * @ignore
  79507. * Specifies if the lens flare pipeline is enabed
  79508. */
  79509. get LensFlareEnabled(): boolean;
  79510. set LensFlareEnabled(enabled: boolean);
  79511. /**
  79512. * @ignore
  79513. * Specifies if the HDR pipeline is enabled
  79514. */
  79515. get HDREnabled(): boolean;
  79516. set HDREnabled(enabled: boolean);
  79517. /**
  79518. * @ignore
  79519. * Specifies if the volumetric lights scattering effect is enabled
  79520. */
  79521. get VLSEnabled(): boolean;
  79522. set VLSEnabled(enabled: boolean);
  79523. /**
  79524. * @ignore
  79525. * Specifies if the motion blur effect is enabled
  79526. */
  79527. get MotionBlurEnabled(): boolean;
  79528. set MotionBlurEnabled(enabled: boolean);
  79529. /**
  79530. * Specifies if anti-aliasing is enabled
  79531. */
  79532. get fxaaEnabled(): boolean;
  79533. set fxaaEnabled(enabled: boolean);
  79534. /**
  79535. * Specifies if screen space reflections are enabled.
  79536. */
  79537. get screenSpaceReflectionsEnabled(): boolean;
  79538. set screenSpaceReflectionsEnabled(enabled: boolean);
  79539. /**
  79540. * Specifies the number of steps used to calculate the volumetric lights
  79541. * Typically in interval [50, 200]
  79542. */
  79543. get volumetricLightStepsCount(): number;
  79544. set volumetricLightStepsCount(count: number);
  79545. /**
  79546. * Specifies the number of samples used for the motion blur effect
  79547. * Typically in interval [16, 64]
  79548. */
  79549. get motionBlurSamples(): number;
  79550. set motionBlurSamples(samples: number);
  79551. /**
  79552. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  79553. */
  79554. get samples(): number;
  79555. set samples(sampleCount: number);
  79556. /**
  79557. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79558. * @constructor
  79559. * @param name The rendering pipeline name
  79560. * @param scene The scene linked to this pipeline
  79561. * @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)
  79562. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  79563. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79564. */
  79565. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  79566. private _buildPipeline;
  79567. private _createDownSampleX4PostProcess;
  79568. private _createBrightPassPostProcess;
  79569. private _createBlurPostProcesses;
  79570. private _createTextureAdderPostProcess;
  79571. private _createVolumetricLightPostProcess;
  79572. private _createLuminancePostProcesses;
  79573. private _createHdrPostProcess;
  79574. private _createLensFlarePostProcess;
  79575. private _createDepthOfFieldPostProcess;
  79576. private _createMotionBlurPostProcess;
  79577. private _getDepthTexture;
  79578. private _disposePostProcesses;
  79579. /**
  79580. * Dispose of the pipeline and stop all post processes
  79581. */
  79582. dispose(): void;
  79583. /**
  79584. * Serialize the rendering pipeline (Used when exporting)
  79585. * @returns the serialized object
  79586. */
  79587. serialize(): any;
  79588. /**
  79589. * Parse the serialized pipeline
  79590. * @param source Source pipeline.
  79591. * @param scene The scene to load the pipeline to.
  79592. * @param rootUrl The URL of the serialized pipeline.
  79593. * @returns An instantiated pipeline from the serialized object.
  79594. */
  79595. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  79596. /**
  79597. * Luminance steps
  79598. */
  79599. static LuminanceSteps: number;
  79600. }
  79601. }
  79602. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  79603. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  79604. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  79605. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  79606. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  79607. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  79608. }
  79609. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  79610. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  79611. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  79612. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79613. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  79614. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79615. }
  79616. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  79617. /** @hidden */
  79618. export var stereoscopicInterlacePixelShader: {
  79619. name: string;
  79620. shader: string;
  79621. };
  79622. }
  79623. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  79624. import { Camera } from "babylonjs/Cameras/camera";
  79625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79626. import { Engine } from "babylonjs/Engines/engine";
  79627. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  79628. /**
  79629. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  79630. */
  79631. export class StereoscopicInterlacePostProcessI extends PostProcess {
  79632. private _stepSize;
  79633. private _passedProcess;
  79634. /**
  79635. * Gets a string identifying the name of the class
  79636. * @returns "StereoscopicInterlacePostProcessI" string
  79637. */
  79638. getClassName(): string;
  79639. /**
  79640. * Initializes a StereoscopicInterlacePostProcessI
  79641. * @param name The name of the effect.
  79642. * @param rigCameras The rig cameras to be appled to the post process
  79643. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  79644. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  79645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79646. * @param engine The engine which the post process will be applied. (default: current engine)
  79647. * @param reusable If the post process can be reused on the same frame. (default: false)
  79648. */
  79649. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  79650. }
  79651. /**
  79652. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  79653. */
  79654. export class StereoscopicInterlacePostProcess extends PostProcess {
  79655. private _stepSize;
  79656. private _passedProcess;
  79657. /**
  79658. * Gets a string identifying the name of the class
  79659. * @returns "StereoscopicInterlacePostProcess" string
  79660. */
  79661. getClassName(): string;
  79662. /**
  79663. * Initializes a StereoscopicInterlacePostProcess
  79664. * @param name The name of the effect.
  79665. * @param rigCameras The rig cameras to be appled to the post process
  79666. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  79667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79668. * @param engine The engine which the post process will be applied. (default: current engine)
  79669. * @param reusable If the post process can be reused on the same frame. (default: false)
  79670. */
  79671. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  79672. }
  79673. }
  79674. declare module "babylonjs/Shaders/tonemap.fragment" {
  79675. /** @hidden */
  79676. export var tonemapPixelShader: {
  79677. name: string;
  79678. shader: string;
  79679. };
  79680. }
  79681. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  79682. import { Camera } from "babylonjs/Cameras/camera";
  79683. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79684. import "babylonjs/Shaders/tonemap.fragment";
  79685. import { Engine } from "babylonjs/Engines/engine";
  79686. /** Defines operator used for tonemapping */
  79687. export enum TonemappingOperator {
  79688. /** Hable */
  79689. Hable = 0,
  79690. /** Reinhard */
  79691. Reinhard = 1,
  79692. /** HejiDawson */
  79693. HejiDawson = 2,
  79694. /** Photographic */
  79695. Photographic = 3
  79696. }
  79697. /**
  79698. * Defines a post process to apply tone mapping
  79699. */
  79700. export class TonemapPostProcess extends PostProcess {
  79701. private _operator;
  79702. /** Defines the required exposure adjustement */
  79703. exposureAdjustment: number;
  79704. /**
  79705. * Gets a string identifying the name of the class
  79706. * @returns "TonemapPostProcess" string
  79707. */
  79708. getClassName(): string;
  79709. /**
  79710. * Creates a new TonemapPostProcess
  79711. * @param name defines the name of the postprocess
  79712. * @param _operator defines the operator to use
  79713. * @param exposureAdjustment defines the required exposure adjustement
  79714. * @param camera defines the camera to use (can be null)
  79715. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  79716. * @param engine defines the hosting engine (can be ignore if camera is set)
  79717. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79718. */
  79719. constructor(name: string, _operator: TonemappingOperator,
  79720. /** Defines the required exposure adjustement */
  79721. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  79722. }
  79723. }
  79724. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  79725. /** @hidden */
  79726. export var volumetricLightScatteringPixelShader: {
  79727. name: string;
  79728. shader: string;
  79729. };
  79730. }
  79731. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  79732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  79733. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  79734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  79735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  79736. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  79737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  79738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  79739. /** @hidden */
  79740. export var volumetricLightScatteringPassVertexShader: {
  79741. name: string;
  79742. shader: string;
  79743. };
  79744. }
  79745. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  79746. /** @hidden */
  79747. export var volumetricLightScatteringPassPixelShader: {
  79748. name: string;
  79749. shader: string;
  79750. };
  79751. }
  79752. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  79753. import { Vector3 } from "babylonjs/Maths/math.vector";
  79754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79755. import { Mesh } from "babylonjs/Meshes/mesh";
  79756. import { Camera } from "babylonjs/Cameras/camera";
  79757. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  79758. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79759. import { Scene } from "babylonjs/scene";
  79760. import "babylonjs/Meshes/Builders/planeBuilder";
  79761. import "babylonjs/Shaders/depth.vertex";
  79762. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  79763. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  79764. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  79765. import { Engine } from "babylonjs/Engines/engine";
  79766. /**
  79767. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  79768. */
  79769. export class VolumetricLightScatteringPostProcess extends PostProcess {
  79770. private _volumetricLightScatteringPass;
  79771. private _volumetricLightScatteringRTT;
  79772. private _viewPort;
  79773. private _screenCoordinates;
  79774. private _cachedDefines;
  79775. /**
  79776. * If not undefined, the mesh position is computed from the attached node position
  79777. */
  79778. attachedNode: {
  79779. position: Vector3;
  79780. };
  79781. /**
  79782. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  79783. */
  79784. customMeshPosition: Vector3;
  79785. /**
  79786. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  79787. */
  79788. useCustomMeshPosition: boolean;
  79789. /**
  79790. * If the post-process should inverse the light scattering direction
  79791. */
  79792. invert: boolean;
  79793. /**
  79794. * The internal mesh used by the post-process
  79795. */
  79796. mesh: Mesh;
  79797. /**
  79798. * @hidden
  79799. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  79800. */
  79801. get useDiffuseColor(): boolean;
  79802. set useDiffuseColor(useDiffuseColor: boolean);
  79803. /**
  79804. * Array containing the excluded meshes not rendered in the internal pass
  79805. */
  79806. excludedMeshes: AbstractMesh[];
  79807. /**
  79808. * Controls the overall intensity of the post-process
  79809. */
  79810. exposure: number;
  79811. /**
  79812. * Dissipates each sample's contribution in range [0, 1]
  79813. */
  79814. decay: number;
  79815. /**
  79816. * Controls the overall intensity of each sample
  79817. */
  79818. weight: number;
  79819. /**
  79820. * Controls the density of each sample
  79821. */
  79822. density: number;
  79823. /**
  79824. * @constructor
  79825. * @param name The post-process name
  79826. * @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)
  79827. * @param camera The camera that the post-process will be attached to
  79828. * @param mesh The mesh used to create the light scattering
  79829. * @param samples The post-process quality, default 100
  79830. * @param samplingModeThe post-process filtering mode
  79831. * @param engine The babylon engine
  79832. * @param reusable If the post-process is reusable
  79833. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  79834. */
  79835. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  79836. /**
  79837. * Returns the string "VolumetricLightScatteringPostProcess"
  79838. * @returns "VolumetricLightScatteringPostProcess"
  79839. */
  79840. getClassName(): string;
  79841. private _isReady;
  79842. /**
  79843. * Sets the new light position for light scattering effect
  79844. * @param position The new custom light position
  79845. */
  79846. setCustomMeshPosition(position: Vector3): void;
  79847. /**
  79848. * Returns the light position for light scattering effect
  79849. * @return Vector3 The custom light position
  79850. */
  79851. getCustomMeshPosition(): Vector3;
  79852. /**
  79853. * Disposes the internal assets and detaches the post-process from the camera
  79854. */
  79855. dispose(camera: Camera): void;
  79856. /**
  79857. * Returns the render target texture used by the post-process
  79858. * @return the render target texture used by the post-process
  79859. */
  79860. getPass(): RenderTargetTexture;
  79861. private _meshExcluded;
  79862. private _createPass;
  79863. private _updateMeshScreenCoordinates;
  79864. /**
  79865. * Creates a default mesh for the Volumeric Light Scattering post-process
  79866. * @param name The mesh name
  79867. * @param scene The scene where to create the mesh
  79868. * @return the default mesh
  79869. */
  79870. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  79871. }
  79872. }
  79873. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  79874. /** @hidden */
  79875. export var screenSpaceCurvaturePixelShader: {
  79876. name: string;
  79877. shader: string;
  79878. };
  79879. }
  79880. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  79881. import { Nullable } from "babylonjs/types";
  79882. import { Camera } from "babylonjs/Cameras/camera";
  79883. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79884. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  79885. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  79886. import { Engine } from "babylonjs/Engines/engine";
  79887. import { Scene } from "babylonjs/scene";
  79888. /**
  79889. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  79890. */
  79891. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  79892. /**
  79893. * Defines how much ridge the curvature effect displays.
  79894. */
  79895. ridge: number;
  79896. /**
  79897. * Defines how much valley the curvature effect displays.
  79898. */
  79899. valley: number;
  79900. private _geometryBufferRenderer;
  79901. /**
  79902. * Gets a string identifying the name of the class
  79903. * @returns "ScreenSpaceCurvaturePostProcess" string
  79904. */
  79905. getClassName(): string;
  79906. /**
  79907. * Creates a new instance ScreenSpaceCurvaturePostProcess
  79908. * @param name The name of the effect.
  79909. * @param scene The scene containing the objects to blur according to their velocity.
  79910. * @param options The required width/height ratio to downsize to before computing the render pass.
  79911. * @param camera The camera to apply the render pass to.
  79912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79913. * @param engine The engine which the post process will be applied. (default: current engine)
  79914. * @param reusable If the post process can be reused on the same frame. (default: false)
  79915. * @param textureType Type of textures used when performing the post process. (default: 0)
  79916. * @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)
  79917. */
  79918. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  79919. /**
  79920. * Support test.
  79921. */
  79922. static get IsSupported(): boolean;
  79923. /** @hidden */
  79924. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  79925. }
  79926. }
  79927. declare module "babylonjs/PostProcesses/index" {
  79928. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  79929. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  79930. export * from "babylonjs/PostProcesses/bloomEffect";
  79931. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  79932. export * from "babylonjs/PostProcesses/blurPostProcess";
  79933. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  79934. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  79935. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  79936. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  79937. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  79938. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  79939. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  79940. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  79941. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  79942. export * from "babylonjs/PostProcesses/filterPostProcess";
  79943. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  79944. export * from "babylonjs/PostProcesses/grainPostProcess";
  79945. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  79946. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  79947. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  79948. export * from "babylonjs/PostProcesses/passPostProcess";
  79949. export * from "babylonjs/PostProcesses/postProcess";
  79950. export * from "babylonjs/PostProcesses/postProcessManager";
  79951. export * from "babylonjs/PostProcesses/refractionPostProcess";
  79952. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  79953. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  79954. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  79955. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  79956. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  79957. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  79958. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  79959. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  79960. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  79961. }
  79962. declare module "babylonjs/Probes/index" {
  79963. export * from "babylonjs/Probes/reflectionProbe";
  79964. }
  79965. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  79966. import { Scene } from "babylonjs/scene";
  79967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79968. import { SmartArray } from "babylonjs/Misc/smartArray";
  79969. import { ISceneComponent } from "babylonjs/sceneComponent";
  79970. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  79971. import "babylonjs/Meshes/Builders/boxBuilder";
  79972. import "babylonjs/Shaders/color.fragment";
  79973. import "babylonjs/Shaders/color.vertex";
  79974. import { Color3 } from "babylonjs/Maths/math.color";
  79975. import { Observable } from "babylonjs/Misc/observable";
  79976. module "babylonjs/scene" {
  79977. interface Scene {
  79978. /** @hidden (Backing field) */
  79979. _boundingBoxRenderer: BoundingBoxRenderer;
  79980. /** @hidden (Backing field) */
  79981. _forceShowBoundingBoxes: boolean;
  79982. /**
  79983. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  79984. */
  79985. forceShowBoundingBoxes: boolean;
  79986. /**
  79987. * Gets the bounding box renderer associated with the scene
  79988. * @returns a BoundingBoxRenderer
  79989. */
  79990. getBoundingBoxRenderer(): BoundingBoxRenderer;
  79991. }
  79992. }
  79993. module "babylonjs/Meshes/abstractMesh" {
  79994. interface AbstractMesh {
  79995. /** @hidden (Backing field) */
  79996. _showBoundingBox: boolean;
  79997. /**
  79998. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  79999. */
  80000. showBoundingBox: boolean;
  80001. }
  80002. }
  80003. /**
  80004. * Component responsible of rendering the bounding box of the meshes in a scene.
  80005. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  80006. */
  80007. export class BoundingBoxRenderer implements ISceneComponent {
  80008. /**
  80009. * The component name helpfull to identify the component in the list of scene components.
  80010. */
  80011. readonly name: string;
  80012. /**
  80013. * The scene the component belongs to.
  80014. */
  80015. scene: Scene;
  80016. /**
  80017. * Color of the bounding box lines placed in front of an object
  80018. */
  80019. frontColor: Color3;
  80020. /**
  80021. * Color of the bounding box lines placed behind an object
  80022. */
  80023. backColor: Color3;
  80024. /**
  80025. * Defines if the renderer should show the back lines or not
  80026. */
  80027. showBackLines: boolean;
  80028. /**
  80029. * Observable raised before rendering a bounding box
  80030. */
  80031. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  80032. /**
  80033. * Observable raised after rendering a bounding box
  80034. */
  80035. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  80036. /**
  80037. * Observable raised after resources are created
  80038. */
  80039. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  80040. /**
  80041. * When false, no bounding boxes will be rendered
  80042. */
  80043. enabled: boolean;
  80044. /**
  80045. * @hidden
  80046. */
  80047. renderList: SmartArray<BoundingBox>;
  80048. private _colorShader;
  80049. private _vertexBuffers;
  80050. private _indexBuffer;
  80051. private _fillIndexBuffer;
  80052. private _fillIndexData;
  80053. /**
  80054. * Instantiates a new bounding box renderer in a scene.
  80055. * @param scene the scene the renderer renders in
  80056. */
  80057. constructor(scene: Scene);
  80058. /**
  80059. * Registers the component in a given scene
  80060. */
  80061. register(): void;
  80062. private _evaluateSubMesh;
  80063. private _preActiveMesh;
  80064. private _prepareResources;
  80065. private _createIndexBuffer;
  80066. /**
  80067. * Rebuilds the elements related to this component in case of
  80068. * context lost for instance.
  80069. */
  80070. rebuild(): void;
  80071. /**
  80072. * @hidden
  80073. */
  80074. reset(): void;
  80075. /**
  80076. * Render the bounding boxes of a specific rendering group
  80077. * @param renderingGroupId defines the rendering group to render
  80078. */
  80079. render(renderingGroupId: number): void;
  80080. /**
  80081. * In case of occlusion queries, we can render the occlusion bounding box through this method
  80082. * @param mesh Define the mesh to render the occlusion bounding box for
  80083. */
  80084. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  80085. /**
  80086. * Dispose and release the resources attached to this renderer.
  80087. */
  80088. dispose(): void;
  80089. }
  80090. }
  80091. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  80092. import { Nullable } from "babylonjs/types";
  80093. import { Scene } from "babylonjs/scene";
  80094. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  80095. import { Camera } from "babylonjs/Cameras/camera";
  80096. import { ISceneComponent } from "babylonjs/sceneComponent";
  80097. module "babylonjs/scene" {
  80098. interface Scene {
  80099. /** @hidden (Backing field) */
  80100. _depthRenderer: {
  80101. [id: string]: DepthRenderer;
  80102. };
  80103. /**
  80104. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  80105. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  80106. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  80107. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  80108. * @returns the created depth renderer
  80109. */
  80110. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  80111. /**
  80112. * Disables a depth renderer for a given camera
  80113. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  80114. */
  80115. disableDepthRenderer(camera?: Nullable<Camera>): void;
  80116. }
  80117. }
  80118. /**
  80119. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  80120. * in several rendering techniques.
  80121. */
  80122. export class DepthRendererSceneComponent implements ISceneComponent {
  80123. /**
  80124. * The component name helpfull to identify the component in the list of scene components.
  80125. */
  80126. readonly name: string;
  80127. /**
  80128. * The scene the component belongs to.
  80129. */
  80130. scene: Scene;
  80131. /**
  80132. * Creates a new instance of the component for the given scene
  80133. * @param scene Defines the scene to register the component in
  80134. */
  80135. constructor(scene: Scene);
  80136. /**
  80137. * Registers the component in a given scene
  80138. */
  80139. register(): void;
  80140. /**
  80141. * Rebuilds the elements related to this component in case of
  80142. * context lost for instance.
  80143. */
  80144. rebuild(): void;
  80145. /**
  80146. * Disposes the component and the associated ressources
  80147. */
  80148. dispose(): void;
  80149. private _gatherRenderTargets;
  80150. private _gatherActiveCameraRenderTargets;
  80151. }
  80152. }
  80153. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  80154. import { Nullable } from "babylonjs/types";
  80155. import { Scene } from "babylonjs/scene";
  80156. import { ISceneComponent } from "babylonjs/sceneComponent";
  80157. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  80158. module "babylonjs/abstractScene" {
  80159. interface AbstractScene {
  80160. /** @hidden (Backing field) */
  80161. _prePassRenderer: Nullable<PrePassRenderer>;
  80162. /**
  80163. * Gets or Sets the current prepass renderer associated to the scene.
  80164. */
  80165. prePassRenderer: Nullable<PrePassRenderer>;
  80166. /**
  80167. * Enables the prepass and associates it with the scene
  80168. * @returns the PrePassRenderer
  80169. */
  80170. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  80171. /**
  80172. * Disables the prepass associated with the scene
  80173. */
  80174. disablePrePassRenderer(): void;
  80175. }
  80176. }
  80177. /**
  80178. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80179. * in several rendering techniques.
  80180. */
  80181. export class PrePassRendererSceneComponent implements ISceneComponent {
  80182. /**
  80183. * The component name helpful to identify the component in the list of scene components.
  80184. */
  80185. readonly name: string;
  80186. /**
  80187. * The scene the component belongs to.
  80188. */
  80189. scene: Scene;
  80190. /**
  80191. * Creates a new instance of the component for the given scene
  80192. * @param scene Defines the scene to register the component in
  80193. */
  80194. constructor(scene: Scene);
  80195. /**
  80196. * Registers the component in a given scene
  80197. */
  80198. register(): void;
  80199. private _beforeCameraDraw;
  80200. private _afterCameraDraw;
  80201. private _beforeClearStage;
  80202. private _beforeRenderingMeshStage;
  80203. private _afterRenderingMeshStage;
  80204. /**
  80205. * Rebuilds the elements related to this component in case of
  80206. * context lost for instance.
  80207. */
  80208. rebuild(): void;
  80209. /**
  80210. * Disposes the component and the associated ressources
  80211. */
  80212. dispose(): void;
  80213. }
  80214. }
  80215. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  80216. /** @hidden */
  80217. export var fibonacci: {
  80218. name: string;
  80219. shader: string;
  80220. };
  80221. }
  80222. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  80223. /** @hidden */
  80224. export var diffusionProfile: {
  80225. name: string;
  80226. shader: string;
  80227. };
  80228. }
  80229. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  80230. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  80231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  80232. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  80233. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  80234. /** @hidden */
  80235. export var subSurfaceScatteringPixelShader: {
  80236. name: string;
  80237. shader: string;
  80238. };
  80239. }
  80240. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  80241. import { Nullable } from "babylonjs/types";
  80242. import { Camera } from "babylonjs/Cameras/camera";
  80243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80244. import { Engine } from "babylonjs/Engines/engine";
  80245. import { Scene } from "babylonjs/scene";
  80246. import "babylonjs/Shaders/imageProcessing.fragment";
  80247. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  80248. import "babylonjs/Shaders/postprocess.vertex";
  80249. /**
  80250. * Sub surface scattering post process
  80251. */
  80252. export class SubSurfaceScatteringPostProcess extends PostProcess {
  80253. /**
  80254. * Gets a string identifying the name of the class
  80255. * @returns "SubSurfaceScatteringPostProcess" string
  80256. */
  80257. getClassName(): string;
  80258. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  80259. }
  80260. }
  80261. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  80262. import { Scene } from "babylonjs/scene";
  80263. import { Color3 } from "babylonjs/Maths/math.color";
  80264. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  80265. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  80266. /**
  80267. * Contains all parameters needed for the prepass to perform
  80268. * screen space subsurface scattering
  80269. */
  80270. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  80271. /** @hidden */
  80272. static _SceneComponentInitialization: (scene: Scene) => void;
  80273. private _ssDiffusionS;
  80274. private _ssFilterRadii;
  80275. private _ssDiffusionD;
  80276. /**
  80277. * Post process to attach for screen space subsurface scattering
  80278. */
  80279. postProcess: SubSurfaceScatteringPostProcess;
  80280. /**
  80281. * Diffusion profile color for subsurface scattering
  80282. */
  80283. get ssDiffusionS(): number[];
  80284. /**
  80285. * Diffusion profile max color channel value for subsurface scattering
  80286. */
  80287. get ssDiffusionD(): number[];
  80288. /**
  80289. * Diffusion profile filter radius for subsurface scattering
  80290. */
  80291. get ssFilterRadii(): number[];
  80292. /**
  80293. * Is subsurface enabled
  80294. */
  80295. enabled: boolean;
  80296. /**
  80297. * Name of the configuration
  80298. */
  80299. name: string;
  80300. /**
  80301. * Diffusion profile colors for subsurface scattering
  80302. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  80303. * See ...
  80304. * Note that you can only store up to 5 of them
  80305. */
  80306. ssDiffusionProfileColors: Color3[];
  80307. /**
  80308. * Defines the ratio real world => scene units.
  80309. * Used for subsurface scattering
  80310. */
  80311. metersPerUnit: number;
  80312. /**
  80313. * Textures that should be present in the MRT for this effect to work
  80314. */
  80315. readonly texturesRequired: number[];
  80316. private _scene;
  80317. /**
  80318. * Builds a subsurface configuration object
  80319. * @param scene The scene
  80320. */
  80321. constructor(scene: Scene);
  80322. /**
  80323. * Adds a new diffusion profile.
  80324. * Useful for more realistic subsurface scattering on diverse materials.
  80325. * @param color The color of the diffusion profile. Should be the average color of the material.
  80326. * @return The index of the diffusion profile for the material subsurface configuration
  80327. */
  80328. addDiffusionProfile(color: Color3): number;
  80329. /**
  80330. * Creates the sss post process
  80331. * @return The created post process
  80332. */
  80333. createPostProcess(): SubSurfaceScatteringPostProcess;
  80334. /**
  80335. * Deletes all diffusion profiles.
  80336. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  80337. */
  80338. clearAllDiffusionProfiles(): void;
  80339. /**
  80340. * Disposes this object
  80341. */
  80342. dispose(): void;
  80343. /**
  80344. * @hidden
  80345. * https://zero-radiance.github.io/post/sampling-diffusion/
  80346. *
  80347. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  80348. * ------------------------------------------------------------------------------------
  80349. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  80350. * PDF[r, phi, s] = r * R[r, phi, s]
  80351. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  80352. * ------------------------------------------------------------------------------------
  80353. * We importance sample the color channel with the widest scattering distance.
  80354. */
  80355. getDiffusionProfileParameters(color: Color3): number;
  80356. /**
  80357. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  80358. * 'u' is the random number (the value of the CDF): [0, 1).
  80359. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  80360. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  80361. */
  80362. private _sampleBurleyDiffusionProfile;
  80363. }
  80364. }
  80365. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  80366. import { Nullable } from "babylonjs/types";
  80367. import { Scene } from "babylonjs/scene";
  80368. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  80369. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  80370. import { AbstractScene } from "babylonjs/abstractScene";
  80371. module "babylonjs/abstractScene" {
  80372. interface AbstractScene {
  80373. /** @hidden (Backing field) */
  80374. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80375. /**
  80376. * Gets or Sets the current prepass renderer associated to the scene.
  80377. */
  80378. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80379. /**
  80380. * Enables the subsurface effect for prepass
  80381. * @returns the SubSurfaceConfiguration
  80382. */
  80383. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  80384. /**
  80385. * Disables the subsurface effect for prepass
  80386. */
  80387. disableSubSurfaceForPrePass(): void;
  80388. }
  80389. }
  80390. /**
  80391. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80392. * in several rendering techniques.
  80393. */
  80394. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  80395. /**
  80396. * The component name helpful to identify the component in the list of scene components.
  80397. */
  80398. readonly name: string;
  80399. /**
  80400. * The scene the component belongs to.
  80401. */
  80402. scene: Scene;
  80403. /**
  80404. * Creates a new instance of the component for the given scene
  80405. * @param scene Defines the scene to register the component in
  80406. */
  80407. constructor(scene: Scene);
  80408. /**
  80409. * Registers the component in a given scene
  80410. */
  80411. register(): void;
  80412. /**
  80413. * Serializes the component data to the specified json object
  80414. * @param serializationObject The object to serialize to
  80415. */
  80416. serialize(serializationObject: any): void;
  80417. /**
  80418. * Adds all the elements from the container to the scene
  80419. * @param container the container holding the elements
  80420. */
  80421. addFromContainer(container: AbstractScene): void;
  80422. /**
  80423. * Removes all the elements in the container from the scene
  80424. * @param container contains the elements to remove
  80425. * @param dispose if the removed element should be disposed (default: false)
  80426. */
  80427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80428. /**
  80429. * Rebuilds the elements related to this component in case of
  80430. * context lost for instance.
  80431. */
  80432. rebuild(): void;
  80433. /**
  80434. * Disposes the component and the associated ressources
  80435. */
  80436. dispose(): void;
  80437. }
  80438. }
  80439. declare module "babylonjs/Shaders/outline.fragment" {
  80440. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80441. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  80442. /** @hidden */
  80443. export var outlinePixelShader: {
  80444. name: string;
  80445. shader: string;
  80446. };
  80447. }
  80448. declare module "babylonjs/Shaders/outline.vertex" {
  80449. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  80450. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  80451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  80452. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  80453. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  80455. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  80456. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  80457. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  80458. /** @hidden */
  80459. export var outlineVertexShader: {
  80460. name: string;
  80461. shader: string;
  80462. };
  80463. }
  80464. declare module "babylonjs/Rendering/outlineRenderer" {
  80465. import { SubMesh } from "babylonjs/Meshes/subMesh";
  80466. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  80467. import { Scene } from "babylonjs/scene";
  80468. import { ISceneComponent } from "babylonjs/sceneComponent";
  80469. import "babylonjs/Shaders/outline.fragment";
  80470. import "babylonjs/Shaders/outline.vertex";
  80471. module "babylonjs/scene" {
  80472. interface Scene {
  80473. /** @hidden */
  80474. _outlineRenderer: OutlineRenderer;
  80475. /**
  80476. * Gets the outline renderer associated with the scene
  80477. * @returns a OutlineRenderer
  80478. */
  80479. getOutlineRenderer(): OutlineRenderer;
  80480. }
  80481. }
  80482. module "babylonjs/Meshes/abstractMesh" {
  80483. interface AbstractMesh {
  80484. /** @hidden (Backing field) */
  80485. _renderOutline: boolean;
  80486. /**
  80487. * Gets or sets a boolean indicating if the outline must be rendered as well
  80488. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  80489. */
  80490. renderOutline: boolean;
  80491. /** @hidden (Backing field) */
  80492. _renderOverlay: boolean;
  80493. /**
  80494. * Gets or sets a boolean indicating if the overlay must be rendered as well
  80495. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  80496. */
  80497. renderOverlay: boolean;
  80498. }
  80499. }
  80500. /**
  80501. * This class is responsible to draw bothe outline/overlay of meshes.
  80502. * It should not be used directly but through the available method on mesh.
  80503. */
  80504. export class OutlineRenderer implements ISceneComponent {
  80505. /**
  80506. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  80507. */
  80508. private static _StencilReference;
  80509. /**
  80510. * The name of the component. Each component must have a unique name.
  80511. */
  80512. name: string;
  80513. /**
  80514. * The scene the component belongs to.
  80515. */
  80516. scene: Scene;
  80517. /**
  80518. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  80519. */
  80520. zOffset: number;
  80521. private _engine;
  80522. private _effect;
  80523. private _cachedDefines;
  80524. private _savedDepthWrite;
  80525. /**
  80526. * Instantiates a new outline renderer. (There could be only one per scene).
  80527. * @param scene Defines the scene it belongs to
  80528. */
  80529. constructor(scene: Scene);
  80530. /**
  80531. * Register the component to one instance of a scene.
  80532. */
  80533. register(): void;
  80534. /**
  80535. * Rebuilds the elements related to this component in case of
  80536. * context lost for instance.
  80537. */
  80538. rebuild(): void;
  80539. /**
  80540. * Disposes the component and the associated ressources.
  80541. */
  80542. dispose(): void;
  80543. /**
  80544. * Renders the outline in the canvas.
  80545. * @param subMesh Defines the sumesh to render
  80546. * @param batch Defines the batch of meshes in case of instances
  80547. * @param useOverlay Defines if the rendering is for the overlay or the outline
  80548. */
  80549. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  80550. /**
  80551. * Returns whether or not the outline renderer is ready for a given submesh.
  80552. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  80553. * @param subMesh Defines the submesh to check readyness for
  80554. * @param useInstances Defines wheter wee are trying to render instances or not
  80555. * @returns true if ready otherwise false
  80556. */
  80557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80558. private _beforeRenderingMesh;
  80559. private _afterRenderingMesh;
  80560. }
  80561. }
  80562. declare module "babylonjs/Rendering/index" {
  80563. export * from "babylonjs/Rendering/boundingBoxRenderer";
  80564. export * from "babylonjs/Rendering/depthRenderer";
  80565. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  80566. export * from "babylonjs/Rendering/edgesRenderer";
  80567. export * from "babylonjs/Rendering/geometryBufferRenderer";
  80568. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80569. export * from "babylonjs/Rendering/prePassRenderer";
  80570. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  80571. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  80572. export * from "babylonjs/Rendering/outlineRenderer";
  80573. export * from "babylonjs/Rendering/renderingGroup";
  80574. export * from "babylonjs/Rendering/renderingManager";
  80575. export * from "babylonjs/Rendering/utilityLayerRenderer";
  80576. }
  80577. declare module "babylonjs/Sprites/ISprites" {
  80578. /**
  80579. * Defines the basic options interface of a Sprite Frame Source Size.
  80580. */
  80581. export interface ISpriteJSONSpriteSourceSize {
  80582. /**
  80583. * number of the original width of the Frame
  80584. */
  80585. w: number;
  80586. /**
  80587. * number of the original height of the Frame
  80588. */
  80589. h: number;
  80590. }
  80591. /**
  80592. * Defines the basic options interface of a Sprite Frame Data.
  80593. */
  80594. export interface ISpriteJSONSpriteFrameData {
  80595. /**
  80596. * number of the x offset of the Frame
  80597. */
  80598. x: number;
  80599. /**
  80600. * number of the y offset of the Frame
  80601. */
  80602. y: number;
  80603. /**
  80604. * number of the width of the Frame
  80605. */
  80606. w: number;
  80607. /**
  80608. * number of the height of the Frame
  80609. */
  80610. h: number;
  80611. }
  80612. /**
  80613. * Defines the basic options interface of a JSON Sprite.
  80614. */
  80615. export interface ISpriteJSONSprite {
  80616. /**
  80617. * string name of the Frame
  80618. */
  80619. filename: string;
  80620. /**
  80621. * ISpriteJSONSpriteFrame basic object of the frame data
  80622. */
  80623. frame: ISpriteJSONSpriteFrameData;
  80624. /**
  80625. * boolean to flag is the frame was rotated.
  80626. */
  80627. rotated: boolean;
  80628. /**
  80629. * boolean to flag is the frame was trimmed.
  80630. */
  80631. trimmed: boolean;
  80632. /**
  80633. * ISpriteJSONSpriteFrame basic object of the source data
  80634. */
  80635. spriteSourceSize: ISpriteJSONSpriteFrameData;
  80636. /**
  80637. * ISpriteJSONSpriteFrame basic object of the source data
  80638. */
  80639. sourceSize: ISpriteJSONSpriteSourceSize;
  80640. }
  80641. /**
  80642. * Defines the basic options interface of a JSON atlas.
  80643. */
  80644. export interface ISpriteJSONAtlas {
  80645. /**
  80646. * Array of objects that contain the frame data.
  80647. */
  80648. frames: Array<ISpriteJSONSprite>;
  80649. /**
  80650. * object basic object containing the sprite meta data.
  80651. */
  80652. meta?: object;
  80653. }
  80654. }
  80655. declare module "babylonjs/Shaders/spriteMap.fragment" {
  80656. /** @hidden */
  80657. export var spriteMapPixelShader: {
  80658. name: string;
  80659. shader: string;
  80660. };
  80661. }
  80662. declare module "babylonjs/Shaders/spriteMap.vertex" {
  80663. /** @hidden */
  80664. export var spriteMapVertexShader: {
  80665. name: string;
  80666. shader: string;
  80667. };
  80668. }
  80669. declare module "babylonjs/Sprites/spriteMap" {
  80670. import { IDisposable, Scene } from "babylonjs/scene";
  80671. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  80672. import { Texture } from "babylonjs/Materials/Textures/texture";
  80673. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  80674. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  80675. import "babylonjs/Meshes/Builders/planeBuilder";
  80676. import "babylonjs/Shaders/spriteMap.fragment";
  80677. import "babylonjs/Shaders/spriteMap.vertex";
  80678. /**
  80679. * Defines the basic options interface of a SpriteMap
  80680. */
  80681. export interface ISpriteMapOptions {
  80682. /**
  80683. * Vector2 of the number of cells in the grid.
  80684. */
  80685. stageSize?: Vector2;
  80686. /**
  80687. * Vector2 of the size of the output plane in World Units.
  80688. */
  80689. outputSize?: Vector2;
  80690. /**
  80691. * Vector3 of the position of the output plane in World Units.
  80692. */
  80693. outputPosition?: Vector3;
  80694. /**
  80695. * Vector3 of the rotation of the output plane.
  80696. */
  80697. outputRotation?: Vector3;
  80698. /**
  80699. * number of layers that the system will reserve in resources.
  80700. */
  80701. layerCount?: number;
  80702. /**
  80703. * number of max animation frames a single cell will reserve in resources.
  80704. */
  80705. maxAnimationFrames?: number;
  80706. /**
  80707. * number cell index of the base tile when the system compiles.
  80708. */
  80709. baseTile?: number;
  80710. /**
  80711. * boolean flip the sprite after its been repositioned by the framing data.
  80712. */
  80713. flipU?: boolean;
  80714. /**
  80715. * Vector3 scalar of the global RGB values of the SpriteMap.
  80716. */
  80717. colorMultiply?: Vector3;
  80718. }
  80719. /**
  80720. * Defines the IDisposable interface in order to be cleanable from resources.
  80721. */
  80722. export interface ISpriteMap extends IDisposable {
  80723. /**
  80724. * String name of the SpriteMap.
  80725. */
  80726. name: string;
  80727. /**
  80728. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  80729. */
  80730. atlasJSON: ISpriteJSONAtlas;
  80731. /**
  80732. * Texture of the SpriteMap.
  80733. */
  80734. spriteSheet: Texture;
  80735. /**
  80736. * The parameters to initialize the SpriteMap with.
  80737. */
  80738. options: ISpriteMapOptions;
  80739. }
  80740. /**
  80741. * Class used to manage a grid restricted sprite deployment on an Output plane.
  80742. */
  80743. export class SpriteMap implements ISpriteMap {
  80744. /** The Name of the spriteMap */
  80745. name: string;
  80746. /** The JSON file with the frame and meta data */
  80747. atlasJSON: ISpriteJSONAtlas;
  80748. /** The systems Sprite Sheet Texture */
  80749. spriteSheet: Texture;
  80750. /** Arguments passed with the Constructor */
  80751. options: ISpriteMapOptions;
  80752. /** Public Sprite Storage array, parsed from atlasJSON */
  80753. sprites: Array<ISpriteJSONSprite>;
  80754. /** Returns the Number of Sprites in the System */
  80755. get spriteCount(): number;
  80756. /** Returns the Position of Output Plane*/
  80757. get position(): Vector3;
  80758. /** Returns the Position of Output Plane*/
  80759. set position(v: Vector3);
  80760. /** Returns the Rotation of Output Plane*/
  80761. get rotation(): Vector3;
  80762. /** Returns the Rotation of Output Plane*/
  80763. set rotation(v: Vector3);
  80764. /** Sets the AnimationMap*/
  80765. get animationMap(): RawTexture;
  80766. /** Sets the AnimationMap*/
  80767. set animationMap(v: RawTexture);
  80768. /** Scene that the SpriteMap was created in */
  80769. private _scene;
  80770. /** Texture Buffer of Float32 that holds tile frame data*/
  80771. private _frameMap;
  80772. /** Texture Buffers of Float32 that holds tileMap data*/
  80773. private _tileMaps;
  80774. /** Texture Buffer of Float32 that holds Animation Data*/
  80775. private _animationMap;
  80776. /** Custom ShaderMaterial Central to the System*/
  80777. private _material;
  80778. /** Custom ShaderMaterial Central to the System*/
  80779. private _output;
  80780. /** Systems Time Ticker*/
  80781. private _time;
  80782. /**
  80783. * Creates a new SpriteMap
  80784. * @param name defines the SpriteMaps Name
  80785. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  80786. * @param spriteSheet is the Texture that the Sprites are on.
  80787. * @param options a basic deployment configuration
  80788. * @param scene The Scene that the map is deployed on
  80789. */
  80790. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  80791. /**
  80792. * Returns tileID location
  80793. * @returns Vector2 the cell position ID
  80794. */
  80795. getTileID(): Vector2;
  80796. /**
  80797. * Gets the UV location of the mouse over the SpriteMap.
  80798. * @returns Vector2 the UV position of the mouse interaction
  80799. */
  80800. getMousePosition(): Vector2;
  80801. /**
  80802. * Creates the "frame" texture Buffer
  80803. * -------------------------------------
  80804. * Structure of frames
  80805. * "filename": "Falling-Water-2.png",
  80806. * "frame": {"x":69,"y":103,"w":24,"h":32},
  80807. * "rotated": true,
  80808. * "trimmed": true,
  80809. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  80810. * "sourceSize": {"w":32,"h":32}
  80811. * @returns RawTexture of the frameMap
  80812. */
  80813. private _createFrameBuffer;
  80814. /**
  80815. * Creates the tileMap texture Buffer
  80816. * @param buffer normally and array of numbers, or a false to generate from scratch
  80817. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  80818. * @returns RawTexture of the tileMap
  80819. */
  80820. private _createTileBuffer;
  80821. /**
  80822. * Modifies the data of the tileMaps
  80823. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  80824. * @param pos is the iVector2 Coordinates of the Tile
  80825. * @param tile The SpriteIndex of the new Tile
  80826. */
  80827. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  80828. /**
  80829. * Creates the animationMap texture Buffer
  80830. * @param buffer normally and array of numbers, or a false to generate from scratch
  80831. * @returns RawTexture of the animationMap
  80832. */
  80833. private _createTileAnimationBuffer;
  80834. /**
  80835. * Modifies the data of the animationMap
  80836. * @param cellID is the Index of the Sprite
  80837. * @param _frame is the target Animation frame
  80838. * @param toCell is the Target Index of the next frame of the animation
  80839. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  80840. * @param speed is a global scalar of the time variable on the map.
  80841. */
  80842. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  80843. /**
  80844. * Exports the .tilemaps file
  80845. */
  80846. saveTileMaps(): void;
  80847. /**
  80848. * Imports the .tilemaps file
  80849. * @param url of the .tilemaps file
  80850. */
  80851. loadTileMaps(url: string): void;
  80852. /**
  80853. * Release associated resources
  80854. */
  80855. dispose(): void;
  80856. }
  80857. }
  80858. declare module "babylonjs/Sprites/spritePackedManager" {
  80859. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  80860. import { Scene } from "babylonjs/scene";
  80861. /**
  80862. * Class used to manage multiple sprites of different sizes on the same spritesheet
  80863. * @see https://doc.babylonjs.com/babylon101/sprites
  80864. */
  80865. export class SpritePackedManager extends SpriteManager {
  80866. /** defines the packed manager's name */
  80867. name: string;
  80868. /**
  80869. * Creates a new sprite manager from a packed sprite sheet
  80870. * @param name defines the manager's name
  80871. * @param imgUrl defines the sprite sheet url
  80872. * @param capacity defines the maximum allowed number of sprites
  80873. * @param scene defines the hosting scene
  80874. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  80875. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80876. * @param samplingMode defines the smapling mode to use with spritesheet
  80877. * @param fromPacked set to true; do not alter
  80878. */
  80879. constructor(
  80880. /** defines the packed manager's name */
  80881. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  80882. }
  80883. }
  80884. declare module "babylonjs/Sprites/index" {
  80885. export * from "babylonjs/Sprites/sprite";
  80886. export * from "babylonjs/Sprites/ISprites";
  80887. export * from "babylonjs/Sprites/spriteManager";
  80888. export * from "babylonjs/Sprites/spriteMap";
  80889. export * from "babylonjs/Sprites/spritePackedManager";
  80890. export * from "babylonjs/Sprites/spriteSceneComponent";
  80891. }
  80892. declare module "babylonjs/States/index" {
  80893. export * from "babylonjs/States/alphaCullingState";
  80894. export * from "babylonjs/States/depthCullingState";
  80895. export * from "babylonjs/States/stencilState";
  80896. }
  80897. declare module "babylonjs/Misc/assetsManager" {
  80898. import { Scene } from "babylonjs/scene";
  80899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80900. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  80901. import { Skeleton } from "babylonjs/Bones/skeleton";
  80902. import { Observable } from "babylonjs/Misc/observable";
  80903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  80904. import { Texture } from "babylonjs/Materials/Textures/texture";
  80905. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  80906. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  80907. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  80908. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  80909. import { AssetContainer } from "babylonjs/assetContainer";
  80910. /**
  80911. * Defines the list of states available for a task inside a AssetsManager
  80912. */
  80913. export enum AssetTaskState {
  80914. /**
  80915. * Initialization
  80916. */
  80917. INIT = 0,
  80918. /**
  80919. * Running
  80920. */
  80921. RUNNING = 1,
  80922. /**
  80923. * Done
  80924. */
  80925. DONE = 2,
  80926. /**
  80927. * Error
  80928. */
  80929. ERROR = 3
  80930. }
  80931. /**
  80932. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  80933. */
  80934. export abstract class AbstractAssetTask {
  80935. /**
  80936. * Task name
  80937. */ name: string;
  80938. /**
  80939. * Callback called when the task is successful
  80940. */
  80941. onSuccess: (task: any) => void;
  80942. /**
  80943. * Callback called when the task is not successful
  80944. */
  80945. onError: (task: any, message?: string, exception?: any) => void;
  80946. /**
  80947. * Creates a new AssetsManager
  80948. * @param name defines the name of the task
  80949. */
  80950. constructor(
  80951. /**
  80952. * Task name
  80953. */ name: string);
  80954. private _isCompleted;
  80955. private _taskState;
  80956. private _errorObject;
  80957. /**
  80958. * Get if the task is completed
  80959. */
  80960. get isCompleted(): boolean;
  80961. /**
  80962. * Gets the current state of the task
  80963. */
  80964. get taskState(): AssetTaskState;
  80965. /**
  80966. * Gets the current error object (if task is in error)
  80967. */
  80968. get errorObject(): {
  80969. message?: string;
  80970. exception?: any;
  80971. };
  80972. /**
  80973. * Internal only
  80974. * @hidden
  80975. */
  80976. _setErrorObject(message?: string, exception?: any): void;
  80977. /**
  80978. * Execute the current task
  80979. * @param scene defines the scene where you want your assets to be loaded
  80980. * @param onSuccess is a callback called when the task is successfully executed
  80981. * @param onError is a callback called if an error occurs
  80982. */
  80983. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  80984. /**
  80985. * Execute the current task
  80986. * @param scene defines the scene where you want your assets to be loaded
  80987. * @param onSuccess is a callback called when the task is successfully executed
  80988. * @param onError is a callback called if an error occurs
  80989. */
  80990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  80991. /**
  80992. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  80993. * This can be used with failed tasks that have the reason for failure fixed.
  80994. */
  80995. reset(): void;
  80996. private onErrorCallback;
  80997. private onDoneCallback;
  80998. }
  80999. /**
  81000. * Define the interface used by progress events raised during assets loading
  81001. */
  81002. export interface IAssetsProgressEvent {
  81003. /**
  81004. * Defines the number of remaining tasks to process
  81005. */
  81006. remainingCount: number;
  81007. /**
  81008. * Defines the total number of tasks
  81009. */
  81010. totalCount: number;
  81011. /**
  81012. * Defines the task that was just processed
  81013. */
  81014. task: AbstractAssetTask;
  81015. }
  81016. /**
  81017. * Class used to share progress information about assets loading
  81018. */
  81019. export class AssetsProgressEvent implements IAssetsProgressEvent {
  81020. /**
  81021. * Defines the number of remaining tasks to process
  81022. */
  81023. remainingCount: number;
  81024. /**
  81025. * Defines the total number of tasks
  81026. */
  81027. totalCount: number;
  81028. /**
  81029. * Defines the task that was just processed
  81030. */
  81031. task: AbstractAssetTask;
  81032. /**
  81033. * Creates a AssetsProgressEvent
  81034. * @param remainingCount defines the number of remaining tasks to process
  81035. * @param totalCount defines the total number of tasks
  81036. * @param task defines the task that was just processed
  81037. */
  81038. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  81039. }
  81040. /**
  81041. * Define a task used by AssetsManager to load assets into a container
  81042. */
  81043. export class ContainerAssetTask extends AbstractAssetTask {
  81044. /**
  81045. * Defines the name of the task
  81046. */
  81047. name: string;
  81048. /**
  81049. * Defines the list of mesh's names you want to load
  81050. */
  81051. meshesNames: any;
  81052. /**
  81053. * Defines the root url to use as a base to load your meshes and associated resources
  81054. */
  81055. rootUrl: string;
  81056. /**
  81057. * Defines the filename or File of the scene to load from
  81058. */
  81059. sceneFilename: string | File;
  81060. /**
  81061. * Get the loaded asset container
  81062. */
  81063. loadedContainer: AssetContainer;
  81064. /**
  81065. * Gets the list of loaded meshes
  81066. */
  81067. loadedMeshes: Array<AbstractMesh>;
  81068. /**
  81069. * Gets the list of loaded particle systems
  81070. */
  81071. loadedParticleSystems: Array<IParticleSystem>;
  81072. /**
  81073. * Gets the list of loaded skeletons
  81074. */
  81075. loadedSkeletons: Array<Skeleton>;
  81076. /**
  81077. * Gets the list of loaded animation groups
  81078. */
  81079. loadedAnimationGroups: Array<AnimationGroup>;
  81080. /**
  81081. * Callback called when the task is successful
  81082. */
  81083. onSuccess: (task: ContainerAssetTask) => void;
  81084. /**
  81085. * Callback called when the task is successful
  81086. */
  81087. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  81088. /**
  81089. * Creates a new ContainerAssetTask
  81090. * @param name defines the name of the task
  81091. * @param meshesNames defines the list of mesh's names you want to load
  81092. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81093. * @param sceneFilename defines the filename or File of the scene to load from
  81094. */
  81095. constructor(
  81096. /**
  81097. * Defines the name of the task
  81098. */
  81099. name: string,
  81100. /**
  81101. * Defines the list of mesh's names you want to load
  81102. */
  81103. meshesNames: any,
  81104. /**
  81105. * Defines the root url to use as a base to load your meshes and associated resources
  81106. */
  81107. rootUrl: string,
  81108. /**
  81109. * Defines the filename or File of the scene to load from
  81110. */
  81111. sceneFilename: string | File);
  81112. /**
  81113. * Execute the current task
  81114. * @param scene defines the scene where you want your assets to be loaded
  81115. * @param onSuccess is a callback called when the task is successfully executed
  81116. * @param onError is a callback called if an error occurs
  81117. */
  81118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81119. }
  81120. /**
  81121. * Define a task used by AssetsManager to load meshes
  81122. */
  81123. export class MeshAssetTask extends AbstractAssetTask {
  81124. /**
  81125. * Defines the name of the task
  81126. */
  81127. name: string;
  81128. /**
  81129. * Defines the list of mesh's names you want to load
  81130. */
  81131. meshesNames: any;
  81132. /**
  81133. * Defines the root url to use as a base to load your meshes and associated resources
  81134. */
  81135. rootUrl: string;
  81136. /**
  81137. * Defines the filename or File of the scene to load from
  81138. */
  81139. sceneFilename: string | File;
  81140. /**
  81141. * Gets the list of loaded meshes
  81142. */
  81143. loadedMeshes: Array<AbstractMesh>;
  81144. /**
  81145. * Gets the list of loaded particle systems
  81146. */
  81147. loadedParticleSystems: Array<IParticleSystem>;
  81148. /**
  81149. * Gets the list of loaded skeletons
  81150. */
  81151. loadedSkeletons: Array<Skeleton>;
  81152. /**
  81153. * Gets the list of loaded animation groups
  81154. */
  81155. loadedAnimationGroups: Array<AnimationGroup>;
  81156. /**
  81157. * Callback called when the task is successful
  81158. */
  81159. onSuccess: (task: MeshAssetTask) => void;
  81160. /**
  81161. * Callback called when the task is successful
  81162. */
  81163. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  81164. /**
  81165. * Creates a new MeshAssetTask
  81166. * @param name defines the name of the task
  81167. * @param meshesNames defines the list of mesh's names you want to load
  81168. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81169. * @param sceneFilename defines the filename or File of the scene to load from
  81170. */
  81171. constructor(
  81172. /**
  81173. * Defines the name of the task
  81174. */
  81175. name: string,
  81176. /**
  81177. * Defines the list of mesh's names you want to load
  81178. */
  81179. meshesNames: any,
  81180. /**
  81181. * Defines the root url to use as a base to load your meshes and associated resources
  81182. */
  81183. rootUrl: string,
  81184. /**
  81185. * Defines the filename or File of the scene to load from
  81186. */
  81187. sceneFilename: string | File);
  81188. /**
  81189. * Execute the current task
  81190. * @param scene defines the scene where you want your assets to be loaded
  81191. * @param onSuccess is a callback called when the task is successfully executed
  81192. * @param onError is a callback called if an error occurs
  81193. */
  81194. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81195. }
  81196. /**
  81197. * Define a task used by AssetsManager to load text content
  81198. */
  81199. export class TextFileAssetTask extends AbstractAssetTask {
  81200. /**
  81201. * Defines the name of the task
  81202. */
  81203. name: string;
  81204. /**
  81205. * Defines the location of the file to load
  81206. */
  81207. url: string;
  81208. /**
  81209. * Gets the loaded text string
  81210. */
  81211. text: string;
  81212. /**
  81213. * Callback called when the task is successful
  81214. */
  81215. onSuccess: (task: TextFileAssetTask) => void;
  81216. /**
  81217. * Callback called when the task is successful
  81218. */
  81219. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  81220. /**
  81221. * Creates a new TextFileAssetTask object
  81222. * @param name defines the name of the task
  81223. * @param url defines the location of the file to load
  81224. */
  81225. constructor(
  81226. /**
  81227. * Defines the name of the task
  81228. */
  81229. name: string,
  81230. /**
  81231. * Defines the location of the file to load
  81232. */
  81233. url: string);
  81234. /**
  81235. * Execute the current task
  81236. * @param scene defines the scene where you want your assets to be loaded
  81237. * @param onSuccess is a callback called when the task is successfully executed
  81238. * @param onError is a callback called if an error occurs
  81239. */
  81240. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81241. }
  81242. /**
  81243. * Define a task used by AssetsManager to load binary data
  81244. */
  81245. export class BinaryFileAssetTask extends AbstractAssetTask {
  81246. /**
  81247. * Defines the name of the task
  81248. */
  81249. name: string;
  81250. /**
  81251. * Defines the location of the file to load
  81252. */
  81253. url: string;
  81254. /**
  81255. * Gets the lodaded data (as an array buffer)
  81256. */
  81257. data: ArrayBuffer;
  81258. /**
  81259. * Callback called when the task is successful
  81260. */
  81261. onSuccess: (task: BinaryFileAssetTask) => void;
  81262. /**
  81263. * Callback called when the task is successful
  81264. */
  81265. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  81266. /**
  81267. * Creates a new BinaryFileAssetTask object
  81268. * @param name defines the name of the new task
  81269. * @param url defines the location of the file to load
  81270. */
  81271. constructor(
  81272. /**
  81273. * Defines the name of the task
  81274. */
  81275. name: string,
  81276. /**
  81277. * Defines the location of the file to load
  81278. */
  81279. url: string);
  81280. /**
  81281. * Execute the current task
  81282. * @param scene defines the scene where you want your assets to be loaded
  81283. * @param onSuccess is a callback called when the task is successfully executed
  81284. * @param onError is a callback called if an error occurs
  81285. */
  81286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81287. }
  81288. /**
  81289. * Define a task used by AssetsManager to load images
  81290. */
  81291. export class ImageAssetTask extends AbstractAssetTask {
  81292. /**
  81293. * Defines the name of the task
  81294. */
  81295. name: string;
  81296. /**
  81297. * Defines the location of the image to load
  81298. */
  81299. url: string;
  81300. /**
  81301. * Gets the loaded images
  81302. */
  81303. image: HTMLImageElement;
  81304. /**
  81305. * Callback called when the task is successful
  81306. */
  81307. onSuccess: (task: ImageAssetTask) => void;
  81308. /**
  81309. * Callback called when the task is successful
  81310. */
  81311. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  81312. /**
  81313. * Creates a new ImageAssetTask
  81314. * @param name defines the name of the task
  81315. * @param url defines the location of the image to load
  81316. */
  81317. constructor(
  81318. /**
  81319. * Defines the name of the task
  81320. */
  81321. name: string,
  81322. /**
  81323. * Defines the location of the image to load
  81324. */
  81325. url: string);
  81326. /**
  81327. * Execute the current task
  81328. * @param scene defines the scene where you want your assets to be loaded
  81329. * @param onSuccess is a callback called when the task is successfully executed
  81330. * @param onError is a callback called if an error occurs
  81331. */
  81332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81333. }
  81334. /**
  81335. * Defines the interface used by texture loading tasks
  81336. */
  81337. export interface ITextureAssetTask<TEX extends BaseTexture> {
  81338. /**
  81339. * Gets the loaded texture
  81340. */
  81341. texture: TEX;
  81342. }
  81343. /**
  81344. * Define a task used by AssetsManager to load 2D textures
  81345. */
  81346. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  81347. /**
  81348. * Defines the name of the task
  81349. */
  81350. name: string;
  81351. /**
  81352. * Defines the location of the file to load
  81353. */
  81354. url: string;
  81355. /**
  81356. * Defines if mipmap should not be generated (default is false)
  81357. */
  81358. noMipmap?: boolean | undefined;
  81359. /**
  81360. * Defines if texture must be inverted on Y axis (default is true)
  81361. */
  81362. invertY: boolean;
  81363. /**
  81364. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81365. */
  81366. samplingMode: number;
  81367. /**
  81368. * Gets the loaded texture
  81369. */
  81370. texture: Texture;
  81371. /**
  81372. * Callback called when the task is successful
  81373. */
  81374. onSuccess: (task: TextureAssetTask) => void;
  81375. /**
  81376. * Callback called when the task is successful
  81377. */
  81378. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  81379. /**
  81380. * Creates a new TextureAssetTask object
  81381. * @param name defines the name of the task
  81382. * @param url defines the location of the file to load
  81383. * @param noMipmap defines if mipmap should not be generated (default is false)
  81384. * @param invertY defines if texture must be inverted on Y axis (default is true)
  81385. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81386. */
  81387. constructor(
  81388. /**
  81389. * Defines the name of the task
  81390. */
  81391. name: string,
  81392. /**
  81393. * Defines the location of the file to load
  81394. */
  81395. url: string,
  81396. /**
  81397. * Defines if mipmap should not be generated (default is false)
  81398. */
  81399. noMipmap?: boolean | undefined,
  81400. /**
  81401. * Defines if texture must be inverted on Y axis (default is true)
  81402. */
  81403. invertY?: boolean,
  81404. /**
  81405. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81406. */
  81407. samplingMode?: number);
  81408. /**
  81409. * Execute the current task
  81410. * @param scene defines the scene where you want your assets to be loaded
  81411. * @param onSuccess is a callback called when the task is successfully executed
  81412. * @param onError is a callback called if an error occurs
  81413. */
  81414. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81415. }
  81416. /**
  81417. * Define a task used by AssetsManager to load cube textures
  81418. */
  81419. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  81420. /**
  81421. * Defines the name of the task
  81422. */
  81423. name: string;
  81424. /**
  81425. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81426. */
  81427. url: string;
  81428. /**
  81429. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81430. */
  81431. extensions?: string[] | undefined;
  81432. /**
  81433. * Defines if mipmaps should not be generated (default is false)
  81434. */
  81435. noMipmap?: boolean | undefined;
  81436. /**
  81437. * Defines the explicit list of files (undefined by default)
  81438. */
  81439. files?: string[] | undefined;
  81440. /**
  81441. * Gets the loaded texture
  81442. */
  81443. texture: CubeTexture;
  81444. /**
  81445. * Callback called when the task is successful
  81446. */
  81447. onSuccess: (task: CubeTextureAssetTask) => void;
  81448. /**
  81449. * Callback called when the task is successful
  81450. */
  81451. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  81452. /**
  81453. * Creates a new CubeTextureAssetTask
  81454. * @param name defines the name of the task
  81455. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81456. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81457. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81458. * @param files defines the explicit list of files (undefined by default)
  81459. */
  81460. constructor(
  81461. /**
  81462. * Defines the name of the task
  81463. */
  81464. name: string,
  81465. /**
  81466. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81467. */
  81468. url: string,
  81469. /**
  81470. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81471. */
  81472. extensions?: string[] | undefined,
  81473. /**
  81474. * Defines if mipmaps should not be generated (default is false)
  81475. */
  81476. noMipmap?: boolean | undefined,
  81477. /**
  81478. * Defines the explicit list of files (undefined by default)
  81479. */
  81480. files?: string[] | undefined);
  81481. /**
  81482. * Execute the current task
  81483. * @param scene defines the scene where you want your assets to be loaded
  81484. * @param onSuccess is a callback called when the task is successfully executed
  81485. * @param onError is a callback called if an error occurs
  81486. */
  81487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81488. }
  81489. /**
  81490. * Define a task used by AssetsManager to load HDR cube textures
  81491. */
  81492. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  81493. /**
  81494. * Defines the name of the task
  81495. */
  81496. name: string;
  81497. /**
  81498. * Defines the location of the file to load
  81499. */
  81500. url: string;
  81501. /**
  81502. * Defines the desired size (the more it increases the longer the generation will be)
  81503. */
  81504. size: number;
  81505. /**
  81506. * Defines if mipmaps should not be generated (default is false)
  81507. */
  81508. noMipmap: boolean;
  81509. /**
  81510. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81511. */
  81512. generateHarmonics: boolean;
  81513. /**
  81514. * 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)
  81515. */
  81516. gammaSpace: boolean;
  81517. /**
  81518. * Internal Use Only
  81519. */
  81520. reserved: boolean;
  81521. /**
  81522. * Gets the loaded texture
  81523. */
  81524. texture: HDRCubeTexture;
  81525. /**
  81526. * Callback called when the task is successful
  81527. */
  81528. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  81529. /**
  81530. * Callback called when the task is successful
  81531. */
  81532. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  81533. /**
  81534. * Creates a new HDRCubeTextureAssetTask object
  81535. * @param name defines the name of the task
  81536. * @param url defines the location of the file to load
  81537. * @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.
  81538. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81539. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81540. * @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)
  81541. * @param reserved Internal use only
  81542. */
  81543. constructor(
  81544. /**
  81545. * Defines the name of the task
  81546. */
  81547. name: string,
  81548. /**
  81549. * Defines the location of the file to load
  81550. */
  81551. url: string,
  81552. /**
  81553. * Defines the desired size (the more it increases the longer the generation will be)
  81554. */
  81555. size: number,
  81556. /**
  81557. * Defines if mipmaps should not be generated (default is false)
  81558. */
  81559. noMipmap?: boolean,
  81560. /**
  81561. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81562. */
  81563. generateHarmonics?: boolean,
  81564. /**
  81565. * 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)
  81566. */
  81567. gammaSpace?: boolean,
  81568. /**
  81569. * Internal Use Only
  81570. */
  81571. reserved?: boolean);
  81572. /**
  81573. * Execute the current task
  81574. * @param scene defines the scene where you want your assets to be loaded
  81575. * @param onSuccess is a callback called when the task is successfully executed
  81576. * @param onError is a callback called if an error occurs
  81577. */
  81578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81579. }
  81580. /**
  81581. * Define a task used by AssetsManager to load Equirectangular cube textures
  81582. */
  81583. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  81584. /**
  81585. * Defines the name of the task
  81586. */
  81587. name: string;
  81588. /**
  81589. * Defines the location of the file to load
  81590. */
  81591. url: string;
  81592. /**
  81593. * Defines the desired size (the more it increases the longer the generation will be)
  81594. */
  81595. size: number;
  81596. /**
  81597. * Defines if mipmaps should not be generated (default is false)
  81598. */
  81599. noMipmap: boolean;
  81600. /**
  81601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81602. * but the standard material would require them in Gamma space) (default is true)
  81603. */
  81604. gammaSpace: boolean;
  81605. /**
  81606. * Gets the loaded texture
  81607. */
  81608. texture: EquiRectangularCubeTexture;
  81609. /**
  81610. * Callback called when the task is successful
  81611. */
  81612. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  81613. /**
  81614. * Callback called when the task is successful
  81615. */
  81616. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  81617. /**
  81618. * Creates a new EquiRectangularCubeTextureAssetTask object
  81619. * @param name defines the name of the task
  81620. * @param url defines the location of the file to load
  81621. * @param size defines the desired size (the more it increases the longer the generation will be)
  81622. * If the size is omitted this implies you are using a preprocessed cubemap.
  81623. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81624. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  81625. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  81626. * (default is true)
  81627. */
  81628. constructor(
  81629. /**
  81630. * Defines the name of the task
  81631. */
  81632. name: string,
  81633. /**
  81634. * Defines the location of the file to load
  81635. */
  81636. url: string,
  81637. /**
  81638. * Defines the desired size (the more it increases the longer the generation will be)
  81639. */
  81640. size: number,
  81641. /**
  81642. * Defines if mipmaps should not be generated (default is false)
  81643. */
  81644. noMipmap?: boolean,
  81645. /**
  81646. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81647. * but the standard material would require them in Gamma space) (default is true)
  81648. */
  81649. gammaSpace?: boolean);
  81650. /**
  81651. * Execute the current task
  81652. * @param scene defines the scene where you want your assets to be loaded
  81653. * @param onSuccess is a callback called when the task is successfully executed
  81654. * @param onError is a callback called if an error occurs
  81655. */
  81656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81657. }
  81658. /**
  81659. * This class can be used to easily import assets into a scene
  81660. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  81661. */
  81662. export class AssetsManager {
  81663. private _scene;
  81664. private _isLoading;
  81665. protected _tasks: AbstractAssetTask[];
  81666. protected _waitingTasksCount: number;
  81667. protected _totalTasksCount: number;
  81668. /**
  81669. * Callback called when all tasks are processed
  81670. */
  81671. onFinish: (tasks: AbstractAssetTask[]) => void;
  81672. /**
  81673. * Callback called when a task is successful
  81674. */
  81675. onTaskSuccess: (task: AbstractAssetTask) => void;
  81676. /**
  81677. * Callback called when a task had an error
  81678. */
  81679. onTaskError: (task: AbstractAssetTask) => void;
  81680. /**
  81681. * Callback called when a task is done (whatever the result is)
  81682. */
  81683. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  81684. /**
  81685. * Observable called when all tasks are processed
  81686. */
  81687. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  81688. /**
  81689. * Observable called when a task had an error
  81690. */
  81691. onTaskErrorObservable: Observable<AbstractAssetTask>;
  81692. /**
  81693. * Observable called when all tasks were executed
  81694. */
  81695. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  81696. /**
  81697. * Observable called when a task is done (whatever the result is)
  81698. */
  81699. onProgressObservable: Observable<IAssetsProgressEvent>;
  81700. /**
  81701. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  81702. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  81703. */
  81704. useDefaultLoadingScreen: boolean;
  81705. /**
  81706. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  81707. * when all assets have been downloaded.
  81708. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  81709. */
  81710. autoHideLoadingUI: boolean;
  81711. /**
  81712. * Creates a new AssetsManager
  81713. * @param scene defines the scene to work on
  81714. */
  81715. constructor(scene: Scene);
  81716. /**
  81717. * Add a ContainerAssetTask to the list of active tasks
  81718. * @param taskName defines the name of the new task
  81719. * @param meshesNames defines the name of meshes to load
  81720. * @param rootUrl defines the root url to use to locate files
  81721. * @param sceneFilename defines the filename of the scene file
  81722. * @returns a new ContainerAssetTask object
  81723. */
  81724. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  81725. /**
  81726. * Add a MeshAssetTask to the list of active tasks
  81727. * @param taskName defines the name of the new task
  81728. * @param meshesNames defines the name of meshes to load
  81729. * @param rootUrl defines the root url to use to locate files
  81730. * @param sceneFilename defines the filename of the scene file
  81731. * @returns a new MeshAssetTask object
  81732. */
  81733. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  81734. /**
  81735. * Add a TextFileAssetTask to the list of active tasks
  81736. * @param taskName defines the name of the new task
  81737. * @param url defines the url of the file to load
  81738. * @returns a new TextFileAssetTask object
  81739. */
  81740. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  81741. /**
  81742. * Add a BinaryFileAssetTask to the list of active tasks
  81743. * @param taskName defines the name of the new task
  81744. * @param url defines the url of the file to load
  81745. * @returns a new BinaryFileAssetTask object
  81746. */
  81747. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  81748. /**
  81749. * Add a ImageAssetTask to the list of active tasks
  81750. * @param taskName defines the name of the new task
  81751. * @param url defines the url of the file to load
  81752. * @returns a new ImageAssetTask object
  81753. */
  81754. addImageTask(taskName: string, url: string): ImageAssetTask;
  81755. /**
  81756. * Add a TextureAssetTask to the list of active tasks
  81757. * @param taskName defines the name of the new task
  81758. * @param url defines the url of the file to load
  81759. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81760. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  81761. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  81762. * @returns a new TextureAssetTask object
  81763. */
  81764. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  81765. /**
  81766. * Add a CubeTextureAssetTask to the list of active tasks
  81767. * @param taskName defines the name of the new task
  81768. * @param url defines the url of the file to load
  81769. * @param extensions defines the extension to use to load the cube map (can be null)
  81770. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81771. * @param files defines the list of files to load (can be null)
  81772. * @returns a new CubeTextureAssetTask object
  81773. */
  81774. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  81775. /**
  81776. *
  81777. * Add a HDRCubeTextureAssetTask to the list of active tasks
  81778. * @param taskName defines the name of the new task
  81779. * @param url defines the url of the file to load
  81780. * @param size defines the size you want for the cubemap (can be null)
  81781. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81782. * @param generateHarmonics defines if you want to automatically generate (true by default)
  81783. * @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)
  81784. * @param reserved Internal use only
  81785. * @returns a new HDRCubeTextureAssetTask object
  81786. */
  81787. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  81788. /**
  81789. *
  81790. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  81791. * @param taskName defines the name of the new task
  81792. * @param url defines the url of the file to load
  81793. * @param size defines the size you want for the cubemap (can be null)
  81794. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81795. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  81796. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  81797. * @returns a new EquiRectangularCubeTextureAssetTask object
  81798. */
  81799. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  81800. /**
  81801. * Remove a task from the assets manager.
  81802. * @param task the task to remove
  81803. */
  81804. removeTask(task: AbstractAssetTask): void;
  81805. private _decreaseWaitingTasksCount;
  81806. private _runTask;
  81807. /**
  81808. * Reset the AssetsManager and remove all tasks
  81809. * @return the current instance of the AssetsManager
  81810. */
  81811. reset(): AssetsManager;
  81812. /**
  81813. * Start the loading process
  81814. * @return the current instance of the AssetsManager
  81815. */
  81816. load(): AssetsManager;
  81817. /**
  81818. * Start the loading process as an async operation
  81819. * @return a promise returning the list of failed tasks
  81820. */
  81821. loadAsync(): Promise<void>;
  81822. }
  81823. }
  81824. declare module "babylonjs/Misc/deferred" {
  81825. /**
  81826. * Wrapper class for promise with external resolve and reject.
  81827. */
  81828. export class Deferred<T> {
  81829. /**
  81830. * The promise associated with this deferred object.
  81831. */
  81832. readonly promise: Promise<T>;
  81833. private _resolve;
  81834. private _reject;
  81835. /**
  81836. * The resolve method of the promise associated with this deferred object.
  81837. */
  81838. get resolve(): (value: T | PromiseLike<T>) => void;
  81839. /**
  81840. * The reject method of the promise associated with this deferred object.
  81841. */
  81842. get reject(): (reason?: any) => void;
  81843. /**
  81844. * Constructor for this deferred object.
  81845. */
  81846. constructor();
  81847. }
  81848. }
  81849. declare module "babylonjs/Misc/meshExploder" {
  81850. import { Mesh } from "babylonjs/Meshes/mesh";
  81851. /**
  81852. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  81853. */
  81854. export class MeshExploder {
  81855. private _centerMesh;
  81856. private _meshes;
  81857. private _meshesOrigins;
  81858. private _toCenterVectors;
  81859. private _scaledDirection;
  81860. private _newPosition;
  81861. private _centerPosition;
  81862. /**
  81863. * Explodes meshes from a center mesh.
  81864. * @param meshes The meshes to explode.
  81865. * @param centerMesh The mesh to be center of explosion.
  81866. */
  81867. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  81868. private _setCenterMesh;
  81869. /**
  81870. * Get class name
  81871. * @returns "MeshExploder"
  81872. */
  81873. getClassName(): string;
  81874. /**
  81875. * "Exploded meshes"
  81876. * @returns Array of meshes with the centerMesh at index 0.
  81877. */
  81878. getMeshes(): Array<Mesh>;
  81879. /**
  81880. * Explodes meshes giving a specific direction
  81881. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  81882. */
  81883. explode(direction?: number): void;
  81884. }
  81885. }
  81886. declare module "babylonjs/Misc/filesInput" {
  81887. import { Engine } from "babylonjs/Engines/engine";
  81888. import { Scene } from "babylonjs/scene";
  81889. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  81890. import { Nullable } from "babylonjs/types";
  81891. /**
  81892. * Class used to help managing file picking and drag'n'drop
  81893. */
  81894. export class FilesInput {
  81895. /**
  81896. * List of files ready to be loaded
  81897. */
  81898. static get FilesToLoad(): {
  81899. [key: string]: File;
  81900. };
  81901. /**
  81902. * Callback called when a file is processed
  81903. */
  81904. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  81905. /**
  81906. * Function used when loading the scene file
  81907. */
  81908. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  81909. private _engine;
  81910. private _currentScene;
  81911. private _sceneLoadedCallback;
  81912. private _progressCallback;
  81913. private _additionalRenderLoopLogicCallback;
  81914. private _textureLoadingCallback;
  81915. private _startingProcessingFilesCallback;
  81916. private _onReloadCallback;
  81917. private _errorCallback;
  81918. private _elementToMonitor;
  81919. private _sceneFileToLoad;
  81920. private _filesToLoad;
  81921. /**
  81922. * Creates a new FilesInput
  81923. * @param engine defines the rendering engine
  81924. * @param scene defines the hosting scene
  81925. * @param sceneLoadedCallback callback called when scene is loaded
  81926. * @param progressCallback callback called to track progress
  81927. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  81928. * @param textureLoadingCallback callback called when a texture is loading
  81929. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  81930. * @param onReloadCallback callback called when a reload is requested
  81931. * @param errorCallback callback call if an error occurs
  81932. */
  81933. 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>);
  81934. private _dragEnterHandler;
  81935. private _dragOverHandler;
  81936. private _dropHandler;
  81937. /**
  81938. * Calls this function to listen to drag'n'drop events on a specific DOM element
  81939. * @param elementToMonitor defines the DOM element to track
  81940. */
  81941. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  81942. /** Gets the current list of files to load */
  81943. get filesToLoad(): File[];
  81944. /**
  81945. * Release all associated resources
  81946. */
  81947. dispose(): void;
  81948. private renderFunction;
  81949. private drag;
  81950. private drop;
  81951. private _traverseFolder;
  81952. private _processFiles;
  81953. /**
  81954. * Load files from a drop event
  81955. * @param event defines the drop event to use as source
  81956. */
  81957. loadFiles(event: any): void;
  81958. private _processReload;
  81959. /**
  81960. * Reload the current scene from the loaded files
  81961. */
  81962. reload(): void;
  81963. }
  81964. }
  81965. declare module "babylonjs/Misc/HighDynamicRange/index" {
  81966. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  81967. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  81968. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  81969. }
  81970. declare module "babylonjs/Misc/sceneOptimizer" {
  81971. import { Scene, IDisposable } from "babylonjs/scene";
  81972. import { Observable } from "babylonjs/Misc/observable";
  81973. /**
  81974. * Defines the root class used to create scene optimization to use with SceneOptimizer
  81975. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  81976. */
  81977. export class SceneOptimization {
  81978. /**
  81979. * Defines the priority of this optimization (0 by default which means first in the list)
  81980. */
  81981. priority: number;
  81982. /**
  81983. * Gets a string describing the action executed by the current optimization
  81984. * @returns description string
  81985. */
  81986. getDescription(): string;
  81987. /**
  81988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  81989. * @param scene defines the current scene where to apply this optimization
  81990. * @param optimizer defines the current optimizer
  81991. * @returns true if everything that can be done was applied
  81992. */
  81993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  81994. /**
  81995. * Creates the SceneOptimization object
  81996. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  81997. * @param desc defines the description associated with the optimization
  81998. */
  81999. constructor(
  82000. /**
  82001. * Defines the priority of this optimization (0 by default which means first in the list)
  82002. */
  82003. priority?: number);
  82004. }
  82005. /**
  82006. * Defines an optimization used to reduce the size of render target textures
  82007. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82008. */
  82009. export class TextureOptimization extends SceneOptimization {
  82010. /**
  82011. * Defines the priority of this optimization (0 by default which means first in the list)
  82012. */
  82013. priority: number;
  82014. /**
  82015. * 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
  82016. */
  82017. maximumSize: number;
  82018. /**
  82019. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82020. */
  82021. step: number;
  82022. /**
  82023. * Gets a string describing the action executed by the current optimization
  82024. * @returns description string
  82025. */
  82026. getDescription(): string;
  82027. /**
  82028. * Creates the TextureOptimization object
  82029. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82030. * @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
  82031. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82032. */
  82033. constructor(
  82034. /**
  82035. * Defines the priority of this optimization (0 by default which means first in the list)
  82036. */
  82037. priority?: number,
  82038. /**
  82039. * 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
  82040. */
  82041. maximumSize?: number,
  82042. /**
  82043. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82044. */
  82045. step?: number);
  82046. /**
  82047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82048. * @param scene defines the current scene where to apply this optimization
  82049. * @param optimizer defines the current optimizer
  82050. * @returns true if everything that can be done was applied
  82051. */
  82052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82053. }
  82054. /**
  82055. * Defines an optimization used to increase or decrease the rendering resolution
  82056. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82057. */
  82058. export class HardwareScalingOptimization extends SceneOptimization {
  82059. /**
  82060. * Defines the priority of this optimization (0 by default which means first in the list)
  82061. */
  82062. priority: number;
  82063. /**
  82064. * Defines the maximum scale to use (2 by default)
  82065. */
  82066. maximumScale: number;
  82067. /**
  82068. * Defines the step to use between two passes (0.5 by default)
  82069. */
  82070. step: number;
  82071. private _currentScale;
  82072. private _directionOffset;
  82073. /**
  82074. * Gets a string describing the action executed by the current optimization
  82075. * @return description string
  82076. */
  82077. getDescription(): string;
  82078. /**
  82079. * Creates the HardwareScalingOptimization object
  82080. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82081. * @param maximumScale defines the maximum scale to use (2 by default)
  82082. * @param step defines the step to use between two passes (0.5 by default)
  82083. */
  82084. constructor(
  82085. /**
  82086. * Defines the priority of this optimization (0 by default which means first in the list)
  82087. */
  82088. priority?: number,
  82089. /**
  82090. * Defines the maximum scale to use (2 by default)
  82091. */
  82092. maximumScale?: number,
  82093. /**
  82094. * Defines the step to use between two passes (0.5 by default)
  82095. */
  82096. step?: number);
  82097. /**
  82098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82099. * @param scene defines the current scene where to apply this optimization
  82100. * @param optimizer defines the current optimizer
  82101. * @returns true if everything that can be done was applied
  82102. */
  82103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82104. }
  82105. /**
  82106. * Defines an optimization used to remove shadows
  82107. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82108. */
  82109. export class ShadowsOptimization extends SceneOptimization {
  82110. /**
  82111. * Gets a string describing the action executed by the current optimization
  82112. * @return description string
  82113. */
  82114. getDescription(): string;
  82115. /**
  82116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82117. * @param scene defines the current scene where to apply this optimization
  82118. * @param optimizer defines the current optimizer
  82119. * @returns true if everything that can be done was applied
  82120. */
  82121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82122. }
  82123. /**
  82124. * Defines an optimization used to turn post-processes off
  82125. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82126. */
  82127. export class PostProcessesOptimization extends SceneOptimization {
  82128. /**
  82129. * Gets a string describing the action executed by the current optimization
  82130. * @return description string
  82131. */
  82132. getDescription(): string;
  82133. /**
  82134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82135. * @param scene defines the current scene where to apply this optimization
  82136. * @param optimizer defines the current optimizer
  82137. * @returns true if everything that can be done was applied
  82138. */
  82139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82140. }
  82141. /**
  82142. * Defines an optimization used to turn lens flares off
  82143. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82144. */
  82145. export class LensFlaresOptimization extends SceneOptimization {
  82146. /**
  82147. * Gets a string describing the action executed by the current optimization
  82148. * @return description string
  82149. */
  82150. getDescription(): string;
  82151. /**
  82152. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82153. * @param scene defines the current scene where to apply this optimization
  82154. * @param optimizer defines the current optimizer
  82155. * @returns true if everything that can be done was applied
  82156. */
  82157. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82158. }
  82159. /**
  82160. * Defines an optimization based on user defined callback.
  82161. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82162. */
  82163. export class CustomOptimization extends SceneOptimization {
  82164. /**
  82165. * Callback called to apply the custom optimization.
  82166. */
  82167. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  82168. /**
  82169. * Callback called to get custom description
  82170. */
  82171. onGetDescription: () => string;
  82172. /**
  82173. * Gets a string describing the action executed by the current optimization
  82174. * @returns description string
  82175. */
  82176. getDescription(): string;
  82177. /**
  82178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82179. * @param scene defines the current scene where to apply this optimization
  82180. * @param optimizer defines the current optimizer
  82181. * @returns true if everything that can be done was applied
  82182. */
  82183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82184. }
  82185. /**
  82186. * Defines an optimization used to turn particles off
  82187. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82188. */
  82189. export class ParticlesOptimization extends SceneOptimization {
  82190. /**
  82191. * Gets a string describing the action executed by the current optimization
  82192. * @return description string
  82193. */
  82194. getDescription(): string;
  82195. /**
  82196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82197. * @param scene defines the current scene where to apply this optimization
  82198. * @param optimizer defines the current optimizer
  82199. * @returns true if everything that can be done was applied
  82200. */
  82201. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82202. }
  82203. /**
  82204. * Defines an optimization used to turn render targets off
  82205. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82206. */
  82207. export class RenderTargetsOptimization extends SceneOptimization {
  82208. /**
  82209. * Gets a string describing the action executed by the current optimization
  82210. * @return description string
  82211. */
  82212. getDescription(): string;
  82213. /**
  82214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82215. * @param scene defines the current scene where to apply this optimization
  82216. * @param optimizer defines the current optimizer
  82217. * @returns true if everything that can be done was applied
  82218. */
  82219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82220. }
  82221. /**
  82222. * Defines an optimization used to merge meshes with compatible materials
  82223. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82224. */
  82225. export class MergeMeshesOptimization extends SceneOptimization {
  82226. private static _UpdateSelectionTree;
  82227. /**
  82228. * Gets or sets a boolean which defines if optimization octree has to be updated
  82229. */
  82230. static get UpdateSelectionTree(): boolean;
  82231. /**
  82232. * Gets or sets a boolean which defines if optimization octree has to be updated
  82233. */
  82234. static set UpdateSelectionTree(value: boolean);
  82235. /**
  82236. * Gets a string describing the action executed by the current optimization
  82237. * @return description string
  82238. */
  82239. getDescription(): string;
  82240. private _canBeMerged;
  82241. /**
  82242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82243. * @param scene defines the current scene where to apply this optimization
  82244. * @param optimizer defines the current optimizer
  82245. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  82246. * @returns true if everything that can be done was applied
  82247. */
  82248. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  82249. }
  82250. /**
  82251. * Defines a list of options used by SceneOptimizer
  82252. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82253. */
  82254. export class SceneOptimizerOptions {
  82255. /**
  82256. * Defines the target frame rate to reach (60 by default)
  82257. */
  82258. targetFrameRate: number;
  82259. /**
  82260. * Defines the interval between two checkes (2000ms by default)
  82261. */
  82262. trackerDuration: number;
  82263. /**
  82264. * Gets the list of optimizations to apply
  82265. */
  82266. optimizations: SceneOptimization[];
  82267. /**
  82268. * Creates a new list of options used by SceneOptimizer
  82269. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  82270. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  82271. */
  82272. constructor(
  82273. /**
  82274. * Defines the target frame rate to reach (60 by default)
  82275. */
  82276. targetFrameRate?: number,
  82277. /**
  82278. * Defines the interval between two checkes (2000ms by default)
  82279. */
  82280. trackerDuration?: number);
  82281. /**
  82282. * Add a new optimization
  82283. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  82284. * @returns the current SceneOptimizerOptions
  82285. */
  82286. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  82287. /**
  82288. * Add a new custom optimization
  82289. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  82290. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  82291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82292. * @returns the current SceneOptimizerOptions
  82293. */
  82294. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  82295. /**
  82296. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  82297. * @param targetFrameRate defines the target frame rate (60 by default)
  82298. * @returns a SceneOptimizerOptions object
  82299. */
  82300. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82301. /**
  82302. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  82303. * @param targetFrameRate defines the target frame rate (60 by default)
  82304. * @returns a SceneOptimizerOptions object
  82305. */
  82306. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82307. /**
  82308. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  82309. * @param targetFrameRate defines the target frame rate (60 by default)
  82310. * @returns a SceneOptimizerOptions object
  82311. */
  82312. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82313. }
  82314. /**
  82315. * Class used to run optimizations in order to reach a target frame rate
  82316. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82317. */
  82318. export class SceneOptimizer implements IDisposable {
  82319. private _isRunning;
  82320. private _options;
  82321. private _scene;
  82322. private _currentPriorityLevel;
  82323. private _targetFrameRate;
  82324. private _trackerDuration;
  82325. private _currentFrameRate;
  82326. private _sceneDisposeObserver;
  82327. private _improvementMode;
  82328. /**
  82329. * Defines an observable called when the optimizer reaches the target frame rate
  82330. */
  82331. onSuccessObservable: Observable<SceneOptimizer>;
  82332. /**
  82333. * Defines an observable called when the optimizer enables an optimization
  82334. */
  82335. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  82336. /**
  82337. * Defines an observable called when the optimizer is not able to reach the target frame rate
  82338. */
  82339. onFailureObservable: Observable<SceneOptimizer>;
  82340. /**
  82341. * Gets a boolean indicating if the optimizer is in improvement mode
  82342. */
  82343. get isInImprovementMode(): boolean;
  82344. /**
  82345. * Gets the current priority level (0 at start)
  82346. */
  82347. get currentPriorityLevel(): number;
  82348. /**
  82349. * Gets the current frame rate checked by the SceneOptimizer
  82350. */
  82351. get currentFrameRate(): number;
  82352. /**
  82353. * Gets or sets the current target frame rate (60 by default)
  82354. */
  82355. get targetFrameRate(): number;
  82356. /**
  82357. * Gets or sets the current target frame rate (60 by default)
  82358. */
  82359. set targetFrameRate(value: number);
  82360. /**
  82361. * Gets or sets the current interval between two checks (every 2000ms by default)
  82362. */
  82363. get trackerDuration(): number;
  82364. /**
  82365. * Gets or sets the current interval between two checks (every 2000ms by default)
  82366. */
  82367. set trackerDuration(value: number);
  82368. /**
  82369. * Gets the list of active optimizations
  82370. */
  82371. get optimizations(): SceneOptimization[];
  82372. /**
  82373. * Creates a new SceneOptimizer
  82374. * @param scene defines the scene to work on
  82375. * @param options defines the options to use with the SceneOptimizer
  82376. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  82377. * @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)
  82378. */
  82379. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  82380. /**
  82381. * Stops the current optimizer
  82382. */
  82383. stop(): void;
  82384. /**
  82385. * Reset the optimizer to initial step (current priority level = 0)
  82386. */
  82387. reset(): void;
  82388. /**
  82389. * Start the optimizer. By default it will try to reach a specific framerate
  82390. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  82391. */
  82392. start(): void;
  82393. private _checkCurrentState;
  82394. /**
  82395. * Release all resources
  82396. */
  82397. dispose(): void;
  82398. /**
  82399. * Helper function to create a SceneOptimizer with one single line of code
  82400. * @param scene defines the scene to work on
  82401. * @param options defines the options to use with the SceneOptimizer
  82402. * @param onSuccess defines a callback to call on success
  82403. * @param onFailure defines a callback to call on failure
  82404. * @returns the new SceneOptimizer object
  82405. */
  82406. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  82407. }
  82408. }
  82409. declare module "babylonjs/Misc/sceneSerializer" {
  82410. import { Scene } from "babylonjs/scene";
  82411. /**
  82412. * Class used to serialize a scene into a string
  82413. */
  82414. export class SceneSerializer {
  82415. /**
  82416. * Clear cache used by a previous serialization
  82417. */
  82418. static ClearCache(): void;
  82419. /**
  82420. * Serialize a scene into a JSON compatible object
  82421. * @param scene defines the scene to serialize
  82422. * @returns a JSON compatible object
  82423. */
  82424. static Serialize(scene: Scene): any;
  82425. /**
  82426. * Serialize a mesh into a JSON compatible object
  82427. * @param toSerialize defines the mesh to serialize
  82428. * @param withParents defines if parents must be serialized as well
  82429. * @param withChildren defines if children must be serialized as well
  82430. * @returns a JSON compatible object
  82431. */
  82432. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  82433. }
  82434. }
  82435. declare module "babylonjs/Misc/videoRecorder" {
  82436. import { Nullable } from "babylonjs/types";
  82437. import { Engine } from "babylonjs/Engines/engine";
  82438. /**
  82439. * This represents the different options available for the video capture.
  82440. */
  82441. export interface VideoRecorderOptions {
  82442. /** Defines the mime type of the video. */
  82443. mimeType: string;
  82444. /** Defines the FPS the video should be recorded at. */
  82445. fps: number;
  82446. /** Defines the chunk size for the recording data. */
  82447. recordChunckSize: number;
  82448. /** The audio tracks to attach to the recording. */
  82449. audioTracks?: MediaStreamTrack[];
  82450. }
  82451. /**
  82452. * This can help with recording videos from BabylonJS.
  82453. * This is based on the available WebRTC functionalities of the browser.
  82454. *
  82455. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  82456. */
  82457. export class VideoRecorder {
  82458. private static readonly _defaultOptions;
  82459. /**
  82460. * Returns whether or not the VideoRecorder is available in your browser.
  82461. * @param engine Defines the Babylon Engine.
  82462. * @returns true if supported otherwise false.
  82463. */
  82464. static IsSupported(engine: Engine): boolean;
  82465. private readonly _options;
  82466. private _canvas;
  82467. private _mediaRecorder;
  82468. private _recordedChunks;
  82469. private _fileName;
  82470. private _resolve;
  82471. private _reject;
  82472. /**
  82473. * True when a recording is already in progress.
  82474. */
  82475. get isRecording(): boolean;
  82476. /**
  82477. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  82478. * @param engine Defines the BabylonJS Engine you wish to record.
  82479. * @param options Defines options that can be used to customize the capture.
  82480. */
  82481. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  82482. /**
  82483. * Stops the current recording before the default capture timeout passed in the startRecording function.
  82484. */
  82485. stopRecording(): void;
  82486. /**
  82487. * Starts recording the canvas for a max duration specified in parameters.
  82488. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  82489. * If null no automatic download will start and you can rely on the promise to get the data back.
  82490. * @param maxDuration Defines the maximum recording time in seconds.
  82491. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  82492. * @return A promise callback at the end of the recording with the video data in Blob.
  82493. */
  82494. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  82495. /**
  82496. * Releases internal resources used during the recording.
  82497. */
  82498. dispose(): void;
  82499. private _handleDataAvailable;
  82500. private _handleError;
  82501. private _handleStop;
  82502. }
  82503. }
  82504. declare module "babylonjs/Misc/screenshotTools" {
  82505. import { Camera } from "babylonjs/Cameras/camera";
  82506. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  82507. import { Engine } from "babylonjs/Engines/engine";
  82508. /**
  82509. * Class containing a set of static utilities functions for screenshots
  82510. */
  82511. export class ScreenshotTools {
  82512. /**
  82513. * Captures a screenshot of the current rendering
  82514. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82515. * @param engine defines the rendering engine
  82516. * @param camera defines the source camera
  82517. * @param size This parameter can be set to a single number or to an object with the
  82518. * following (optional) properties: precision, width, height. If a single number is passed,
  82519. * it will be used for both width and height. If an object is passed, the screenshot size
  82520. * will be derived from the parameters. The precision property is a multiplier allowing
  82521. * rendering at a higher or lower resolution
  82522. * @param successCallback defines the callback receives a single parameter which contains the
  82523. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82524. * src parameter of an <img> to display it
  82525. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82526. * Check your browser for supported MIME types
  82527. */
  82528. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  82529. /**
  82530. * Captures a screenshot of the current rendering
  82531. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82532. * @param engine defines the rendering engine
  82533. * @param camera defines the source camera
  82534. * @param size This parameter can be set to a single number or to an object with the
  82535. * following (optional) properties: precision, width, height. If a single number is passed,
  82536. * it will be used for both width and height. If an object is passed, the screenshot size
  82537. * will be derived from the parameters. The precision property is a multiplier allowing
  82538. * rendering at a higher or lower resolution
  82539. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82540. * Check your browser for supported MIME types
  82541. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82542. * to the src parameter of an <img> to display it
  82543. */
  82544. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  82545. /**
  82546. * Generates an image screenshot from the specified camera.
  82547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82548. * @param engine The engine to use for rendering
  82549. * @param camera The camera to use for rendering
  82550. * @param size This parameter can be set to a single number or to an object with the
  82551. * following (optional) properties: precision, width, height. If a single number is passed,
  82552. * it will be used for both width and height. If an object is passed, the screenshot size
  82553. * will be derived from the parameters. The precision property is a multiplier allowing
  82554. * rendering at a higher or lower resolution
  82555. * @param successCallback The callback receives a single parameter which contains the
  82556. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82557. * src parameter of an <img> to display it
  82558. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82559. * Check your browser for supported MIME types
  82560. * @param samples Texture samples (default: 1)
  82561. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82562. * @param fileName A name for for the downloaded file.
  82563. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82564. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  82565. */
  82566. 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;
  82567. /**
  82568. * Generates an image screenshot from the specified camera.
  82569. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82570. * @param engine The engine to use for rendering
  82571. * @param camera The camera to use for rendering
  82572. * @param size This parameter can be set to a single number or to an object with the
  82573. * following (optional) properties: precision, width, height. If a single number is passed,
  82574. * it will be used for both width and height. If an object is passed, the screenshot size
  82575. * will be derived from the parameters. The precision property is a multiplier allowing
  82576. * rendering at a higher or lower resolution
  82577. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82578. * Check your browser for supported MIME types
  82579. * @param samples Texture samples (default: 1)
  82580. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82581. * @param fileName A name for for the downloaded file.
  82582. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82583. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82584. * to the src parameter of an <img> to display it
  82585. */
  82586. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  82587. /**
  82588. * Gets height and width for screenshot size
  82589. * @private
  82590. */
  82591. private static _getScreenshotSize;
  82592. }
  82593. }
  82594. declare module "babylonjs/Misc/dataReader" {
  82595. /**
  82596. * Interface for a data buffer
  82597. */
  82598. export interface IDataBuffer {
  82599. /**
  82600. * Reads bytes from the data buffer.
  82601. * @param byteOffset The byte offset to read
  82602. * @param byteLength The byte length to read
  82603. * @returns A promise that resolves when the bytes are read
  82604. */
  82605. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  82606. /**
  82607. * The byte length of the buffer.
  82608. */
  82609. readonly byteLength: number;
  82610. }
  82611. /**
  82612. * Utility class for reading from a data buffer
  82613. */
  82614. export class DataReader {
  82615. /**
  82616. * The data buffer associated with this data reader.
  82617. */
  82618. readonly buffer: IDataBuffer;
  82619. /**
  82620. * The current byte offset from the beginning of the data buffer.
  82621. */
  82622. byteOffset: number;
  82623. private _dataView;
  82624. private _dataByteOffset;
  82625. /**
  82626. * Constructor
  82627. * @param buffer The buffer to read
  82628. */
  82629. constructor(buffer: IDataBuffer);
  82630. /**
  82631. * Loads the given byte length.
  82632. * @param byteLength The byte length to load
  82633. * @returns A promise that resolves when the load is complete
  82634. */
  82635. loadAsync(byteLength: number): Promise<void>;
  82636. /**
  82637. * Read a unsigned 32-bit integer from the currently loaded data range.
  82638. * @returns The 32-bit integer read
  82639. */
  82640. readUint32(): number;
  82641. /**
  82642. * Read a byte array from the currently loaded data range.
  82643. * @param byteLength The byte length to read
  82644. * @returns The byte array read
  82645. */
  82646. readUint8Array(byteLength: number): Uint8Array;
  82647. /**
  82648. * Read a string from the currently loaded data range.
  82649. * @param byteLength The byte length to read
  82650. * @returns The string read
  82651. */
  82652. readString(byteLength: number): string;
  82653. /**
  82654. * Skips the given byte length the currently loaded data range.
  82655. * @param byteLength The byte length to skip
  82656. */
  82657. skipBytes(byteLength: number): void;
  82658. }
  82659. }
  82660. declare module "babylonjs/Misc/dataStorage" {
  82661. /**
  82662. * Class for storing data to local storage if available or in-memory storage otherwise
  82663. */
  82664. export class DataStorage {
  82665. private static _Storage;
  82666. private static _GetStorage;
  82667. /**
  82668. * Reads a string from the data storage
  82669. * @param key The key to read
  82670. * @param defaultValue The value if the key doesn't exist
  82671. * @returns The string value
  82672. */
  82673. static ReadString(key: string, defaultValue: string): string;
  82674. /**
  82675. * Writes a string to the data storage
  82676. * @param key The key to write
  82677. * @param value The value to write
  82678. */
  82679. static WriteString(key: string, value: string): void;
  82680. /**
  82681. * Reads a boolean from the data storage
  82682. * @param key The key to read
  82683. * @param defaultValue The value if the key doesn't exist
  82684. * @returns The boolean value
  82685. */
  82686. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  82687. /**
  82688. * Writes a boolean to the data storage
  82689. * @param key The key to write
  82690. * @param value The value to write
  82691. */
  82692. static WriteBoolean(key: string, value: boolean): void;
  82693. /**
  82694. * Reads a number from the data storage
  82695. * @param key The key to read
  82696. * @param defaultValue The value if the key doesn't exist
  82697. * @returns The number value
  82698. */
  82699. static ReadNumber(key: string, defaultValue: number): number;
  82700. /**
  82701. * Writes a number to the data storage
  82702. * @param key The key to write
  82703. * @param value The value to write
  82704. */
  82705. static WriteNumber(key: string, value: number): void;
  82706. }
  82707. }
  82708. declare module "babylonjs/Misc/sceneRecorder" {
  82709. import { Scene } from "babylonjs/scene";
  82710. /**
  82711. * Class used to record delta files between 2 scene states
  82712. */
  82713. export class SceneRecorder {
  82714. private _trackedScene;
  82715. private _savedJSON;
  82716. /**
  82717. * Track a given scene. This means the current scene state will be considered the original state
  82718. * @param scene defines the scene to track
  82719. */
  82720. track(scene: Scene): void;
  82721. /**
  82722. * Get the delta between current state and original state
  82723. * @returns a string containing the delta
  82724. */
  82725. getDelta(): any;
  82726. private _compareArray;
  82727. private _compareObjects;
  82728. private _compareCollections;
  82729. private static GetShadowGeneratorById;
  82730. /**
  82731. * Apply a given delta to a given scene
  82732. * @param deltaJSON defines the JSON containing the delta
  82733. * @param scene defines the scene to apply the delta to
  82734. */
  82735. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  82736. private static _ApplyPropertiesToEntity;
  82737. private static _ApplyDeltaForEntity;
  82738. }
  82739. }
  82740. declare module "babylonjs/Misc/trajectoryClassifier" {
  82741. import { DeepImmutable, Nullable } from "babylonjs/types";
  82742. import { Vector3 } from "babylonjs/Maths/math.vector";
  82743. /**
  82744. * A 3D trajectory consisting of an order list of vectors describing a
  82745. * path of motion through 3D space.
  82746. */
  82747. export class Trajectory {
  82748. private _points;
  82749. private readonly _segmentLength;
  82750. /**
  82751. * Serialize to JSON.
  82752. * @returns serialized JSON string
  82753. */
  82754. serialize(): string;
  82755. /**
  82756. * Deserialize from JSON.
  82757. * @param json serialized JSON string
  82758. * @returns deserialized Trajectory
  82759. */
  82760. static Deserialize(json: string): Trajectory;
  82761. /**
  82762. * Create a new empty Trajectory.
  82763. * @param segmentLength radius of discretization for Trajectory points
  82764. */
  82765. constructor(segmentLength?: number);
  82766. /**
  82767. * Get the length of the Trajectory.
  82768. * @returns length of the Trajectory
  82769. */
  82770. getLength(): number;
  82771. /**
  82772. * Append a new point to the Trajectory.
  82773. * NOTE: This implementation has many allocations.
  82774. * @param point point to append to the Trajectory
  82775. */
  82776. add(point: DeepImmutable<Vector3>): void;
  82777. /**
  82778. * Create a new Trajectory with a segment length chosen to make it
  82779. * probable that the new Trajectory will have a specified number of
  82780. * segments. This operation is imprecise.
  82781. * @param targetResolution number of segments desired
  82782. * @returns new Trajectory with approximately the requested number of segments
  82783. */
  82784. resampleAtTargetResolution(targetResolution: number): Trajectory;
  82785. /**
  82786. * Convert Trajectory segments into tokenized representation. This
  82787. * representation is an array of numbers where each nth number is the
  82788. * index of the token which is most similar to the nth segment of the
  82789. * Trajectory.
  82790. * @param tokens list of vectors which serve as discrete tokens
  82791. * @returns list of indices of most similar token per segment
  82792. */
  82793. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  82794. private static _forwardDir;
  82795. private static _inverseFromVec;
  82796. private static _upDir;
  82797. private static _fromToVec;
  82798. private static _lookMatrix;
  82799. /**
  82800. * Transform the rotation (i.e., direction) of a segment to isolate
  82801. * the relative transformation represented by the segment. This operation
  82802. * may or may not succeed due to singularities in the equations that define
  82803. * motion relativity in this context.
  82804. * @param priorVec the origin of the prior segment
  82805. * @param fromVec the origin of the current segment
  82806. * @param toVec the destination of the current segment
  82807. * @param result reference to output variable
  82808. * @returns whether or not transformation was successful
  82809. */
  82810. private static _transformSegmentDirToRef;
  82811. private static _bestMatch;
  82812. private static _score;
  82813. private static _bestScore;
  82814. /**
  82815. * Determine which token vector is most similar to the
  82816. * segment vector.
  82817. * @param segment segment vector
  82818. * @param tokens token vector list
  82819. * @returns index of the most similar token to the segment
  82820. */
  82821. private static _tokenizeSegment;
  82822. }
  82823. /**
  82824. * Class representing a set of known, named trajectories to which Trajectories can be
  82825. * added and using which Trajectories can be recognized.
  82826. */
  82827. export class TrajectoryClassifier {
  82828. private _maximumAllowableMatchCost;
  82829. private _vector3Alphabet;
  82830. private _levenshteinAlphabet;
  82831. private _nameToDescribedTrajectory;
  82832. /**
  82833. * Serialize to JSON.
  82834. * @returns JSON serialization
  82835. */
  82836. serialize(): string;
  82837. /**
  82838. * Deserialize from JSON.
  82839. * @param json JSON serialization
  82840. * @returns deserialized TrajectorySet
  82841. */
  82842. static Deserialize(json: string): TrajectoryClassifier;
  82843. /**
  82844. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  82845. * VERY naive, need to be generating these things from known
  82846. * sets. Better version later, probably eliminating this one.
  82847. * @returns auto-generated TrajectorySet
  82848. */
  82849. static Generate(): TrajectoryClassifier;
  82850. private constructor();
  82851. /**
  82852. * Add a new Trajectory to the set with a given name.
  82853. * @param trajectory new Trajectory to be added
  82854. * @param classification name to which to add the Trajectory
  82855. */
  82856. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  82857. /**
  82858. * Remove a known named trajectory and all Trajectories associated with it.
  82859. * @param classification name to remove
  82860. * @returns whether anything was removed
  82861. */
  82862. deleteClassification(classification: string): boolean;
  82863. /**
  82864. * Attempt to recognize a Trajectory from among all the classifications
  82865. * already known to the classifier.
  82866. * @param trajectory Trajectory to be recognized
  82867. * @returns classification of Trajectory if recognized, null otherwise
  82868. */
  82869. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  82870. }
  82871. }
  82872. declare module "babylonjs/Misc/index" {
  82873. export * from "babylonjs/Misc/andOrNotEvaluator";
  82874. export * from "babylonjs/Misc/assetsManager";
  82875. export * from "babylonjs/Misc/basis";
  82876. export * from "babylonjs/Misc/dds";
  82877. export * from "babylonjs/Misc/decorators";
  82878. export * from "babylonjs/Misc/deferred";
  82879. export * from "babylonjs/Misc/environmentTextureTools";
  82880. export * from "babylonjs/Misc/meshExploder";
  82881. export * from "babylonjs/Misc/filesInput";
  82882. export * from "babylonjs/Misc/HighDynamicRange/index";
  82883. export * from "babylonjs/Misc/khronosTextureContainer";
  82884. export * from "babylonjs/Misc/observable";
  82885. export * from "babylonjs/Misc/performanceMonitor";
  82886. export * from "babylonjs/Misc/promise";
  82887. export * from "babylonjs/Misc/sceneOptimizer";
  82888. export * from "babylonjs/Misc/sceneSerializer";
  82889. export * from "babylonjs/Misc/smartArray";
  82890. export * from "babylonjs/Misc/stringDictionary";
  82891. export * from "babylonjs/Misc/tags";
  82892. export * from "babylonjs/Misc/textureTools";
  82893. export * from "babylonjs/Misc/tga";
  82894. export * from "babylonjs/Misc/tools";
  82895. export * from "babylonjs/Misc/videoRecorder";
  82896. export * from "babylonjs/Misc/virtualJoystick";
  82897. export * from "babylonjs/Misc/workerPool";
  82898. export * from "babylonjs/Misc/logger";
  82899. export * from "babylonjs/Misc/typeStore";
  82900. export * from "babylonjs/Misc/filesInputStore";
  82901. export * from "babylonjs/Misc/deepCopier";
  82902. export * from "babylonjs/Misc/pivotTools";
  82903. export * from "babylonjs/Misc/precisionDate";
  82904. export * from "babylonjs/Misc/screenshotTools";
  82905. export * from "babylonjs/Misc/typeStore";
  82906. export * from "babylonjs/Misc/webRequest";
  82907. export * from "babylonjs/Misc/iInspectable";
  82908. export * from "babylonjs/Misc/brdfTextureTools";
  82909. export * from "babylonjs/Misc/rgbdTextureTools";
  82910. export * from "babylonjs/Misc/gradients";
  82911. export * from "babylonjs/Misc/perfCounter";
  82912. export * from "babylonjs/Misc/fileRequest";
  82913. export * from "babylonjs/Misc/customAnimationFrameRequester";
  82914. export * from "babylonjs/Misc/retryStrategy";
  82915. export * from "babylonjs/Misc/interfaces/screenshotSize";
  82916. export * from "babylonjs/Misc/canvasGenerator";
  82917. export * from "babylonjs/Misc/fileTools";
  82918. export * from "babylonjs/Misc/stringTools";
  82919. export * from "babylonjs/Misc/dataReader";
  82920. export * from "babylonjs/Misc/minMaxReducer";
  82921. export * from "babylonjs/Misc/depthReducer";
  82922. export * from "babylonjs/Misc/dataStorage";
  82923. export * from "babylonjs/Misc/sceneRecorder";
  82924. export * from "babylonjs/Misc/khronosTextureContainer2";
  82925. export * from "babylonjs/Misc/trajectoryClassifier";
  82926. export * from "babylonjs/Misc/timer";
  82927. export * from "babylonjs/Misc/copyTools";
  82928. }
  82929. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  82930. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  82931. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  82932. import { Observable } from "babylonjs/Misc/observable";
  82933. import { Matrix } from "babylonjs/Maths/math.vector";
  82934. import { TransformNode } from "babylonjs/Meshes/transformNode";
  82935. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  82936. /**
  82937. * An interface for all Hit test features
  82938. */
  82939. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  82940. /**
  82941. * Triggered when new babylon (transformed) hit test results are available
  82942. */
  82943. onHitTestResultObservable: Observable<T[]>;
  82944. }
  82945. /**
  82946. * Options used for hit testing
  82947. */
  82948. export interface IWebXRLegacyHitTestOptions {
  82949. /**
  82950. * Only test when user interacted with the scene. Default - hit test every frame
  82951. */
  82952. testOnPointerDownOnly?: boolean;
  82953. /**
  82954. * The node to use to transform the local results to world coordinates
  82955. */
  82956. worldParentNode?: TransformNode;
  82957. }
  82958. /**
  82959. * Interface defining the babylon result of raycasting/hit-test
  82960. */
  82961. export interface IWebXRLegacyHitResult {
  82962. /**
  82963. * Transformation matrix that can be applied to a node that will put it in the hit point location
  82964. */
  82965. transformationMatrix: Matrix;
  82966. /**
  82967. * The native hit test result
  82968. */
  82969. xrHitResult: XRHitResult | XRHitTestResult;
  82970. }
  82971. /**
  82972. * The currently-working hit-test module.
  82973. * Hit test (or Ray-casting) is used to interact with the real world.
  82974. * For further information read here - https://github.com/immersive-web/hit-test
  82975. */
  82976. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  82977. /**
  82978. * options to use when constructing this feature
  82979. */
  82980. readonly options: IWebXRLegacyHitTestOptions;
  82981. private _direction;
  82982. private _mat;
  82983. private _onSelectEnabled;
  82984. private _origin;
  82985. /**
  82986. * The module's name
  82987. */
  82988. static readonly Name: string;
  82989. /**
  82990. * The (Babylon) version of this module.
  82991. * This is an integer representing the implementation version.
  82992. * This number does not correspond to the WebXR specs version
  82993. */
  82994. static readonly Version: number;
  82995. /**
  82996. * Populated with the last native XR Hit Results
  82997. */
  82998. lastNativeXRHitResults: XRHitResult[];
  82999. /**
  83000. * Triggered when new babylon (transformed) hit test results are available
  83001. */
  83002. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  83003. /**
  83004. * Creates a new instance of the (legacy version) hit test feature
  83005. * @param _xrSessionManager an instance of WebXRSessionManager
  83006. * @param options options to use when constructing this feature
  83007. */
  83008. constructor(_xrSessionManager: WebXRSessionManager,
  83009. /**
  83010. * options to use when constructing this feature
  83011. */
  83012. options?: IWebXRLegacyHitTestOptions);
  83013. /**
  83014. * execute a hit test with an XR Ray
  83015. *
  83016. * @param xrSession a native xrSession that will execute this hit test
  83017. * @param xrRay the ray (position and direction) to use for ray-casting
  83018. * @param referenceSpace native XR reference space to use for the hit-test
  83019. * @param filter filter function that will filter the results
  83020. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83021. */
  83022. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  83023. /**
  83024. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  83025. * @param event the (select) event to use to select with
  83026. * @param referenceSpace the reference space to use for this hit test
  83027. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83028. */
  83029. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  83030. /**
  83031. * attach this feature
  83032. * Will usually be called by the features manager
  83033. *
  83034. * @returns true if successful.
  83035. */
  83036. attach(): boolean;
  83037. /**
  83038. * detach this feature.
  83039. * Will usually be called by the features manager
  83040. *
  83041. * @returns true if successful.
  83042. */
  83043. detach(): boolean;
  83044. /**
  83045. * Dispose this feature and all of the resources attached
  83046. */
  83047. dispose(): void;
  83048. protected _onXRFrame(frame: XRFrame): void;
  83049. private _onHitTestResults;
  83050. private _onSelect;
  83051. }
  83052. }
  83053. declare module "babylonjs/XR/features/WebXRHitTest" {
  83054. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83055. import { Observable } from "babylonjs/Misc/observable";
  83056. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83057. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83058. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  83059. /**
  83060. * Options used for hit testing (version 2)
  83061. */
  83062. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  83063. /**
  83064. * Do not create a permanent hit test. Will usually be used when only
  83065. * transient inputs are needed.
  83066. */
  83067. disablePermanentHitTest?: boolean;
  83068. /**
  83069. * Enable transient (for example touch-based) hit test inspections
  83070. */
  83071. enableTransientHitTest?: boolean;
  83072. /**
  83073. * Offset ray for the permanent hit test
  83074. */
  83075. offsetRay?: Vector3;
  83076. /**
  83077. * Offset ray for the transient hit test
  83078. */
  83079. transientOffsetRay?: Vector3;
  83080. /**
  83081. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  83082. */
  83083. useReferenceSpace?: boolean;
  83084. /**
  83085. * Override the default entity type(s) of the hit-test result
  83086. */
  83087. entityTypes?: XRHitTestTrackableType[];
  83088. }
  83089. /**
  83090. * Interface defining the babylon result of hit-test
  83091. */
  83092. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  83093. /**
  83094. * The input source that generated this hit test (if transient)
  83095. */
  83096. inputSource?: XRInputSource;
  83097. /**
  83098. * Is this a transient hit test
  83099. */
  83100. isTransient?: boolean;
  83101. /**
  83102. * Position of the hit test result
  83103. */
  83104. position: Vector3;
  83105. /**
  83106. * Rotation of the hit test result
  83107. */
  83108. rotationQuaternion: Quaternion;
  83109. /**
  83110. * The native hit test result
  83111. */
  83112. xrHitResult: XRHitTestResult;
  83113. }
  83114. /**
  83115. * The currently-working hit-test module.
  83116. * Hit test (or Ray-casting) is used to interact with the real world.
  83117. * For further information read here - https://github.com/immersive-web/hit-test
  83118. *
  83119. * Tested on chrome (mobile) 80.
  83120. */
  83121. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  83122. /**
  83123. * options to use when constructing this feature
  83124. */
  83125. readonly options: IWebXRHitTestOptions;
  83126. private _tmpMat;
  83127. private _tmpPos;
  83128. private _tmpQuat;
  83129. private _transientXrHitTestSource;
  83130. private _xrHitTestSource;
  83131. private initHitTestSource;
  83132. /**
  83133. * The module's name
  83134. */
  83135. static readonly Name: string;
  83136. /**
  83137. * The (Babylon) version of this module.
  83138. * This is an integer representing the implementation version.
  83139. * This number does not correspond to the WebXR specs version
  83140. */
  83141. static readonly Version: number;
  83142. /**
  83143. * When set to true, each hit test will have its own position/rotation objects
  83144. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  83145. * the developers will clone them or copy them as they see fit.
  83146. */
  83147. autoCloneTransformation: boolean;
  83148. /**
  83149. * Triggered when new babylon (transformed) hit test results are available
  83150. * Note - this will be called when results come back from the device. It can be an empty array!!
  83151. */
  83152. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  83153. /**
  83154. * Use this to temporarily pause hit test checks.
  83155. */
  83156. paused: boolean;
  83157. /**
  83158. * Creates a new instance of the hit test feature
  83159. * @param _xrSessionManager an instance of WebXRSessionManager
  83160. * @param options options to use when constructing this feature
  83161. */
  83162. constructor(_xrSessionManager: WebXRSessionManager,
  83163. /**
  83164. * options to use when constructing this feature
  83165. */
  83166. options?: IWebXRHitTestOptions);
  83167. /**
  83168. * attach this feature
  83169. * Will usually be called by the features manager
  83170. *
  83171. * @returns true if successful.
  83172. */
  83173. attach(): boolean;
  83174. /**
  83175. * detach this feature.
  83176. * Will usually be called by the features manager
  83177. *
  83178. * @returns true if successful.
  83179. */
  83180. detach(): boolean;
  83181. /**
  83182. * Dispose this feature and all of the resources attached
  83183. */
  83184. dispose(): void;
  83185. protected _onXRFrame(frame: XRFrame): void;
  83186. private _processWebXRHitTestResult;
  83187. }
  83188. }
  83189. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  83190. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83191. import { Observable } from "babylonjs/Misc/observable";
  83192. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83194. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83195. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  83196. /**
  83197. * Configuration options of the anchor system
  83198. */
  83199. export interface IWebXRAnchorSystemOptions {
  83200. /**
  83201. * a node that will be used to convert local to world coordinates
  83202. */
  83203. worldParentNode?: TransformNode;
  83204. /**
  83205. * If set to true a reference of the created anchors will be kept until the next session starts
  83206. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  83207. */
  83208. doNotRemoveAnchorsOnSessionEnded?: boolean;
  83209. }
  83210. /**
  83211. * A babylon container for an XR Anchor
  83212. */
  83213. export interface IWebXRAnchor {
  83214. /**
  83215. * A babylon-assigned ID for this anchor
  83216. */
  83217. id: number;
  83218. /**
  83219. * Transformation matrix to apply to an object attached to this anchor
  83220. */
  83221. transformationMatrix: Matrix;
  83222. /**
  83223. * The native anchor object
  83224. */
  83225. xrAnchor: XRAnchor;
  83226. /**
  83227. * if defined, this object will be constantly updated by the anchor's position and rotation
  83228. */
  83229. attachedNode?: TransformNode;
  83230. /**
  83231. * Remove this anchor from the scene
  83232. */
  83233. remove(): void;
  83234. }
  83235. /**
  83236. * An implementation of the anchor system for WebXR.
  83237. * For further information see https://github.com/immersive-web/anchors/
  83238. */
  83239. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  83240. private _options;
  83241. private _lastFrameDetected;
  83242. private _trackedAnchors;
  83243. private _referenceSpaceForFrameAnchors;
  83244. private _futureAnchors;
  83245. /**
  83246. * The module's name
  83247. */
  83248. static readonly Name: string;
  83249. /**
  83250. * The (Babylon) version of this module.
  83251. * This is an integer representing the implementation version.
  83252. * This number does not correspond to the WebXR specs version
  83253. */
  83254. static readonly Version: number;
  83255. /**
  83256. * Observers registered here will be executed when a new anchor was added to the session
  83257. */
  83258. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  83259. /**
  83260. * Observers registered here will be executed when an anchor was removed from the session
  83261. */
  83262. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  83263. /**
  83264. * Observers registered here will be executed when an existing anchor updates
  83265. * This can execute N times every frame
  83266. */
  83267. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  83268. /**
  83269. * Set the reference space to use for anchor creation, when not using a hit test.
  83270. * Will default to the session's reference space if not defined
  83271. */
  83272. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  83273. /**
  83274. * constructs a new anchor system
  83275. * @param _xrSessionManager an instance of WebXRSessionManager
  83276. * @param _options configuration object for this feature
  83277. */
  83278. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  83279. private _tmpVector;
  83280. private _tmpQuaternion;
  83281. private _populateTmpTransformation;
  83282. /**
  83283. * Create a new anchor point using a hit test result at a specific point in the scene
  83284. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83285. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83286. *
  83287. * @param hitTestResult The hit test result to use for this anchor creation
  83288. * @param position an optional position offset for this anchor
  83289. * @param rotationQuaternion an optional rotation offset for this anchor
  83290. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83291. */
  83292. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  83293. /**
  83294. * Add a new anchor at a specific position and rotation
  83295. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  83296. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  83297. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83298. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83299. *
  83300. * @param position the position in which to add an anchor
  83301. * @param rotationQuaternion an optional rotation for the anchor transformation
  83302. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  83303. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83304. */
  83305. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  83306. /**
  83307. * Get the list of anchors currently being tracked by the system
  83308. */
  83309. get anchors(): IWebXRAnchor[];
  83310. /**
  83311. * detach this feature.
  83312. * Will usually be called by the features manager
  83313. *
  83314. * @returns true if successful.
  83315. */
  83316. detach(): boolean;
  83317. /**
  83318. * Dispose this feature and all of the resources attached
  83319. */
  83320. dispose(): void;
  83321. protected _onXRFrame(frame: XRFrame): void;
  83322. /**
  83323. * avoiding using Array.find for global support.
  83324. * @param xrAnchor the plane to find in the array
  83325. */
  83326. private _findIndexInAnchorArray;
  83327. private _updateAnchorWithXRFrame;
  83328. private _createAnchorAtTransformation;
  83329. }
  83330. }
  83331. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  83332. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83333. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83334. import { Observable } from "babylonjs/Misc/observable";
  83335. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  83336. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83337. /**
  83338. * Options used in the plane detector module
  83339. */
  83340. export interface IWebXRPlaneDetectorOptions {
  83341. /**
  83342. * The node to use to transform the local results to world coordinates
  83343. */
  83344. worldParentNode?: TransformNode;
  83345. /**
  83346. * If set to true a reference of the created planes will be kept until the next session starts
  83347. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  83348. */
  83349. doNotRemovePlanesOnSessionEnded?: boolean;
  83350. /**
  83351. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  83352. */
  83353. preferredDetectorOptions?: XRGeometryDetectorOptions;
  83354. }
  83355. /**
  83356. * A babylon interface for a WebXR plane.
  83357. * A Plane is actually a polygon, built from N points in space
  83358. *
  83359. * Supported in chrome 79, not supported in canary 81 ATM
  83360. */
  83361. export interface IWebXRPlane {
  83362. /**
  83363. * a babylon-assigned ID for this polygon
  83364. */
  83365. id: number;
  83366. /**
  83367. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  83368. */
  83369. polygonDefinition: Array<Vector3>;
  83370. /**
  83371. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  83372. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  83373. */
  83374. transformationMatrix: Matrix;
  83375. /**
  83376. * the native xr-plane object
  83377. */
  83378. xrPlane: XRPlane;
  83379. }
  83380. /**
  83381. * The plane detector is used to detect planes in the real world when in AR
  83382. * For more information see https://github.com/immersive-web/real-world-geometry/
  83383. */
  83384. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  83385. private _options;
  83386. private _detectedPlanes;
  83387. private _enabled;
  83388. private _lastFrameDetected;
  83389. /**
  83390. * The module's name
  83391. */
  83392. static readonly Name: string;
  83393. /**
  83394. * The (Babylon) version of this module.
  83395. * This is an integer representing the implementation version.
  83396. * This number does not correspond to the WebXR specs version
  83397. */
  83398. static readonly Version: number;
  83399. /**
  83400. * Observers registered here will be executed when a new plane was added to the session
  83401. */
  83402. onPlaneAddedObservable: Observable<IWebXRPlane>;
  83403. /**
  83404. * Observers registered here will be executed when a plane is no longer detected in the session
  83405. */
  83406. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  83407. /**
  83408. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  83409. * This can execute N times every frame
  83410. */
  83411. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  83412. /**
  83413. * construct a new Plane Detector
  83414. * @param _xrSessionManager an instance of xr Session manager
  83415. * @param _options configuration to use when constructing this feature
  83416. */
  83417. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  83418. /**
  83419. * detach this feature.
  83420. * Will usually be called by the features manager
  83421. *
  83422. * @returns true if successful.
  83423. */
  83424. detach(): boolean;
  83425. /**
  83426. * Dispose this feature and all of the resources attached
  83427. */
  83428. dispose(): void;
  83429. /**
  83430. * Check if the needed objects are defined.
  83431. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  83432. */
  83433. isCompatible(): boolean;
  83434. protected _onXRFrame(frame: XRFrame): void;
  83435. private _init;
  83436. private _updatePlaneWithXRPlane;
  83437. /**
  83438. * avoiding using Array.find for global support.
  83439. * @param xrPlane the plane to find in the array
  83440. */
  83441. private _findIndexInPlaneArray;
  83442. }
  83443. }
  83444. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  83445. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  83447. import { Observable } from "babylonjs/Misc/observable";
  83448. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83449. /**
  83450. * Options interface for the background remover plugin
  83451. */
  83452. export interface IWebXRBackgroundRemoverOptions {
  83453. /**
  83454. * Further background meshes to disable when entering AR
  83455. */
  83456. backgroundMeshes?: AbstractMesh[];
  83457. /**
  83458. * flags to configure the removal of the environment helper.
  83459. * If not set, the entire background will be removed. If set, flags should be set as well.
  83460. */
  83461. environmentHelperRemovalFlags?: {
  83462. /**
  83463. * Should the skybox be removed (default false)
  83464. */
  83465. skyBox?: boolean;
  83466. /**
  83467. * Should the ground be removed (default false)
  83468. */
  83469. ground?: boolean;
  83470. };
  83471. /**
  83472. * don't disable the environment helper
  83473. */
  83474. ignoreEnvironmentHelper?: boolean;
  83475. }
  83476. /**
  83477. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  83478. */
  83479. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  83480. /**
  83481. * read-only options to be used in this module
  83482. */
  83483. readonly options: IWebXRBackgroundRemoverOptions;
  83484. /**
  83485. * The module's name
  83486. */
  83487. static readonly Name: string;
  83488. /**
  83489. * The (Babylon) version of this module.
  83490. * This is an integer representing the implementation version.
  83491. * This number does not correspond to the WebXR specs version
  83492. */
  83493. static readonly Version: number;
  83494. /**
  83495. * registered observers will be triggered when the background state changes
  83496. */
  83497. onBackgroundStateChangedObservable: Observable<boolean>;
  83498. /**
  83499. * constructs a new background remover module
  83500. * @param _xrSessionManager the session manager for this module
  83501. * @param options read-only options to be used in this module
  83502. */
  83503. constructor(_xrSessionManager: WebXRSessionManager,
  83504. /**
  83505. * read-only options to be used in this module
  83506. */
  83507. options?: IWebXRBackgroundRemoverOptions);
  83508. /**
  83509. * attach this feature
  83510. * Will usually be called by the features manager
  83511. *
  83512. * @returns true if successful.
  83513. */
  83514. attach(): boolean;
  83515. /**
  83516. * detach this feature.
  83517. * Will usually be called by the features manager
  83518. *
  83519. * @returns true if successful.
  83520. */
  83521. detach(): boolean;
  83522. /**
  83523. * Dispose this feature and all of the resources attached
  83524. */
  83525. dispose(): void;
  83526. protected _onXRFrame(_xrFrame: XRFrame): void;
  83527. private _setBackgroundState;
  83528. }
  83529. }
  83530. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  83531. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83532. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  83533. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  83534. import { WebXRInput } from "babylonjs/XR/webXRInput";
  83535. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83536. import { Nullable } from "babylonjs/types";
  83537. /**
  83538. * Options for the controller physics feature
  83539. */
  83540. export class IWebXRControllerPhysicsOptions {
  83541. /**
  83542. * Should the headset get its own impostor
  83543. */
  83544. enableHeadsetImpostor?: boolean;
  83545. /**
  83546. * Optional parameters for the headset impostor
  83547. */
  83548. headsetImpostorParams?: {
  83549. /**
  83550. * The type of impostor to create. Default is sphere
  83551. */
  83552. impostorType: number;
  83553. /**
  83554. * the size of the impostor. Defaults to 10cm
  83555. */
  83556. impostorSize?: number | {
  83557. width: number;
  83558. height: number;
  83559. depth: number;
  83560. };
  83561. /**
  83562. * Friction definitions
  83563. */
  83564. friction?: number;
  83565. /**
  83566. * Restitution
  83567. */
  83568. restitution?: number;
  83569. };
  83570. /**
  83571. * The physics properties of the future impostors
  83572. */
  83573. physicsProperties?: {
  83574. /**
  83575. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  83576. * Note that this requires a physics engine that supports mesh impostors!
  83577. */
  83578. useControllerMesh?: boolean;
  83579. /**
  83580. * The type of impostor to create. Default is sphere
  83581. */
  83582. impostorType?: number;
  83583. /**
  83584. * the size of the impostor. Defaults to 10cm
  83585. */
  83586. impostorSize?: number | {
  83587. width: number;
  83588. height: number;
  83589. depth: number;
  83590. };
  83591. /**
  83592. * Friction definitions
  83593. */
  83594. friction?: number;
  83595. /**
  83596. * Restitution
  83597. */
  83598. restitution?: number;
  83599. };
  83600. /**
  83601. * the xr input to use with this pointer selection
  83602. */
  83603. xrInput: WebXRInput;
  83604. }
  83605. /**
  83606. * Add physics impostor to your webxr controllers,
  83607. * including naive calculation of their linear and angular velocity
  83608. */
  83609. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  83610. private readonly _options;
  83611. private _attachController;
  83612. private _controllers;
  83613. private _debugMode;
  83614. private _delta;
  83615. private _headsetImpostor?;
  83616. private _headsetMesh?;
  83617. private _lastTimestamp;
  83618. private _tmpQuaternion;
  83619. private _tmpVector;
  83620. /**
  83621. * The module's name
  83622. */
  83623. static readonly Name: string;
  83624. /**
  83625. * The (Babylon) version of this module.
  83626. * This is an integer representing the implementation version.
  83627. * This number does not correspond to the webxr specs version
  83628. */
  83629. static readonly Version: number;
  83630. /**
  83631. * Construct a new Controller Physics Feature
  83632. * @param _xrSessionManager the corresponding xr session manager
  83633. * @param _options options to create this feature with
  83634. */
  83635. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  83636. /**
  83637. * @hidden
  83638. * enable debugging - will show console outputs and the impostor mesh
  83639. */
  83640. _enablePhysicsDebug(): void;
  83641. /**
  83642. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  83643. * @param xrController the controller to add
  83644. */
  83645. addController(xrController: WebXRInputSource): void;
  83646. /**
  83647. * attach this feature
  83648. * Will usually be called by the features manager
  83649. *
  83650. * @returns true if successful.
  83651. */
  83652. attach(): boolean;
  83653. /**
  83654. * detach this feature.
  83655. * Will usually be called by the features manager
  83656. *
  83657. * @returns true if successful.
  83658. */
  83659. detach(): boolean;
  83660. /**
  83661. * Get the headset impostor, if enabled
  83662. * @returns the impostor
  83663. */
  83664. getHeadsetImpostor(): PhysicsImpostor | undefined;
  83665. /**
  83666. * Get the physics impostor of a specific controller.
  83667. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  83668. * @param controller the controller or the controller id of which to get the impostor
  83669. * @returns the impostor or null
  83670. */
  83671. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  83672. /**
  83673. * Update the physics properties provided in the constructor
  83674. * @param newProperties the new properties object
  83675. */
  83676. setPhysicsProperties(newProperties: {
  83677. impostorType?: number;
  83678. impostorSize?: number | {
  83679. width: number;
  83680. height: number;
  83681. depth: number;
  83682. };
  83683. friction?: number;
  83684. restitution?: number;
  83685. }): void;
  83686. protected _onXRFrame(_xrFrame: any): void;
  83687. private _detachController;
  83688. }
  83689. }
  83690. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  83691. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83692. import { Observable } from "babylonjs/Misc/observable";
  83693. import { Vector3 } from "babylonjs/Maths/math.vector";
  83694. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83695. /**
  83696. * A babylon interface for a "WebXR" feature point.
  83697. * Represents the position and confidence value of a given feature point.
  83698. */
  83699. export interface IWebXRFeaturePoint {
  83700. /**
  83701. * Represents the position of the feature point in world space.
  83702. */
  83703. position: Vector3;
  83704. /**
  83705. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  83706. */
  83707. confidenceValue: number;
  83708. }
  83709. /**
  83710. * The feature point system is used to detect feature points from real world geometry.
  83711. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  83712. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  83713. */
  83714. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  83715. private _enabled;
  83716. private _featurePointCloud;
  83717. /**
  83718. * The module's name
  83719. */
  83720. static readonly Name: string;
  83721. /**
  83722. * The (Babylon) version of this module.
  83723. * This is an integer representing the implementation version.
  83724. * This number does not correspond to the WebXR specs version
  83725. */
  83726. static readonly Version: number;
  83727. /**
  83728. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  83729. * Will notify the observers about which feature points have been added.
  83730. */
  83731. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  83732. /**
  83733. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  83734. * Will notify the observers about which feature points have been updated.
  83735. */
  83736. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  83737. /**
  83738. * The current feature point cloud maintained across frames.
  83739. */
  83740. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  83741. /**
  83742. * construct the feature point system
  83743. * @param _xrSessionManager an instance of xr Session manager
  83744. */
  83745. constructor(_xrSessionManager: WebXRSessionManager);
  83746. /**
  83747. * Detach this feature.
  83748. * Will usually be called by the features manager
  83749. *
  83750. * @returns true if successful.
  83751. */
  83752. detach(): boolean;
  83753. /**
  83754. * Dispose this feature and all of the resources attached
  83755. */
  83756. dispose(): void;
  83757. /**
  83758. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  83759. */
  83760. protected _onXRFrame(frame: XRFrame): void;
  83761. /**
  83762. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  83763. */
  83764. private _init;
  83765. }
  83766. }
  83767. declare module "babylonjs/XR/features/WebXRHandTracking" {
  83768. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83769. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  83771. import { Mesh } from "babylonjs/Meshes/mesh";
  83772. import { WebXRInput } from "babylonjs/XR/webXRInput";
  83773. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  83774. import { Nullable } from "babylonjs/types";
  83775. import { IDisposable } from "babylonjs/scene";
  83776. import { Observable } from "babylonjs/Misc/observable";
  83777. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  83778. /**
  83779. * Configuration interface for the hand tracking feature
  83780. */
  83781. export interface IWebXRHandTrackingOptions {
  83782. /**
  83783. * The xrInput that will be used as source for new hands
  83784. */
  83785. xrInput: WebXRInput;
  83786. /**
  83787. * Configuration object for the joint meshes
  83788. */
  83789. jointMeshes?: {
  83790. /**
  83791. * Should the meshes created be invisible (defaults to false)
  83792. */
  83793. invisible?: boolean;
  83794. /**
  83795. * A source mesh to be used to create instances. Defaults to a sphere.
  83796. * This mesh will be the source for all other (25) meshes.
  83797. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  83798. */
  83799. sourceMesh?: Mesh;
  83800. /**
  83801. * This function will be called after a mesh was created for a specific joint.
  83802. * Using this function you can either manipulate the instance or return a new mesh.
  83803. * When returning a new mesh the instance created before will be disposed
  83804. */
  83805. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  83806. /**
  83807. * Should the source mesh stay visible. Defaults to false
  83808. */
  83809. keepOriginalVisible?: boolean;
  83810. /**
  83811. * Scale factor for all instances (defaults to 2)
  83812. */
  83813. scaleFactor?: number;
  83814. /**
  83815. * Should each instance have its own physics impostor
  83816. */
  83817. enablePhysics?: boolean;
  83818. /**
  83819. * If enabled, override default physics properties
  83820. */
  83821. physicsProps?: {
  83822. friction?: number;
  83823. restitution?: number;
  83824. impostorType?: number;
  83825. };
  83826. /**
  83827. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  83828. */
  83829. disableDefaultHandMesh?: boolean;
  83830. /**
  83831. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  83832. */
  83833. handMeshes?: {
  83834. right: AbstractMesh;
  83835. left: AbstractMesh;
  83836. };
  83837. /**
  83838. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  83839. */
  83840. rigMapping?: {
  83841. right: string[];
  83842. left: string[];
  83843. };
  83844. };
  83845. }
  83846. /**
  83847. * Parts of the hands divided to writs and finger names
  83848. */
  83849. export const enum HandPart {
  83850. /**
  83851. * HandPart - Wrist
  83852. */
  83853. WRIST = "wrist",
  83854. /**
  83855. * HandPart - The THumb
  83856. */
  83857. THUMB = "thumb",
  83858. /**
  83859. * HandPart - Index finger
  83860. */
  83861. INDEX = "index",
  83862. /**
  83863. * HandPart - Middle finger
  83864. */
  83865. MIDDLE = "middle",
  83866. /**
  83867. * HandPart - Ring finger
  83868. */
  83869. RING = "ring",
  83870. /**
  83871. * HandPart - Little finger
  83872. */
  83873. LITTLE = "little"
  83874. }
  83875. /**
  83876. * Representing a single hand (with its corresponding native XRHand object)
  83877. */
  83878. export class WebXRHand implements IDisposable {
  83879. /** the controller to which the hand correlates */
  83880. readonly xrController: WebXRInputSource;
  83881. /** the meshes to be used to track the hand joints */
  83882. readonly trackedMeshes: AbstractMesh[];
  83883. private _handMesh?;
  83884. private _rigMapping?;
  83885. private _scene;
  83886. private _defaultHandMesh;
  83887. private _transformNodeMapping;
  83888. /**
  83889. * Hand-parts definition (key is HandPart)
  83890. */
  83891. handPartsDefinition: {
  83892. [key: string]: number[];
  83893. };
  83894. /**
  83895. * Observers will be triggered when the mesh for this hand was initialized.
  83896. */
  83897. onHandMeshReadyObservable: Observable<WebXRHand>;
  83898. /**
  83899. * Populate the HandPartsDefinition object.
  83900. * This is called as a side effect since certain browsers don't have XRHand defined.
  83901. */
  83902. private generateHandPartsDefinition;
  83903. /**
  83904. * Construct a new hand object
  83905. * @param xrController the controller to which the hand correlates
  83906. * @param trackedMeshes the meshes to be used to track the hand joints
  83907. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  83908. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  83909. * @param disableDefaultHandMesh should the default mesh creation be disabled
  83910. */
  83911. constructor(
  83912. /** the controller to which the hand correlates */
  83913. xrController: WebXRInputSource,
  83914. /** the meshes to be used to track the hand joints */
  83915. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  83916. /**
  83917. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  83918. */
  83919. get handMesh(): AbstractMesh | undefined;
  83920. /**
  83921. * Update this hand from the latest xr frame
  83922. * @param xrFrame xrFrame to update from
  83923. * @param referenceSpace The current viewer reference space
  83924. * @param scaleFactor optional scale factor for the meshes
  83925. */
  83926. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  83927. /**
  83928. * Get meshes of part of the hand
  83929. * @param part the part of hand to get
  83930. * @returns An array of meshes that correlate to the hand part requested
  83931. */
  83932. getHandPartMeshes(part: HandPart): AbstractMesh[];
  83933. /**
  83934. * Dispose this Hand object
  83935. */
  83936. dispose(): void;
  83937. private _generateDefaultHandMesh;
  83938. }
  83939. /**
  83940. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  83941. */
  83942. export class WebXRHandTracking extends WebXRAbstractFeature {
  83943. /**
  83944. * options to use when constructing this feature
  83945. */
  83946. readonly options: IWebXRHandTrackingOptions;
  83947. private static _idCounter;
  83948. /**
  83949. * The module's name
  83950. */
  83951. static readonly Name: string;
  83952. /**
  83953. * The (Babylon) version of this module.
  83954. * This is an integer representing the implementation version.
  83955. * This number does not correspond to the WebXR specs version
  83956. */
  83957. static readonly Version: number;
  83958. /**
  83959. * This observable will notify registered observers when a new hand object was added and initialized
  83960. */
  83961. onHandAddedObservable: Observable<WebXRHand>;
  83962. /**
  83963. * This observable will notify its observers right before the hand object is disposed
  83964. */
  83965. onHandRemovedObservable: Observable<WebXRHand>;
  83966. private _hands;
  83967. /**
  83968. * Creates a new instance of the hit test feature
  83969. * @param _xrSessionManager an instance of WebXRSessionManager
  83970. * @param options options to use when constructing this feature
  83971. */
  83972. constructor(_xrSessionManager: WebXRSessionManager,
  83973. /**
  83974. * options to use when constructing this feature
  83975. */
  83976. options: IWebXRHandTrackingOptions);
  83977. /**
  83978. * Check if the needed objects are defined.
  83979. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  83980. */
  83981. isCompatible(): boolean;
  83982. /**
  83983. * attach this feature
  83984. * Will usually be called by the features manager
  83985. *
  83986. * @returns true if successful.
  83987. */
  83988. attach(): boolean;
  83989. /**
  83990. * detach this feature.
  83991. * Will usually be called by the features manager
  83992. *
  83993. * @returns true if successful.
  83994. */
  83995. detach(): boolean;
  83996. /**
  83997. * Dispose this feature and all of the resources attached
  83998. */
  83999. dispose(): void;
  84000. /**
  84001. * Get the hand object according to the controller id
  84002. * @param controllerId the controller id to which we want to get the hand
  84003. * @returns null if not found or the WebXRHand object if found
  84004. */
  84005. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  84006. /**
  84007. * Get a hand object according to the requested handedness
  84008. * @param handedness the handedness to request
  84009. * @returns null if not found or the WebXRHand object if found
  84010. */
  84011. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  84012. protected _onXRFrame(_xrFrame: XRFrame): void;
  84013. private _attachHand;
  84014. private _detachHand;
  84015. }
  84016. }
  84017. declare module "babylonjs/XR/features/WebXRMeshDetector" {
  84018. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84019. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84021. import { Matrix } from "babylonjs/Maths/math";
  84022. import { Observable } from "babylonjs/Misc/observable";
  84023. /**
  84024. * Options used in the mesh detector module
  84025. */
  84026. export interface IWebXRMeshDetectorOptions {
  84027. /**
  84028. * The node to use to transform the local results to world coordinates
  84029. */
  84030. worldParentNode?: TransformNode;
  84031. /**
  84032. * If set to true a reference of the created meshes will be kept until the next session starts
  84033. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  84034. */
  84035. doNotRemoveMeshesOnSessionEnded?: boolean;
  84036. /**
  84037. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  84038. */
  84039. preferredDetectorOptions?: XRGeometryDetectorOptions;
  84040. /**
  84041. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  84042. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  84043. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  84044. */
  84045. convertCoordinateSystems?: boolean;
  84046. }
  84047. /**
  84048. * A babylon interface for a XR mesh's vertex data.
  84049. *
  84050. * Currently not supported by WebXR, available only with BabylonNative
  84051. */
  84052. export interface IWebXRVertexData {
  84053. /**
  84054. * A babylon-assigned ID for this mesh
  84055. */
  84056. id: number;
  84057. /**
  84058. * Data required for constructing a mesh in Babylon.js.
  84059. */
  84060. xrMesh: XRMesh;
  84061. /**
  84062. * The node to use to transform the local results to world coordinates.
  84063. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  84064. */
  84065. worldParentNode?: TransformNode;
  84066. /**
  84067. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  84068. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84069. */
  84070. positions?: Float32Array;
  84071. /**
  84072. * An array of indices in babylon space. right/left hand system is taken into account.
  84073. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84074. */
  84075. indices?: Uint32Array;
  84076. /**
  84077. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  84078. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  84079. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  84080. */
  84081. normals?: Float32Array;
  84082. /**
  84083. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  84084. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  84085. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84086. */
  84087. transformationMatrix?: Matrix;
  84088. }
  84089. /**
  84090. * The mesh detector is used to detect meshes in the real world when in AR
  84091. */
  84092. export class WebXRMeshDetector extends WebXRAbstractFeature {
  84093. private _options;
  84094. private _detectedMeshes;
  84095. /**
  84096. * The module's name
  84097. */
  84098. static readonly Name: string;
  84099. /**
  84100. * The (Babylon) version of this module.
  84101. * This is an integer representing the implementation version.
  84102. * This number does not correspond to the WebXR specs version
  84103. */
  84104. static readonly Version: number;
  84105. /**
  84106. * Observers registered here will be executed when a new mesh was added to the session
  84107. */
  84108. onMeshAddedObservable: Observable<IWebXRVertexData>;
  84109. /**
  84110. * Observers registered here will be executed when a mesh is no longer detected in the session
  84111. */
  84112. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  84113. /**
  84114. * Observers registered here will be executed when an existing mesh updates
  84115. */
  84116. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  84117. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  84118. detach(): boolean;
  84119. dispose(): void;
  84120. protected _onXRFrame(frame: XRFrame): void;
  84121. private _init;
  84122. private _updateVertexDataWithXRMesh;
  84123. }
  84124. }
  84125. declare module "babylonjs/XR/features/index" {
  84126. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  84127. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  84128. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  84129. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  84130. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  84131. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  84132. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  84133. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  84134. export * from "babylonjs/XR/features/WebXRHitTest";
  84135. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  84136. export * from "babylonjs/XR/features/WebXRHandTracking";
  84137. export * from "babylonjs/XR/features/WebXRMeshDetector";
  84138. }
  84139. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  84140. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84142. import { Scene } from "babylonjs/scene";
  84143. /**
  84144. * The motion controller class for all microsoft mixed reality controllers
  84145. */
  84146. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  84147. protected readonly _mapping: {
  84148. defaultButton: {
  84149. valueNodeName: string;
  84150. unpressedNodeName: string;
  84151. pressedNodeName: string;
  84152. };
  84153. defaultAxis: {
  84154. valueNodeName: string;
  84155. minNodeName: string;
  84156. maxNodeName: string;
  84157. };
  84158. buttons: {
  84159. "xr-standard-trigger": {
  84160. rootNodeName: string;
  84161. componentProperty: string;
  84162. states: string[];
  84163. };
  84164. "xr-standard-squeeze": {
  84165. rootNodeName: string;
  84166. componentProperty: string;
  84167. states: string[];
  84168. };
  84169. "xr-standard-touchpad": {
  84170. rootNodeName: string;
  84171. labelAnchorNodeName: string;
  84172. touchPointNodeName: string;
  84173. };
  84174. "xr-standard-thumbstick": {
  84175. rootNodeName: string;
  84176. componentProperty: string;
  84177. states: string[];
  84178. };
  84179. };
  84180. axes: {
  84181. "xr-standard-touchpad": {
  84182. "x-axis": {
  84183. rootNodeName: string;
  84184. };
  84185. "y-axis": {
  84186. rootNodeName: string;
  84187. };
  84188. };
  84189. "xr-standard-thumbstick": {
  84190. "x-axis": {
  84191. rootNodeName: string;
  84192. };
  84193. "y-axis": {
  84194. rootNodeName: string;
  84195. };
  84196. };
  84197. };
  84198. };
  84199. /**
  84200. * The base url used to load the left and right controller models
  84201. */
  84202. static MODEL_BASE_URL: string;
  84203. /**
  84204. * The name of the left controller model file
  84205. */
  84206. static MODEL_LEFT_FILENAME: string;
  84207. /**
  84208. * The name of the right controller model file
  84209. */
  84210. static MODEL_RIGHT_FILENAME: string;
  84211. profileId: string;
  84212. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84213. protected _getFilenameAndPath(): {
  84214. filename: string;
  84215. path: string;
  84216. };
  84217. protected _getModelLoadingConstraints(): boolean;
  84218. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84219. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84220. protected _updateModel(): void;
  84221. }
  84222. }
  84223. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  84224. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84226. import { Scene } from "babylonjs/scene";
  84227. /**
  84228. * The motion controller class for oculus touch (quest, rift).
  84229. * This class supports legacy mapping as well the standard xr mapping
  84230. */
  84231. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  84232. private _forceLegacyControllers;
  84233. private _modelRootNode;
  84234. /**
  84235. * The base url used to load the left and right controller models
  84236. */
  84237. static MODEL_BASE_URL: string;
  84238. /**
  84239. * The name of the left controller model file
  84240. */
  84241. static MODEL_LEFT_FILENAME: string;
  84242. /**
  84243. * The name of the right controller model file
  84244. */
  84245. static MODEL_RIGHT_FILENAME: string;
  84246. /**
  84247. * Base Url for the Quest controller model.
  84248. */
  84249. static QUEST_MODEL_BASE_URL: string;
  84250. profileId: string;
  84251. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  84252. protected _getFilenameAndPath(): {
  84253. filename: string;
  84254. path: string;
  84255. };
  84256. protected _getModelLoadingConstraints(): boolean;
  84257. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84258. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84259. protected _updateModel(): void;
  84260. /**
  84261. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  84262. * between the touch and touch 2.
  84263. */
  84264. private _isQuest;
  84265. }
  84266. }
  84267. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  84268. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84269. import { Scene } from "babylonjs/scene";
  84270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84271. /**
  84272. * The motion controller class for the standard HTC-Vive controllers
  84273. */
  84274. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  84275. private _modelRootNode;
  84276. /**
  84277. * The base url used to load the left and right controller models
  84278. */
  84279. static MODEL_BASE_URL: string;
  84280. /**
  84281. * File name for the controller model.
  84282. */
  84283. static MODEL_FILENAME: string;
  84284. profileId: string;
  84285. /**
  84286. * Create a new Vive motion controller object
  84287. * @param scene the scene to use to create this controller
  84288. * @param gamepadObject the corresponding gamepad object
  84289. * @param handedness the handedness of the controller
  84290. */
  84291. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84292. protected _getFilenameAndPath(): {
  84293. filename: string;
  84294. path: string;
  84295. };
  84296. protected _getModelLoadingConstraints(): boolean;
  84297. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84298. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84299. protected _updateModel(): void;
  84300. }
  84301. }
  84302. declare module "babylonjs/XR/motionController/index" {
  84303. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84304. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  84305. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  84306. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  84307. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  84308. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  84309. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  84310. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  84311. }
  84312. declare module "babylonjs/XR/index" {
  84313. export * from "babylonjs/XR/webXRCamera";
  84314. export * from "babylonjs/XR/webXREnterExitUI";
  84315. export * from "babylonjs/XR/webXRExperienceHelper";
  84316. export * from "babylonjs/XR/webXRInput";
  84317. export * from "babylonjs/XR/webXRInputSource";
  84318. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  84319. export * from "babylonjs/XR/webXRTypes";
  84320. export * from "babylonjs/XR/webXRSessionManager";
  84321. export * from "babylonjs/XR/webXRDefaultExperience";
  84322. export * from "babylonjs/XR/webXRFeaturesManager";
  84323. export * from "babylonjs/XR/features/index";
  84324. export * from "babylonjs/XR/motionController/index";
  84325. }
  84326. declare module "babylonjs/index" {
  84327. export * from "babylonjs/abstractScene";
  84328. export * from "babylonjs/Actions/index";
  84329. export * from "babylonjs/Animations/index";
  84330. export * from "babylonjs/assetContainer";
  84331. export * from "babylonjs/Audio/index";
  84332. export * from "babylonjs/Behaviors/index";
  84333. export * from "babylonjs/Bones/index";
  84334. export * from "babylonjs/Cameras/index";
  84335. export * from "babylonjs/Collisions/index";
  84336. export * from "babylonjs/Culling/index";
  84337. export * from "babylonjs/Debug/index";
  84338. export * from "babylonjs/DeviceInput/index";
  84339. export * from "babylonjs/Engines/index";
  84340. export * from "babylonjs/Events/index";
  84341. export * from "babylonjs/Gamepads/index";
  84342. export * from "babylonjs/Gizmos/index";
  84343. export * from "babylonjs/Helpers/index";
  84344. export * from "babylonjs/Instrumentation/index";
  84345. export * from "babylonjs/Layers/index";
  84346. export * from "babylonjs/LensFlares/index";
  84347. export * from "babylonjs/Lights/index";
  84348. export * from "babylonjs/Loading/index";
  84349. export * from "babylonjs/Materials/index";
  84350. export * from "babylonjs/Maths/index";
  84351. export * from "babylonjs/Meshes/index";
  84352. export * from "babylonjs/Morph/index";
  84353. export * from "babylonjs/Navigation/index";
  84354. export * from "babylonjs/node";
  84355. export * from "babylonjs/Offline/index";
  84356. export * from "babylonjs/Particles/index";
  84357. export * from "babylonjs/Physics/index";
  84358. export * from "babylonjs/PostProcesses/index";
  84359. export * from "babylonjs/Probes/index";
  84360. export * from "babylonjs/Rendering/index";
  84361. export * from "babylonjs/scene";
  84362. export * from "babylonjs/sceneComponent";
  84363. export * from "babylonjs/Sprites/index";
  84364. export * from "babylonjs/States/index";
  84365. export * from "babylonjs/Misc/index";
  84366. export * from "babylonjs/XR/index";
  84367. export * from "babylonjs/types";
  84368. }
  84369. declare module "babylonjs/Animations/pathCursor" {
  84370. import { Vector3 } from "babylonjs/Maths/math.vector";
  84371. import { Path2 } from "babylonjs/Maths/math.path";
  84372. /**
  84373. * A cursor which tracks a point on a path
  84374. */
  84375. export class PathCursor {
  84376. private path;
  84377. /**
  84378. * Stores path cursor callbacks for when an onchange event is triggered
  84379. */
  84380. private _onchange;
  84381. /**
  84382. * The value of the path cursor
  84383. */
  84384. value: number;
  84385. /**
  84386. * The animation array of the path cursor
  84387. */
  84388. animations: Animation[];
  84389. /**
  84390. * Initializes the path cursor
  84391. * @param path The path to track
  84392. */
  84393. constructor(path: Path2);
  84394. /**
  84395. * Gets the cursor point on the path
  84396. * @returns A point on the path cursor at the cursor location
  84397. */
  84398. getPoint(): Vector3;
  84399. /**
  84400. * Moves the cursor ahead by the step amount
  84401. * @param step The amount to move the cursor forward
  84402. * @returns This path cursor
  84403. */
  84404. moveAhead(step?: number): PathCursor;
  84405. /**
  84406. * Moves the cursor behind by the step amount
  84407. * @param step The amount to move the cursor back
  84408. * @returns This path cursor
  84409. */
  84410. moveBack(step?: number): PathCursor;
  84411. /**
  84412. * Moves the cursor by the step amount
  84413. * If the step amount is greater than one, an exception is thrown
  84414. * @param step The amount to move the cursor
  84415. * @returns This path cursor
  84416. */
  84417. move(step: number): PathCursor;
  84418. /**
  84419. * Ensures that the value is limited between zero and one
  84420. * @returns This path cursor
  84421. */
  84422. private ensureLimits;
  84423. /**
  84424. * Runs onchange callbacks on change (used by the animation engine)
  84425. * @returns This path cursor
  84426. */
  84427. private raiseOnChange;
  84428. /**
  84429. * Executes a function on change
  84430. * @param f A path cursor onchange callback
  84431. * @returns This path cursor
  84432. */
  84433. onchange(f: (cursor: PathCursor) => void): PathCursor;
  84434. }
  84435. }
  84436. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  84437. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  84438. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  84439. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  84440. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  84441. }
  84442. declare module "babylonjs/Engines/Processors/Expressions/index" {
  84443. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  84444. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  84445. }
  84446. declare module "babylonjs/Engines/Processors/index" {
  84447. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  84448. export * from "babylonjs/Engines/Processors/Expressions/index";
  84449. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  84450. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  84451. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  84452. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  84453. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  84454. export * from "babylonjs/Engines/Processors/shaderProcessor";
  84455. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  84456. }
  84457. declare module "babylonjs/Legacy/legacy" {
  84458. import * as Babylon from "babylonjs/index";
  84459. export * from "babylonjs/index";
  84460. }
  84461. declare module "babylonjs/Shaders/blur.fragment" {
  84462. /** @hidden */
  84463. export var blurPixelShader: {
  84464. name: string;
  84465. shader: string;
  84466. };
  84467. }
  84468. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  84469. /** @hidden */
  84470. export var pointCloudVertexDeclaration: {
  84471. name: string;
  84472. shader: string;
  84473. };
  84474. }
  84475. declare module "babylonjs" {
  84476. export * from "babylonjs/Legacy/legacy";
  84477. }
  84478. declare module BABYLON {
  84479. /** Alias type for value that can be null */
  84480. export type Nullable<T> = T | null;
  84481. /**
  84482. * Alias type for number that are floats
  84483. * @ignorenaming
  84484. */
  84485. export type float = number;
  84486. /**
  84487. * Alias type for number that are doubles.
  84488. * @ignorenaming
  84489. */
  84490. export type double = number;
  84491. /**
  84492. * Alias type for number that are integer
  84493. * @ignorenaming
  84494. */
  84495. export type int = number;
  84496. /** Alias type for number array or Float32Array */
  84497. export type FloatArray = number[] | Float32Array;
  84498. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  84499. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  84500. /**
  84501. * Alias for types that can be used by a Buffer or VertexBuffer.
  84502. */
  84503. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  84504. /**
  84505. * Alias type for primitive types
  84506. * @ignorenaming
  84507. */
  84508. type Primitive = undefined | null | boolean | string | number | Function;
  84509. /**
  84510. * Type modifier to make all the properties of an object Readonly
  84511. */
  84512. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  84513. /**
  84514. * Type modifier to make all the properties of an object Readonly recursively
  84515. */
  84516. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  84517. /**
  84518. * Type modifier to make object properties readonly.
  84519. */
  84520. export type DeepImmutableObject<T> = {
  84521. readonly [K in keyof T]: DeepImmutable<T[K]>;
  84522. };
  84523. /** @hidden */
  84524. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  84525. }
  84526. }
  84527. declare module BABYLON {
  84528. /**
  84529. * A class serves as a medium between the observable and its observers
  84530. */
  84531. export class EventState {
  84532. /**
  84533. * Create a new EventState
  84534. * @param mask defines the mask associated with this state
  84535. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  84536. * @param target defines the original target of the state
  84537. * @param currentTarget defines the current target of the state
  84538. */
  84539. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  84540. /**
  84541. * Initialize the current event state
  84542. * @param mask defines the mask associated with this state
  84543. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  84544. * @param target defines the original target of the state
  84545. * @param currentTarget defines the current target of the state
  84546. * @returns the current event state
  84547. */
  84548. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  84549. /**
  84550. * An Observer can set this property to true to prevent subsequent observers of being notified
  84551. */
  84552. skipNextObservers: boolean;
  84553. /**
  84554. * Get the mask value that were used to trigger the event corresponding to this EventState object
  84555. */
  84556. mask: number;
  84557. /**
  84558. * The object that originally notified the event
  84559. */
  84560. target?: any;
  84561. /**
  84562. * The current object in the bubbling phase
  84563. */
  84564. currentTarget?: any;
  84565. /**
  84566. * This will be populated with the return value of the last function that was executed.
  84567. * If it is the first function in the callback chain it will be the event data.
  84568. */
  84569. lastReturnValue?: any;
  84570. /**
  84571. * User defined information that will be sent to observers
  84572. */
  84573. userInfo?: any;
  84574. }
  84575. /**
  84576. * Represent an Observer registered to a given Observable object.
  84577. */
  84578. export class Observer<T> {
  84579. /**
  84580. * Defines the callback to call when the observer is notified
  84581. */
  84582. callback: (eventData: T, eventState: EventState) => void;
  84583. /**
  84584. * Defines the mask of the observer (used to filter notifications)
  84585. */
  84586. mask: number;
  84587. /**
  84588. * Defines the current scope used to restore the JS context
  84589. */
  84590. scope: any;
  84591. /** @hidden */
  84592. _willBeUnregistered: boolean;
  84593. /**
  84594. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  84595. */
  84596. unregisterOnNextCall: boolean;
  84597. /**
  84598. * Creates a new observer
  84599. * @param callback defines the callback to call when the observer is notified
  84600. * @param mask defines the mask of the observer (used to filter notifications)
  84601. * @param scope defines the current scope used to restore the JS context
  84602. */
  84603. constructor(
  84604. /**
  84605. * Defines the callback to call when the observer is notified
  84606. */
  84607. callback: (eventData: T, eventState: EventState) => void,
  84608. /**
  84609. * Defines the mask of the observer (used to filter notifications)
  84610. */
  84611. mask: number,
  84612. /**
  84613. * Defines the current scope used to restore the JS context
  84614. */
  84615. scope?: any);
  84616. }
  84617. /**
  84618. * Represent a list of observers registered to multiple Observables object.
  84619. */
  84620. export class MultiObserver<T> {
  84621. private _observers;
  84622. private _observables;
  84623. /**
  84624. * Release associated resources
  84625. */
  84626. dispose(): void;
  84627. /**
  84628. * Raise a callback when one of the observable will notify
  84629. * @param observables defines a list of observables to watch
  84630. * @param callback defines the callback to call on notification
  84631. * @param mask defines the mask used to filter notifications
  84632. * @param scope defines the current scope used to restore the JS context
  84633. * @returns the new MultiObserver
  84634. */
  84635. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  84636. }
  84637. /**
  84638. * The Observable class is a simple implementation of the Observable pattern.
  84639. *
  84640. * 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.
  84641. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  84642. * 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).
  84643. * 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.
  84644. */
  84645. export class Observable<T> {
  84646. private _observers;
  84647. private _eventState;
  84648. private _onObserverAdded;
  84649. /**
  84650. * Gets the list of observers
  84651. */
  84652. get observers(): Array<Observer<T>>;
  84653. /**
  84654. * Creates a new observable
  84655. * @param onObserverAdded defines a callback to call when a new observer is added
  84656. */
  84657. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  84658. /**
  84659. * Create a new Observer with the specified callback
  84660. * @param callback the callback that will be executed for that Observer
  84661. * @param mask the mask used to filter observers
  84662. * @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.
  84663. * @param scope optional scope for the callback to be called from
  84664. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  84665. * @returns the new observer created for the callback
  84666. */
  84667. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  84668. /**
  84669. * Create a new Observer with the specified callback and unregisters after the next notification
  84670. * @param callback the callback that will be executed for that Observer
  84671. * @returns the new observer created for the callback
  84672. */
  84673. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  84674. /**
  84675. * Remove an Observer from the Observable object
  84676. * @param observer the instance of the Observer to remove
  84677. * @returns false if it doesn't belong to this Observable
  84678. */
  84679. remove(observer: Nullable<Observer<T>>): boolean;
  84680. /**
  84681. * Remove a callback from the Observable object
  84682. * @param callback the callback to remove
  84683. * @param scope optional scope. If used only the callbacks with this scope will be removed
  84684. * @returns false if it doesn't belong to this Observable
  84685. */
  84686. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  84687. private _deferUnregister;
  84688. private _remove;
  84689. /**
  84690. * Moves the observable to the top of the observer list making it get called first when notified
  84691. * @param observer the observer to move
  84692. */
  84693. makeObserverTopPriority(observer: Observer<T>): void;
  84694. /**
  84695. * Moves the observable to the bottom of the observer list making it get called last when notified
  84696. * @param observer the observer to move
  84697. */
  84698. makeObserverBottomPriority(observer: Observer<T>): void;
  84699. /**
  84700. * Notify all Observers by calling their respective callback with the given data
  84701. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  84702. * @param eventData defines the data to send to all observers
  84703. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  84704. * @param target defines the original target of the state
  84705. * @param currentTarget defines the current target of the state
  84706. * @param userInfo defines any user info to send to observers
  84707. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  84708. */
  84709. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  84710. /**
  84711. * Calling this will execute each callback, expecting it to be a promise or return a value.
  84712. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  84713. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  84714. * and it is crucial that all callbacks will be executed.
  84715. * The order of the callbacks is kept, callbacks are not executed parallel.
  84716. *
  84717. * @param eventData The data to be sent to each callback
  84718. * @param mask is used to filter observers defaults to -1
  84719. * @param target defines the callback target (see EventState)
  84720. * @param currentTarget defines he current object in the bubbling phase
  84721. * @param userInfo defines any user info to send to observers
  84722. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  84723. */
  84724. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  84725. /**
  84726. * Notify a specific observer
  84727. * @param observer defines the observer to notify
  84728. * @param eventData defines the data to be sent to each callback
  84729. * @param mask is used to filter observers defaults to -1
  84730. */
  84731. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  84732. /**
  84733. * Gets a boolean indicating if the observable has at least one observer
  84734. * @returns true is the Observable has at least one Observer registered
  84735. */
  84736. hasObservers(): boolean;
  84737. /**
  84738. * Clear the list of observers
  84739. */
  84740. clear(): void;
  84741. /**
  84742. * Clone the current observable
  84743. * @returns a new observable
  84744. */
  84745. clone(): Observable<T>;
  84746. /**
  84747. * Does this observable handles observer registered with a given mask
  84748. * @param mask defines the mask to be tested
  84749. * @return whether or not one observer registered with the given mask is handeled
  84750. **/
  84751. hasSpecificMask(mask?: number): boolean;
  84752. }
  84753. }
  84754. declare module BABYLON {
  84755. /**
  84756. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  84757. * Babylon.js
  84758. */
  84759. export class DomManagement {
  84760. /**
  84761. * Checks if the window object exists
  84762. * @returns true if the window object exists
  84763. */
  84764. static IsWindowObjectExist(): boolean;
  84765. /**
  84766. * Checks if the navigator object exists
  84767. * @returns true if the navigator object exists
  84768. */
  84769. static IsNavigatorAvailable(): boolean;
  84770. /**
  84771. * Check if the document object exists
  84772. * @returns true if the document object exists
  84773. */
  84774. static IsDocumentAvailable(): boolean;
  84775. /**
  84776. * Extracts text content from a DOM element hierarchy
  84777. * @param element defines the root element
  84778. * @returns a string
  84779. */
  84780. static GetDOMTextContent(element: HTMLElement): string;
  84781. }
  84782. }
  84783. declare module BABYLON {
  84784. /**
  84785. * Logger used througouht the application to allow configuration of
  84786. * the log level required for the messages.
  84787. */
  84788. export class Logger {
  84789. /**
  84790. * No log
  84791. */
  84792. static readonly NoneLogLevel: number;
  84793. /**
  84794. * Only message logs
  84795. */
  84796. static readonly MessageLogLevel: number;
  84797. /**
  84798. * Only warning logs
  84799. */
  84800. static readonly WarningLogLevel: number;
  84801. /**
  84802. * Only error logs
  84803. */
  84804. static readonly ErrorLogLevel: number;
  84805. /**
  84806. * All logs
  84807. */
  84808. static readonly AllLogLevel: number;
  84809. /**
  84810. * Message to display when a message has been logged too many times
  84811. */
  84812. static MessageLimitReached: string;
  84813. private static _LogCache;
  84814. private static _LogLimitOutputs;
  84815. /**
  84816. * Gets a value indicating the number of loading errors
  84817. * @ignorenaming
  84818. */
  84819. static errorsCount: number;
  84820. /**
  84821. * Callback called when a new log is added
  84822. */
  84823. static OnNewCacheEntry: (entry: string) => void;
  84824. private static _CheckLimit;
  84825. private static _GenerateLimitMessage;
  84826. private static _AddLogEntry;
  84827. private static _FormatMessage;
  84828. private static _LogDisabled;
  84829. private static _LogEnabled;
  84830. private static _WarnDisabled;
  84831. private static _WarnEnabled;
  84832. private static _ErrorDisabled;
  84833. private static _ErrorEnabled;
  84834. /**
  84835. * Log a message to the console
  84836. */
  84837. static Log: (message: string, limit?: number) => void;
  84838. /**
  84839. * Write a warning message to the console
  84840. */
  84841. static Warn: (message: string, limit?: number) => void;
  84842. /**
  84843. * Write an error message to the console
  84844. */
  84845. static Error: (message: string, limit?: number) => void;
  84846. /**
  84847. * Gets current log cache (list of logs)
  84848. */
  84849. static get LogCache(): string;
  84850. /**
  84851. * Clears the log cache
  84852. */
  84853. static ClearLogCache(): void;
  84854. /**
  84855. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  84856. */
  84857. static set LogLevels(level: number);
  84858. }
  84859. }
  84860. declare module BABYLON {
  84861. /** @hidden */
  84862. export class _TypeStore {
  84863. /** @hidden */
  84864. static RegisteredTypes: {
  84865. [key: string]: Object;
  84866. };
  84867. /** @hidden */
  84868. static GetClass(fqdn: string): any;
  84869. }
  84870. }
  84871. declare module BABYLON {
  84872. /**
  84873. * Helper to manipulate strings
  84874. */
  84875. export class StringTools {
  84876. /**
  84877. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  84878. * @param str Source string
  84879. * @param suffix Suffix to search for in the source string
  84880. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  84881. */
  84882. static EndsWith(str: string, suffix: string): boolean;
  84883. /**
  84884. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  84885. * @param str Source string
  84886. * @param suffix Suffix to search for in the source string
  84887. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  84888. */
  84889. static StartsWith(str: string, suffix: string): boolean;
  84890. /**
  84891. * Decodes a buffer into a string
  84892. * @param buffer The buffer to decode
  84893. * @returns The decoded string
  84894. */
  84895. static Decode(buffer: Uint8Array | Uint16Array): string;
  84896. /**
  84897. * Encode a buffer to a base64 string
  84898. * @param buffer defines the buffer to encode
  84899. * @returns the encoded string
  84900. */
  84901. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  84902. /**
  84903. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  84904. * @param num the number to convert and pad
  84905. * @param length the expected length of the string
  84906. * @returns the padded string
  84907. */
  84908. static PadNumber(num: number, length: number): string;
  84909. }
  84910. }
  84911. declare module BABYLON {
  84912. /**
  84913. * Class containing a set of static utilities functions for deep copy.
  84914. */
  84915. export class DeepCopier {
  84916. /**
  84917. * Tries to copy an object by duplicating every property
  84918. * @param source defines the source object
  84919. * @param destination defines the target object
  84920. * @param doNotCopyList defines a list of properties to avoid
  84921. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  84922. */
  84923. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  84924. }
  84925. }
  84926. declare module BABYLON {
  84927. /**
  84928. * Class containing a set of static utilities functions for precision date
  84929. */
  84930. export class PrecisionDate {
  84931. /**
  84932. * Gets either window.performance.now() if supported or Date.now() else
  84933. */
  84934. static get Now(): number;
  84935. }
  84936. }
  84937. declare module BABYLON {
  84938. /** @hidden */
  84939. export class _DevTools {
  84940. static WarnImport(name: string): string;
  84941. }
  84942. }
  84943. declare module BABYLON {
  84944. /**
  84945. * Interface used to define the mechanism to get data from the network
  84946. */
  84947. export interface IWebRequest {
  84948. /**
  84949. * Returns client's response url
  84950. */
  84951. responseURL: string;
  84952. /**
  84953. * Returns client's status
  84954. */
  84955. status: number;
  84956. /**
  84957. * Returns client's status as a text
  84958. */
  84959. statusText: string;
  84960. }
  84961. }
  84962. declare module BABYLON {
  84963. /**
  84964. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  84965. */
  84966. export class WebRequest implements IWebRequest {
  84967. private readonly _xhr;
  84968. /**
  84969. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  84970. * i.e. when loading files, where the server/service expects an Authorization header
  84971. */
  84972. static CustomRequestHeaders: {
  84973. [key: string]: string;
  84974. };
  84975. /**
  84976. * Add callback functions in this array to update all the requests before they get sent to the network
  84977. */
  84978. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  84979. private _injectCustomRequestHeaders;
  84980. /**
  84981. * Gets or sets a function to be called when loading progress changes
  84982. */
  84983. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  84984. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  84985. /**
  84986. * Returns client's state
  84987. */
  84988. get readyState(): number;
  84989. /**
  84990. * Returns client's status
  84991. */
  84992. get status(): number;
  84993. /**
  84994. * Returns client's status as a text
  84995. */
  84996. get statusText(): string;
  84997. /**
  84998. * Returns client's response
  84999. */
  85000. get response(): any;
  85001. /**
  85002. * Returns client's response url
  85003. */
  85004. get responseURL(): string;
  85005. /**
  85006. * Returns client's response as text
  85007. */
  85008. get responseText(): string;
  85009. /**
  85010. * Gets or sets the expected response type
  85011. */
  85012. get responseType(): XMLHttpRequestResponseType;
  85013. set responseType(value: XMLHttpRequestResponseType);
  85014. /** @hidden */
  85015. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  85016. /** @hidden */
  85017. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  85018. /**
  85019. * Cancels any network activity
  85020. */
  85021. abort(): void;
  85022. /**
  85023. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  85024. * @param body defines an optional request body
  85025. */
  85026. send(body?: Document | BodyInit | null): void;
  85027. /**
  85028. * Sets the request method, request URL
  85029. * @param method defines the method to use (GET, POST, etc..)
  85030. * @param url defines the url to connect with
  85031. */
  85032. open(method: string, url: string): void;
  85033. /**
  85034. * Sets the value of a request header.
  85035. * @param name The name of the header whose value is to be set
  85036. * @param value The value to set as the body of the header
  85037. */
  85038. setRequestHeader(name: string, value: string): void;
  85039. /**
  85040. * Get the string containing the text of a particular header's value.
  85041. * @param name The name of the header
  85042. * @returns The string containing the text of the given header name
  85043. */
  85044. getResponseHeader(name: string): Nullable<string>;
  85045. }
  85046. }
  85047. declare module BABYLON {
  85048. /**
  85049. * File request interface
  85050. */
  85051. export interface IFileRequest {
  85052. /**
  85053. * Raised when the request is complete (success or error).
  85054. */
  85055. onCompleteObservable: Observable<IFileRequest>;
  85056. /**
  85057. * Aborts the request for a file.
  85058. */
  85059. abort: () => void;
  85060. }
  85061. }
  85062. declare module BABYLON {
  85063. /**
  85064. * Define options used to create a render target texture
  85065. */
  85066. export class RenderTargetCreationOptions {
  85067. /**
  85068. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  85069. */
  85070. createMipMaps?: boolean;
  85071. /**
  85072. * Specifies if mipmaps must be generated
  85073. */
  85074. generateMipMaps?: boolean;
  85075. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  85076. generateDepthBuffer?: boolean;
  85077. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  85078. generateStencilBuffer?: boolean;
  85079. /** Defines texture type (int by default) */
  85080. type?: number;
  85081. /** Defines sampling mode (trilinear by default) */
  85082. samplingMode?: number;
  85083. /** Defines format (RGBA by default) */
  85084. format?: number;
  85085. /** Defines sample count (1 by default) */
  85086. samples?: number;
  85087. }
  85088. }
  85089. declare module BABYLON {
  85090. /** Defines the cross module used constants to avoid circular dependncies */
  85091. export class Constants {
  85092. /** Defines that alpha blending is disabled */
  85093. static readonly ALPHA_DISABLE: number;
  85094. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  85095. static readonly ALPHA_ADD: number;
  85096. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85097. static readonly ALPHA_COMBINE: number;
  85098. /** Defines that alpha blending is DEST - SRC * DEST */
  85099. static readonly ALPHA_SUBTRACT: number;
  85100. /** Defines that alpha blending is SRC * DEST */
  85101. static readonly ALPHA_MULTIPLY: number;
  85102. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  85103. static readonly ALPHA_MAXIMIZED: number;
  85104. /** Defines that alpha blending is SRC + DEST */
  85105. static readonly ALPHA_ONEONE: number;
  85106. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  85107. static readonly ALPHA_PREMULTIPLIED: number;
  85108. /**
  85109. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  85110. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85111. */
  85112. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85113. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  85114. static readonly ALPHA_INTERPOLATE: number;
  85115. /**
  85116. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  85117. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85118. */
  85119. static readonly ALPHA_SCREENMODE: number;
  85120. /**
  85121. * Defines that alpha blending is SRC + DST
  85122. * Alpha will be set to SRC ALPHA + DST ALPHA
  85123. */
  85124. static readonly ALPHA_ONEONE_ONEONE: number;
  85125. /**
  85126. * Defines that alpha blending is SRC * DST ALPHA + DST
  85127. * Alpha will be set to 0
  85128. */
  85129. static readonly ALPHA_ALPHATOCOLOR: number;
  85130. /**
  85131. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85132. */
  85133. static readonly ALPHA_REVERSEONEMINUS: number;
  85134. /**
  85135. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  85136. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  85137. */
  85138. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  85139. /**
  85140. * Defines that alpha blending is SRC + DST
  85141. * Alpha will be set to SRC ALPHA
  85142. */
  85143. static readonly ALPHA_ONEONE_ONEZERO: number;
  85144. /**
  85145. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85146. * Alpha will be set to DST ALPHA
  85147. */
  85148. static readonly ALPHA_EXCLUSION: number;
  85149. /** Defines that alpha blending equation a SUM */
  85150. static readonly ALPHA_EQUATION_ADD: number;
  85151. /** Defines that alpha blending equation a SUBSTRACTION */
  85152. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  85153. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  85154. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  85155. /** Defines that alpha blending equation a MAX operation */
  85156. static readonly ALPHA_EQUATION_MAX: number;
  85157. /** Defines that alpha blending equation a MIN operation */
  85158. static readonly ALPHA_EQUATION_MIN: number;
  85159. /**
  85160. * Defines that alpha blending equation a DARKEN operation:
  85161. * It takes the min of the src and sums the alpha channels.
  85162. */
  85163. static readonly ALPHA_EQUATION_DARKEN: number;
  85164. /** Defines that the ressource is not delayed*/
  85165. static readonly DELAYLOADSTATE_NONE: number;
  85166. /** Defines that the ressource was successfully delay loaded */
  85167. static readonly DELAYLOADSTATE_LOADED: number;
  85168. /** Defines that the ressource is currently delay loading */
  85169. static readonly DELAYLOADSTATE_LOADING: number;
  85170. /** Defines that the ressource is delayed and has not started loading */
  85171. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85172. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85173. static readonly NEVER: number;
  85174. /** 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 */
  85175. static readonly ALWAYS: number;
  85176. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85177. static readonly LESS: number;
  85178. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85179. static readonly EQUAL: number;
  85180. /** 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 */
  85181. static readonly LEQUAL: number;
  85182. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85183. static readonly GREATER: number;
  85184. /** 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 */
  85185. static readonly GEQUAL: number;
  85186. /** 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 */
  85187. static readonly NOTEQUAL: number;
  85188. /** Passed to stencilOperation to specify that stencil value must be kept */
  85189. static readonly KEEP: number;
  85190. /** Passed to stencilOperation to specify that stencil value must be zero */
  85191. static readonly ZERO: number;
  85192. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85193. static readonly REPLACE: number;
  85194. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85195. static readonly INCR: number;
  85196. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85197. static readonly DECR: number;
  85198. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85199. static readonly INVERT: number;
  85200. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85201. static readonly INCR_WRAP: number;
  85202. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85203. static readonly DECR_WRAP: number;
  85204. /** Texture is not repeating outside of 0..1 UVs */
  85205. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85206. /** Texture is repeating outside of 0..1 UVs */
  85207. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85208. /** Texture is repeating and mirrored */
  85209. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85210. /** ALPHA */
  85211. static readonly TEXTUREFORMAT_ALPHA: number;
  85212. /** LUMINANCE */
  85213. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85214. /** LUMINANCE_ALPHA */
  85215. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85216. /** RGB */
  85217. static readonly TEXTUREFORMAT_RGB: number;
  85218. /** RGBA */
  85219. static readonly TEXTUREFORMAT_RGBA: number;
  85220. /** RED */
  85221. static readonly TEXTUREFORMAT_RED: number;
  85222. /** RED (2nd reference) */
  85223. static readonly TEXTUREFORMAT_R: number;
  85224. /** RG */
  85225. static readonly TEXTUREFORMAT_RG: number;
  85226. /** RED_INTEGER */
  85227. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85228. /** RED_INTEGER (2nd reference) */
  85229. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85230. /** RG_INTEGER */
  85231. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85232. /** RGB_INTEGER */
  85233. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85234. /** RGBA_INTEGER */
  85235. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85236. /** BGRA */
  85237. static readonly TEXTUREFORMAT_BGRA: number;
  85238. /** Depth 24 bits + Stencil 8 bits */
  85239. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  85240. /** Depth 32 bits float */
  85241. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  85242. /** Compressed BC7 */
  85243. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  85244. /** Compressed BC6 unsigned float */
  85245. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  85246. /** Compressed BC6 signed float */
  85247. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  85248. /** Compressed BC3 */
  85249. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  85250. /** Compressed BC2 */
  85251. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  85252. /** Compressed BC1 */
  85253. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  85254. /** UNSIGNED_BYTE */
  85255. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85256. /** UNSIGNED_BYTE (2nd reference) */
  85257. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85258. /** FLOAT */
  85259. static readonly TEXTURETYPE_FLOAT: number;
  85260. /** HALF_FLOAT */
  85261. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85262. /** BYTE */
  85263. static readonly TEXTURETYPE_BYTE: number;
  85264. /** SHORT */
  85265. static readonly TEXTURETYPE_SHORT: number;
  85266. /** UNSIGNED_SHORT */
  85267. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85268. /** INT */
  85269. static readonly TEXTURETYPE_INT: number;
  85270. /** UNSIGNED_INT */
  85271. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85272. /** UNSIGNED_SHORT_4_4_4_4 */
  85273. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85274. /** UNSIGNED_SHORT_5_5_5_1 */
  85275. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85276. /** UNSIGNED_SHORT_5_6_5 */
  85277. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85278. /** UNSIGNED_INT_2_10_10_10_REV */
  85279. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85280. /** UNSIGNED_INT_24_8 */
  85281. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85282. /** UNSIGNED_INT_10F_11F_11F_REV */
  85283. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85284. /** UNSIGNED_INT_5_9_9_9_REV */
  85285. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85286. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85287. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85288. /** nearest is mag = nearest and min = nearest and no mip */
  85289. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85290. /** mag = nearest and min = nearest and mip = none */
  85291. static readonly TEXTURE_NEAREST_NEAREST: number;
  85292. /** Bilinear is mag = linear and min = linear and no mip */
  85293. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85294. /** mag = linear and min = linear and mip = none */
  85295. static readonly TEXTURE_LINEAR_LINEAR: number;
  85296. /** Trilinear is mag = linear and min = linear and mip = linear */
  85297. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85298. /** Trilinear is mag = linear and min = linear and mip = linear */
  85299. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85300. /** mag = nearest and min = nearest and mip = nearest */
  85301. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85302. /** mag = nearest and min = linear and mip = nearest */
  85303. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85304. /** mag = nearest and min = linear and mip = linear */
  85305. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85306. /** mag = nearest and min = linear and mip = none */
  85307. static readonly TEXTURE_NEAREST_LINEAR: number;
  85308. /** nearest is mag = nearest and min = nearest and mip = linear */
  85309. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85310. /** mag = linear and min = nearest and mip = nearest */
  85311. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85312. /** mag = linear and min = nearest and mip = linear */
  85313. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85314. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85315. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85316. /** mag = linear and min = nearest and mip = none */
  85317. static readonly TEXTURE_LINEAR_NEAREST: number;
  85318. /** Explicit coordinates mode */
  85319. static readonly TEXTURE_EXPLICIT_MODE: number;
  85320. /** Spherical coordinates mode */
  85321. static readonly TEXTURE_SPHERICAL_MODE: number;
  85322. /** Planar coordinates mode */
  85323. static readonly TEXTURE_PLANAR_MODE: number;
  85324. /** Cubic coordinates mode */
  85325. static readonly TEXTURE_CUBIC_MODE: number;
  85326. /** Projection coordinates mode */
  85327. static readonly TEXTURE_PROJECTION_MODE: number;
  85328. /** Skybox coordinates mode */
  85329. static readonly TEXTURE_SKYBOX_MODE: number;
  85330. /** Inverse Cubic coordinates mode */
  85331. static readonly TEXTURE_INVCUBIC_MODE: number;
  85332. /** Equirectangular coordinates mode */
  85333. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85334. /** Equirectangular Fixed coordinates mode */
  85335. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85336. /** Equirectangular Fixed Mirrored coordinates mode */
  85337. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85338. /** Offline (baking) quality for texture filtering */
  85339. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  85340. /** High quality for texture filtering */
  85341. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  85342. /** Medium quality for texture filtering */
  85343. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  85344. /** Low quality for texture filtering */
  85345. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  85346. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85347. static readonly SCALEMODE_FLOOR: number;
  85348. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85349. static readonly SCALEMODE_NEAREST: number;
  85350. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85351. static readonly SCALEMODE_CEILING: number;
  85352. /**
  85353. * The dirty texture flag value
  85354. */
  85355. static readonly MATERIAL_TextureDirtyFlag: number;
  85356. /**
  85357. * The dirty light flag value
  85358. */
  85359. static readonly MATERIAL_LightDirtyFlag: number;
  85360. /**
  85361. * The dirty fresnel flag value
  85362. */
  85363. static readonly MATERIAL_FresnelDirtyFlag: number;
  85364. /**
  85365. * The dirty attribute flag value
  85366. */
  85367. static readonly MATERIAL_AttributesDirtyFlag: number;
  85368. /**
  85369. * The dirty misc flag value
  85370. */
  85371. static readonly MATERIAL_MiscDirtyFlag: number;
  85372. /**
  85373. * The dirty prepass flag value
  85374. */
  85375. static readonly MATERIAL_PrePassDirtyFlag: number;
  85376. /**
  85377. * The all dirty flag value
  85378. */
  85379. static readonly MATERIAL_AllDirtyFlag: number;
  85380. /**
  85381. * Returns the triangle fill mode
  85382. */
  85383. static readonly MATERIAL_TriangleFillMode: number;
  85384. /**
  85385. * Returns the wireframe mode
  85386. */
  85387. static readonly MATERIAL_WireFrameFillMode: number;
  85388. /**
  85389. * Returns the point fill mode
  85390. */
  85391. static readonly MATERIAL_PointFillMode: number;
  85392. /**
  85393. * Returns the point list draw mode
  85394. */
  85395. static readonly MATERIAL_PointListDrawMode: number;
  85396. /**
  85397. * Returns the line list draw mode
  85398. */
  85399. static readonly MATERIAL_LineListDrawMode: number;
  85400. /**
  85401. * Returns the line loop draw mode
  85402. */
  85403. static readonly MATERIAL_LineLoopDrawMode: number;
  85404. /**
  85405. * Returns the line strip draw mode
  85406. */
  85407. static readonly MATERIAL_LineStripDrawMode: number;
  85408. /**
  85409. * Returns the triangle strip draw mode
  85410. */
  85411. static readonly MATERIAL_TriangleStripDrawMode: number;
  85412. /**
  85413. * Returns the triangle fan draw mode
  85414. */
  85415. static readonly MATERIAL_TriangleFanDrawMode: number;
  85416. /**
  85417. * Stores the clock-wise side orientation
  85418. */
  85419. static readonly MATERIAL_ClockWiseSideOrientation: number;
  85420. /**
  85421. * Stores the counter clock-wise side orientation
  85422. */
  85423. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  85424. /**
  85425. * Nothing
  85426. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85427. */
  85428. static readonly ACTION_NothingTrigger: number;
  85429. /**
  85430. * On pick
  85431. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85432. */
  85433. static readonly ACTION_OnPickTrigger: number;
  85434. /**
  85435. * On left pick
  85436. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85437. */
  85438. static readonly ACTION_OnLeftPickTrigger: number;
  85439. /**
  85440. * On right pick
  85441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85442. */
  85443. static readonly ACTION_OnRightPickTrigger: number;
  85444. /**
  85445. * On center pick
  85446. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85447. */
  85448. static readonly ACTION_OnCenterPickTrigger: number;
  85449. /**
  85450. * On pick down
  85451. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85452. */
  85453. static readonly ACTION_OnPickDownTrigger: number;
  85454. /**
  85455. * On double pick
  85456. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85457. */
  85458. static readonly ACTION_OnDoublePickTrigger: number;
  85459. /**
  85460. * On pick up
  85461. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85462. */
  85463. static readonly ACTION_OnPickUpTrigger: number;
  85464. /**
  85465. * On pick out.
  85466. * This trigger will only be raised if you also declared a OnPickDown
  85467. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85468. */
  85469. static readonly ACTION_OnPickOutTrigger: number;
  85470. /**
  85471. * On long press
  85472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85473. */
  85474. static readonly ACTION_OnLongPressTrigger: number;
  85475. /**
  85476. * On pointer over
  85477. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85478. */
  85479. static readonly ACTION_OnPointerOverTrigger: number;
  85480. /**
  85481. * On pointer out
  85482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85483. */
  85484. static readonly ACTION_OnPointerOutTrigger: number;
  85485. /**
  85486. * On every frame
  85487. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85488. */
  85489. static readonly ACTION_OnEveryFrameTrigger: number;
  85490. /**
  85491. * On intersection enter
  85492. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85493. */
  85494. static readonly ACTION_OnIntersectionEnterTrigger: number;
  85495. /**
  85496. * On intersection exit
  85497. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85498. */
  85499. static readonly ACTION_OnIntersectionExitTrigger: number;
  85500. /**
  85501. * On key down
  85502. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85503. */
  85504. static readonly ACTION_OnKeyDownTrigger: number;
  85505. /**
  85506. * On key up
  85507. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85508. */
  85509. static readonly ACTION_OnKeyUpTrigger: number;
  85510. /**
  85511. * Billboard mode will only apply to Y axis
  85512. */
  85513. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  85514. /**
  85515. * Billboard mode will apply to all axes
  85516. */
  85517. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  85518. /**
  85519. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85520. */
  85521. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  85522. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  85523. * Test order :
  85524. * Is the bounding sphere outside the frustum ?
  85525. * If not, are the bounding box vertices outside the frustum ?
  85526. * It not, then the cullable object is in the frustum.
  85527. */
  85528. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  85529. /** Culling strategy : Bounding Sphere Only.
  85530. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  85531. * It's also less accurate than the standard because some not visible objects can still be selected.
  85532. * Test : is the bounding sphere outside the frustum ?
  85533. * If not, then the cullable object is in the frustum.
  85534. */
  85535. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  85536. /** Culling strategy : Optimistic Inclusion.
  85537. * This in an inclusion test first, then the standard exclusion test.
  85538. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  85539. * 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.
  85540. * Anyway, it's as accurate as the standard strategy.
  85541. * Test :
  85542. * Is the cullable object bounding sphere center in the frustum ?
  85543. * If not, apply the default culling strategy.
  85544. */
  85545. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  85546. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  85547. * This in an inclusion test first, then the bounding sphere only exclusion test.
  85548. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  85549. * 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.
  85550. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  85551. * Test :
  85552. * Is the cullable object bounding sphere center in the frustum ?
  85553. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  85554. */
  85555. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  85556. /**
  85557. * No logging while loading
  85558. */
  85559. static readonly SCENELOADER_NO_LOGGING: number;
  85560. /**
  85561. * Minimal logging while loading
  85562. */
  85563. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  85564. /**
  85565. * Summary logging while loading
  85566. */
  85567. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  85568. /**
  85569. * Detailled logging while loading
  85570. */
  85571. static readonly SCENELOADER_DETAILED_LOGGING: number;
  85572. /**
  85573. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  85574. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  85575. */
  85576. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  85577. /**
  85578. * Constant used to retrieve the position texture index in the textures array in the prepass
  85579. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  85580. */
  85581. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  85582. /**
  85583. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  85584. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  85585. */
  85586. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  85587. /**
  85588. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  85589. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  85590. */
  85591. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  85592. /**
  85593. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  85594. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  85595. */
  85596. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  85597. /**
  85598. * Constant used to retrieve depth + normal index in the textures array in the prepass
  85599. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  85600. */
  85601. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  85602. /**
  85603. * Constant used to retrieve albedo index in the textures array in the prepass
  85604. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  85605. */
  85606. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  85607. /**
  85608. * Prefixes used by the engine for custom effects
  85609. */
  85610. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  85611. }
  85612. }
  85613. declare module BABYLON {
  85614. /** @hidden */
  85615. export interface HardwareTextureWrapper {
  85616. underlyingResource: any;
  85617. set(hardwareTexture: any): void;
  85618. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  85619. reset(): void;
  85620. release(): void;
  85621. }
  85622. }
  85623. declare module BABYLON {
  85624. /**
  85625. * This represents the required contract to create a new type of texture loader.
  85626. */
  85627. export interface IInternalTextureLoader {
  85628. /**
  85629. * Defines wether the loader supports cascade loading the different faces.
  85630. */
  85631. supportCascades: boolean;
  85632. /**
  85633. * This returns if the loader support the current file information.
  85634. * @param extension defines the file extension of the file being loaded
  85635. * @param mimeType defines the optional mime type of the file being loaded
  85636. * @returns true if the loader can load the specified file
  85637. */
  85638. canLoad(extension: string, mimeType?: string): boolean;
  85639. /**
  85640. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  85641. * @param data contains the texture data
  85642. * @param texture defines the BabylonJS internal texture
  85643. * @param createPolynomials will be true if polynomials have been requested
  85644. * @param onLoad defines the callback to trigger once the texture is ready
  85645. * @param onError defines the callback to trigger in case of error
  85646. * @param options options to be passed to the loader
  85647. */
  85648. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  85649. /**
  85650. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  85651. * @param data contains the texture data
  85652. * @param texture defines the BabylonJS internal texture
  85653. * @param callback defines the method to call once ready to upload
  85654. * @param options options to be passed to the loader
  85655. */
  85656. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  85657. }
  85658. }
  85659. declare module BABYLON {
  85660. /**
  85661. * @hidden
  85662. */
  85663. export interface IColor4Like {
  85664. r: float;
  85665. g: float;
  85666. b: float;
  85667. a: float;
  85668. }
  85669. /**
  85670. * @hidden
  85671. */
  85672. export interface IColor3Like {
  85673. r: float;
  85674. g: float;
  85675. b: float;
  85676. }
  85677. /**
  85678. * @hidden
  85679. */
  85680. export interface IVector4Like {
  85681. x: float;
  85682. y: float;
  85683. z: float;
  85684. w: float;
  85685. }
  85686. /**
  85687. * @hidden
  85688. */
  85689. export interface IVector3Like {
  85690. x: float;
  85691. y: float;
  85692. z: float;
  85693. }
  85694. /**
  85695. * @hidden
  85696. */
  85697. export interface IVector2Like {
  85698. x: float;
  85699. y: float;
  85700. }
  85701. /**
  85702. * @hidden
  85703. */
  85704. export interface IMatrixLike {
  85705. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85706. updateFlag: int;
  85707. }
  85708. /**
  85709. * @hidden
  85710. */
  85711. export interface IViewportLike {
  85712. x: float;
  85713. y: float;
  85714. width: float;
  85715. height: float;
  85716. }
  85717. /**
  85718. * @hidden
  85719. */
  85720. export interface IPlaneLike {
  85721. normal: IVector3Like;
  85722. d: float;
  85723. normalize(): void;
  85724. }
  85725. }
  85726. declare module BABYLON {
  85727. /**
  85728. * Class used to store and describe the pipeline context associated with an effect
  85729. */
  85730. export interface IPipelineContext {
  85731. /**
  85732. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  85733. */
  85734. isAsync: boolean;
  85735. /**
  85736. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  85737. */
  85738. isReady: boolean;
  85739. /** @hidden */
  85740. _name?: string;
  85741. /** @hidden */
  85742. _getVertexShaderCode(): string | null;
  85743. /** @hidden */
  85744. _getFragmentShaderCode(): string | null;
  85745. /** @hidden */
  85746. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  85747. /** @hidden */
  85748. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  85749. [key: string]: number;
  85750. }, uniformsNames: string[], uniforms: {
  85751. [key: string]: Nullable<WebGLUniformLocation>;
  85752. }, samplerList: string[], samplers: {
  85753. [key: string]: number;
  85754. }, attributesNames: string[], attributes: number[]): void;
  85755. /** Releases the resources associated with the pipeline. */
  85756. dispose(): void;
  85757. /**
  85758. * Sets an integer value on a uniform variable.
  85759. * @param uniformName Name of the variable.
  85760. * @param value Value to be set.
  85761. */
  85762. setInt(uniformName: string, value: number): void;
  85763. /**
  85764. * Sets an int2 value on a uniform variable.
  85765. * @param uniformName Name of the variable.
  85766. * @param x First int in int2.
  85767. * @param y Second int in int2.
  85768. */
  85769. setInt2(uniformName: string, x: number, y: number): void;
  85770. /**
  85771. * Sets an int3 value on a uniform variable.
  85772. * @param uniformName Name of the variable.
  85773. * @param x First int in int3.
  85774. * @param y Second int in int3.
  85775. * @param z Third int in int3.
  85776. */
  85777. setInt3(uniformName: string, x: number, y: number, z: number): void;
  85778. /**
  85779. * Sets an int4 value on a uniform variable.
  85780. * @param uniformName Name of the variable.
  85781. * @param x First int in int4.
  85782. * @param y Second int in int4.
  85783. * @param z Third int in int4.
  85784. * @param w Fourth int in int4.
  85785. */
  85786. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  85787. /**
  85788. * Sets an int array on a uniform variable.
  85789. * @param uniformName Name of the variable.
  85790. * @param array array to be set.
  85791. */
  85792. setIntArray(uniformName: string, array: Int32Array): void;
  85793. /**
  85794. * 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)
  85795. * @param uniformName Name of the variable.
  85796. * @param array array to be set.
  85797. */
  85798. setIntArray2(uniformName: string, array: Int32Array): void;
  85799. /**
  85800. * 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)
  85801. * @param uniformName Name of the variable.
  85802. * @param array array to be set.
  85803. */
  85804. setIntArray3(uniformName: string, array: Int32Array): void;
  85805. /**
  85806. * 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)
  85807. * @param uniformName Name of the variable.
  85808. * @param array array to be set.
  85809. */
  85810. setIntArray4(uniformName: string, array: Int32Array): void;
  85811. /**
  85812. * Sets an array on a uniform variable.
  85813. * @param uniformName Name of the variable.
  85814. * @param array array to be set.
  85815. */
  85816. setArray(uniformName: string, array: number[] | Float32Array): void;
  85817. /**
  85818. * 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)
  85819. * @param uniformName Name of the variable.
  85820. * @param array array to be set.
  85821. */
  85822. setArray2(uniformName: string, array: number[] | Float32Array): void;
  85823. /**
  85824. * 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)
  85825. * @param uniformName Name of the variable.
  85826. * @param array array to be set.
  85827. */
  85828. setArray3(uniformName: string, array: number[] | Float32Array): void;
  85829. /**
  85830. * 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)
  85831. * @param uniformName Name of the variable.
  85832. * @param array array to be set.
  85833. */
  85834. setArray4(uniformName: string, array: number[] | Float32Array): void;
  85835. /**
  85836. * Sets matrices on a uniform variable.
  85837. * @param uniformName Name of the variable.
  85838. * @param matrices matrices to be set.
  85839. */
  85840. setMatrices(uniformName: string, matrices: Float32Array): void;
  85841. /**
  85842. * Sets matrix on a uniform variable.
  85843. * @param uniformName Name of the variable.
  85844. * @param matrix matrix to be set.
  85845. */
  85846. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  85847. /**
  85848. * 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)
  85849. * @param uniformName Name of the variable.
  85850. * @param matrix matrix to be set.
  85851. */
  85852. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  85853. /**
  85854. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85855. * @param uniformName Name of the variable.
  85856. * @param matrix matrix to be set.
  85857. */
  85858. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  85859. /**
  85860. * Sets a float on a uniform variable.
  85861. * @param uniformName Name of the variable.
  85862. * @param value value to be set.
  85863. */
  85864. setFloat(uniformName: string, value: number): void;
  85865. /**
  85866. * Sets a Vector2 on a uniform variable.
  85867. * @param uniformName Name of the variable.
  85868. * @param vector2 vector2 to be set.
  85869. */
  85870. setVector2(uniformName: string, vector2: IVector2Like): void;
  85871. /**
  85872. * Sets a float2 on a uniform variable.
  85873. * @param uniformName Name of the variable.
  85874. * @param x First float in float2.
  85875. * @param y Second float in float2.
  85876. */
  85877. setFloat2(uniformName: string, x: number, y: number): void;
  85878. /**
  85879. * Sets a Vector3 on a uniform variable.
  85880. * @param uniformName Name of the variable.
  85881. * @param vector3 Value to be set.
  85882. */
  85883. setVector3(uniformName: string, vector3: IVector3Like): void;
  85884. /**
  85885. * Sets a float3 on a uniform variable.
  85886. * @param uniformName Name of the variable.
  85887. * @param x First float in float3.
  85888. * @param y Second float in float3.
  85889. * @param z Third float in float3.
  85890. */
  85891. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  85892. /**
  85893. * Sets a Vector4 on a uniform variable.
  85894. * @param uniformName Name of the variable.
  85895. * @param vector4 Value to be set.
  85896. */
  85897. setVector4(uniformName: string, vector4: IVector4Like): void;
  85898. /**
  85899. * Sets a float4 on a uniform variable.
  85900. * @param uniformName Name of the variable.
  85901. * @param x First float in float4.
  85902. * @param y Second float in float4.
  85903. * @param z Third float in float4.
  85904. * @param w Fourth float in float4.
  85905. */
  85906. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  85907. /**
  85908. * Sets a Color3 on a uniform variable.
  85909. * @param uniformName Name of the variable.
  85910. * @param color3 Value to be set.
  85911. */
  85912. setColor3(uniformName: string, color3: IColor3Like): void;
  85913. /**
  85914. * Sets a Color4 on a uniform variable.
  85915. * @param uniformName Name of the variable.
  85916. * @param color3 Value to be set.
  85917. * @param alpha Alpha value to be set.
  85918. */
  85919. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  85920. /**
  85921. * Sets a Color4 on a uniform variable
  85922. * @param uniformName defines the name of the variable
  85923. * @param color4 defines the value to be set
  85924. */
  85925. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  85926. }
  85927. }
  85928. declare module BABYLON {
  85929. /**
  85930. * Class used to store gfx data (like WebGLBuffer)
  85931. */
  85932. export class DataBuffer {
  85933. /**
  85934. * Gets or sets the number of objects referencing this buffer
  85935. */
  85936. references: number;
  85937. /** Gets or sets the size of the underlying buffer */
  85938. capacity: number;
  85939. /**
  85940. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  85941. */
  85942. is32Bits: boolean;
  85943. /**
  85944. * Gets the underlying buffer
  85945. */
  85946. get underlyingResource(): any;
  85947. }
  85948. }
  85949. declare module BABYLON {
  85950. /** @hidden */
  85951. export interface IShaderProcessor {
  85952. attributeProcessor?: (attribute: string, preProcessors: {
  85953. [key: string]: string;
  85954. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  85955. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  85956. [key: string]: string;
  85957. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  85958. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  85959. [key: string]: string;
  85960. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  85961. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85962. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85963. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85964. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85965. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  85966. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  85967. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  85968. vertexCode: string;
  85969. fragmentCode: string;
  85970. };
  85971. }
  85972. }
  85973. declare module BABYLON {
  85974. /** @hidden */
  85975. export interface ShaderProcessingContext {
  85976. }
  85977. /** @hidden */
  85978. export interface ProcessingOptions {
  85979. defines: string[];
  85980. indexParameters: any;
  85981. isFragment: boolean;
  85982. shouldUseHighPrecisionShader: boolean;
  85983. supportsUniformBuffers: boolean;
  85984. shadersRepository: string;
  85985. includesShadersStore: {
  85986. [key: string]: string;
  85987. };
  85988. processor: Nullable<IShaderProcessor>;
  85989. version: string;
  85990. platformName: string;
  85991. lookForClosingBracketForUniformBuffer?: boolean;
  85992. processingContext: Nullable<ShaderProcessingContext>;
  85993. }
  85994. }
  85995. declare module BABYLON {
  85996. /** @hidden */
  85997. export class ShaderCodeNode {
  85998. line: string;
  85999. children: ShaderCodeNode[];
  86000. additionalDefineKey?: string;
  86001. additionalDefineValue?: string;
  86002. isValid(preprocessors: {
  86003. [key: string]: string;
  86004. }): boolean;
  86005. process(preprocessors: {
  86006. [key: string]: string;
  86007. }, options: ProcessingOptions): string;
  86008. }
  86009. }
  86010. declare module BABYLON {
  86011. /** @hidden */
  86012. export class ShaderCodeCursor {
  86013. private _lines;
  86014. lineIndex: number;
  86015. get currentLine(): string;
  86016. get canRead(): boolean;
  86017. set lines(value: string[]);
  86018. }
  86019. }
  86020. declare module BABYLON {
  86021. /** @hidden */
  86022. export class ShaderCodeConditionNode extends ShaderCodeNode {
  86023. process(preprocessors: {
  86024. [key: string]: string;
  86025. }, options: ProcessingOptions): string;
  86026. }
  86027. }
  86028. declare module BABYLON {
  86029. /** @hidden */
  86030. export class ShaderDefineExpression {
  86031. isTrue(preprocessors: {
  86032. [key: string]: string;
  86033. }): boolean;
  86034. private static _OperatorPriority;
  86035. private static _Stack;
  86036. static postfixToInfix(postfix: string[]): string;
  86037. static infixToPostfix(infix: string): string[];
  86038. }
  86039. }
  86040. declare module BABYLON {
  86041. /** @hidden */
  86042. export class ShaderCodeTestNode extends ShaderCodeNode {
  86043. testExpression: ShaderDefineExpression;
  86044. isValid(preprocessors: {
  86045. [key: string]: string;
  86046. }): boolean;
  86047. }
  86048. }
  86049. declare module BABYLON {
  86050. /** @hidden */
  86051. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  86052. define: string;
  86053. not: boolean;
  86054. constructor(define: string, not?: boolean);
  86055. isTrue(preprocessors: {
  86056. [key: string]: string;
  86057. }): boolean;
  86058. }
  86059. }
  86060. declare module BABYLON {
  86061. /** @hidden */
  86062. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  86063. leftOperand: ShaderDefineExpression;
  86064. rightOperand: ShaderDefineExpression;
  86065. isTrue(preprocessors: {
  86066. [key: string]: string;
  86067. }): boolean;
  86068. }
  86069. }
  86070. declare module BABYLON {
  86071. /** @hidden */
  86072. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  86073. leftOperand: ShaderDefineExpression;
  86074. rightOperand: ShaderDefineExpression;
  86075. isTrue(preprocessors: {
  86076. [key: string]: string;
  86077. }): boolean;
  86078. }
  86079. }
  86080. declare module BABYLON {
  86081. /** @hidden */
  86082. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  86083. define: string;
  86084. operand: string;
  86085. testValue: string;
  86086. constructor(define: string, operand: string, testValue: string);
  86087. isTrue(preprocessors: {
  86088. [key: string]: string;
  86089. }): boolean;
  86090. }
  86091. }
  86092. declare module BABYLON {
  86093. /**
  86094. * Class used to enable access to offline support
  86095. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  86096. */
  86097. export interface IOfflineProvider {
  86098. /**
  86099. * Gets a boolean indicating if scene must be saved in the database
  86100. */
  86101. enableSceneOffline: boolean;
  86102. /**
  86103. * Gets a boolean indicating if textures must be saved in the database
  86104. */
  86105. enableTexturesOffline: boolean;
  86106. /**
  86107. * Open the offline support and make it available
  86108. * @param successCallback defines the callback to call on success
  86109. * @param errorCallback defines the callback to call on error
  86110. */
  86111. open(successCallback: () => void, errorCallback: () => void): void;
  86112. /**
  86113. * Loads an image from the offline support
  86114. * @param url defines the url to load from
  86115. * @param image defines the target DOM image
  86116. */
  86117. loadImage(url: string, image: HTMLImageElement): void;
  86118. /**
  86119. * Loads a file from offline support
  86120. * @param url defines the URL to load from
  86121. * @param sceneLoaded defines a callback to call on success
  86122. * @param progressCallBack defines a callback to call when progress changed
  86123. * @param errorCallback defines a callback to call on error
  86124. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  86125. */
  86126. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  86127. }
  86128. }
  86129. declare module BABYLON {
  86130. /**
  86131. * Class used to help managing file picking and drag'n'drop
  86132. * File Storage
  86133. */
  86134. export class FilesInputStore {
  86135. /**
  86136. * List of files ready to be loaded
  86137. */
  86138. static FilesToLoad: {
  86139. [key: string]: File;
  86140. };
  86141. }
  86142. }
  86143. declare module BABYLON {
  86144. /**
  86145. * Class used to define a retry strategy when error happens while loading assets
  86146. */
  86147. export class RetryStrategy {
  86148. /**
  86149. * Function used to defines an exponential back off strategy
  86150. * @param maxRetries defines the maximum number of retries (3 by default)
  86151. * @param baseInterval defines the interval between retries
  86152. * @returns the strategy function to use
  86153. */
  86154. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  86155. }
  86156. }
  86157. declare module BABYLON {
  86158. /**
  86159. * @ignore
  86160. * Application error to support additional information when loading a file
  86161. */
  86162. export abstract class BaseError extends Error {
  86163. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  86164. }
  86165. }
  86166. declare module BABYLON {
  86167. /** @ignore */
  86168. export class LoadFileError extends BaseError {
  86169. request?: WebRequest;
  86170. file?: File;
  86171. /**
  86172. * Creates a new LoadFileError
  86173. * @param message defines the message of the error
  86174. * @param request defines the optional web request
  86175. * @param file defines the optional file
  86176. */
  86177. constructor(message: string, object?: WebRequest | File);
  86178. }
  86179. /** @ignore */
  86180. export class RequestFileError extends BaseError {
  86181. request: WebRequest;
  86182. /**
  86183. * Creates a new LoadFileError
  86184. * @param message defines the message of the error
  86185. * @param request defines the optional web request
  86186. */
  86187. constructor(message: string, request: WebRequest);
  86188. }
  86189. /** @ignore */
  86190. export class ReadFileError extends BaseError {
  86191. file: File;
  86192. /**
  86193. * Creates a new ReadFileError
  86194. * @param message defines the message of the error
  86195. * @param file defines the optional file
  86196. */
  86197. constructor(message: string, file: File);
  86198. }
  86199. /**
  86200. * @hidden
  86201. */
  86202. export class FileTools {
  86203. /**
  86204. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86205. */
  86206. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  86207. /**
  86208. * Gets or sets the base URL to use to load assets
  86209. */
  86210. static BaseUrl: string;
  86211. /**
  86212. * Default behaviour for cors in the application.
  86213. * It can be a string if the expected behavior is identical in the entire app.
  86214. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86215. */
  86216. static CorsBehavior: string | ((url: string | string[]) => string);
  86217. /**
  86218. * Gets or sets a function used to pre-process url before using them to load assets
  86219. */
  86220. static PreprocessUrl: (url: string) => string;
  86221. /**
  86222. * Removes unwanted characters from an url
  86223. * @param url defines the url to clean
  86224. * @returns the cleaned url
  86225. */
  86226. private static _CleanUrl;
  86227. /**
  86228. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86229. * @param url define the url we are trying
  86230. * @param element define the dom element where to configure the cors policy
  86231. */
  86232. static SetCorsBehavior(url: string | string[], element: {
  86233. crossOrigin: string | null;
  86234. }): void;
  86235. /**
  86236. * Loads an image as an HTMLImageElement.
  86237. * @param input url string, ArrayBuffer, or Blob to load
  86238. * @param onLoad callback called when the image successfully loads
  86239. * @param onError callback called when the image fails to load
  86240. * @param offlineProvider offline provider for caching
  86241. * @param mimeType optional mime type
  86242. * @returns the HTMLImageElement of the loaded image
  86243. */
  86244. 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>;
  86245. /**
  86246. * Reads a file from a File object
  86247. * @param file defines the file to load
  86248. * @param onSuccess defines the callback to call when data is loaded
  86249. * @param onProgress defines the callback to call during loading process
  86250. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86251. * @param onError defines the callback to call when an error occurs
  86252. * @returns a file request object
  86253. */
  86254. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  86255. /**
  86256. * Loads a file from a url
  86257. * @param url url to load
  86258. * @param onSuccess callback called when the file successfully loads
  86259. * @param onProgress callback called while file is loading (if the server supports this mode)
  86260. * @param offlineProvider defines the offline provider for caching
  86261. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86262. * @param onError callback called when the file fails to load
  86263. * @returns a file request object
  86264. */
  86265. 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;
  86266. /**
  86267. * Loads a file
  86268. * @param url url to load
  86269. * @param onSuccess callback called when the file successfully loads
  86270. * @param onProgress callback called while file is loading (if the server supports this mode)
  86271. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86272. * @param onError callback called when the file fails to load
  86273. * @param onOpened callback called when the web request is opened
  86274. * @returns a file request object
  86275. */
  86276. 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;
  86277. /**
  86278. * Checks if the loaded document was accessed via `file:`-Protocol.
  86279. * @returns boolean
  86280. */
  86281. static IsFileURL(): boolean;
  86282. }
  86283. }
  86284. declare module BABYLON {
  86285. /** @hidden */
  86286. export class ShaderProcessor {
  86287. static Initialize(options: ProcessingOptions): void;
  86288. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  86289. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  86290. vertexCode: string;
  86291. fragmentCode: string;
  86292. };
  86293. private static _ProcessPrecision;
  86294. private static _ExtractOperation;
  86295. private static _BuildSubExpression;
  86296. private static _BuildExpression;
  86297. private static _MoveCursorWithinIf;
  86298. private static _MoveCursor;
  86299. private static _EvaluatePreProcessors;
  86300. private static _PreparePreProcessors;
  86301. private static _ProcessShaderConversion;
  86302. private static _ProcessIncludes;
  86303. /**
  86304. * Loads a file from a url
  86305. * @param url url to load
  86306. * @param onSuccess callback called when the file successfully loads
  86307. * @param onProgress callback called while file is loading (if the server supports this mode)
  86308. * @param offlineProvider defines the offline provider for caching
  86309. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86310. * @param onError callback called when the file fails to load
  86311. * @returns a file request object
  86312. * @hidden
  86313. */
  86314. 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;
  86315. }
  86316. }
  86317. declare module BABYLON {
  86318. /**
  86319. * Interface used to define common properties for effect fallbacks
  86320. */
  86321. export interface IEffectFallbacks {
  86322. /**
  86323. * Removes the defines that should be removed when falling back.
  86324. * @param currentDefines defines the current define statements for the shader.
  86325. * @param effect defines the current effect we try to compile
  86326. * @returns The resulting defines with defines of the current rank removed.
  86327. */
  86328. reduce(currentDefines: string, effect: Effect): string;
  86329. /**
  86330. * Removes the fallback from the bound mesh.
  86331. */
  86332. unBindMesh(): void;
  86333. /**
  86334. * Checks to see if more fallbacks are still availible.
  86335. */
  86336. hasMoreFallbacks: boolean;
  86337. }
  86338. }
  86339. declare module BABYLON {
  86340. /**
  86341. * Interface for the size containing width and height
  86342. */
  86343. export interface ISize {
  86344. /**
  86345. * Width
  86346. */
  86347. width: number;
  86348. /**
  86349. * Heighht
  86350. */
  86351. height: number;
  86352. }
  86353. /**
  86354. * Size containing widht and height
  86355. */
  86356. export class Size implements ISize {
  86357. /**
  86358. * Width
  86359. */
  86360. width: number;
  86361. /**
  86362. * Height
  86363. */
  86364. height: number;
  86365. /**
  86366. * Creates a Size object from the given width and height (floats).
  86367. * @param width width of the new size
  86368. * @param height height of the new size
  86369. */
  86370. constructor(width: number, height: number);
  86371. /**
  86372. * Returns a string with the Size width and height
  86373. * @returns a string with the Size width and height
  86374. */
  86375. toString(): string;
  86376. /**
  86377. * "Size"
  86378. * @returns the string "Size"
  86379. */
  86380. getClassName(): string;
  86381. /**
  86382. * Returns the Size hash code.
  86383. * @returns a hash code for a unique width and height
  86384. */
  86385. getHashCode(): number;
  86386. /**
  86387. * Updates the current size from the given one.
  86388. * @param src the given size
  86389. */
  86390. copyFrom(src: Size): void;
  86391. /**
  86392. * Updates in place the current Size from the given floats.
  86393. * @param width width of the new size
  86394. * @param height height of the new size
  86395. * @returns the updated Size.
  86396. */
  86397. copyFromFloats(width: number, height: number): Size;
  86398. /**
  86399. * Updates in place the current Size from the given floats.
  86400. * @param width width to set
  86401. * @param height height to set
  86402. * @returns the updated Size.
  86403. */
  86404. set(width: number, height: number): Size;
  86405. /**
  86406. * Multiplies the width and height by numbers
  86407. * @param w factor to multiple the width by
  86408. * @param h factor to multiple the height by
  86409. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86410. */
  86411. multiplyByFloats(w: number, h: number): Size;
  86412. /**
  86413. * Clones the size
  86414. * @returns a new Size copied from the given one.
  86415. */
  86416. clone(): Size;
  86417. /**
  86418. * True if the current Size and the given one width and height are strictly equal.
  86419. * @param other the other size to compare against
  86420. * @returns True if the current Size and the given one width and height are strictly equal.
  86421. */
  86422. equals(other: Size): boolean;
  86423. /**
  86424. * The surface of the Size : width * height (float).
  86425. */
  86426. get surface(): number;
  86427. /**
  86428. * Create a new size of zero
  86429. * @returns a new Size set to (0.0, 0.0)
  86430. */
  86431. static Zero(): Size;
  86432. /**
  86433. * Sums the width and height of two sizes
  86434. * @param otherSize size to add to this size
  86435. * @returns a new Size set as the addition result of the current Size and the given one.
  86436. */
  86437. add(otherSize: Size): Size;
  86438. /**
  86439. * Subtracts the width and height of two
  86440. * @param otherSize size to subtract to this size
  86441. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86442. */
  86443. subtract(otherSize: Size): Size;
  86444. /**
  86445. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86446. * @param start starting size to lerp between
  86447. * @param end end size to lerp between
  86448. * @param amount amount to lerp between the start and end values
  86449. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86450. */
  86451. static Lerp(start: Size, end: Size, amount: number): Size;
  86452. }
  86453. }
  86454. declare module BABYLON {
  86455. /**
  86456. * Base class of all the textures in babylon.
  86457. * It groups all the common properties required to work with Thin Engine.
  86458. */
  86459. export class ThinTexture {
  86460. protected _wrapU: number;
  86461. /**
  86462. * | Value | Type | Description |
  86463. * | ----- | ------------------ | ----------- |
  86464. * | 0 | CLAMP_ADDRESSMODE | |
  86465. * | 1 | WRAP_ADDRESSMODE | |
  86466. * | 2 | MIRROR_ADDRESSMODE | |
  86467. */
  86468. get wrapU(): number;
  86469. set wrapU(value: number);
  86470. protected _wrapV: number;
  86471. /**
  86472. * | Value | Type | Description |
  86473. * | ----- | ------------------ | ----------- |
  86474. * | 0 | CLAMP_ADDRESSMODE | |
  86475. * | 1 | WRAP_ADDRESSMODE | |
  86476. * | 2 | MIRROR_ADDRESSMODE | |
  86477. */
  86478. get wrapV(): number;
  86479. set wrapV(value: number);
  86480. /**
  86481. * | Value | Type | Description |
  86482. * | ----- | ------------------ | ----------- |
  86483. * | 0 | CLAMP_ADDRESSMODE | |
  86484. * | 1 | WRAP_ADDRESSMODE | |
  86485. * | 2 | MIRROR_ADDRESSMODE | |
  86486. */
  86487. wrapR: number;
  86488. /**
  86489. * With compliant hardware and browser (supporting anisotropic filtering)
  86490. * this defines the level of anisotropic filtering in the texture.
  86491. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  86492. */
  86493. anisotropicFilteringLevel: number;
  86494. /**
  86495. * Define the current state of the loading sequence when in delayed load mode.
  86496. */
  86497. delayLoadState: number;
  86498. /**
  86499. * How a texture is mapped.
  86500. * Unused in thin texture mode.
  86501. */
  86502. get coordinatesMode(): number;
  86503. /**
  86504. * Define if the texture is a cube texture or if false a 2d texture.
  86505. */
  86506. get isCube(): boolean;
  86507. set isCube(value: boolean);
  86508. /**
  86509. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  86510. */
  86511. get is3D(): boolean;
  86512. set is3D(value: boolean);
  86513. /**
  86514. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  86515. */
  86516. get is2DArray(): boolean;
  86517. set is2DArray(value: boolean);
  86518. /**
  86519. * Get the class name of the texture.
  86520. * @returns "ThinTexture"
  86521. */
  86522. getClassName(): string;
  86523. /** @hidden */
  86524. _texture: Nullable<InternalTexture>;
  86525. protected _engine: Nullable<ThinEngine>;
  86526. private _cachedSize;
  86527. private _cachedBaseSize;
  86528. /**
  86529. * Instantiates a new ThinTexture.
  86530. * Base class of all the textures in babylon.
  86531. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  86532. * @param internalTexture Define the internalTexture to wrap
  86533. */
  86534. constructor(internalTexture: Nullable<InternalTexture>);
  86535. /**
  86536. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86537. * @returns true if fully ready
  86538. */
  86539. isReady(): boolean;
  86540. /**
  86541. * Triggers the load sequence in delayed load mode.
  86542. */
  86543. delayLoad(): void;
  86544. /**
  86545. * Get the underlying lower level texture from Babylon.
  86546. * @returns the insternal texture
  86547. */
  86548. getInternalTexture(): Nullable<InternalTexture>;
  86549. /**
  86550. * Get the size of the texture.
  86551. * @returns the texture size.
  86552. */
  86553. getSize(): ISize;
  86554. /**
  86555. * Get the base size of the texture.
  86556. * It can be different from the size if the texture has been resized for POT for instance
  86557. * @returns the base size
  86558. */
  86559. getBaseSize(): ISize;
  86560. /**
  86561. * Update the sampling mode of the texture.
  86562. * Default is Trilinear mode.
  86563. *
  86564. * | Value | Type | Description |
  86565. * | ----- | ------------------ | ----------- |
  86566. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86567. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86568. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86569. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86570. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86571. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86572. * | 7 | NEAREST_LINEAR | |
  86573. * | 8 | NEAREST_NEAREST | |
  86574. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86575. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86576. * | 11 | LINEAR_LINEAR | |
  86577. * | 12 | LINEAR_NEAREST | |
  86578. *
  86579. * > _mag_: magnification filter (close to the viewer)
  86580. * > _min_: minification filter (far from the viewer)
  86581. * > _mip_: filter used between mip map levels
  86582. *@param samplingMode Define the new sampling mode of the texture
  86583. */
  86584. updateSamplingMode(samplingMode: number): void;
  86585. /**
  86586. * Release and destroy the underlying lower level texture aka internalTexture.
  86587. */
  86588. releaseInternalTexture(): void;
  86589. /**
  86590. * Dispose the texture and release its associated resources.
  86591. */
  86592. dispose(): void;
  86593. }
  86594. }
  86595. declare module BABYLON {
  86596. /**
  86597. * Defines an array and its length.
  86598. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86599. */
  86600. export interface ISmartArrayLike<T> {
  86601. /**
  86602. * The data of the array.
  86603. */
  86604. data: Array<T>;
  86605. /**
  86606. * The active length of the array.
  86607. */
  86608. length: number;
  86609. }
  86610. /**
  86611. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86612. */
  86613. export class SmartArray<T> implements ISmartArrayLike<T> {
  86614. /**
  86615. * The full set of data from the array.
  86616. */
  86617. data: Array<T>;
  86618. /**
  86619. * The active length of the array.
  86620. */
  86621. length: number;
  86622. protected _id: number;
  86623. /**
  86624. * Instantiates a Smart Array.
  86625. * @param capacity defines the default capacity of the array.
  86626. */
  86627. constructor(capacity: number);
  86628. /**
  86629. * Pushes a value at the end of the active data.
  86630. * @param value defines the object to push in the array.
  86631. */
  86632. push(value: T): void;
  86633. /**
  86634. * Iterates over the active data and apply the lambda to them.
  86635. * @param func defines the action to apply on each value.
  86636. */
  86637. forEach(func: (content: T) => void): void;
  86638. /**
  86639. * Sorts the full sets of data.
  86640. * @param compareFn defines the comparison function to apply.
  86641. */
  86642. sort(compareFn: (a: T, b: T) => number): void;
  86643. /**
  86644. * Resets the active data to an empty array.
  86645. */
  86646. reset(): void;
  86647. /**
  86648. * Releases all the data from the array as well as the array.
  86649. */
  86650. dispose(): void;
  86651. /**
  86652. * Concats the active data with a given array.
  86653. * @param array defines the data to concatenate with.
  86654. */
  86655. concat(array: any): void;
  86656. /**
  86657. * Returns the position of a value in the active data.
  86658. * @param value defines the value to find the index for
  86659. * @returns the index if found in the active data otherwise -1
  86660. */
  86661. indexOf(value: T): number;
  86662. /**
  86663. * Returns whether an element is part of the active data.
  86664. * @param value defines the value to look for
  86665. * @returns true if found in the active data otherwise false
  86666. */
  86667. contains(value: T): boolean;
  86668. private static _GlobalId;
  86669. }
  86670. /**
  86671. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86672. * The data in this array can only be present once
  86673. */
  86674. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86675. private _duplicateId;
  86676. /**
  86677. * Pushes a value at the end of the active data.
  86678. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86679. * @param value defines the object to push in the array.
  86680. */
  86681. push(value: T): void;
  86682. /**
  86683. * Pushes a value at the end of the active data.
  86684. * If the data is already present, it won t be added again
  86685. * @param value defines the object to push in the array.
  86686. * @returns true if added false if it was already present
  86687. */
  86688. pushNoDuplicate(value: T): boolean;
  86689. /**
  86690. * Resets the active data to an empty array.
  86691. */
  86692. reset(): void;
  86693. /**
  86694. * Concats the active data with a given array.
  86695. * This ensures no dupplicate will be present in the result.
  86696. * @param array defines the data to concatenate with.
  86697. */
  86698. concatWithNoDuplicate(array: any): void;
  86699. }
  86700. }
  86701. declare module BABYLON {
  86702. /**
  86703. * Class used to evalaute queries containing `and` and `or` operators
  86704. */
  86705. export class AndOrNotEvaluator {
  86706. /**
  86707. * Evaluate a query
  86708. * @param query defines the query to evaluate
  86709. * @param evaluateCallback defines the callback used to filter result
  86710. * @returns true if the query matches
  86711. */
  86712. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  86713. private static _HandleParenthesisContent;
  86714. private static _SimplifyNegation;
  86715. }
  86716. }
  86717. declare module BABYLON {
  86718. /**
  86719. * Class used to store custom tags
  86720. */
  86721. export class Tags {
  86722. /**
  86723. * Adds support for tags on the given object
  86724. * @param obj defines the object to use
  86725. */
  86726. static EnableFor(obj: any): void;
  86727. /**
  86728. * Removes tags support
  86729. * @param obj defines the object to use
  86730. */
  86731. static DisableFor(obj: any): void;
  86732. /**
  86733. * Gets a boolean indicating if the given object has tags
  86734. * @param obj defines the object to use
  86735. * @returns a boolean
  86736. */
  86737. static HasTags(obj: any): boolean;
  86738. /**
  86739. * Gets the tags available on a given object
  86740. * @param obj defines the object to use
  86741. * @param asString defines if the tags must be returned as a string instead of an array of strings
  86742. * @returns the tags
  86743. */
  86744. static GetTags(obj: any, asString?: boolean): any;
  86745. /**
  86746. * Adds tags to an object
  86747. * @param obj defines the object to use
  86748. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  86749. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  86750. */
  86751. static AddTagsTo(obj: any, tagsString: string): void;
  86752. /**
  86753. * @hidden
  86754. */
  86755. static _AddTagTo(obj: any, tag: string): void;
  86756. /**
  86757. * Removes specific tags from a specific object
  86758. * @param obj defines the object to use
  86759. * @param tagsString defines the tags to remove
  86760. */
  86761. static RemoveTagsFrom(obj: any, tagsString: string): void;
  86762. /**
  86763. * @hidden
  86764. */
  86765. static _RemoveTagFrom(obj: any, tag: string): void;
  86766. /**
  86767. * Defines if tags hosted on an object match a given query
  86768. * @param obj defines the object to use
  86769. * @param tagsQuery defines the tag query
  86770. * @returns a boolean
  86771. */
  86772. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  86773. }
  86774. }
  86775. declare module BABYLON {
  86776. /**
  86777. * Scalar computation library
  86778. */
  86779. export class Scalar {
  86780. /**
  86781. * Two pi constants convenient for computation.
  86782. */
  86783. static TwoPi: number;
  86784. /**
  86785. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  86786. * @param a number
  86787. * @param b number
  86788. * @param epsilon (default = 1.401298E-45)
  86789. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  86790. */
  86791. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  86792. /**
  86793. * Returns a string : the upper case translation of the number i to hexadecimal.
  86794. * @param i number
  86795. * @returns the upper case translation of the number i to hexadecimal.
  86796. */
  86797. static ToHex(i: number): string;
  86798. /**
  86799. * Returns -1 if value is negative and +1 is value is positive.
  86800. * @param value the value
  86801. * @returns the value itself if it's equal to zero.
  86802. */
  86803. static Sign(value: number): number;
  86804. /**
  86805. * Returns the value itself if it's between min and max.
  86806. * Returns min if the value is lower than min.
  86807. * Returns max if the value is greater than max.
  86808. * @param value the value to clmap
  86809. * @param min the min value to clamp to (default: 0)
  86810. * @param max the max value to clamp to (default: 1)
  86811. * @returns the clamped value
  86812. */
  86813. static Clamp(value: number, min?: number, max?: number): number;
  86814. /**
  86815. * the log2 of value.
  86816. * @param value the value to compute log2 of
  86817. * @returns the log2 of value.
  86818. */
  86819. static Log2(value: number): number;
  86820. /**
  86821. * the floor part of a log2 value.
  86822. * @param value the value to compute log2 of
  86823. * @returns the log2 of value.
  86824. */
  86825. static ILog2(value: number): number;
  86826. /**
  86827. * Loops the value, so that it is never larger than length and never smaller than 0.
  86828. *
  86829. * This is similar to the modulo operator but it works with floating point numbers.
  86830. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  86831. * With t = 5 and length = 2.5, the result would be 0.0.
  86832. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  86833. * @param value the value
  86834. * @param length the length
  86835. * @returns the looped value
  86836. */
  86837. static Repeat(value: number, length: number): number;
  86838. /**
  86839. * Normalize the value between 0.0 and 1.0 using min and max values
  86840. * @param value value to normalize
  86841. * @param min max to normalize between
  86842. * @param max min to normalize between
  86843. * @returns the normalized value
  86844. */
  86845. static Normalize(value: number, min: number, max: number): number;
  86846. /**
  86847. * Denormalize the value from 0.0 and 1.0 using min and max values
  86848. * @param normalized value to denormalize
  86849. * @param min max to denormalize between
  86850. * @param max min to denormalize between
  86851. * @returns the denormalized value
  86852. */
  86853. static Denormalize(normalized: number, min: number, max: number): number;
  86854. /**
  86855. * Calculates the shortest difference between two given angles given in degrees.
  86856. * @param current current angle in degrees
  86857. * @param target target angle in degrees
  86858. * @returns the delta
  86859. */
  86860. static DeltaAngle(current: number, target: number): number;
  86861. /**
  86862. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  86863. * @param tx value
  86864. * @param length length
  86865. * @returns The returned value will move back and forth between 0 and length
  86866. */
  86867. static PingPong(tx: number, length: number): number;
  86868. /**
  86869. * Interpolates between min and max with smoothing at the limits.
  86870. *
  86871. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  86872. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  86873. * @param from from
  86874. * @param to to
  86875. * @param tx value
  86876. * @returns the smooth stepped value
  86877. */
  86878. static SmoothStep(from: number, to: number, tx: number): number;
  86879. /**
  86880. * Moves a value current towards target.
  86881. *
  86882. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  86883. * Negative values of maxDelta pushes the value away from target.
  86884. * @param current current value
  86885. * @param target target value
  86886. * @param maxDelta max distance to move
  86887. * @returns resulting value
  86888. */
  86889. static MoveTowards(current: number, target: number, maxDelta: number): number;
  86890. /**
  86891. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  86892. *
  86893. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  86894. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  86895. * @param current current value
  86896. * @param target target value
  86897. * @param maxDelta max distance to move
  86898. * @returns resulting angle
  86899. */
  86900. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  86901. /**
  86902. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  86903. * @param start start value
  86904. * @param end target value
  86905. * @param amount amount to lerp between
  86906. * @returns the lerped value
  86907. */
  86908. static Lerp(start: number, end: number, amount: number): number;
  86909. /**
  86910. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  86911. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  86912. * @param start start value
  86913. * @param end target value
  86914. * @param amount amount to lerp between
  86915. * @returns the lerped value
  86916. */
  86917. static LerpAngle(start: number, end: number, amount: number): number;
  86918. /**
  86919. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  86920. * @param a start value
  86921. * @param b target value
  86922. * @param value value between a and b
  86923. * @returns the inverseLerp value
  86924. */
  86925. static InverseLerp(a: number, b: number, value: number): number;
  86926. /**
  86927. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  86928. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  86929. * @param value1 spline value
  86930. * @param tangent1 spline value
  86931. * @param value2 spline value
  86932. * @param tangent2 spline value
  86933. * @param amount input value
  86934. * @returns hermite result
  86935. */
  86936. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  86937. /**
  86938. * Returns a random float number between and min and max values
  86939. * @param min min value of random
  86940. * @param max max value of random
  86941. * @returns random value
  86942. */
  86943. static RandomRange(min: number, max: number): number;
  86944. /**
  86945. * This function returns percentage of a number in a given range.
  86946. *
  86947. * RangeToPercent(40,20,60) will return 0.5 (50%)
  86948. * RangeToPercent(34,0,100) will return 0.34 (34%)
  86949. * @param number to convert to percentage
  86950. * @param min min range
  86951. * @param max max range
  86952. * @returns the percentage
  86953. */
  86954. static RangeToPercent(number: number, min: number, max: number): number;
  86955. /**
  86956. * This function returns number that corresponds to the percentage in a given range.
  86957. *
  86958. * PercentToRange(0.34,0,100) will return 34.
  86959. * @param percent to convert to number
  86960. * @param min min range
  86961. * @param max max range
  86962. * @returns the number
  86963. */
  86964. static PercentToRange(percent: number, min: number, max: number): number;
  86965. /**
  86966. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  86967. * @param angle The angle to normalize in radian.
  86968. * @return The converted angle.
  86969. */
  86970. static NormalizeRadians(angle: number): number;
  86971. }
  86972. }
  86973. declare module BABYLON {
  86974. /**
  86975. * Constant used to convert a value to gamma space
  86976. * @ignorenaming
  86977. */
  86978. export const ToGammaSpace: number;
  86979. /**
  86980. * Constant used to convert a value to linear space
  86981. * @ignorenaming
  86982. */
  86983. export const ToLinearSpace = 2.2;
  86984. /**
  86985. * Constant used to define the minimal number value in Babylon.js
  86986. * @ignorenaming
  86987. */
  86988. let Epsilon: number;
  86989. }
  86990. declare module BABYLON {
  86991. /**
  86992. * Class used to represent a viewport on screen
  86993. */
  86994. export class Viewport {
  86995. /** viewport left coordinate */
  86996. x: number;
  86997. /** viewport top coordinate */
  86998. y: number;
  86999. /**viewport width */
  87000. width: number;
  87001. /** viewport height */
  87002. height: number;
  87003. /**
  87004. * Creates a Viewport object located at (x, y) and sized (width, height)
  87005. * @param x defines viewport left coordinate
  87006. * @param y defines viewport top coordinate
  87007. * @param width defines the viewport width
  87008. * @param height defines the viewport height
  87009. */
  87010. constructor(
  87011. /** viewport left coordinate */
  87012. x: number,
  87013. /** viewport top coordinate */
  87014. y: number,
  87015. /**viewport width */
  87016. width: number,
  87017. /** viewport height */
  87018. height: number);
  87019. /**
  87020. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  87021. * @param renderWidth defines the rendering width
  87022. * @param renderHeight defines the rendering height
  87023. * @returns a new Viewport
  87024. */
  87025. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  87026. /**
  87027. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  87028. * @param renderWidth defines the rendering width
  87029. * @param renderHeight defines the rendering height
  87030. * @param ref defines the target viewport
  87031. * @returns the current viewport
  87032. */
  87033. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  87034. /**
  87035. * Returns a new Viewport copied from the current one
  87036. * @returns a new Viewport
  87037. */
  87038. clone(): Viewport;
  87039. }
  87040. }
  87041. declare module BABYLON {
  87042. /**
  87043. * Class containing a set of static utilities functions for arrays.
  87044. */
  87045. export class ArrayTools {
  87046. /**
  87047. * Returns an array of the given size filled with element built from the given constructor and the paramters
  87048. * @param size the number of element to construct and put in the array
  87049. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  87050. * @returns a new array filled with new objects
  87051. */
  87052. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  87053. }
  87054. }
  87055. declare module BABYLON {
  87056. /**
  87057. * Represents a plane by the equation ax + by + cz + d = 0
  87058. */
  87059. export class Plane {
  87060. private static _TmpMatrix;
  87061. /**
  87062. * Normal of the plane (a,b,c)
  87063. */
  87064. normal: Vector3;
  87065. /**
  87066. * d component of the plane
  87067. */
  87068. d: number;
  87069. /**
  87070. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  87071. * @param a a component of the plane
  87072. * @param b b component of the plane
  87073. * @param c c component of the plane
  87074. * @param d d component of the plane
  87075. */
  87076. constructor(a: number, b: number, c: number, d: number);
  87077. /**
  87078. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  87079. */
  87080. asArray(): number[];
  87081. /**
  87082. * @returns a new plane copied from the current Plane.
  87083. */
  87084. clone(): Plane;
  87085. /**
  87086. * @returns the string "Plane".
  87087. */
  87088. getClassName(): string;
  87089. /**
  87090. * @returns the Plane hash code.
  87091. */
  87092. getHashCode(): number;
  87093. /**
  87094. * Normalize the current Plane in place.
  87095. * @returns the updated Plane.
  87096. */
  87097. normalize(): Plane;
  87098. /**
  87099. * Applies a transformation the plane and returns the result
  87100. * @param transformation the transformation matrix to be applied to the plane
  87101. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  87102. */
  87103. transform(transformation: DeepImmutable<Matrix>): Plane;
  87104. /**
  87105. * Compute the dot product between the point and the plane normal
  87106. * @param point point to calculate the dot product with
  87107. * @returns the dot product (float) of the point coordinates and the plane normal.
  87108. */
  87109. dotCoordinate(point: DeepImmutable<Vector3>): number;
  87110. /**
  87111. * Updates the current Plane from the plane defined by the three given points.
  87112. * @param point1 one of the points used to contruct the plane
  87113. * @param point2 one of the points used to contruct the plane
  87114. * @param point3 one of the points used to contruct the plane
  87115. * @returns the updated Plane.
  87116. */
  87117. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87118. /**
  87119. * 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).
  87120. * Note that for this function to work as expected you should make sure that:
  87121. * - direction and the plane normal are normalized
  87122. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  87123. * @param direction the direction to check if the plane is facing
  87124. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  87125. * @returns True if the plane is facing the given direction
  87126. */
  87127. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  87128. /**
  87129. * Calculates the distance to a point
  87130. * @param point point to calculate distance to
  87131. * @returns the signed distance (float) from the given point to the Plane.
  87132. */
  87133. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  87134. /**
  87135. * Creates a plane from an array
  87136. * @param array the array to create a plane from
  87137. * @returns a new Plane from the given array.
  87138. */
  87139. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  87140. /**
  87141. * Creates a plane from three points
  87142. * @param point1 point used to create the plane
  87143. * @param point2 point used to create the plane
  87144. * @param point3 point used to create the plane
  87145. * @returns a new Plane defined by the three given points.
  87146. */
  87147. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87148. /**
  87149. * Creates a plane from an origin point and a normal
  87150. * @param origin origin of the plane to be constructed
  87151. * @param normal normal of the plane to be constructed
  87152. * @returns a new Plane the normal vector to this plane at the given origin point.
  87153. * Note : the vector "normal" is updated because normalized.
  87154. */
  87155. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  87156. /**
  87157. * Calculates the distance from a plane and a point
  87158. * @param origin origin of the plane to be constructed
  87159. * @param normal normal of the plane to be constructed
  87160. * @param point point to calculate distance to
  87161. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  87162. */
  87163. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  87164. }
  87165. }
  87166. declare module BABYLON {
  87167. /** @hidden */
  87168. export class PerformanceConfigurator {
  87169. /** @hidden */
  87170. static MatrixUse64Bits: boolean;
  87171. /** @hidden */
  87172. static MatrixTrackPrecisionChange: boolean;
  87173. /** @hidden */
  87174. static MatrixCurrentType: any;
  87175. /** @hidden */
  87176. static MatrixTrackedMatrices: Array<any> | null;
  87177. /** @hidden */
  87178. static SetMatrixPrecision(use64bits: boolean): void;
  87179. }
  87180. }
  87181. declare module BABYLON {
  87182. /**
  87183. * Class representing a vector containing 2 coordinates
  87184. */
  87185. export class Vector2 {
  87186. /** defines the first coordinate */
  87187. x: number;
  87188. /** defines the second coordinate */
  87189. y: number;
  87190. /**
  87191. * Creates a new Vector2 from the given x and y coordinates
  87192. * @param x defines the first coordinate
  87193. * @param y defines the second coordinate
  87194. */
  87195. constructor(
  87196. /** defines the first coordinate */
  87197. x?: number,
  87198. /** defines the second coordinate */
  87199. y?: number);
  87200. /**
  87201. * Gets a string with the Vector2 coordinates
  87202. * @returns a string with the Vector2 coordinates
  87203. */
  87204. toString(): string;
  87205. /**
  87206. * Gets class name
  87207. * @returns the string "Vector2"
  87208. */
  87209. getClassName(): string;
  87210. /**
  87211. * Gets current vector hash code
  87212. * @returns the Vector2 hash code as a number
  87213. */
  87214. getHashCode(): number;
  87215. /**
  87216. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  87217. * @param array defines the source array
  87218. * @param index defines the offset in source array
  87219. * @returns the current Vector2
  87220. */
  87221. toArray(array: FloatArray, index?: number): Vector2;
  87222. /**
  87223. * Update the current vector from an array
  87224. * @param array defines the destination array
  87225. * @param index defines the offset in the destination array
  87226. * @returns the current Vector3
  87227. */
  87228. fromArray(array: FloatArray, index?: number): Vector2;
  87229. /**
  87230. * Copy the current vector to an array
  87231. * @returns a new array with 2 elements: the Vector2 coordinates.
  87232. */
  87233. asArray(): number[];
  87234. /**
  87235. * Sets the Vector2 coordinates with the given Vector2 coordinates
  87236. * @param source defines the source Vector2
  87237. * @returns the current updated Vector2
  87238. */
  87239. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  87240. /**
  87241. * Sets the Vector2 coordinates with the given floats
  87242. * @param x defines the first coordinate
  87243. * @param y defines the second coordinate
  87244. * @returns the current updated Vector2
  87245. */
  87246. copyFromFloats(x: number, y: number): Vector2;
  87247. /**
  87248. * Sets the Vector2 coordinates with the given floats
  87249. * @param x defines the first coordinate
  87250. * @param y defines the second coordinate
  87251. * @returns the current updated Vector2
  87252. */
  87253. set(x: number, y: number): Vector2;
  87254. /**
  87255. * Add another vector with the current one
  87256. * @param otherVector defines the other vector
  87257. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  87258. */
  87259. add(otherVector: DeepImmutable<Vector2>): Vector2;
  87260. /**
  87261. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  87262. * @param otherVector defines the other vector
  87263. * @param result defines the target vector
  87264. * @returns the unmodified current Vector2
  87265. */
  87266. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87267. /**
  87268. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  87269. * @param otherVector defines the other vector
  87270. * @returns the current updated Vector2
  87271. */
  87272. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87273. /**
  87274. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  87275. * @param otherVector defines the other vector
  87276. * @returns a new Vector2
  87277. */
  87278. addVector3(otherVector: Vector3): Vector2;
  87279. /**
  87280. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  87281. * @param otherVector defines the other vector
  87282. * @returns a new Vector2
  87283. */
  87284. subtract(otherVector: Vector2): Vector2;
  87285. /**
  87286. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  87287. * @param otherVector defines the other vector
  87288. * @param result defines the target vector
  87289. * @returns the unmodified current Vector2
  87290. */
  87291. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87292. /**
  87293. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  87294. * @param otherVector defines the other vector
  87295. * @returns the current updated Vector2
  87296. */
  87297. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87298. /**
  87299. * Multiplies in place the current Vector2 coordinates by the given ones
  87300. * @param otherVector defines the other vector
  87301. * @returns the current updated Vector2
  87302. */
  87303. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87304. /**
  87305. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  87306. * @param otherVector defines the other vector
  87307. * @returns a new Vector2
  87308. */
  87309. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  87310. /**
  87311. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  87312. * @param otherVector defines the other vector
  87313. * @param result defines the target vector
  87314. * @returns the unmodified current Vector2
  87315. */
  87316. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87317. /**
  87318. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  87319. * @param x defines the first coordinate
  87320. * @param y defines the second coordinate
  87321. * @returns a new Vector2
  87322. */
  87323. multiplyByFloats(x: number, y: number): Vector2;
  87324. /**
  87325. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  87326. * @param otherVector defines the other vector
  87327. * @returns a new Vector2
  87328. */
  87329. divide(otherVector: Vector2): Vector2;
  87330. /**
  87331. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  87332. * @param otherVector defines the other vector
  87333. * @param result defines the target vector
  87334. * @returns the unmodified current Vector2
  87335. */
  87336. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87337. /**
  87338. * Divides the current Vector2 coordinates by the given ones
  87339. * @param otherVector defines the other vector
  87340. * @returns the current updated Vector2
  87341. */
  87342. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87343. /**
  87344. * Gets a new Vector2 with current Vector2 negated coordinates
  87345. * @returns a new Vector2
  87346. */
  87347. negate(): Vector2;
  87348. /**
  87349. * Negate this vector in place
  87350. * @returns this
  87351. */
  87352. negateInPlace(): Vector2;
  87353. /**
  87354. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  87355. * @param result defines the Vector3 object where to store the result
  87356. * @returns the current Vector2
  87357. */
  87358. negateToRef(result: Vector2): Vector2;
  87359. /**
  87360. * Multiply the Vector2 coordinates by scale
  87361. * @param scale defines the scaling factor
  87362. * @returns the current updated Vector2
  87363. */
  87364. scaleInPlace(scale: number): Vector2;
  87365. /**
  87366. * Returns a new Vector2 scaled by "scale" from the current Vector2
  87367. * @param scale defines the scaling factor
  87368. * @returns a new Vector2
  87369. */
  87370. scale(scale: number): Vector2;
  87371. /**
  87372. * Scale the current Vector2 values by a factor to a given Vector2
  87373. * @param scale defines the scale factor
  87374. * @param result defines the Vector2 object where to store the result
  87375. * @returns the unmodified current Vector2
  87376. */
  87377. scaleToRef(scale: number, result: Vector2): Vector2;
  87378. /**
  87379. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  87380. * @param scale defines the scale factor
  87381. * @param result defines the Vector2 object where to store the result
  87382. * @returns the unmodified current Vector2
  87383. */
  87384. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  87385. /**
  87386. * Gets a boolean if two vectors are equals
  87387. * @param otherVector defines the other vector
  87388. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  87389. */
  87390. equals(otherVector: DeepImmutable<Vector2>): boolean;
  87391. /**
  87392. * Gets a boolean if two vectors are equals (using an epsilon value)
  87393. * @param otherVector defines the other vector
  87394. * @param epsilon defines the minimal distance to consider equality
  87395. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  87396. */
  87397. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  87398. /**
  87399. * Gets a new Vector2 from current Vector2 floored values
  87400. * @returns a new Vector2
  87401. */
  87402. floor(): Vector2;
  87403. /**
  87404. * Gets a new Vector2 from current Vector2 floored values
  87405. * @returns a new Vector2
  87406. */
  87407. fract(): Vector2;
  87408. /**
  87409. * Gets the length of the vector
  87410. * @returns the vector length (float)
  87411. */
  87412. length(): number;
  87413. /**
  87414. * Gets the vector squared length
  87415. * @returns the vector squared length (float)
  87416. */
  87417. lengthSquared(): number;
  87418. /**
  87419. * Normalize the vector
  87420. * @returns the current updated Vector2
  87421. */
  87422. normalize(): Vector2;
  87423. /**
  87424. * Gets a new Vector2 copied from the Vector2
  87425. * @returns a new Vector2
  87426. */
  87427. clone(): Vector2;
  87428. /**
  87429. * Gets a new Vector2(0, 0)
  87430. * @returns a new Vector2
  87431. */
  87432. static Zero(): Vector2;
  87433. /**
  87434. * Gets a new Vector2(1, 1)
  87435. * @returns a new Vector2
  87436. */
  87437. static One(): Vector2;
  87438. /**
  87439. * Gets a new Vector2 set from the given index element of the given array
  87440. * @param array defines the data source
  87441. * @param offset defines the offset in the data source
  87442. * @returns a new Vector2
  87443. */
  87444. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  87445. /**
  87446. * Sets "result" from the given index element of the given array
  87447. * @param array defines the data source
  87448. * @param offset defines the offset in the data source
  87449. * @param result defines the target vector
  87450. */
  87451. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  87452. /**
  87453. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  87454. * @param value1 defines 1st point of control
  87455. * @param value2 defines 2nd point of control
  87456. * @param value3 defines 3rd point of control
  87457. * @param value4 defines 4th point of control
  87458. * @param amount defines the interpolation factor
  87459. * @returns a new Vector2
  87460. */
  87461. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  87462. /**
  87463. * 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".
  87464. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  87465. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  87466. * @param value defines the value to clamp
  87467. * @param min defines the lower limit
  87468. * @param max defines the upper limit
  87469. * @returns a new Vector2
  87470. */
  87471. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  87472. /**
  87473. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  87474. * @param value1 defines the 1st control point
  87475. * @param tangent1 defines the outgoing tangent
  87476. * @param value2 defines the 2nd control point
  87477. * @param tangent2 defines the incoming tangent
  87478. * @param amount defines the interpolation factor
  87479. * @returns a new Vector2
  87480. */
  87481. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  87482. /**
  87483. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  87484. * @param start defines the start vector
  87485. * @param end defines the end vector
  87486. * @param amount defines the interpolation factor
  87487. * @returns a new Vector2
  87488. */
  87489. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  87490. /**
  87491. * Gets the dot product of the vector "left" and the vector "right"
  87492. * @param left defines first vector
  87493. * @param right defines second vector
  87494. * @returns the dot product (float)
  87495. */
  87496. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  87497. /**
  87498. * Returns a new Vector2 equal to the normalized given vector
  87499. * @param vector defines the vector to normalize
  87500. * @returns a new Vector2
  87501. */
  87502. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  87503. /**
  87504. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  87505. * @param left defines 1st vector
  87506. * @param right defines 2nd vector
  87507. * @returns a new Vector2
  87508. */
  87509. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  87510. /**
  87511. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  87512. * @param left defines 1st vector
  87513. * @param right defines 2nd vector
  87514. * @returns a new Vector2
  87515. */
  87516. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  87517. /**
  87518. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  87519. * @param vector defines the vector to transform
  87520. * @param transformation defines the matrix to apply
  87521. * @returns a new Vector2
  87522. */
  87523. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  87524. /**
  87525. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  87526. * @param vector defines the vector to transform
  87527. * @param transformation defines the matrix to apply
  87528. * @param result defines the target vector
  87529. */
  87530. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  87531. /**
  87532. * Determines if a given vector is included in a triangle
  87533. * @param p defines the vector to test
  87534. * @param p0 defines 1st triangle point
  87535. * @param p1 defines 2nd triangle point
  87536. * @param p2 defines 3rd triangle point
  87537. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  87538. */
  87539. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  87540. /**
  87541. * Gets the distance between the vectors "value1" and "value2"
  87542. * @param value1 defines first vector
  87543. * @param value2 defines second vector
  87544. * @returns the distance between vectors
  87545. */
  87546. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  87547. /**
  87548. * Returns the squared distance between the vectors "value1" and "value2"
  87549. * @param value1 defines first vector
  87550. * @param value2 defines second vector
  87551. * @returns the squared distance between vectors
  87552. */
  87553. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  87554. /**
  87555. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  87556. * @param value1 defines first vector
  87557. * @param value2 defines second vector
  87558. * @returns a new Vector2
  87559. */
  87560. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  87561. /**
  87562. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  87563. * @param value1 defines first vector
  87564. * @param value2 defines second vector
  87565. * @param ref defines third vector
  87566. * @returns ref
  87567. */
  87568. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  87569. /**
  87570. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  87571. * @param p defines the middle point
  87572. * @param segA defines one point of the segment
  87573. * @param segB defines the other point of the segment
  87574. * @returns the shortest distance
  87575. */
  87576. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  87577. }
  87578. /**
  87579. * Class used to store (x,y,z) vector representation
  87580. * A Vector3 is the main object used in 3D geometry
  87581. * It can represent etiher the coordinates of a point the space, either a direction
  87582. * Reminder: js uses a left handed forward facing system
  87583. */
  87584. export class Vector3 {
  87585. private static _UpReadOnly;
  87586. private static _ZeroReadOnly;
  87587. /** @hidden */
  87588. _x: number;
  87589. /** @hidden */
  87590. _y: number;
  87591. /** @hidden */
  87592. _z: number;
  87593. /** @hidden */
  87594. _isDirty: boolean;
  87595. /** Gets or sets the x coordinate */
  87596. get x(): number;
  87597. set x(value: number);
  87598. /** Gets or sets the y coordinate */
  87599. get y(): number;
  87600. set y(value: number);
  87601. /** Gets or sets the z coordinate */
  87602. get z(): number;
  87603. set z(value: number);
  87604. /**
  87605. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  87606. * @param x defines the first coordinates (on X axis)
  87607. * @param y defines the second coordinates (on Y axis)
  87608. * @param z defines the third coordinates (on Z axis)
  87609. */
  87610. constructor(x?: number, y?: number, z?: number);
  87611. /**
  87612. * Creates a string representation of the Vector3
  87613. * @returns a string with the Vector3 coordinates.
  87614. */
  87615. toString(): string;
  87616. /**
  87617. * Gets the class name
  87618. * @returns the string "Vector3"
  87619. */
  87620. getClassName(): string;
  87621. /**
  87622. * Creates the Vector3 hash code
  87623. * @returns a number which tends to be unique between Vector3 instances
  87624. */
  87625. getHashCode(): number;
  87626. /**
  87627. * Creates an array containing three elements : the coordinates of the Vector3
  87628. * @returns a new array of numbers
  87629. */
  87630. asArray(): number[];
  87631. /**
  87632. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  87633. * @param array defines the destination array
  87634. * @param index defines the offset in the destination array
  87635. * @returns the current Vector3
  87636. */
  87637. toArray(array: FloatArray, index?: number): Vector3;
  87638. /**
  87639. * Update the current vector from an array
  87640. * @param array defines the destination array
  87641. * @param index defines the offset in the destination array
  87642. * @returns the current Vector3
  87643. */
  87644. fromArray(array: FloatArray, index?: number): Vector3;
  87645. /**
  87646. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  87647. * @returns a new Quaternion object, computed from the Vector3 coordinates
  87648. */
  87649. toQuaternion(): Quaternion;
  87650. /**
  87651. * Adds the given vector to the current Vector3
  87652. * @param otherVector defines the second operand
  87653. * @returns the current updated Vector3
  87654. */
  87655. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  87656. /**
  87657. * Adds the given coordinates to the current Vector3
  87658. * @param x defines the x coordinate of the operand
  87659. * @param y defines the y coordinate of the operand
  87660. * @param z defines the z coordinate of the operand
  87661. * @returns the current updated Vector3
  87662. */
  87663. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  87664. /**
  87665. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  87666. * @param otherVector defines the second operand
  87667. * @returns the resulting Vector3
  87668. */
  87669. add(otherVector: DeepImmutable<Vector3>): Vector3;
  87670. /**
  87671. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  87672. * @param otherVector defines the second operand
  87673. * @param result defines the Vector3 object where to store the result
  87674. * @returns the current Vector3
  87675. */
  87676. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87677. /**
  87678. * Subtract the given vector from the current Vector3
  87679. * @param otherVector defines the second operand
  87680. * @returns the current updated Vector3
  87681. */
  87682. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  87683. /**
  87684. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  87685. * @param otherVector defines the second operand
  87686. * @returns the resulting Vector3
  87687. */
  87688. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  87689. /**
  87690. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  87691. * @param otherVector defines the second operand
  87692. * @param result defines the Vector3 object where to store the result
  87693. * @returns the current Vector3
  87694. */
  87695. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87696. /**
  87697. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  87698. * @param x defines the x coordinate of the operand
  87699. * @param y defines the y coordinate of the operand
  87700. * @param z defines the z coordinate of the operand
  87701. * @returns the resulting Vector3
  87702. */
  87703. subtractFromFloats(x: number, y: number, z: number): Vector3;
  87704. /**
  87705. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  87706. * @param x defines the x coordinate of the operand
  87707. * @param y defines the y coordinate of the operand
  87708. * @param z defines the z coordinate of the operand
  87709. * @param result defines the Vector3 object where to store the result
  87710. * @returns the current Vector3
  87711. */
  87712. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  87713. /**
  87714. * Gets a new Vector3 set with the current Vector3 negated coordinates
  87715. * @returns a new Vector3
  87716. */
  87717. negate(): Vector3;
  87718. /**
  87719. * Negate this vector in place
  87720. * @returns this
  87721. */
  87722. negateInPlace(): Vector3;
  87723. /**
  87724. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  87725. * @param result defines the Vector3 object where to store the result
  87726. * @returns the current Vector3
  87727. */
  87728. negateToRef(result: Vector3): Vector3;
  87729. /**
  87730. * Multiplies the Vector3 coordinates by the float "scale"
  87731. * @param scale defines the multiplier factor
  87732. * @returns the current updated Vector3
  87733. */
  87734. scaleInPlace(scale: number): Vector3;
  87735. /**
  87736. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  87737. * @param scale defines the multiplier factor
  87738. * @returns a new Vector3
  87739. */
  87740. scale(scale: number): Vector3;
  87741. /**
  87742. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  87743. * @param scale defines the multiplier factor
  87744. * @param result defines the Vector3 object where to store the result
  87745. * @returns the current Vector3
  87746. */
  87747. scaleToRef(scale: number, result: Vector3): Vector3;
  87748. /**
  87749. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  87750. * @param scale defines the scale factor
  87751. * @param result defines the Vector3 object where to store the result
  87752. * @returns the unmodified current Vector3
  87753. */
  87754. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  87755. /**
  87756. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  87757. * @param origin defines the origin of the projection ray
  87758. * @param plane defines the plane to project to
  87759. * @returns the projected vector3
  87760. */
  87761. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  87762. /**
  87763. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  87764. * @param origin defines the origin of the projection ray
  87765. * @param plane defines the plane to project to
  87766. * @param result defines the Vector3 where to store the result
  87767. */
  87768. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  87769. /**
  87770. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  87771. * @param otherVector defines the second operand
  87772. * @returns true if both vectors are equals
  87773. */
  87774. equals(otherVector: DeepImmutable<Vector3>): boolean;
  87775. /**
  87776. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  87777. * @param otherVector defines the second operand
  87778. * @param epsilon defines the minimal distance to define values as equals
  87779. * @returns true if both vectors are distant less than epsilon
  87780. */
  87781. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  87782. /**
  87783. * Returns true if the current Vector3 coordinates equals the given floats
  87784. * @param x defines the x coordinate of the operand
  87785. * @param y defines the y coordinate of the operand
  87786. * @param z defines the z coordinate of the operand
  87787. * @returns true if both vectors are equals
  87788. */
  87789. equalsToFloats(x: number, y: number, z: number): boolean;
  87790. /**
  87791. * Multiplies the current Vector3 coordinates by the given ones
  87792. * @param otherVector defines the second operand
  87793. * @returns the current updated Vector3
  87794. */
  87795. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  87796. /**
  87797. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  87798. * @param otherVector defines the second operand
  87799. * @returns the new Vector3
  87800. */
  87801. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  87802. /**
  87803. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  87804. * @param otherVector defines the second operand
  87805. * @param result defines the Vector3 object where to store the result
  87806. * @returns the current Vector3
  87807. */
  87808. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87809. /**
  87810. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  87811. * @param x defines the x coordinate of the operand
  87812. * @param y defines the y coordinate of the operand
  87813. * @param z defines the z coordinate of the operand
  87814. * @returns the new Vector3
  87815. */
  87816. multiplyByFloats(x: number, y: number, z: number): Vector3;
  87817. /**
  87818. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  87819. * @param otherVector defines the second operand
  87820. * @returns the new Vector3
  87821. */
  87822. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  87823. /**
  87824. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  87825. * @param otherVector defines the second operand
  87826. * @param result defines the Vector3 object where to store the result
  87827. * @returns the current Vector3
  87828. */
  87829. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87830. /**
  87831. * Divides the current Vector3 coordinates by the given ones.
  87832. * @param otherVector defines the second operand
  87833. * @returns the current updated Vector3
  87834. */
  87835. divideInPlace(otherVector: Vector3): Vector3;
  87836. /**
  87837. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  87838. * @param other defines the second operand
  87839. * @returns the current updated Vector3
  87840. */
  87841. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  87842. /**
  87843. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  87844. * @param other defines the second operand
  87845. * @returns the current updated Vector3
  87846. */
  87847. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  87848. /**
  87849. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  87850. * @param x defines the x coordinate of the operand
  87851. * @param y defines the y coordinate of the operand
  87852. * @param z defines the z coordinate of the operand
  87853. * @returns the current updated Vector3
  87854. */
  87855. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  87856. /**
  87857. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  87858. * @param x defines the x coordinate of the operand
  87859. * @param y defines the y coordinate of the operand
  87860. * @param z defines the z coordinate of the operand
  87861. * @returns the current updated Vector3
  87862. */
  87863. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  87864. /**
  87865. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  87866. * Check if is non uniform within a certain amount of decimal places to account for this
  87867. * @param epsilon the amount the values can differ
  87868. * @returns if the the vector is non uniform to a certain number of decimal places
  87869. */
  87870. isNonUniformWithinEpsilon(epsilon: number): boolean;
  87871. /**
  87872. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  87873. */
  87874. get isNonUniform(): boolean;
  87875. /**
  87876. * Gets a new Vector3 from current Vector3 floored values
  87877. * @returns a new Vector3
  87878. */
  87879. floor(): Vector3;
  87880. /**
  87881. * Gets a new Vector3 from current Vector3 floored values
  87882. * @returns a new Vector3
  87883. */
  87884. fract(): Vector3;
  87885. /**
  87886. * Gets the length of the Vector3
  87887. * @returns the length of the Vector3
  87888. */
  87889. length(): number;
  87890. /**
  87891. * Gets the squared length of the Vector3
  87892. * @returns squared length of the Vector3
  87893. */
  87894. lengthSquared(): number;
  87895. /**
  87896. * Normalize the current Vector3.
  87897. * Please note that this is an in place operation.
  87898. * @returns the current updated Vector3
  87899. */
  87900. normalize(): Vector3;
  87901. /**
  87902. * Reorders the x y z properties of the vector in place
  87903. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  87904. * @returns the current updated vector
  87905. */
  87906. reorderInPlace(order: string): this;
  87907. /**
  87908. * Rotates the vector around 0,0,0 by a quaternion
  87909. * @param quaternion the rotation quaternion
  87910. * @param result vector to store the result
  87911. * @returns the resulting vector
  87912. */
  87913. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  87914. /**
  87915. * Rotates a vector around a given point
  87916. * @param quaternion the rotation quaternion
  87917. * @param point the point to rotate around
  87918. * @param result vector to store the result
  87919. * @returns the resulting vector
  87920. */
  87921. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  87922. /**
  87923. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  87924. * The cross product is then orthogonal to both current and "other"
  87925. * @param other defines the right operand
  87926. * @returns the cross product
  87927. */
  87928. cross(other: Vector3): Vector3;
  87929. /**
  87930. * Normalize the current Vector3 with the given input length.
  87931. * Please note that this is an in place operation.
  87932. * @param len the length of the vector
  87933. * @returns the current updated Vector3
  87934. */
  87935. normalizeFromLength(len: number): Vector3;
  87936. /**
  87937. * Normalize the current Vector3 to a new vector
  87938. * @returns the new Vector3
  87939. */
  87940. normalizeToNew(): Vector3;
  87941. /**
  87942. * Normalize the current Vector3 to the reference
  87943. * @param reference define the Vector3 to update
  87944. * @returns the updated Vector3
  87945. */
  87946. normalizeToRef(reference: Vector3): Vector3;
  87947. /**
  87948. * Creates a new Vector3 copied from the current Vector3
  87949. * @returns the new Vector3
  87950. */
  87951. clone(): Vector3;
  87952. /**
  87953. * Copies the given vector coordinates to the current Vector3 ones
  87954. * @param source defines the source Vector3
  87955. * @returns the current updated Vector3
  87956. */
  87957. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  87958. /**
  87959. * Copies the given floats to the current Vector3 coordinates
  87960. * @param x defines the x coordinate of the operand
  87961. * @param y defines the y coordinate of the operand
  87962. * @param z defines the z coordinate of the operand
  87963. * @returns the current updated Vector3
  87964. */
  87965. copyFromFloats(x: number, y: number, z: number): Vector3;
  87966. /**
  87967. * Copies the given floats to the current Vector3 coordinates
  87968. * @param x defines the x coordinate of the operand
  87969. * @param y defines the y coordinate of the operand
  87970. * @param z defines the z coordinate of the operand
  87971. * @returns the current updated Vector3
  87972. */
  87973. set(x: number, y: number, z: number): Vector3;
  87974. /**
  87975. * Copies the given float to the current Vector3 coordinates
  87976. * @param v defines the x, y and z coordinates of the operand
  87977. * @returns the current updated Vector3
  87978. */
  87979. setAll(v: number): Vector3;
  87980. /**
  87981. * Get the clip factor between two vectors
  87982. * @param vector0 defines the first operand
  87983. * @param vector1 defines the second operand
  87984. * @param axis defines the axis to use
  87985. * @param size defines the size along the axis
  87986. * @returns the clip factor
  87987. */
  87988. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  87989. /**
  87990. * Get angle between two vectors
  87991. * @param vector0 angle between vector0 and vector1
  87992. * @param vector1 angle between vector0 and vector1
  87993. * @param normal direction of the normal
  87994. * @return the angle between vector0 and vector1
  87995. */
  87996. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  87997. /**
  87998. * Returns a new Vector3 set from the index "offset" of the given array
  87999. * @param array defines the source array
  88000. * @param offset defines the offset in the source array
  88001. * @returns the new Vector3
  88002. */
  88003. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  88004. /**
  88005. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  88006. * @param array defines the source array
  88007. * @param offset defines the offset in the source array
  88008. * @returns the new Vector3
  88009. * @deprecated Please use FromArray instead.
  88010. */
  88011. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  88012. /**
  88013. * Sets the given vector "result" with the element values from the index "offset" of the given array
  88014. * @param array defines the source array
  88015. * @param offset defines the offset in the source array
  88016. * @param result defines the Vector3 where to store the result
  88017. */
  88018. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  88019. /**
  88020. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  88021. * @param array defines the source array
  88022. * @param offset defines the offset in the source array
  88023. * @param result defines the Vector3 where to store the result
  88024. * @deprecated Please use FromArrayToRef instead.
  88025. */
  88026. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  88027. /**
  88028. * Sets the given vector "result" with the given floats.
  88029. * @param x defines the x coordinate of the source
  88030. * @param y defines the y coordinate of the source
  88031. * @param z defines the z coordinate of the source
  88032. * @param result defines the Vector3 where to store the result
  88033. */
  88034. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  88035. /**
  88036. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  88037. * @returns a new empty Vector3
  88038. */
  88039. static Zero(): Vector3;
  88040. /**
  88041. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  88042. * @returns a new unit Vector3
  88043. */
  88044. static One(): Vector3;
  88045. /**
  88046. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  88047. * @returns a new up Vector3
  88048. */
  88049. static Up(): Vector3;
  88050. /**
  88051. * Gets a up Vector3 that must not be updated
  88052. */
  88053. static get UpReadOnly(): DeepImmutable<Vector3>;
  88054. /**
  88055. * Gets a zero Vector3 that must not be updated
  88056. */
  88057. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  88058. /**
  88059. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  88060. * @returns a new down Vector3
  88061. */
  88062. static Down(): Vector3;
  88063. /**
  88064. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  88065. * @param rightHandedSystem is the scene right-handed (negative z)
  88066. * @returns a new forward Vector3
  88067. */
  88068. static Forward(rightHandedSystem?: boolean): Vector3;
  88069. /**
  88070. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  88071. * @param rightHandedSystem is the scene right-handed (negative-z)
  88072. * @returns a new forward Vector3
  88073. */
  88074. static Backward(rightHandedSystem?: boolean): Vector3;
  88075. /**
  88076. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  88077. * @returns a new right Vector3
  88078. */
  88079. static Right(): Vector3;
  88080. /**
  88081. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  88082. * @returns a new left Vector3
  88083. */
  88084. static Left(): Vector3;
  88085. /**
  88086. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  88087. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88088. * @param vector defines the Vector3 to transform
  88089. * @param transformation defines the transformation matrix
  88090. * @returns the transformed Vector3
  88091. */
  88092. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88093. /**
  88094. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  88095. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88096. * @param vector defines the Vector3 to transform
  88097. * @param transformation defines the transformation matrix
  88098. * @param result defines the Vector3 where to store the result
  88099. */
  88100. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88101. /**
  88102. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  88103. * This method computes tranformed coordinates only, not transformed direction vectors
  88104. * @param x define the x coordinate of the source vector
  88105. * @param y define the y coordinate of the source vector
  88106. * @param z define the z coordinate of the source vector
  88107. * @param transformation defines the transformation matrix
  88108. * @param result defines the Vector3 where to store the result
  88109. */
  88110. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88111. /**
  88112. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  88113. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88114. * @param vector defines the Vector3 to transform
  88115. * @param transformation defines the transformation matrix
  88116. * @returns the new Vector3
  88117. */
  88118. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88119. /**
  88120. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  88121. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88122. * @param vector defines the Vector3 to transform
  88123. * @param transformation defines the transformation matrix
  88124. * @param result defines the Vector3 where to store the result
  88125. */
  88126. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88127. /**
  88128. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  88129. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88130. * @param x define the x coordinate of the source vector
  88131. * @param y define the y coordinate of the source vector
  88132. * @param z define the z coordinate of the source vector
  88133. * @param transformation defines the transformation matrix
  88134. * @param result defines the Vector3 where to store the result
  88135. */
  88136. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88137. /**
  88138. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  88139. * @param value1 defines the first control point
  88140. * @param value2 defines the second control point
  88141. * @param value3 defines the third control point
  88142. * @param value4 defines the fourth control point
  88143. * @param amount defines the amount on the spline to use
  88144. * @returns the new Vector3
  88145. */
  88146. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  88147. /**
  88148. * 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"
  88149. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88150. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88151. * @param value defines the current value
  88152. * @param min defines the lower range value
  88153. * @param max defines the upper range value
  88154. * @returns the new Vector3
  88155. */
  88156. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  88157. /**
  88158. * 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"
  88159. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88160. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88161. * @param value defines the current value
  88162. * @param min defines the lower range value
  88163. * @param max defines the upper range value
  88164. * @param result defines the Vector3 where to store the result
  88165. */
  88166. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  88167. /**
  88168. * Checks if a given vector is inside a specific range
  88169. * @param v defines the vector to test
  88170. * @param min defines the minimum range
  88171. * @param max defines the maximum range
  88172. */
  88173. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88174. /**
  88175. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  88176. * @param value1 defines the first control point
  88177. * @param tangent1 defines the first tangent vector
  88178. * @param value2 defines the second control point
  88179. * @param tangent2 defines the second tangent vector
  88180. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  88181. * @returns the new Vector3
  88182. */
  88183. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  88184. /**
  88185. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  88186. * @param start defines the start value
  88187. * @param end defines the end value
  88188. * @param amount max defines amount between both (between 0 and 1)
  88189. * @returns the new Vector3
  88190. */
  88191. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  88192. /**
  88193. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  88194. * @param start defines the start value
  88195. * @param end defines the end value
  88196. * @param amount max defines amount between both (between 0 and 1)
  88197. * @param result defines the Vector3 where to store the result
  88198. */
  88199. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  88200. /**
  88201. * Returns the dot product (float) between the vectors "left" and "right"
  88202. * @param left defines the left operand
  88203. * @param right defines the right operand
  88204. * @returns the dot product
  88205. */
  88206. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  88207. /**
  88208. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  88209. * The cross product is then orthogonal to both "left" and "right"
  88210. * @param left defines the left operand
  88211. * @param right defines the right operand
  88212. * @returns the cross product
  88213. */
  88214. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88215. /**
  88216. * Sets the given vector "result" with the cross product of "left" and "right"
  88217. * The cross product is then orthogonal to both "left" and "right"
  88218. * @param left defines the left operand
  88219. * @param right defines the right operand
  88220. * @param result defines the Vector3 where to store the result
  88221. */
  88222. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  88223. /**
  88224. * Returns a new Vector3 as the normalization of the given vector
  88225. * @param vector defines the Vector3 to normalize
  88226. * @returns the new Vector3
  88227. */
  88228. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  88229. /**
  88230. * Sets the given vector "result" with the normalization of the given first vector
  88231. * @param vector defines the Vector3 to normalize
  88232. * @param result defines the Vector3 where to store the result
  88233. */
  88234. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  88235. /**
  88236. * Project a Vector3 onto screen space
  88237. * @param vector defines the Vector3 to project
  88238. * @param world defines the world matrix to use
  88239. * @param transform defines the transform (view x projection) matrix to use
  88240. * @param viewport defines the screen viewport to use
  88241. * @returns the new Vector3
  88242. */
  88243. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  88244. /**
  88245. * Project a Vector3 onto screen space to reference
  88246. * @param vector defines the Vector3 to project
  88247. * @param world defines the world matrix to use
  88248. * @param transform defines the transform (view x projection) matrix to use
  88249. * @param viewport defines the screen viewport to use
  88250. * @param result the vector in which the screen space will be stored
  88251. * @returns the new Vector3
  88252. */
  88253. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  88254. /** @hidden */
  88255. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  88256. /**
  88257. * Unproject from screen space to object space
  88258. * @param source defines the screen space Vector3 to use
  88259. * @param viewportWidth defines the current width of the viewport
  88260. * @param viewportHeight defines the current height of the viewport
  88261. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88262. * @param transform defines the transform (view x projection) matrix to use
  88263. * @returns the new Vector3
  88264. */
  88265. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  88266. /**
  88267. * Unproject from screen space to object space
  88268. * @param source defines the screen space Vector3 to use
  88269. * @param viewportWidth defines the current width of the viewport
  88270. * @param viewportHeight defines the current height of the viewport
  88271. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88272. * @param view defines the view matrix to use
  88273. * @param projection defines the projection matrix to use
  88274. * @returns the new Vector3
  88275. */
  88276. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  88277. /**
  88278. * Unproject from screen space to object space
  88279. * @param source defines the screen space Vector3 to use
  88280. * @param viewportWidth defines the current width of the viewport
  88281. * @param viewportHeight defines the current height of the viewport
  88282. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88283. * @param view defines the view matrix to use
  88284. * @param projection defines the projection matrix to use
  88285. * @param result defines the Vector3 where to store the result
  88286. */
  88287. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88288. /**
  88289. * Unproject from screen space to object space
  88290. * @param sourceX defines the screen space x coordinate to use
  88291. * @param sourceY defines the screen space y coordinate to use
  88292. * @param sourceZ defines the screen space z coordinate to use
  88293. * @param viewportWidth defines the current width of the viewport
  88294. * @param viewportHeight defines the current height of the viewport
  88295. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88296. * @param view defines the view matrix to use
  88297. * @param projection defines the projection matrix to use
  88298. * @param result defines the Vector3 where to store the result
  88299. */
  88300. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88301. /**
  88302. * Gets the minimal coordinate values between two Vector3
  88303. * @param left defines the first operand
  88304. * @param right defines the second operand
  88305. * @returns the new Vector3
  88306. */
  88307. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88308. /**
  88309. * Gets the maximal coordinate values between two Vector3
  88310. * @param left defines the first operand
  88311. * @param right defines the second operand
  88312. * @returns the new Vector3
  88313. */
  88314. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88315. /**
  88316. * Returns the distance between the vectors "value1" and "value2"
  88317. * @param value1 defines the first operand
  88318. * @param value2 defines the second operand
  88319. * @returns the distance
  88320. */
  88321. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88322. /**
  88323. * Returns the squared distance between the vectors "value1" and "value2"
  88324. * @param value1 defines the first operand
  88325. * @param value2 defines the second operand
  88326. * @returns the squared distance
  88327. */
  88328. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88329. /**
  88330. * Returns a new Vector3 located at the center between "value1" and "value2"
  88331. * @param value1 defines the first operand
  88332. * @param value2 defines the second operand
  88333. * @returns the new Vector3
  88334. */
  88335. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  88336. /**
  88337. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88338. * @param value1 defines first vector
  88339. * @param value2 defines second vector
  88340. * @param ref defines third vector
  88341. * @returns ref
  88342. */
  88343. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  88344. /**
  88345. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  88346. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  88347. * to something in order to rotate it from its local system to the given target system
  88348. * Note: axis1, axis2 and axis3 are normalized during this operation
  88349. * @param axis1 defines the first axis
  88350. * @param axis2 defines the second axis
  88351. * @param axis3 defines the third axis
  88352. * @returns a new Vector3
  88353. */
  88354. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  88355. /**
  88356. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  88357. * @param axis1 defines the first axis
  88358. * @param axis2 defines the second axis
  88359. * @param axis3 defines the third axis
  88360. * @param ref defines the Vector3 where to store the result
  88361. */
  88362. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  88363. }
  88364. /**
  88365. * Vector4 class created for EulerAngle class conversion to Quaternion
  88366. */
  88367. export class Vector4 {
  88368. /** x value of the vector */
  88369. x: number;
  88370. /** y value of the vector */
  88371. y: number;
  88372. /** z value of the vector */
  88373. z: number;
  88374. /** w value of the vector */
  88375. w: number;
  88376. /**
  88377. * Creates a Vector4 object from the given floats.
  88378. * @param x x value of the vector
  88379. * @param y y value of the vector
  88380. * @param z z value of the vector
  88381. * @param w w value of the vector
  88382. */
  88383. constructor(
  88384. /** x value of the vector */
  88385. x: number,
  88386. /** y value of the vector */
  88387. y: number,
  88388. /** z value of the vector */
  88389. z: number,
  88390. /** w value of the vector */
  88391. w: number);
  88392. /**
  88393. * Returns the string with the Vector4 coordinates.
  88394. * @returns a string containing all the vector values
  88395. */
  88396. toString(): string;
  88397. /**
  88398. * Returns the string "Vector4".
  88399. * @returns "Vector4"
  88400. */
  88401. getClassName(): string;
  88402. /**
  88403. * Returns the Vector4 hash code.
  88404. * @returns a unique hash code
  88405. */
  88406. getHashCode(): number;
  88407. /**
  88408. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  88409. * @returns the resulting array
  88410. */
  88411. asArray(): number[];
  88412. /**
  88413. * Populates the given array from the given index with the Vector4 coordinates.
  88414. * @param array array to populate
  88415. * @param index index of the array to start at (default: 0)
  88416. * @returns the Vector4.
  88417. */
  88418. toArray(array: FloatArray, index?: number): Vector4;
  88419. /**
  88420. * Update the current vector from an array
  88421. * @param array defines the destination array
  88422. * @param index defines the offset in the destination array
  88423. * @returns the current Vector3
  88424. */
  88425. fromArray(array: FloatArray, index?: number): Vector4;
  88426. /**
  88427. * Adds the given vector to the current Vector4.
  88428. * @param otherVector the vector to add
  88429. * @returns the updated Vector4.
  88430. */
  88431. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88432. /**
  88433. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  88434. * @param otherVector the vector to add
  88435. * @returns the resulting vector
  88436. */
  88437. add(otherVector: DeepImmutable<Vector4>): Vector4;
  88438. /**
  88439. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  88440. * @param otherVector the vector to add
  88441. * @param result the vector to store the result
  88442. * @returns the current Vector4.
  88443. */
  88444. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88445. /**
  88446. * Subtract in place the given vector from the current Vector4.
  88447. * @param otherVector the vector to subtract
  88448. * @returns the updated Vector4.
  88449. */
  88450. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88451. /**
  88452. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  88453. * @param otherVector the vector to add
  88454. * @returns the new vector with the result
  88455. */
  88456. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  88457. /**
  88458. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  88459. * @param otherVector the vector to subtract
  88460. * @param result the vector to store the result
  88461. * @returns the current Vector4.
  88462. */
  88463. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88464. /**
  88465. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88466. */
  88467. /**
  88468. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88469. * @param x value to subtract
  88470. * @param y value to subtract
  88471. * @param z value to subtract
  88472. * @param w value to subtract
  88473. * @returns new vector containing the result
  88474. */
  88475. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  88476. /**
  88477. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88478. * @param x value to subtract
  88479. * @param y value to subtract
  88480. * @param z value to subtract
  88481. * @param w value to subtract
  88482. * @param result the vector to store the result in
  88483. * @returns the current Vector4.
  88484. */
  88485. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  88486. /**
  88487. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  88488. * @returns a new vector with the negated values
  88489. */
  88490. negate(): Vector4;
  88491. /**
  88492. * Negate this vector in place
  88493. * @returns this
  88494. */
  88495. negateInPlace(): Vector4;
  88496. /**
  88497. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  88498. * @param result defines the Vector3 object where to store the result
  88499. * @returns the current Vector4
  88500. */
  88501. negateToRef(result: Vector4): Vector4;
  88502. /**
  88503. * Multiplies the current Vector4 coordinates by scale (float).
  88504. * @param scale the number to scale with
  88505. * @returns the updated Vector4.
  88506. */
  88507. scaleInPlace(scale: number): Vector4;
  88508. /**
  88509. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  88510. * @param scale the number to scale with
  88511. * @returns a new vector with the result
  88512. */
  88513. scale(scale: number): Vector4;
  88514. /**
  88515. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  88516. * @param scale the number to scale with
  88517. * @param result a vector to store the result in
  88518. * @returns the current Vector4.
  88519. */
  88520. scaleToRef(scale: number, result: Vector4): Vector4;
  88521. /**
  88522. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  88523. * @param scale defines the scale factor
  88524. * @param result defines the Vector4 object where to store the result
  88525. * @returns the unmodified current Vector4
  88526. */
  88527. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  88528. /**
  88529. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  88530. * @param otherVector the vector to compare against
  88531. * @returns true if they are equal
  88532. */
  88533. equals(otherVector: DeepImmutable<Vector4>): boolean;
  88534. /**
  88535. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  88536. * @param otherVector vector to compare against
  88537. * @param epsilon (Default: very small number)
  88538. * @returns true if they are equal
  88539. */
  88540. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  88541. /**
  88542. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  88543. * @param x x value to compare against
  88544. * @param y y value to compare against
  88545. * @param z z value to compare against
  88546. * @param w w value to compare against
  88547. * @returns true if equal
  88548. */
  88549. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  88550. /**
  88551. * Multiplies in place the current Vector4 by the given one.
  88552. * @param otherVector vector to multiple with
  88553. * @returns the updated Vector4.
  88554. */
  88555. multiplyInPlace(otherVector: Vector4): Vector4;
  88556. /**
  88557. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  88558. * @param otherVector vector to multiple with
  88559. * @returns resulting new vector
  88560. */
  88561. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  88562. /**
  88563. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  88564. * @param otherVector vector to multiple with
  88565. * @param result vector to store the result
  88566. * @returns the current Vector4.
  88567. */
  88568. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88569. /**
  88570. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  88571. * @param x x value multiply with
  88572. * @param y y value multiply with
  88573. * @param z z value multiply with
  88574. * @param w w value multiply with
  88575. * @returns resulting new vector
  88576. */
  88577. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  88578. /**
  88579. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  88580. * @param otherVector vector to devide with
  88581. * @returns resulting new vector
  88582. */
  88583. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  88584. /**
  88585. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  88586. * @param otherVector vector to devide with
  88587. * @param result vector to store the result
  88588. * @returns the current Vector4.
  88589. */
  88590. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88591. /**
  88592. * Divides the current Vector3 coordinates by the given ones.
  88593. * @param otherVector vector to devide with
  88594. * @returns the updated Vector3.
  88595. */
  88596. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88597. /**
  88598. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  88599. * @param other defines the second operand
  88600. * @returns the current updated Vector4
  88601. */
  88602. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  88603. /**
  88604. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  88605. * @param other defines the second operand
  88606. * @returns the current updated Vector4
  88607. */
  88608. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  88609. /**
  88610. * Gets a new Vector4 from current Vector4 floored values
  88611. * @returns a new Vector4
  88612. */
  88613. floor(): Vector4;
  88614. /**
  88615. * Gets a new Vector4 from current Vector3 floored values
  88616. * @returns a new Vector4
  88617. */
  88618. fract(): Vector4;
  88619. /**
  88620. * Returns the Vector4 length (float).
  88621. * @returns the length
  88622. */
  88623. length(): number;
  88624. /**
  88625. * Returns the Vector4 squared length (float).
  88626. * @returns the length squared
  88627. */
  88628. lengthSquared(): number;
  88629. /**
  88630. * Normalizes in place the Vector4.
  88631. * @returns the updated Vector4.
  88632. */
  88633. normalize(): Vector4;
  88634. /**
  88635. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  88636. * @returns this converted to a new vector3
  88637. */
  88638. toVector3(): Vector3;
  88639. /**
  88640. * Returns a new Vector4 copied from the current one.
  88641. * @returns the new cloned vector
  88642. */
  88643. clone(): Vector4;
  88644. /**
  88645. * Updates the current Vector4 with the given one coordinates.
  88646. * @param source the source vector to copy from
  88647. * @returns the updated Vector4.
  88648. */
  88649. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  88650. /**
  88651. * Updates the current Vector4 coordinates with the given floats.
  88652. * @param x float to copy from
  88653. * @param y float to copy from
  88654. * @param z float to copy from
  88655. * @param w float to copy from
  88656. * @returns the updated Vector4.
  88657. */
  88658. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  88659. /**
  88660. * Updates the current Vector4 coordinates with the given floats.
  88661. * @param x float to set from
  88662. * @param y float to set from
  88663. * @param z float to set from
  88664. * @param w float to set from
  88665. * @returns the updated Vector4.
  88666. */
  88667. set(x: number, y: number, z: number, w: number): Vector4;
  88668. /**
  88669. * Copies the given float to the current Vector3 coordinates
  88670. * @param v defines the x, y, z and w coordinates of the operand
  88671. * @returns the current updated Vector3
  88672. */
  88673. setAll(v: number): Vector4;
  88674. /**
  88675. * Returns a new Vector4 set from the starting index of the given array.
  88676. * @param array the array to pull values from
  88677. * @param offset the offset into the array to start at
  88678. * @returns the new vector
  88679. */
  88680. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  88681. /**
  88682. * Updates the given vector "result" from the starting index of the given array.
  88683. * @param array the array to pull values from
  88684. * @param offset the offset into the array to start at
  88685. * @param result the vector to store the result in
  88686. */
  88687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  88688. /**
  88689. * Updates the given vector "result" from the starting index of the given Float32Array.
  88690. * @param array the array to pull values from
  88691. * @param offset the offset into the array to start at
  88692. * @param result the vector to store the result in
  88693. */
  88694. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  88695. /**
  88696. * Updates the given vector "result" coordinates from the given floats.
  88697. * @param x float to set from
  88698. * @param y float to set from
  88699. * @param z float to set from
  88700. * @param w float to set from
  88701. * @param result the vector to the floats in
  88702. */
  88703. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  88704. /**
  88705. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  88706. * @returns the new vector
  88707. */
  88708. static Zero(): Vector4;
  88709. /**
  88710. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  88711. * @returns the new vector
  88712. */
  88713. static One(): Vector4;
  88714. /**
  88715. * Returns a new normalized Vector4 from the given one.
  88716. * @param vector the vector to normalize
  88717. * @returns the vector
  88718. */
  88719. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  88720. /**
  88721. * Updates the given vector "result" from the normalization of the given one.
  88722. * @param vector the vector to normalize
  88723. * @param result the vector to store the result in
  88724. */
  88725. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  88726. /**
  88727. * Returns a vector with the minimum values from the left and right vectors
  88728. * @param left left vector to minimize
  88729. * @param right right vector to minimize
  88730. * @returns a new vector with the minimum of the left and right vector values
  88731. */
  88732. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  88733. /**
  88734. * Returns a vector with the maximum values from the left and right vectors
  88735. * @param left left vector to maximize
  88736. * @param right right vector to maximize
  88737. * @returns a new vector with the maximum of the left and right vector values
  88738. */
  88739. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  88740. /**
  88741. * Returns the distance (float) between the vectors "value1" and "value2".
  88742. * @param value1 value to calulate the distance between
  88743. * @param value2 value to calulate the distance between
  88744. * @return the distance between the two vectors
  88745. */
  88746. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  88747. /**
  88748. * Returns the squared distance (float) between the vectors "value1" and "value2".
  88749. * @param value1 value to calulate the distance between
  88750. * @param value2 value to calulate the distance between
  88751. * @return the distance between the two vectors squared
  88752. */
  88753. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  88754. /**
  88755. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  88756. * @param value1 value to calulate the center between
  88757. * @param value2 value to calulate the center between
  88758. * @return the center between the two vectors
  88759. */
  88760. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  88761. /**
  88762. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88763. * @param value1 defines first vector
  88764. * @param value2 defines second vector
  88765. * @param ref defines third vector
  88766. * @returns ref
  88767. */
  88768. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  88769. /**
  88770. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  88771. * This methods computes transformed normalized direction vectors only.
  88772. * @param vector the vector to transform
  88773. * @param transformation the transformation matrix to apply
  88774. * @returns the new vector
  88775. */
  88776. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  88777. /**
  88778. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  88779. * This methods computes transformed normalized direction vectors only.
  88780. * @param vector the vector to transform
  88781. * @param transformation the transformation matrix to apply
  88782. * @param result the vector to store the result in
  88783. */
  88784. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  88785. /**
  88786. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  88787. * This methods computes transformed normalized direction vectors only.
  88788. * @param x value to transform
  88789. * @param y value to transform
  88790. * @param z value to transform
  88791. * @param w value to transform
  88792. * @param transformation the transformation matrix to apply
  88793. * @param result the vector to store the results in
  88794. */
  88795. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  88796. /**
  88797. * Creates a new Vector4 from a Vector3
  88798. * @param source defines the source data
  88799. * @param w defines the 4th component (default is 0)
  88800. * @returns a new Vector4
  88801. */
  88802. static FromVector3(source: Vector3, w?: number): Vector4;
  88803. }
  88804. /**
  88805. * Class used to store quaternion data
  88806. * @see https://en.wikipedia.org/wiki/Quaternion
  88807. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  88808. */
  88809. export class Quaternion {
  88810. /** @hidden */
  88811. _x: number;
  88812. /** @hidden */
  88813. _y: number;
  88814. /** @hidden */
  88815. _z: number;
  88816. /** @hidden */
  88817. _w: number;
  88818. /** @hidden */
  88819. _isDirty: boolean;
  88820. /** Gets or sets the x coordinate */
  88821. get x(): number;
  88822. set x(value: number);
  88823. /** Gets or sets the y coordinate */
  88824. get y(): number;
  88825. set y(value: number);
  88826. /** Gets or sets the z coordinate */
  88827. get z(): number;
  88828. set z(value: number);
  88829. /** Gets or sets the w coordinate */
  88830. get w(): number;
  88831. set w(value: number);
  88832. /**
  88833. * Creates a new Quaternion from the given floats
  88834. * @param x defines the first component (0 by default)
  88835. * @param y defines the second component (0 by default)
  88836. * @param z defines the third component (0 by default)
  88837. * @param w defines the fourth component (1.0 by default)
  88838. */
  88839. constructor(x?: number, y?: number, z?: number, w?: number);
  88840. /**
  88841. * Gets a string representation for the current quaternion
  88842. * @returns a string with the Quaternion coordinates
  88843. */
  88844. toString(): string;
  88845. /**
  88846. * Gets the class name of the quaternion
  88847. * @returns the string "Quaternion"
  88848. */
  88849. getClassName(): string;
  88850. /**
  88851. * Gets a hash code for this quaternion
  88852. * @returns the quaternion hash code
  88853. */
  88854. getHashCode(): number;
  88855. /**
  88856. * Copy the quaternion to an array
  88857. * @returns a new array populated with 4 elements from the quaternion coordinates
  88858. */
  88859. asArray(): number[];
  88860. /**
  88861. * Check if two quaternions are equals
  88862. * @param otherQuaternion defines the second operand
  88863. * @return true if the current quaternion and the given one coordinates are strictly equals
  88864. */
  88865. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  88866. /**
  88867. * Gets a boolean if two quaternions are equals (using an epsilon value)
  88868. * @param otherQuaternion defines the other quaternion
  88869. * @param epsilon defines the minimal distance to consider equality
  88870. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  88871. */
  88872. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  88873. /**
  88874. * Clone the current quaternion
  88875. * @returns a new quaternion copied from the current one
  88876. */
  88877. clone(): Quaternion;
  88878. /**
  88879. * Copy a quaternion to the current one
  88880. * @param other defines the other quaternion
  88881. * @returns the updated current quaternion
  88882. */
  88883. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  88884. /**
  88885. * Updates the current quaternion with the given float coordinates
  88886. * @param x defines the x coordinate
  88887. * @param y defines the y coordinate
  88888. * @param z defines the z coordinate
  88889. * @param w defines the w coordinate
  88890. * @returns the updated current quaternion
  88891. */
  88892. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  88893. /**
  88894. * Updates the current quaternion from the given float coordinates
  88895. * @param x defines the x coordinate
  88896. * @param y defines the y coordinate
  88897. * @param z defines the z coordinate
  88898. * @param w defines the w coordinate
  88899. * @returns the updated current quaternion
  88900. */
  88901. set(x: number, y: number, z: number, w: number): Quaternion;
  88902. /**
  88903. * Adds two quaternions
  88904. * @param other defines the second operand
  88905. * @returns a new quaternion as the addition result of the given one and the current quaternion
  88906. */
  88907. add(other: DeepImmutable<Quaternion>): Quaternion;
  88908. /**
  88909. * Add a quaternion to the current one
  88910. * @param other defines the quaternion to add
  88911. * @returns the current quaternion
  88912. */
  88913. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  88914. /**
  88915. * Subtract two quaternions
  88916. * @param other defines the second operand
  88917. * @returns a new quaternion as the subtraction result of the given one from the current one
  88918. */
  88919. subtract(other: Quaternion): Quaternion;
  88920. /**
  88921. * Multiplies the current quaternion by a scale factor
  88922. * @param value defines the scale factor
  88923. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  88924. */
  88925. scale(value: number): Quaternion;
  88926. /**
  88927. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  88928. * @param scale defines the scale factor
  88929. * @param result defines the Quaternion object where to store the result
  88930. * @returns the unmodified current quaternion
  88931. */
  88932. scaleToRef(scale: number, result: Quaternion): Quaternion;
  88933. /**
  88934. * Multiplies in place the current quaternion by a scale factor
  88935. * @param value defines the scale factor
  88936. * @returns the current modified quaternion
  88937. */
  88938. scaleInPlace(value: number): Quaternion;
  88939. /**
  88940. * Scale the current quaternion values by a factor and add the result to a given quaternion
  88941. * @param scale defines the scale factor
  88942. * @param result defines the Quaternion object where to store the result
  88943. * @returns the unmodified current quaternion
  88944. */
  88945. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  88946. /**
  88947. * Multiplies two quaternions
  88948. * @param q1 defines the second operand
  88949. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  88950. */
  88951. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  88952. /**
  88953. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  88954. * @param q1 defines the second operand
  88955. * @param result defines the target quaternion
  88956. * @returns the current quaternion
  88957. */
  88958. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  88959. /**
  88960. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  88961. * @param q1 defines the second operand
  88962. * @returns the currentupdated quaternion
  88963. */
  88964. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  88965. /**
  88966. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  88967. * @param ref defines the target quaternion
  88968. * @returns the current quaternion
  88969. */
  88970. conjugateToRef(ref: Quaternion): Quaternion;
  88971. /**
  88972. * Conjugates in place (1-q) the current quaternion
  88973. * @returns the current updated quaternion
  88974. */
  88975. conjugateInPlace(): Quaternion;
  88976. /**
  88977. * Conjugates in place (1-q) the current quaternion
  88978. * @returns a new quaternion
  88979. */
  88980. conjugate(): Quaternion;
  88981. /**
  88982. * Gets length of current quaternion
  88983. * @returns the quaternion length (float)
  88984. */
  88985. length(): number;
  88986. /**
  88987. * Normalize in place the current quaternion
  88988. * @returns the current updated quaternion
  88989. */
  88990. normalize(): Quaternion;
  88991. /**
  88992. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  88993. * @param order is a reserved parameter and is ignored for now
  88994. * @returns a new Vector3 containing the Euler angles
  88995. */
  88996. toEulerAngles(order?: string): Vector3;
  88997. /**
  88998. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  88999. * @param result defines the vector which will be filled with the Euler angles
  89000. * @returns the current unchanged quaternion
  89001. */
  89002. toEulerAnglesToRef(result: Vector3): Quaternion;
  89003. /**
  89004. * Updates the given rotation matrix with the current quaternion values
  89005. * @param result defines the target matrix
  89006. * @returns the current unchanged quaternion
  89007. */
  89008. toRotationMatrix(result: Matrix): Quaternion;
  89009. /**
  89010. * Updates the current quaternion from the given rotation matrix values
  89011. * @param matrix defines the source matrix
  89012. * @returns the current updated quaternion
  89013. */
  89014. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89015. /**
  89016. * Creates a new quaternion from a rotation matrix
  89017. * @param matrix defines the source matrix
  89018. * @returns a new quaternion created from the given rotation matrix values
  89019. */
  89020. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89021. /**
  89022. * Updates the given quaternion with the given rotation matrix values
  89023. * @param matrix defines the source matrix
  89024. * @param result defines the target quaternion
  89025. */
  89026. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  89027. /**
  89028. * Returns the dot product (float) between the quaternions "left" and "right"
  89029. * @param left defines the left operand
  89030. * @param right defines the right operand
  89031. * @returns the dot product
  89032. */
  89033. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  89034. /**
  89035. * Checks if the two quaternions are close to each other
  89036. * @param quat0 defines the first quaternion to check
  89037. * @param quat1 defines the second quaternion to check
  89038. * @returns true if the two quaternions are close to each other
  89039. */
  89040. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  89041. /**
  89042. * Creates an empty quaternion
  89043. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  89044. */
  89045. static Zero(): Quaternion;
  89046. /**
  89047. * Inverse a given quaternion
  89048. * @param q defines the source quaternion
  89049. * @returns a new quaternion as the inverted current quaternion
  89050. */
  89051. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  89052. /**
  89053. * Inverse a given quaternion
  89054. * @param q defines the source quaternion
  89055. * @param result the quaternion the result will be stored in
  89056. * @returns the result quaternion
  89057. */
  89058. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  89059. /**
  89060. * Creates an identity quaternion
  89061. * @returns the identity quaternion
  89062. */
  89063. static Identity(): Quaternion;
  89064. /**
  89065. * Gets a boolean indicating if the given quaternion is identity
  89066. * @param quaternion defines the quaternion to check
  89067. * @returns true if the quaternion is identity
  89068. */
  89069. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  89070. /**
  89071. * Creates a quaternion from a rotation around an axis
  89072. * @param axis defines the axis to use
  89073. * @param angle defines the angle to use
  89074. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  89075. */
  89076. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  89077. /**
  89078. * Creates a rotation around an axis and stores it into the given quaternion
  89079. * @param axis defines the axis to use
  89080. * @param angle defines the angle to use
  89081. * @param result defines the target quaternion
  89082. * @returns the target quaternion
  89083. */
  89084. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  89085. /**
  89086. * Creates a new quaternion from data stored into an array
  89087. * @param array defines the data source
  89088. * @param offset defines the offset in the source array where the data starts
  89089. * @returns a new quaternion
  89090. */
  89091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  89092. /**
  89093. * Updates the given quaternion "result" from the starting index of the given array.
  89094. * @param array the array to pull values from
  89095. * @param offset the offset into the array to start at
  89096. * @param result the quaternion to store the result in
  89097. */
  89098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  89099. /**
  89100. * Create a quaternion from Euler rotation angles
  89101. * @param x Pitch
  89102. * @param y Yaw
  89103. * @param z Roll
  89104. * @returns the new Quaternion
  89105. */
  89106. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  89107. /**
  89108. * Updates a quaternion from Euler rotation angles
  89109. * @param x Pitch
  89110. * @param y Yaw
  89111. * @param z Roll
  89112. * @param result the quaternion to store the result
  89113. * @returns the updated quaternion
  89114. */
  89115. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  89116. /**
  89117. * Create a quaternion from Euler rotation vector
  89118. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89119. * @returns the new Quaternion
  89120. */
  89121. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  89122. /**
  89123. * Updates a quaternion from Euler rotation vector
  89124. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89125. * @param result the quaternion to store the result
  89126. * @returns the updated quaternion
  89127. */
  89128. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  89129. /**
  89130. * Creates a new quaternion from the given Euler float angles (y, x, z)
  89131. * @param yaw defines the rotation around Y axis
  89132. * @param pitch defines the rotation around X axis
  89133. * @param roll defines the rotation around Z axis
  89134. * @returns the new quaternion
  89135. */
  89136. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  89137. /**
  89138. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  89139. * @param yaw defines the rotation around Y axis
  89140. * @param pitch defines the rotation around X axis
  89141. * @param roll defines the rotation around Z axis
  89142. * @param result defines the target quaternion
  89143. */
  89144. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  89145. /**
  89146. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  89147. * @param alpha defines the rotation around first axis
  89148. * @param beta defines the rotation around second axis
  89149. * @param gamma defines the rotation around third axis
  89150. * @returns the new quaternion
  89151. */
  89152. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  89153. /**
  89154. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  89155. * @param alpha defines the rotation around first axis
  89156. * @param beta defines the rotation around second axis
  89157. * @param gamma defines the rotation around third axis
  89158. * @param result defines the target quaternion
  89159. */
  89160. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  89161. /**
  89162. * 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)
  89163. * @param axis1 defines the first axis
  89164. * @param axis2 defines the second axis
  89165. * @param axis3 defines the third axis
  89166. * @returns the new quaternion
  89167. */
  89168. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  89169. /**
  89170. * 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
  89171. * @param axis1 defines the first axis
  89172. * @param axis2 defines the second axis
  89173. * @param axis3 defines the third axis
  89174. * @param ref defines the target quaternion
  89175. */
  89176. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  89177. /**
  89178. * Interpolates between two quaternions
  89179. * @param left defines first quaternion
  89180. * @param right defines second quaternion
  89181. * @param amount defines the gradient to use
  89182. * @returns the new interpolated quaternion
  89183. */
  89184. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89185. /**
  89186. * Interpolates between two quaternions and stores it into a target quaternion
  89187. * @param left defines first quaternion
  89188. * @param right defines second quaternion
  89189. * @param amount defines the gradient to use
  89190. * @param result defines the target quaternion
  89191. */
  89192. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  89193. /**
  89194. * Interpolate between two quaternions using Hermite interpolation
  89195. * @param value1 defines first quaternion
  89196. * @param tangent1 defines the incoming tangent
  89197. * @param value2 defines second quaternion
  89198. * @param tangent2 defines the outgoing tangent
  89199. * @param amount defines the target quaternion
  89200. * @returns the new interpolated quaternion
  89201. */
  89202. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89203. }
  89204. /**
  89205. * Class used to store matrix data (4x4)
  89206. */
  89207. export class Matrix {
  89208. /**
  89209. * Gets the precision of matrix computations
  89210. */
  89211. static get Use64Bits(): boolean;
  89212. private static _updateFlagSeed;
  89213. private static _identityReadOnly;
  89214. private _isIdentity;
  89215. private _isIdentityDirty;
  89216. private _isIdentity3x2;
  89217. private _isIdentity3x2Dirty;
  89218. /**
  89219. * Gets the update flag of the matrix which is an unique number for the matrix.
  89220. * It will be incremented every time the matrix data change.
  89221. * You can use it to speed the comparison between two versions of the same matrix.
  89222. */
  89223. updateFlag: number;
  89224. private readonly _m;
  89225. /**
  89226. * Gets the internal data of the matrix
  89227. */
  89228. get m(): DeepImmutable<Float32Array | Array<number>>;
  89229. /** @hidden */
  89230. _markAsUpdated(): void;
  89231. /** @hidden */
  89232. private _updateIdentityStatus;
  89233. /**
  89234. * Creates an empty matrix (filled with zeros)
  89235. */
  89236. constructor();
  89237. /**
  89238. * Check if the current matrix is identity
  89239. * @returns true is the matrix is the identity matrix
  89240. */
  89241. isIdentity(): boolean;
  89242. /**
  89243. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  89244. * @returns true is the matrix is the identity matrix
  89245. */
  89246. isIdentityAs3x2(): boolean;
  89247. /**
  89248. * Gets the determinant of the matrix
  89249. * @returns the matrix determinant
  89250. */
  89251. determinant(): number;
  89252. /**
  89253. * Returns the matrix as a Float32Array or Array<number>
  89254. * @returns the matrix underlying array
  89255. */
  89256. toArray(): DeepImmutable<Float32Array | Array<number>>;
  89257. /**
  89258. * Returns the matrix as a Float32Array or Array<number>
  89259. * @returns the matrix underlying array.
  89260. */
  89261. asArray(): DeepImmutable<Float32Array | Array<number>>;
  89262. /**
  89263. * Inverts the current matrix in place
  89264. * @returns the current inverted matrix
  89265. */
  89266. invert(): Matrix;
  89267. /**
  89268. * Sets all the matrix elements to zero
  89269. * @returns the current matrix
  89270. */
  89271. reset(): Matrix;
  89272. /**
  89273. * Adds the current matrix with a second one
  89274. * @param other defines the matrix to add
  89275. * @returns a new matrix as the addition of the current matrix and the given one
  89276. */
  89277. add(other: DeepImmutable<Matrix>): Matrix;
  89278. /**
  89279. * Sets the given matrix "result" to the addition of the current matrix and the given one
  89280. * @param other defines the matrix to add
  89281. * @param result defines the target matrix
  89282. * @returns the current matrix
  89283. */
  89284. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89285. /**
  89286. * Adds in place the given matrix to the current matrix
  89287. * @param other defines the second operand
  89288. * @returns the current updated matrix
  89289. */
  89290. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  89291. /**
  89292. * Sets the given matrix to the current inverted Matrix
  89293. * @param other defines the target matrix
  89294. * @returns the unmodified current matrix
  89295. */
  89296. invertToRef(other: Matrix): Matrix;
  89297. /**
  89298. * add a value at the specified position in the current Matrix
  89299. * @param index the index of the value within the matrix. between 0 and 15.
  89300. * @param value the value to be added
  89301. * @returns the current updated matrix
  89302. */
  89303. addAtIndex(index: number, value: number): Matrix;
  89304. /**
  89305. * mutiply the specified position in the current Matrix by a value
  89306. * @param index the index of the value within the matrix. between 0 and 15.
  89307. * @param value the value to be added
  89308. * @returns the current updated matrix
  89309. */
  89310. multiplyAtIndex(index: number, value: number): Matrix;
  89311. /**
  89312. * Inserts the translation vector (using 3 floats) in the current matrix
  89313. * @param x defines the 1st component of the translation
  89314. * @param y defines the 2nd component of the translation
  89315. * @param z defines the 3rd component of the translation
  89316. * @returns the current updated matrix
  89317. */
  89318. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89319. /**
  89320. * Adds the translation vector (using 3 floats) in the current matrix
  89321. * @param x defines the 1st component of the translation
  89322. * @param y defines the 2nd component of the translation
  89323. * @param z defines the 3rd component of the translation
  89324. * @returns the current updated matrix
  89325. */
  89326. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89327. /**
  89328. * Inserts the translation vector in the current matrix
  89329. * @param vector3 defines the translation to insert
  89330. * @returns the current updated matrix
  89331. */
  89332. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  89333. /**
  89334. * Gets the translation value of the current matrix
  89335. * @returns a new Vector3 as the extracted translation from the matrix
  89336. */
  89337. getTranslation(): Vector3;
  89338. /**
  89339. * Fill a Vector3 with the extracted translation from the matrix
  89340. * @param result defines the Vector3 where to store the translation
  89341. * @returns the current matrix
  89342. */
  89343. getTranslationToRef(result: Vector3): Matrix;
  89344. /**
  89345. * Remove rotation and scaling part from the matrix
  89346. * @returns the updated matrix
  89347. */
  89348. removeRotationAndScaling(): Matrix;
  89349. /**
  89350. * Multiply two matrices
  89351. * @param other defines the second operand
  89352. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  89353. */
  89354. multiply(other: DeepImmutable<Matrix>): Matrix;
  89355. /**
  89356. * Copy the current matrix from the given one
  89357. * @param other defines the source matrix
  89358. * @returns the current updated matrix
  89359. */
  89360. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  89361. /**
  89362. * Populates the given array from the starting index with the current matrix values
  89363. * @param array defines the target array
  89364. * @param offset defines the offset in the target array where to start storing values
  89365. * @returns the current matrix
  89366. */
  89367. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  89368. /**
  89369. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  89370. * @param other defines the second operand
  89371. * @param result defines the matrix where to store the multiplication
  89372. * @returns the current matrix
  89373. */
  89374. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89375. /**
  89376. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  89377. * @param other defines the second operand
  89378. * @param result defines the array where to store the multiplication
  89379. * @param offset defines the offset in the target array where to start storing values
  89380. * @returns the current matrix
  89381. */
  89382. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  89383. /**
  89384. * Check equality between this matrix and a second one
  89385. * @param value defines the second matrix to compare
  89386. * @returns true is the current matrix and the given one values are strictly equal
  89387. */
  89388. equals(value: DeepImmutable<Matrix>): boolean;
  89389. /**
  89390. * Clone the current matrix
  89391. * @returns a new matrix from the current matrix
  89392. */
  89393. clone(): Matrix;
  89394. /**
  89395. * Returns the name of the current matrix class
  89396. * @returns the string "Matrix"
  89397. */
  89398. getClassName(): string;
  89399. /**
  89400. * Gets the hash code of the current matrix
  89401. * @returns the hash code
  89402. */
  89403. getHashCode(): number;
  89404. /**
  89405. * Decomposes the current Matrix into a translation, rotation and scaling components
  89406. * @param scale defines the scale vector3 given as a reference to update
  89407. * @param rotation defines the rotation quaternion given as a reference to update
  89408. * @param translation defines the translation vector3 given as a reference to update
  89409. * @returns true if operation was successful
  89410. */
  89411. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  89412. /**
  89413. * Gets specific row of the matrix
  89414. * @param index defines the number of the row to get
  89415. * @returns the index-th row of the current matrix as a new Vector4
  89416. */
  89417. getRow(index: number): Nullable<Vector4>;
  89418. /**
  89419. * Sets the index-th row of the current matrix to the vector4 values
  89420. * @param index defines the number of the row to set
  89421. * @param row defines the target vector4
  89422. * @returns the updated current matrix
  89423. */
  89424. setRow(index: number, row: Vector4): Matrix;
  89425. /**
  89426. * Compute the transpose of the matrix
  89427. * @returns the new transposed matrix
  89428. */
  89429. transpose(): Matrix;
  89430. /**
  89431. * Compute the transpose of the matrix and store it in a given matrix
  89432. * @param result defines the target matrix
  89433. * @returns the current matrix
  89434. */
  89435. transposeToRef(result: Matrix): Matrix;
  89436. /**
  89437. * Sets the index-th row of the current matrix with the given 4 x float values
  89438. * @param index defines the row index
  89439. * @param x defines the x component to set
  89440. * @param y defines the y component to set
  89441. * @param z defines the z component to set
  89442. * @param w defines the w component to set
  89443. * @returns the updated current matrix
  89444. */
  89445. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  89446. /**
  89447. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  89448. * @param scale defines the scale factor
  89449. * @returns a new matrix
  89450. */
  89451. scale(scale: number): Matrix;
  89452. /**
  89453. * Scale the current matrix values by a factor to a given result matrix
  89454. * @param scale defines the scale factor
  89455. * @param result defines the matrix to store the result
  89456. * @returns the current matrix
  89457. */
  89458. scaleToRef(scale: number, result: Matrix): Matrix;
  89459. /**
  89460. * Scale the current matrix values by a factor and add the result to a given matrix
  89461. * @param scale defines the scale factor
  89462. * @param result defines the Matrix to store the result
  89463. * @returns the current matrix
  89464. */
  89465. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  89466. /**
  89467. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  89468. * @param ref matrix to store the result
  89469. */
  89470. toNormalMatrix(ref: Matrix): void;
  89471. /**
  89472. * Gets only rotation part of the current matrix
  89473. * @returns a new matrix sets to the extracted rotation matrix from the current one
  89474. */
  89475. getRotationMatrix(): Matrix;
  89476. /**
  89477. * Extracts the rotation matrix from the current one and sets it as the given "result"
  89478. * @param result defines the target matrix to store data to
  89479. * @returns the current matrix
  89480. */
  89481. getRotationMatrixToRef(result: Matrix): Matrix;
  89482. /**
  89483. * Toggles model matrix from being right handed to left handed in place and vice versa
  89484. */
  89485. toggleModelMatrixHandInPlace(): void;
  89486. /**
  89487. * Toggles projection matrix from being right handed to left handed in place and vice versa
  89488. */
  89489. toggleProjectionMatrixHandInPlace(): void;
  89490. /**
  89491. * Creates a matrix from an array
  89492. * @param array defines the source array
  89493. * @param offset defines an offset in the source array
  89494. * @returns a new Matrix set from the starting index of the given array
  89495. */
  89496. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  89497. /**
  89498. * Copy the content of an array into a given matrix
  89499. * @param array defines the source array
  89500. * @param offset defines an offset in the source array
  89501. * @param result defines the target matrix
  89502. */
  89503. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  89504. /**
  89505. * Stores an array into a matrix after having multiplied each component by a given factor
  89506. * @param array defines the source array
  89507. * @param offset defines the offset in the source array
  89508. * @param scale defines the scaling factor
  89509. * @param result defines the target matrix
  89510. */
  89511. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  89512. /**
  89513. * Gets an identity matrix that must not be updated
  89514. */
  89515. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  89516. /**
  89517. * Stores a list of values (16) inside a given matrix
  89518. * @param initialM11 defines 1st value of 1st row
  89519. * @param initialM12 defines 2nd value of 1st row
  89520. * @param initialM13 defines 3rd value of 1st row
  89521. * @param initialM14 defines 4th value of 1st row
  89522. * @param initialM21 defines 1st value of 2nd row
  89523. * @param initialM22 defines 2nd value of 2nd row
  89524. * @param initialM23 defines 3rd value of 2nd row
  89525. * @param initialM24 defines 4th value of 2nd row
  89526. * @param initialM31 defines 1st value of 3rd row
  89527. * @param initialM32 defines 2nd value of 3rd row
  89528. * @param initialM33 defines 3rd value of 3rd row
  89529. * @param initialM34 defines 4th value of 3rd row
  89530. * @param initialM41 defines 1st value of 4th row
  89531. * @param initialM42 defines 2nd value of 4th row
  89532. * @param initialM43 defines 3rd value of 4th row
  89533. * @param initialM44 defines 4th value of 4th row
  89534. * @param result defines the target matrix
  89535. */
  89536. 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;
  89537. /**
  89538. * Creates new matrix from a list of values (16)
  89539. * @param initialM11 defines 1st value of 1st row
  89540. * @param initialM12 defines 2nd value of 1st row
  89541. * @param initialM13 defines 3rd value of 1st row
  89542. * @param initialM14 defines 4th value of 1st row
  89543. * @param initialM21 defines 1st value of 2nd row
  89544. * @param initialM22 defines 2nd value of 2nd row
  89545. * @param initialM23 defines 3rd value of 2nd row
  89546. * @param initialM24 defines 4th value of 2nd row
  89547. * @param initialM31 defines 1st value of 3rd row
  89548. * @param initialM32 defines 2nd value of 3rd row
  89549. * @param initialM33 defines 3rd value of 3rd row
  89550. * @param initialM34 defines 4th value of 3rd row
  89551. * @param initialM41 defines 1st value of 4th row
  89552. * @param initialM42 defines 2nd value of 4th row
  89553. * @param initialM43 defines 3rd value of 4th row
  89554. * @param initialM44 defines 4th value of 4th row
  89555. * @returns the new matrix
  89556. */
  89557. 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;
  89558. /**
  89559. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  89560. * @param scale defines the scale vector3
  89561. * @param rotation defines the rotation quaternion
  89562. * @param translation defines the translation vector3
  89563. * @returns a new matrix
  89564. */
  89565. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  89566. /**
  89567. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  89568. * @param scale defines the scale vector3
  89569. * @param rotation defines the rotation quaternion
  89570. * @param translation defines the translation vector3
  89571. * @param result defines the target matrix
  89572. */
  89573. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  89574. /**
  89575. * Creates a new identity matrix
  89576. * @returns a new identity matrix
  89577. */
  89578. static Identity(): Matrix;
  89579. /**
  89580. * Creates a new identity matrix and stores the result in a given matrix
  89581. * @param result defines the target matrix
  89582. */
  89583. static IdentityToRef(result: Matrix): void;
  89584. /**
  89585. * Creates a new zero matrix
  89586. * @returns a new zero matrix
  89587. */
  89588. static Zero(): Matrix;
  89589. /**
  89590. * Creates a new rotation matrix for "angle" radians around the X axis
  89591. * @param angle defines the angle (in radians) to use
  89592. * @return the new matrix
  89593. */
  89594. static RotationX(angle: number): Matrix;
  89595. /**
  89596. * Creates a new matrix as the invert of a given matrix
  89597. * @param source defines the source matrix
  89598. * @returns the new matrix
  89599. */
  89600. static Invert(source: DeepImmutable<Matrix>): Matrix;
  89601. /**
  89602. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  89603. * @param angle defines the angle (in radians) to use
  89604. * @param result defines the target matrix
  89605. */
  89606. static RotationXToRef(angle: number, result: Matrix): void;
  89607. /**
  89608. * Creates a new rotation matrix for "angle" radians around the Y axis
  89609. * @param angle defines the angle (in radians) to use
  89610. * @return the new matrix
  89611. */
  89612. static RotationY(angle: number): Matrix;
  89613. /**
  89614. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  89615. * @param angle defines the angle (in radians) to use
  89616. * @param result defines the target matrix
  89617. */
  89618. static RotationYToRef(angle: number, result: Matrix): void;
  89619. /**
  89620. * Creates a new rotation matrix for "angle" radians around the Z axis
  89621. * @param angle defines the angle (in radians) to use
  89622. * @return the new matrix
  89623. */
  89624. static RotationZ(angle: number): Matrix;
  89625. /**
  89626. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  89627. * @param angle defines the angle (in radians) to use
  89628. * @param result defines the target matrix
  89629. */
  89630. static RotationZToRef(angle: number, result: Matrix): void;
  89631. /**
  89632. * Creates a new rotation matrix for "angle" radians around the given axis
  89633. * @param axis defines the axis to use
  89634. * @param angle defines the angle (in radians) to use
  89635. * @return the new matrix
  89636. */
  89637. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  89638. /**
  89639. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  89640. * @param axis defines the axis to use
  89641. * @param angle defines the angle (in radians) to use
  89642. * @param result defines the target matrix
  89643. */
  89644. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  89645. /**
  89646. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  89647. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  89648. * @param from defines the vector to align
  89649. * @param to defines the vector to align to
  89650. * @param result defines the target matrix
  89651. */
  89652. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  89653. /**
  89654. * Creates a rotation matrix
  89655. * @param yaw defines the yaw angle in radians (Y axis)
  89656. * @param pitch defines the pitch angle in radians (X axis)
  89657. * @param roll defines the roll angle in radians (Z axis)
  89658. * @returns the new rotation matrix
  89659. */
  89660. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  89661. /**
  89662. * Creates a rotation matrix and stores it in a given matrix
  89663. * @param yaw defines the yaw angle in radians (Y axis)
  89664. * @param pitch defines the pitch angle in radians (X axis)
  89665. * @param roll defines the roll angle in radians (Z axis)
  89666. * @param result defines the target matrix
  89667. */
  89668. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  89669. /**
  89670. * Creates a scaling matrix
  89671. * @param x defines the scale factor on X axis
  89672. * @param y defines the scale factor on Y axis
  89673. * @param z defines the scale factor on Z axis
  89674. * @returns the new matrix
  89675. */
  89676. static Scaling(x: number, y: number, z: number): Matrix;
  89677. /**
  89678. * Creates a scaling matrix and stores it in a given matrix
  89679. * @param x defines the scale factor on X axis
  89680. * @param y defines the scale factor on Y axis
  89681. * @param z defines the scale factor on Z axis
  89682. * @param result defines the target matrix
  89683. */
  89684. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  89685. /**
  89686. * Creates a translation matrix
  89687. * @param x defines the translation on X axis
  89688. * @param y defines the translation on Y axis
  89689. * @param z defines the translationon Z axis
  89690. * @returns the new matrix
  89691. */
  89692. static Translation(x: number, y: number, z: number): Matrix;
  89693. /**
  89694. * Creates a translation matrix and stores it in a given matrix
  89695. * @param x defines the translation on X axis
  89696. * @param y defines the translation on Y axis
  89697. * @param z defines the translationon Z axis
  89698. * @param result defines the target matrix
  89699. */
  89700. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  89701. /**
  89702. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  89703. * @param startValue defines the start value
  89704. * @param endValue defines the end value
  89705. * @param gradient defines the gradient factor
  89706. * @returns the new matrix
  89707. */
  89708. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  89709. /**
  89710. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  89711. * @param startValue defines the start value
  89712. * @param endValue defines the end value
  89713. * @param gradient defines the gradient factor
  89714. * @param result defines the Matrix object where to store data
  89715. */
  89716. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  89717. /**
  89718. * Builds a new matrix whose values are computed by:
  89719. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  89720. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  89721. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  89722. * @param startValue defines the first matrix
  89723. * @param endValue defines the second matrix
  89724. * @param gradient defines the gradient between the two matrices
  89725. * @returns the new matrix
  89726. */
  89727. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  89728. /**
  89729. * Update a matrix to values which are computed by:
  89730. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  89731. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  89732. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  89733. * @param startValue defines the first matrix
  89734. * @param endValue defines the second matrix
  89735. * @param gradient defines the gradient between the two matrices
  89736. * @param result defines the target matrix
  89737. */
  89738. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  89739. /**
  89740. * 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"
  89741. * This function works in left handed mode
  89742. * @param eye defines the final position of the entity
  89743. * @param target defines where the entity should look at
  89744. * @param up defines the up vector for the entity
  89745. * @returns the new matrix
  89746. */
  89747. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  89748. /**
  89749. * 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".
  89750. * This function works in left handed mode
  89751. * @param eye defines the final position of the entity
  89752. * @param target defines where the entity should look at
  89753. * @param up defines the up vector for the entity
  89754. * @param result defines the target matrix
  89755. */
  89756. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  89757. /**
  89758. * 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"
  89759. * This function works in right handed mode
  89760. * @param eye defines the final position of the entity
  89761. * @param target defines where the entity should look at
  89762. * @param up defines the up vector for the entity
  89763. * @returns the new matrix
  89764. */
  89765. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  89766. /**
  89767. * 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".
  89768. * This function works in right handed mode
  89769. * @param eye defines the final position of the entity
  89770. * @param target defines where the entity should look at
  89771. * @param up defines the up vector for the entity
  89772. * @param result defines the target matrix
  89773. */
  89774. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  89775. /**
  89776. * Create a left-handed orthographic projection matrix
  89777. * @param width defines the viewport width
  89778. * @param height defines the viewport height
  89779. * @param znear defines the near clip plane
  89780. * @param zfar defines the far clip plane
  89781. * @returns a new matrix as a left-handed orthographic projection matrix
  89782. */
  89783. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  89784. /**
  89785. * Store a left-handed orthographic projection to a given matrix
  89786. * @param width defines the viewport width
  89787. * @param height defines the viewport height
  89788. * @param znear defines the near clip plane
  89789. * @param zfar defines the far clip plane
  89790. * @param result defines the target matrix
  89791. */
  89792. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  89793. /**
  89794. * Create a left-handed orthographic projection matrix
  89795. * @param left defines the viewport left coordinate
  89796. * @param right defines the viewport right coordinate
  89797. * @param bottom defines the viewport bottom coordinate
  89798. * @param top defines the viewport top coordinate
  89799. * @param znear defines the near clip plane
  89800. * @param zfar defines the far clip plane
  89801. * @returns a new matrix as a left-handed orthographic projection matrix
  89802. */
  89803. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  89804. /**
  89805. * Stores a left-handed orthographic projection into a given matrix
  89806. * @param left defines the viewport left coordinate
  89807. * @param right defines the viewport right coordinate
  89808. * @param bottom defines the viewport bottom coordinate
  89809. * @param top defines the viewport top coordinate
  89810. * @param znear defines the near clip plane
  89811. * @param zfar defines the far clip plane
  89812. * @param result defines the target matrix
  89813. */
  89814. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  89815. /**
  89816. * Creates a right-handed orthographic projection matrix
  89817. * @param left defines the viewport left coordinate
  89818. * @param right defines the viewport right coordinate
  89819. * @param bottom defines the viewport bottom coordinate
  89820. * @param top defines the viewport top coordinate
  89821. * @param znear defines the near clip plane
  89822. * @param zfar defines the far clip plane
  89823. * @returns a new matrix as a right-handed orthographic projection matrix
  89824. */
  89825. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  89826. /**
  89827. * Stores a right-handed orthographic projection into a given matrix
  89828. * @param left defines the viewport left coordinate
  89829. * @param right defines the viewport right coordinate
  89830. * @param bottom defines the viewport bottom coordinate
  89831. * @param top defines the viewport top coordinate
  89832. * @param znear defines the near clip plane
  89833. * @param zfar defines the far clip plane
  89834. * @param result defines the target matrix
  89835. */
  89836. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  89837. /**
  89838. * Creates a left-handed perspective projection matrix
  89839. * @param width defines the viewport width
  89840. * @param height defines the viewport height
  89841. * @param znear defines the near clip plane
  89842. * @param zfar defines the far clip plane
  89843. * @returns a new matrix as a left-handed perspective projection matrix
  89844. */
  89845. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  89846. /**
  89847. * Creates a left-handed perspective projection matrix
  89848. * @param fov defines the horizontal field of view
  89849. * @param aspect defines the aspect ratio
  89850. * @param znear defines the near clip plane
  89851. * @param zfar defines the far clip plane
  89852. * @returns a new matrix as a left-handed perspective projection matrix
  89853. */
  89854. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  89855. /**
  89856. * Stores a left-handed perspective projection into a given matrix
  89857. * @param fov defines the horizontal field of view
  89858. * @param aspect defines the aspect ratio
  89859. * @param znear defines the near clip plane
  89860. * @param zfar defines the far clip plane
  89861. * @param result defines the target matrix
  89862. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89863. */
  89864. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89865. /**
  89866. * Stores a left-handed perspective projection into a given matrix with depth reversed
  89867. * @param fov defines the horizontal field of view
  89868. * @param aspect defines the aspect ratio
  89869. * @param znear defines the near clip plane
  89870. * @param zfar not used as infinity is used as far clip
  89871. * @param result defines the target matrix
  89872. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89873. */
  89874. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89875. /**
  89876. * Creates a right-handed perspective projection matrix
  89877. * @param fov defines the horizontal field of view
  89878. * @param aspect defines the aspect ratio
  89879. * @param znear defines the near clip plane
  89880. * @param zfar defines the far clip plane
  89881. * @returns a new matrix as a right-handed perspective projection matrix
  89882. */
  89883. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  89884. /**
  89885. * Stores a right-handed perspective projection into a given matrix
  89886. * @param fov defines the horizontal field of view
  89887. * @param aspect defines the aspect ratio
  89888. * @param znear defines the near clip plane
  89889. * @param zfar defines the far clip plane
  89890. * @param result defines the target matrix
  89891. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89892. */
  89893. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89894. /**
  89895. * Stores a right-handed perspective projection into a given matrix
  89896. * @param fov defines the horizontal field of view
  89897. * @param aspect defines the aspect ratio
  89898. * @param znear defines the near clip plane
  89899. * @param zfar not used as infinity is used as far clip
  89900. * @param result defines the target matrix
  89901. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89902. */
  89903. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89904. /**
  89905. * Stores a perspective projection for WebVR info a given matrix
  89906. * @param fov defines the field of view
  89907. * @param znear defines the near clip plane
  89908. * @param zfar defines the far clip plane
  89909. * @param result defines the target matrix
  89910. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  89911. */
  89912. static PerspectiveFovWebVRToRef(fov: {
  89913. upDegrees: number;
  89914. downDegrees: number;
  89915. leftDegrees: number;
  89916. rightDegrees: number;
  89917. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  89918. /**
  89919. * Computes a complete transformation matrix
  89920. * @param viewport defines the viewport to use
  89921. * @param world defines the world matrix
  89922. * @param view defines the view matrix
  89923. * @param projection defines the projection matrix
  89924. * @param zmin defines the near clip plane
  89925. * @param zmax defines the far clip plane
  89926. * @returns the transformation matrix
  89927. */
  89928. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  89929. /**
  89930. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  89931. * @param matrix defines the matrix to use
  89932. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  89933. */
  89934. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  89935. /**
  89936. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  89937. * @param matrix defines the matrix to use
  89938. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  89939. */
  89940. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  89941. /**
  89942. * Compute the transpose of a given matrix
  89943. * @param matrix defines the matrix to transpose
  89944. * @returns the new matrix
  89945. */
  89946. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  89947. /**
  89948. * Compute the transpose of a matrix and store it in a target matrix
  89949. * @param matrix defines the matrix to transpose
  89950. * @param result defines the target matrix
  89951. */
  89952. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  89953. /**
  89954. * Computes a reflection matrix from a plane
  89955. * @param plane defines the reflection plane
  89956. * @returns a new matrix
  89957. */
  89958. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  89959. /**
  89960. * Computes a reflection matrix from a plane
  89961. * @param plane defines the reflection plane
  89962. * @param result defines the target matrix
  89963. */
  89964. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  89965. /**
  89966. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  89967. * @param xaxis defines the value of the 1st axis
  89968. * @param yaxis defines the value of the 2nd axis
  89969. * @param zaxis defines the value of the 3rd axis
  89970. * @param result defines the target matrix
  89971. */
  89972. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  89973. /**
  89974. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  89975. * @param quat defines the quaternion to use
  89976. * @param result defines the target matrix
  89977. */
  89978. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  89979. }
  89980. /**
  89981. * @hidden
  89982. */
  89983. export class TmpVectors {
  89984. static Vector2: Vector2[];
  89985. static Vector3: Vector3[];
  89986. static Vector4: Vector4[];
  89987. static Quaternion: Quaternion[];
  89988. static Matrix: Matrix[];
  89989. }
  89990. }
  89991. declare module BABYLON {
  89992. /**
  89993. * Defines potential orientation for back face culling
  89994. */
  89995. export enum Orientation {
  89996. /**
  89997. * Clockwise
  89998. */
  89999. CW = 0,
  90000. /** Counter clockwise */
  90001. CCW = 1
  90002. }
  90003. /** Class used to represent a Bezier curve */
  90004. export class BezierCurve {
  90005. /**
  90006. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  90007. * @param t defines the time
  90008. * @param x1 defines the left coordinate on X axis
  90009. * @param y1 defines the left coordinate on Y axis
  90010. * @param x2 defines the right coordinate on X axis
  90011. * @param y2 defines the right coordinate on Y axis
  90012. * @returns the interpolated value
  90013. */
  90014. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  90015. }
  90016. /**
  90017. * Defines angle representation
  90018. */
  90019. export class Angle {
  90020. private _radians;
  90021. /**
  90022. * Creates an Angle object of "radians" radians (float).
  90023. * @param radians the angle in radians
  90024. */
  90025. constructor(radians: number);
  90026. /**
  90027. * Get value in degrees
  90028. * @returns the Angle value in degrees (float)
  90029. */
  90030. degrees(): number;
  90031. /**
  90032. * Get value in radians
  90033. * @returns the Angle value in radians (float)
  90034. */
  90035. radians(): number;
  90036. /**
  90037. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  90038. * @param a defines first point as the origin
  90039. * @param b defines point
  90040. * @returns a new Angle
  90041. */
  90042. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  90043. /**
  90044. * Gets a new Angle object from the given float in radians
  90045. * @param radians defines the angle value in radians
  90046. * @returns a new Angle
  90047. */
  90048. static FromRadians(radians: number): Angle;
  90049. /**
  90050. * Gets a new Angle object from the given float in degrees
  90051. * @param degrees defines the angle value in degrees
  90052. * @returns a new Angle
  90053. */
  90054. static FromDegrees(degrees: number): Angle;
  90055. }
  90056. /**
  90057. * This represents an arc in a 2d space.
  90058. */
  90059. export class Arc2 {
  90060. /** Defines the start point of the arc */
  90061. startPoint: Vector2;
  90062. /** Defines the mid point of the arc */
  90063. midPoint: Vector2;
  90064. /** Defines the end point of the arc */
  90065. endPoint: Vector2;
  90066. /**
  90067. * Defines the center point of the arc.
  90068. */
  90069. centerPoint: Vector2;
  90070. /**
  90071. * Defines the radius of the arc.
  90072. */
  90073. radius: number;
  90074. /**
  90075. * Defines the angle of the arc (from mid point to end point).
  90076. */
  90077. angle: Angle;
  90078. /**
  90079. * Defines the start angle of the arc (from start point to middle point).
  90080. */
  90081. startAngle: Angle;
  90082. /**
  90083. * Defines the orientation of the arc (clock wise/counter clock wise).
  90084. */
  90085. orientation: Orientation;
  90086. /**
  90087. * Creates an Arc object from the three given points : start, middle and end.
  90088. * @param startPoint Defines the start point of the arc
  90089. * @param midPoint Defines the midlle point of the arc
  90090. * @param endPoint Defines the end point of the arc
  90091. */
  90092. constructor(
  90093. /** Defines the start point of the arc */
  90094. startPoint: Vector2,
  90095. /** Defines the mid point of the arc */
  90096. midPoint: Vector2,
  90097. /** Defines the end point of the arc */
  90098. endPoint: Vector2);
  90099. }
  90100. /**
  90101. * Represents a 2D path made up of multiple 2D points
  90102. */
  90103. export class Path2 {
  90104. private _points;
  90105. private _length;
  90106. /**
  90107. * If the path start and end point are the same
  90108. */
  90109. closed: boolean;
  90110. /**
  90111. * Creates a Path2 object from the starting 2D coordinates x and y.
  90112. * @param x the starting points x value
  90113. * @param y the starting points y value
  90114. */
  90115. constructor(x: number, y: number);
  90116. /**
  90117. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  90118. * @param x the added points x value
  90119. * @param y the added points y value
  90120. * @returns the updated Path2.
  90121. */
  90122. addLineTo(x: number, y: number): Path2;
  90123. /**
  90124. * 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.
  90125. * @param midX middle point x value
  90126. * @param midY middle point y value
  90127. * @param endX end point x value
  90128. * @param endY end point y value
  90129. * @param numberOfSegments (default: 36)
  90130. * @returns the updated Path2.
  90131. */
  90132. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  90133. /**
  90134. * Closes the Path2.
  90135. * @returns the Path2.
  90136. */
  90137. close(): Path2;
  90138. /**
  90139. * Gets the sum of the distance between each sequential point in the path
  90140. * @returns the Path2 total length (float).
  90141. */
  90142. length(): number;
  90143. /**
  90144. * Gets the points which construct the path
  90145. * @returns the Path2 internal array of points.
  90146. */
  90147. getPoints(): Vector2[];
  90148. /**
  90149. * Retreives the point at the distance aways from the starting point
  90150. * @param normalizedLengthPosition the length along the path to retreive the point from
  90151. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  90152. */
  90153. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  90154. /**
  90155. * Creates a new path starting from an x and y position
  90156. * @param x starting x value
  90157. * @param y starting y value
  90158. * @returns a new Path2 starting at the coordinates (x, y).
  90159. */
  90160. static StartingAt(x: number, y: number): Path2;
  90161. }
  90162. /**
  90163. * Represents a 3D path made up of multiple 3D points
  90164. */
  90165. export class Path3D {
  90166. /**
  90167. * an array of Vector3, the curve axis of the Path3D
  90168. */
  90169. path: Vector3[];
  90170. private _curve;
  90171. private _distances;
  90172. private _tangents;
  90173. private _normals;
  90174. private _binormals;
  90175. private _raw;
  90176. private _alignTangentsWithPath;
  90177. private readonly _pointAtData;
  90178. /**
  90179. * new Path3D(path, normal, raw)
  90180. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  90181. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  90182. * @param path an array of Vector3, the curve axis of the Path3D
  90183. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  90184. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  90185. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  90186. */
  90187. constructor(
  90188. /**
  90189. * an array of Vector3, the curve axis of the Path3D
  90190. */
  90191. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  90192. /**
  90193. * Returns the Path3D array of successive Vector3 designing its curve.
  90194. * @returns the Path3D array of successive Vector3 designing its curve.
  90195. */
  90196. getCurve(): Vector3[];
  90197. /**
  90198. * Returns the Path3D array of successive Vector3 designing its curve.
  90199. * @returns the Path3D array of successive Vector3 designing its curve.
  90200. */
  90201. getPoints(): Vector3[];
  90202. /**
  90203. * @returns the computed length (float) of the path.
  90204. */
  90205. length(): number;
  90206. /**
  90207. * Returns an array populated with tangent vectors on each Path3D curve point.
  90208. * @returns an array populated with tangent vectors on each Path3D curve point.
  90209. */
  90210. getTangents(): Vector3[];
  90211. /**
  90212. * Returns an array populated with normal vectors on each Path3D curve point.
  90213. * @returns an array populated with normal vectors on each Path3D curve point.
  90214. */
  90215. getNormals(): Vector3[];
  90216. /**
  90217. * Returns an array populated with binormal vectors on each Path3D curve point.
  90218. * @returns an array populated with binormal vectors on each Path3D curve point.
  90219. */
  90220. getBinormals(): Vector3[];
  90221. /**
  90222. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  90223. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  90224. */
  90225. getDistances(): number[];
  90226. /**
  90227. * Returns an interpolated point along this path
  90228. * @param position the position of the point along this path, from 0.0 to 1.0
  90229. * @returns a new Vector3 as the point
  90230. */
  90231. getPointAt(position: number): Vector3;
  90232. /**
  90233. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90234. * @param position the position of the point along this path, from 0.0 to 1.0
  90235. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  90236. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  90237. */
  90238. getTangentAt(position: number, interpolated?: boolean): Vector3;
  90239. /**
  90240. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90241. * @param position the position of the point along this path, from 0.0 to 1.0
  90242. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  90243. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  90244. */
  90245. getNormalAt(position: number, interpolated?: boolean): Vector3;
  90246. /**
  90247. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  90248. * @param position the position of the point along this path, from 0.0 to 1.0
  90249. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  90250. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  90251. */
  90252. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  90253. /**
  90254. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  90255. * @param position the position of the point along this path, from 0.0 to 1.0
  90256. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  90257. */
  90258. getDistanceAt(position: number): number;
  90259. /**
  90260. * Returns the array index of the previous point of an interpolated point along this path
  90261. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90262. * @returns the array index
  90263. */
  90264. getPreviousPointIndexAt(position: number): number;
  90265. /**
  90266. * 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)
  90267. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90268. * @returns the sub position
  90269. */
  90270. getSubPositionAt(position: number): number;
  90271. /**
  90272. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  90273. * @param target the vector of which to get the closest position to
  90274. * @returns the position of the closest virtual point on this path to the target vector
  90275. */
  90276. getClosestPositionTo(target: Vector3): number;
  90277. /**
  90278. * Returns a sub path (slice) of this path
  90279. * @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
  90280. * @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
  90281. * @returns a sub path (slice) of this path
  90282. */
  90283. slice(start?: number, end?: number): Path3D;
  90284. /**
  90285. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  90286. * @param path path which all values are copied into the curves points
  90287. * @param firstNormal which should be projected onto the curve
  90288. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  90289. * @returns the same object updated.
  90290. */
  90291. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  90292. private _compute;
  90293. private _getFirstNonNullVector;
  90294. private _getLastNonNullVector;
  90295. private _normalVector;
  90296. /**
  90297. * Updates the point at data for an interpolated point along this curve
  90298. * @param position the position of the point along this curve, from 0.0 to 1.0
  90299. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  90300. * @returns the (updated) point at data
  90301. */
  90302. private _updatePointAtData;
  90303. /**
  90304. * Updates the point at data from the specified parameters
  90305. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  90306. * @param point the interpolated point
  90307. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  90308. */
  90309. private _setPointAtData;
  90310. /**
  90311. * Updates the point at interpolation matrix for the tangents, normals and binormals
  90312. */
  90313. private _updateInterpolationMatrix;
  90314. }
  90315. /**
  90316. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90317. * A Curve3 is designed from a series of successive Vector3.
  90318. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  90319. */
  90320. export class Curve3 {
  90321. private _points;
  90322. private _length;
  90323. /**
  90324. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  90325. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  90326. * @param v1 (Vector3) the control point
  90327. * @param v2 (Vector3) the end point of the Quadratic Bezier
  90328. * @param nbPoints (integer) the wanted number of points in the curve
  90329. * @returns the created Curve3
  90330. */
  90331. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90332. /**
  90333. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  90334. * @param v0 (Vector3) the origin point of the Cubic Bezier
  90335. * @param v1 (Vector3) the first control point
  90336. * @param v2 (Vector3) the second control point
  90337. * @param v3 (Vector3) the end point of the Cubic Bezier
  90338. * @param nbPoints (integer) the wanted number of points in the curve
  90339. * @returns the created Curve3
  90340. */
  90341. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90342. /**
  90343. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  90344. * @param p1 (Vector3) the origin point of the Hermite Spline
  90345. * @param t1 (Vector3) the tangent vector at the origin point
  90346. * @param p2 (Vector3) the end point of the Hermite Spline
  90347. * @param t2 (Vector3) the tangent vector at the end point
  90348. * @param nbPoints (integer) the wanted number of points in the curve
  90349. * @returns the created Curve3
  90350. */
  90351. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90352. /**
  90353. * Returns a Curve3 object along a CatmullRom Spline curve :
  90354. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  90355. * @param nbPoints (integer) the wanted number of points between each curve control points
  90356. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  90357. * @returns the created Curve3
  90358. */
  90359. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  90360. /**
  90361. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90362. * A Curve3 is designed from a series of successive Vector3.
  90363. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  90364. * @param points points which make up the curve
  90365. */
  90366. constructor(points: Vector3[]);
  90367. /**
  90368. * @returns the Curve3 stored array of successive Vector3
  90369. */
  90370. getPoints(): Vector3[];
  90371. /**
  90372. * @returns the computed length (float) of the curve.
  90373. */
  90374. length(): number;
  90375. /**
  90376. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  90377. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  90378. * curveA and curveB keep unchanged.
  90379. * @param curve the curve to continue from this curve
  90380. * @returns the newly constructed curve
  90381. */
  90382. continue(curve: DeepImmutable<Curve3>): Curve3;
  90383. private _computeLength;
  90384. }
  90385. }
  90386. declare module BABYLON {
  90387. /**
  90388. * This represents the main contract an easing function should follow.
  90389. * Easing functions are used throughout the animation system.
  90390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90391. */
  90392. export interface IEasingFunction {
  90393. /**
  90394. * Given an input gradient between 0 and 1, this returns the corrseponding value
  90395. * of the easing function.
  90396. * The link below provides some of the most common examples of easing functions.
  90397. * @see https://easings.net/
  90398. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90399. * @returns the corresponding value on the curve defined by the easing function
  90400. */
  90401. ease(gradient: number): number;
  90402. }
  90403. /**
  90404. * Base class used for every default easing function.
  90405. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90406. */
  90407. export class EasingFunction implements IEasingFunction {
  90408. /**
  90409. * Interpolation follows the mathematical formula associated with the easing function.
  90410. */
  90411. static readonly EASINGMODE_EASEIN: number;
  90412. /**
  90413. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  90414. */
  90415. static readonly EASINGMODE_EASEOUT: number;
  90416. /**
  90417. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  90418. */
  90419. static readonly EASINGMODE_EASEINOUT: number;
  90420. private _easingMode;
  90421. /**
  90422. * Sets the easing mode of the current function.
  90423. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  90424. */
  90425. setEasingMode(easingMode: number): void;
  90426. /**
  90427. * Gets the current easing mode.
  90428. * @returns the easing mode
  90429. */
  90430. getEasingMode(): number;
  90431. /**
  90432. * @hidden
  90433. */
  90434. easeInCore(gradient: number): number;
  90435. /**
  90436. * Given an input gradient between 0 and 1, this returns the corresponding value
  90437. * of the easing function.
  90438. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90439. * @returns the corresponding value on the curve defined by the easing function
  90440. */
  90441. ease(gradient: number): number;
  90442. }
  90443. /**
  90444. * Easing function with a circle shape (see link below).
  90445. * @see https://easings.net/#easeInCirc
  90446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90447. */
  90448. export class CircleEase extends EasingFunction implements IEasingFunction {
  90449. /** @hidden */
  90450. easeInCore(gradient: number): number;
  90451. }
  90452. /**
  90453. * Easing function with a ease back shape (see link below).
  90454. * @see https://easings.net/#easeInBack
  90455. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90456. */
  90457. export class BackEase extends EasingFunction implements IEasingFunction {
  90458. /** Defines the amplitude of the function */
  90459. amplitude: number;
  90460. /**
  90461. * Instantiates a back ease easing
  90462. * @see https://easings.net/#easeInBack
  90463. * @param amplitude Defines the amplitude of the function
  90464. */
  90465. constructor(
  90466. /** Defines the amplitude of the function */
  90467. amplitude?: number);
  90468. /** @hidden */
  90469. easeInCore(gradient: number): number;
  90470. }
  90471. /**
  90472. * Easing function with a bouncing shape (see link below).
  90473. * @see https://easings.net/#easeInBounce
  90474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90475. */
  90476. export class BounceEase extends EasingFunction implements IEasingFunction {
  90477. /** Defines the number of bounces */
  90478. bounces: number;
  90479. /** Defines the amplitude of the bounce */
  90480. bounciness: number;
  90481. /**
  90482. * Instantiates a bounce easing
  90483. * @see https://easings.net/#easeInBounce
  90484. * @param bounces Defines the number of bounces
  90485. * @param bounciness Defines the amplitude of the bounce
  90486. */
  90487. constructor(
  90488. /** Defines the number of bounces */
  90489. bounces?: number,
  90490. /** Defines the amplitude of the bounce */
  90491. bounciness?: number);
  90492. /** @hidden */
  90493. easeInCore(gradient: number): number;
  90494. }
  90495. /**
  90496. * Easing function with a power of 3 shape (see link below).
  90497. * @see https://easings.net/#easeInCubic
  90498. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90499. */
  90500. export class CubicEase extends EasingFunction implements IEasingFunction {
  90501. /** @hidden */
  90502. easeInCore(gradient: number): number;
  90503. }
  90504. /**
  90505. * Easing function with an elastic shape (see link below).
  90506. * @see https://easings.net/#easeInElastic
  90507. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90508. */
  90509. export class ElasticEase extends EasingFunction implements IEasingFunction {
  90510. /** Defines the number of oscillations*/
  90511. oscillations: number;
  90512. /** Defines the amplitude of the oscillations*/
  90513. springiness: number;
  90514. /**
  90515. * Instantiates an elastic easing function
  90516. * @see https://easings.net/#easeInElastic
  90517. * @param oscillations Defines the number of oscillations
  90518. * @param springiness Defines the amplitude of the oscillations
  90519. */
  90520. constructor(
  90521. /** Defines the number of oscillations*/
  90522. oscillations?: number,
  90523. /** Defines the amplitude of the oscillations*/
  90524. springiness?: number);
  90525. /** @hidden */
  90526. easeInCore(gradient: number): number;
  90527. }
  90528. /**
  90529. * Easing function with an exponential shape (see link below).
  90530. * @see https://easings.net/#easeInExpo
  90531. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90532. */
  90533. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  90534. /** Defines the exponent of the function */
  90535. exponent: number;
  90536. /**
  90537. * Instantiates an exponential easing function
  90538. * @see https://easings.net/#easeInExpo
  90539. * @param exponent Defines the exponent of the function
  90540. */
  90541. constructor(
  90542. /** Defines the exponent of the function */
  90543. exponent?: number);
  90544. /** @hidden */
  90545. easeInCore(gradient: number): number;
  90546. }
  90547. /**
  90548. * Easing function with a power shape (see link below).
  90549. * @see https://easings.net/#easeInQuad
  90550. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90551. */
  90552. export class PowerEase extends EasingFunction implements IEasingFunction {
  90553. /** Defines the power of the function */
  90554. power: number;
  90555. /**
  90556. * Instantiates an power base easing function
  90557. * @see https://easings.net/#easeInQuad
  90558. * @param power Defines the power of the function
  90559. */
  90560. constructor(
  90561. /** Defines the power of the function */
  90562. power?: number);
  90563. /** @hidden */
  90564. easeInCore(gradient: number): number;
  90565. }
  90566. /**
  90567. * Easing function with a power of 2 shape (see link below).
  90568. * @see https://easings.net/#easeInQuad
  90569. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90570. */
  90571. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  90572. /** @hidden */
  90573. easeInCore(gradient: number): number;
  90574. }
  90575. /**
  90576. * Easing function with a power of 4 shape (see link below).
  90577. * @see https://easings.net/#easeInQuart
  90578. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90579. */
  90580. export class QuarticEase extends EasingFunction implements IEasingFunction {
  90581. /** @hidden */
  90582. easeInCore(gradient: number): number;
  90583. }
  90584. /**
  90585. * Easing function with a power of 5 shape (see link below).
  90586. * @see https://easings.net/#easeInQuint
  90587. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90588. */
  90589. export class QuinticEase extends EasingFunction implements IEasingFunction {
  90590. /** @hidden */
  90591. easeInCore(gradient: number): number;
  90592. }
  90593. /**
  90594. * Easing function with a sin shape (see link below).
  90595. * @see https://easings.net/#easeInSine
  90596. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90597. */
  90598. export class SineEase extends EasingFunction implements IEasingFunction {
  90599. /** @hidden */
  90600. easeInCore(gradient: number): number;
  90601. }
  90602. /**
  90603. * Easing function with a bezier shape (see link below).
  90604. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  90605. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90606. */
  90607. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  90608. /** Defines the x component of the start tangent in the bezier curve */
  90609. x1: number;
  90610. /** Defines the y component of the start tangent in the bezier curve */
  90611. y1: number;
  90612. /** Defines the x component of the end tangent in the bezier curve */
  90613. x2: number;
  90614. /** Defines the y component of the end tangent in the bezier curve */
  90615. y2: number;
  90616. /**
  90617. * Instantiates a bezier function
  90618. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  90619. * @param x1 Defines the x component of the start tangent in the bezier curve
  90620. * @param y1 Defines the y component of the start tangent in the bezier curve
  90621. * @param x2 Defines the x component of the end tangent in the bezier curve
  90622. * @param y2 Defines the y component of the end tangent in the bezier curve
  90623. */
  90624. constructor(
  90625. /** Defines the x component of the start tangent in the bezier curve */
  90626. x1?: number,
  90627. /** Defines the y component of the start tangent in the bezier curve */
  90628. y1?: number,
  90629. /** Defines the x component of the end tangent in the bezier curve */
  90630. x2?: number,
  90631. /** Defines the y component of the end tangent in the bezier curve */
  90632. y2?: number);
  90633. /** @hidden */
  90634. easeInCore(gradient: number): number;
  90635. }
  90636. }
  90637. declare module BABYLON {
  90638. /**
  90639. * Class used to hold a RBG color
  90640. */
  90641. export class Color3 {
  90642. /**
  90643. * Defines the red component (between 0 and 1, default is 0)
  90644. */
  90645. r: number;
  90646. /**
  90647. * Defines the green component (between 0 and 1, default is 0)
  90648. */
  90649. g: number;
  90650. /**
  90651. * Defines the blue component (between 0 and 1, default is 0)
  90652. */
  90653. b: number;
  90654. /**
  90655. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  90656. * @param r defines the red component (between 0 and 1, default is 0)
  90657. * @param g defines the green component (between 0 and 1, default is 0)
  90658. * @param b defines the blue component (between 0 and 1, default is 0)
  90659. */
  90660. constructor(
  90661. /**
  90662. * Defines the red component (between 0 and 1, default is 0)
  90663. */
  90664. r?: number,
  90665. /**
  90666. * Defines the green component (between 0 and 1, default is 0)
  90667. */
  90668. g?: number,
  90669. /**
  90670. * Defines the blue component (between 0 and 1, default is 0)
  90671. */
  90672. b?: number);
  90673. /**
  90674. * Creates a string with the Color3 current values
  90675. * @returns the string representation of the Color3 object
  90676. */
  90677. toString(): string;
  90678. /**
  90679. * Returns the string "Color3"
  90680. * @returns "Color3"
  90681. */
  90682. getClassName(): string;
  90683. /**
  90684. * Compute the Color3 hash code
  90685. * @returns an unique number that can be used to hash Color3 objects
  90686. */
  90687. getHashCode(): number;
  90688. /**
  90689. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  90690. * @param array defines the array where to store the r,g,b components
  90691. * @param index defines an optional index in the target array to define where to start storing values
  90692. * @returns the current Color3 object
  90693. */
  90694. toArray(array: FloatArray, index?: number): Color3;
  90695. /**
  90696. * Update the current color with values stored in an array from the starting index of the given array
  90697. * @param array defines the source array
  90698. * @param offset defines an offset in the source array
  90699. * @returns the current Color3 object
  90700. */
  90701. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  90702. /**
  90703. * Returns a new Color4 object from the current Color3 and the given alpha
  90704. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  90705. * @returns a new Color4 object
  90706. */
  90707. toColor4(alpha?: number): Color4;
  90708. /**
  90709. * Returns a new array populated with 3 numeric elements : red, green and blue values
  90710. * @returns the new array
  90711. */
  90712. asArray(): number[];
  90713. /**
  90714. * Returns the luminance value
  90715. * @returns a float value
  90716. */
  90717. toLuminance(): number;
  90718. /**
  90719. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  90720. * @param otherColor defines the second operand
  90721. * @returns the new Color3 object
  90722. */
  90723. multiply(otherColor: DeepImmutable<Color3>): Color3;
  90724. /**
  90725. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  90726. * @param otherColor defines the second operand
  90727. * @param result defines the Color3 object where to store the result
  90728. * @returns the current Color3
  90729. */
  90730. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  90731. /**
  90732. * Determines equality between Color3 objects
  90733. * @param otherColor defines the second operand
  90734. * @returns true if the rgb values are equal to the given ones
  90735. */
  90736. equals(otherColor: DeepImmutable<Color3>): boolean;
  90737. /**
  90738. * Determines equality between the current Color3 object and a set of r,b,g values
  90739. * @param r defines the red component to check
  90740. * @param g defines the green component to check
  90741. * @param b defines the blue component to check
  90742. * @returns true if the rgb values are equal to the given ones
  90743. */
  90744. equalsFloats(r: number, g: number, b: number): boolean;
  90745. /**
  90746. * Multiplies in place each rgb value by scale
  90747. * @param scale defines the scaling factor
  90748. * @returns the updated Color3
  90749. */
  90750. scale(scale: number): Color3;
  90751. /**
  90752. * Multiplies the rgb values by scale and stores the result into "result"
  90753. * @param scale defines the scaling factor
  90754. * @param result defines the Color3 object where to store the result
  90755. * @returns the unmodified current Color3
  90756. */
  90757. scaleToRef(scale: number, result: Color3): Color3;
  90758. /**
  90759. * Scale the current Color3 values by a factor and add the result to a given Color3
  90760. * @param scale defines the scale factor
  90761. * @param result defines color to store the result into
  90762. * @returns the unmodified current Color3
  90763. */
  90764. scaleAndAddToRef(scale: number, result: Color3): Color3;
  90765. /**
  90766. * Clamps the rgb values by the min and max values and stores the result into "result"
  90767. * @param min defines minimum clamping value (default is 0)
  90768. * @param max defines maximum clamping value (default is 1)
  90769. * @param result defines color to store the result into
  90770. * @returns the original Color3
  90771. */
  90772. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  90773. /**
  90774. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  90775. * @param otherColor defines the second operand
  90776. * @returns the new Color3
  90777. */
  90778. add(otherColor: DeepImmutable<Color3>): Color3;
  90779. /**
  90780. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  90781. * @param otherColor defines the second operand
  90782. * @param result defines Color3 object to store the result into
  90783. * @returns the unmodified current Color3
  90784. */
  90785. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  90786. /**
  90787. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  90788. * @param otherColor defines the second operand
  90789. * @returns the new Color3
  90790. */
  90791. subtract(otherColor: DeepImmutable<Color3>): Color3;
  90792. /**
  90793. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  90794. * @param otherColor defines the second operand
  90795. * @param result defines Color3 object to store the result into
  90796. * @returns the unmodified current Color3
  90797. */
  90798. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  90799. /**
  90800. * Copy the current object
  90801. * @returns a new Color3 copied the current one
  90802. */
  90803. clone(): Color3;
  90804. /**
  90805. * Copies the rgb values from the source in the current Color3
  90806. * @param source defines the source Color3 object
  90807. * @returns the updated Color3 object
  90808. */
  90809. copyFrom(source: DeepImmutable<Color3>): Color3;
  90810. /**
  90811. * Updates the Color3 rgb values from the given floats
  90812. * @param r defines the red component to read from
  90813. * @param g defines the green component to read from
  90814. * @param b defines the blue component to read from
  90815. * @returns the current Color3 object
  90816. */
  90817. copyFromFloats(r: number, g: number, b: number): Color3;
  90818. /**
  90819. * Updates the Color3 rgb values from the given floats
  90820. * @param r defines the red component to read from
  90821. * @param g defines the green component to read from
  90822. * @param b defines the blue component to read from
  90823. * @returns the current Color3 object
  90824. */
  90825. set(r: number, g: number, b: number): Color3;
  90826. /**
  90827. * Compute the Color3 hexadecimal code as a string
  90828. * @returns a string containing the hexadecimal representation of the Color3 object
  90829. */
  90830. toHexString(): string;
  90831. /**
  90832. * Computes a new Color3 converted from the current one to linear space
  90833. * @returns a new Color3 object
  90834. */
  90835. toLinearSpace(): Color3;
  90836. /**
  90837. * Converts current color in rgb space to HSV values
  90838. * @returns a new color3 representing the HSV values
  90839. */
  90840. toHSV(): Color3;
  90841. /**
  90842. * Converts current color in rgb space to HSV values
  90843. * @param result defines the Color3 where to store the HSV values
  90844. */
  90845. toHSVToRef(result: Color3): void;
  90846. /**
  90847. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  90848. * @param convertedColor defines the Color3 object where to store the linear space version
  90849. * @returns the unmodified Color3
  90850. */
  90851. toLinearSpaceToRef(convertedColor: Color3): Color3;
  90852. /**
  90853. * Computes a new Color3 converted from the current one to gamma space
  90854. * @returns a new Color3 object
  90855. */
  90856. toGammaSpace(): Color3;
  90857. /**
  90858. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  90859. * @param convertedColor defines the Color3 object where to store the gamma space version
  90860. * @returns the unmodified Color3
  90861. */
  90862. toGammaSpaceToRef(convertedColor: Color3): Color3;
  90863. private static _BlackReadOnly;
  90864. /**
  90865. * Convert Hue, saturation and value to a Color3 (RGB)
  90866. * @param hue defines the hue
  90867. * @param saturation defines the saturation
  90868. * @param value defines the value
  90869. * @param result defines the Color3 where to store the RGB values
  90870. */
  90871. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  90872. /**
  90873. * Creates a new Color3 from the string containing valid hexadecimal values
  90874. * @param hex defines a string containing valid hexadecimal values
  90875. * @returns a new Color3 object
  90876. */
  90877. static FromHexString(hex: string): Color3;
  90878. /**
  90879. * Creates a new Color3 from the starting index of the given array
  90880. * @param array defines the source array
  90881. * @param offset defines an offset in the source array
  90882. * @returns a new Color3 object
  90883. */
  90884. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  90885. /**
  90886. * Creates a new Color3 from the starting index element of the given array
  90887. * @param array defines the source array to read from
  90888. * @param offset defines the offset in the source array
  90889. * @param result defines the target Color3 object
  90890. */
  90891. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  90892. /**
  90893. * Creates a new Color3 from integer values (< 256)
  90894. * @param r defines the red component to read from (value between 0 and 255)
  90895. * @param g defines the green component to read from (value between 0 and 255)
  90896. * @param b defines the blue component to read from (value between 0 and 255)
  90897. * @returns a new Color3 object
  90898. */
  90899. static FromInts(r: number, g: number, b: number): Color3;
  90900. /**
  90901. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  90902. * @param start defines the start Color3 value
  90903. * @param end defines the end Color3 value
  90904. * @param amount defines the gradient value between start and end
  90905. * @returns a new Color3 object
  90906. */
  90907. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  90908. /**
  90909. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  90910. * @param left defines the start value
  90911. * @param right defines the end value
  90912. * @param amount defines the gradient factor
  90913. * @param result defines the Color3 object where to store the result
  90914. */
  90915. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  90916. /**
  90917. * Returns a Color3 value containing a red color
  90918. * @returns a new Color3 object
  90919. */
  90920. static Red(): Color3;
  90921. /**
  90922. * Returns a Color3 value containing a green color
  90923. * @returns a new Color3 object
  90924. */
  90925. static Green(): Color3;
  90926. /**
  90927. * Returns a Color3 value containing a blue color
  90928. * @returns a new Color3 object
  90929. */
  90930. static Blue(): Color3;
  90931. /**
  90932. * Returns a Color3 value containing a black color
  90933. * @returns a new Color3 object
  90934. */
  90935. static Black(): Color3;
  90936. /**
  90937. * Gets a Color3 value containing a black color that must not be updated
  90938. */
  90939. static get BlackReadOnly(): DeepImmutable<Color3>;
  90940. /**
  90941. * Returns a Color3 value containing a white color
  90942. * @returns a new Color3 object
  90943. */
  90944. static White(): Color3;
  90945. /**
  90946. * Returns a Color3 value containing a purple color
  90947. * @returns a new Color3 object
  90948. */
  90949. static Purple(): Color3;
  90950. /**
  90951. * Returns a Color3 value containing a magenta color
  90952. * @returns a new Color3 object
  90953. */
  90954. static Magenta(): Color3;
  90955. /**
  90956. * Returns a Color3 value containing a yellow color
  90957. * @returns a new Color3 object
  90958. */
  90959. static Yellow(): Color3;
  90960. /**
  90961. * Returns a Color3 value containing a gray color
  90962. * @returns a new Color3 object
  90963. */
  90964. static Gray(): Color3;
  90965. /**
  90966. * Returns a Color3 value containing a teal color
  90967. * @returns a new Color3 object
  90968. */
  90969. static Teal(): Color3;
  90970. /**
  90971. * Returns a Color3 value containing a random color
  90972. * @returns a new Color3 object
  90973. */
  90974. static Random(): Color3;
  90975. }
  90976. /**
  90977. * Class used to hold a RBGA color
  90978. */
  90979. export class Color4 {
  90980. /**
  90981. * Defines the red component (between 0 and 1, default is 0)
  90982. */
  90983. r: number;
  90984. /**
  90985. * Defines the green component (between 0 and 1, default is 0)
  90986. */
  90987. g: number;
  90988. /**
  90989. * Defines the blue component (between 0 and 1, default is 0)
  90990. */
  90991. b: number;
  90992. /**
  90993. * Defines the alpha component (between 0 and 1, default is 1)
  90994. */
  90995. a: number;
  90996. /**
  90997. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  90998. * @param r defines the red component (between 0 and 1, default is 0)
  90999. * @param g defines the green component (between 0 and 1, default is 0)
  91000. * @param b defines the blue component (between 0 and 1, default is 0)
  91001. * @param a defines the alpha component (between 0 and 1, default is 1)
  91002. */
  91003. constructor(
  91004. /**
  91005. * Defines the red component (between 0 and 1, default is 0)
  91006. */
  91007. r?: number,
  91008. /**
  91009. * Defines the green component (between 0 and 1, default is 0)
  91010. */
  91011. g?: number,
  91012. /**
  91013. * Defines the blue component (between 0 and 1, default is 0)
  91014. */
  91015. b?: number,
  91016. /**
  91017. * Defines the alpha component (between 0 and 1, default is 1)
  91018. */
  91019. a?: number);
  91020. /**
  91021. * Adds in place the given Color4 values to the current Color4 object
  91022. * @param right defines the second operand
  91023. * @returns the current updated Color4 object
  91024. */
  91025. addInPlace(right: DeepImmutable<Color4>): Color4;
  91026. /**
  91027. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  91028. * @returns the new array
  91029. */
  91030. asArray(): number[];
  91031. /**
  91032. * Stores from the starting index in the given array the Color4 successive values
  91033. * @param array defines the array where to store the r,g,b components
  91034. * @param index defines an optional index in the target array to define where to start storing values
  91035. * @returns the current Color4 object
  91036. */
  91037. toArray(array: number[], index?: number): Color4;
  91038. /**
  91039. * Update the current color with values stored in an array from the starting index of the given array
  91040. * @param array defines the source array
  91041. * @param offset defines an offset in the source array
  91042. * @returns the current Color4 object
  91043. */
  91044. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91045. /**
  91046. * Determines equality between Color4 objects
  91047. * @param otherColor defines the second operand
  91048. * @returns true if the rgba values are equal to the given ones
  91049. */
  91050. equals(otherColor: DeepImmutable<Color4>): boolean;
  91051. /**
  91052. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  91053. * @param right defines the second operand
  91054. * @returns a new Color4 object
  91055. */
  91056. add(right: DeepImmutable<Color4>): Color4;
  91057. /**
  91058. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  91059. * @param right defines the second operand
  91060. * @returns a new Color4 object
  91061. */
  91062. subtract(right: DeepImmutable<Color4>): Color4;
  91063. /**
  91064. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  91065. * @param right defines the second operand
  91066. * @param result defines the Color4 object where to store the result
  91067. * @returns the current Color4 object
  91068. */
  91069. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  91070. /**
  91071. * Creates a new Color4 with the current Color4 values multiplied by scale
  91072. * @param scale defines the scaling factor to apply
  91073. * @returns a new Color4 object
  91074. */
  91075. scale(scale: number): Color4;
  91076. /**
  91077. * Multiplies the current Color4 values by scale and stores the result in "result"
  91078. * @param scale defines the scaling factor to apply
  91079. * @param result defines the Color4 object where to store the result
  91080. * @returns the current unmodified Color4
  91081. */
  91082. scaleToRef(scale: number, result: Color4): Color4;
  91083. /**
  91084. * Scale the current Color4 values by a factor and add the result to a given Color4
  91085. * @param scale defines the scale factor
  91086. * @param result defines the Color4 object where to store the result
  91087. * @returns the unmodified current Color4
  91088. */
  91089. scaleAndAddToRef(scale: number, result: Color4): Color4;
  91090. /**
  91091. * Clamps the rgb values by the min and max values and stores the result into "result"
  91092. * @param min defines minimum clamping value (default is 0)
  91093. * @param max defines maximum clamping value (default is 1)
  91094. * @param result defines color to store the result into.
  91095. * @returns the cuurent Color4
  91096. */
  91097. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  91098. /**
  91099. * Multipy an Color4 value by another and return a new Color4 object
  91100. * @param color defines the Color4 value to multiply by
  91101. * @returns a new Color4 object
  91102. */
  91103. multiply(color: Color4): Color4;
  91104. /**
  91105. * Multipy a Color4 value by another and push the result in a reference value
  91106. * @param color defines the Color4 value to multiply by
  91107. * @param result defines the Color4 to fill the result in
  91108. * @returns the result Color4
  91109. */
  91110. multiplyToRef(color: Color4, result: Color4): Color4;
  91111. /**
  91112. * Creates a string with the Color4 current values
  91113. * @returns the string representation of the Color4 object
  91114. */
  91115. toString(): string;
  91116. /**
  91117. * Returns the string "Color4"
  91118. * @returns "Color4"
  91119. */
  91120. getClassName(): string;
  91121. /**
  91122. * Compute the Color4 hash code
  91123. * @returns an unique number that can be used to hash Color4 objects
  91124. */
  91125. getHashCode(): number;
  91126. /**
  91127. * Creates a new Color4 copied from the current one
  91128. * @returns a new Color4 object
  91129. */
  91130. clone(): Color4;
  91131. /**
  91132. * Copies the given Color4 values into the current one
  91133. * @param source defines the source Color4 object
  91134. * @returns the current updated Color4 object
  91135. */
  91136. copyFrom(source: Color4): Color4;
  91137. /**
  91138. * Copies the given float values into the current one
  91139. * @param r defines the red component to read from
  91140. * @param g defines the green component to read from
  91141. * @param b defines the blue component to read from
  91142. * @param a defines the alpha component to read from
  91143. * @returns the current updated Color4 object
  91144. */
  91145. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  91146. /**
  91147. * Copies the given float values into the current one
  91148. * @param r defines the red component to read from
  91149. * @param g defines the green component to read from
  91150. * @param b defines the blue component to read from
  91151. * @param a defines the alpha component to read from
  91152. * @returns the current updated Color4 object
  91153. */
  91154. set(r: number, g: number, b: number, a: number): Color4;
  91155. /**
  91156. * Compute the Color4 hexadecimal code as a string
  91157. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  91158. * @returns a string containing the hexadecimal representation of the Color4 object
  91159. */
  91160. toHexString(returnAsColor3?: boolean): string;
  91161. /**
  91162. * Computes a new Color4 converted from the current one to linear space
  91163. * @returns a new Color4 object
  91164. */
  91165. toLinearSpace(): Color4;
  91166. /**
  91167. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  91168. * @param convertedColor defines the Color4 object where to store the linear space version
  91169. * @returns the unmodified Color4
  91170. */
  91171. toLinearSpaceToRef(convertedColor: Color4): Color4;
  91172. /**
  91173. * Computes a new Color4 converted from the current one to gamma space
  91174. * @returns a new Color4 object
  91175. */
  91176. toGammaSpace(): Color4;
  91177. /**
  91178. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  91179. * @param convertedColor defines the Color4 object where to store the gamma space version
  91180. * @returns the unmodified Color4
  91181. */
  91182. toGammaSpaceToRef(convertedColor: Color4): Color4;
  91183. /**
  91184. * Creates a new Color4 from the string containing valid hexadecimal values
  91185. * @param hex defines a string containing valid hexadecimal values
  91186. * @returns a new Color4 object
  91187. */
  91188. static FromHexString(hex: string): Color4;
  91189. /**
  91190. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91191. * @param left defines the start value
  91192. * @param right defines the end value
  91193. * @param amount defines the gradient factor
  91194. * @returns a new Color4 object
  91195. */
  91196. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  91197. /**
  91198. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91199. * @param left defines the start value
  91200. * @param right defines the end value
  91201. * @param amount defines the gradient factor
  91202. * @param result defines the Color4 object where to store data
  91203. */
  91204. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  91205. /**
  91206. * Creates a new Color4 from a Color3 and an alpha value
  91207. * @param color3 defines the source Color3 to read from
  91208. * @param alpha defines the alpha component (1.0 by default)
  91209. * @returns a new Color4 object
  91210. */
  91211. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  91212. /**
  91213. * Creates a new Color4 from the starting index element of the given array
  91214. * @param array defines the source array to read from
  91215. * @param offset defines the offset in the source array
  91216. * @returns a new Color4 object
  91217. */
  91218. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91219. /**
  91220. * Creates a new Color4 from the starting index element of the given array
  91221. * @param array defines the source array to read from
  91222. * @param offset defines the offset in the source array
  91223. * @param result defines the target Color4 object
  91224. */
  91225. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  91226. /**
  91227. * Creates a new Color3 from integer values (< 256)
  91228. * @param r defines the red component to read from (value between 0 and 255)
  91229. * @param g defines the green component to read from (value between 0 and 255)
  91230. * @param b defines the blue component to read from (value between 0 and 255)
  91231. * @param a defines the alpha component to read from (value between 0 and 255)
  91232. * @returns a new Color3 object
  91233. */
  91234. static FromInts(r: number, g: number, b: number, a: number): Color4;
  91235. /**
  91236. * Check the content of a given array and convert it to an array containing RGBA data
  91237. * If the original array was already containing count * 4 values then it is returned directly
  91238. * @param colors defines the array to check
  91239. * @param count defines the number of RGBA data to expect
  91240. * @returns an array containing count * 4 values (RGBA)
  91241. */
  91242. static CheckColors4(colors: number[], count: number): number[];
  91243. }
  91244. /**
  91245. * @hidden
  91246. */
  91247. export class TmpColors {
  91248. static Color3: Color3[];
  91249. static Color4: Color4[];
  91250. }
  91251. }
  91252. declare module BABYLON {
  91253. /**
  91254. * Defines an interface which represents an animation key frame
  91255. */
  91256. export interface IAnimationKey {
  91257. /**
  91258. * Frame of the key frame
  91259. */
  91260. frame: number;
  91261. /**
  91262. * Value at the specifies key frame
  91263. */
  91264. value: any;
  91265. /**
  91266. * The input tangent for the cubic hermite spline
  91267. */
  91268. inTangent?: any;
  91269. /**
  91270. * The output tangent for the cubic hermite spline
  91271. */
  91272. outTangent?: any;
  91273. /**
  91274. * The animation interpolation type
  91275. */
  91276. interpolation?: AnimationKeyInterpolation;
  91277. }
  91278. /**
  91279. * Enum for the animation key frame interpolation type
  91280. */
  91281. export enum AnimationKeyInterpolation {
  91282. /**
  91283. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  91284. */
  91285. STEP = 1
  91286. }
  91287. }
  91288. declare module BABYLON {
  91289. /**
  91290. * Represents the range of an animation
  91291. */
  91292. export class AnimationRange {
  91293. /**The name of the animation range**/
  91294. name: string;
  91295. /**The starting frame of the animation */
  91296. from: number;
  91297. /**The ending frame of the animation*/
  91298. to: number;
  91299. /**
  91300. * Initializes the range of an animation
  91301. * @param name The name of the animation range
  91302. * @param from The starting frame of the animation
  91303. * @param to The ending frame of the animation
  91304. */
  91305. constructor(
  91306. /**The name of the animation range**/
  91307. name: string,
  91308. /**The starting frame of the animation */
  91309. from: number,
  91310. /**The ending frame of the animation*/
  91311. to: number);
  91312. /**
  91313. * Makes a copy of the animation range
  91314. * @returns A copy of the animation range
  91315. */
  91316. clone(): AnimationRange;
  91317. }
  91318. }
  91319. declare module BABYLON {
  91320. /**
  91321. * Composed of a frame, and an action function
  91322. */
  91323. export class AnimationEvent {
  91324. /** The frame for which the event is triggered **/
  91325. frame: number;
  91326. /** The event to perform when triggered **/
  91327. action: (currentFrame: number) => void;
  91328. /** Specifies if the event should be triggered only once**/
  91329. onlyOnce?: boolean | undefined;
  91330. /**
  91331. * Specifies if the animation event is done
  91332. */
  91333. isDone: boolean;
  91334. /**
  91335. * Initializes the animation event
  91336. * @param frame The frame for which the event is triggered
  91337. * @param action The event to perform when triggered
  91338. * @param onlyOnce Specifies if the event should be triggered only once
  91339. */
  91340. constructor(
  91341. /** The frame for which the event is triggered **/
  91342. frame: number,
  91343. /** The event to perform when triggered **/
  91344. action: (currentFrame: number) => void,
  91345. /** Specifies if the event should be triggered only once**/
  91346. onlyOnce?: boolean | undefined);
  91347. /** @hidden */
  91348. _clone(): AnimationEvent;
  91349. }
  91350. }
  91351. declare module BABYLON {
  91352. /**
  91353. * Interface used to define a behavior
  91354. */
  91355. export interface Behavior<T> {
  91356. /** gets or sets behavior's name */
  91357. name: string;
  91358. /**
  91359. * Function called when the behavior needs to be initialized (after attaching it to a target)
  91360. */
  91361. init(): void;
  91362. /**
  91363. * Called when the behavior is attached to a target
  91364. * @param target defines the target where the behavior is attached to
  91365. */
  91366. attach(target: T): void;
  91367. /**
  91368. * Called when the behavior is detached from its target
  91369. */
  91370. detach(): void;
  91371. }
  91372. /**
  91373. * Interface implemented by classes supporting behaviors
  91374. */
  91375. export interface IBehaviorAware<T> {
  91376. /**
  91377. * Attach a behavior
  91378. * @param behavior defines the behavior to attach
  91379. * @returns the current host
  91380. */
  91381. addBehavior(behavior: Behavior<T>): T;
  91382. /**
  91383. * Remove a behavior from the current object
  91384. * @param behavior defines the behavior to detach
  91385. * @returns the current host
  91386. */
  91387. removeBehavior(behavior: Behavior<T>): T;
  91388. /**
  91389. * Gets a behavior using its name to search
  91390. * @param name defines the name to search
  91391. * @returns the behavior or null if not found
  91392. */
  91393. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  91394. }
  91395. }
  91396. declare module BABYLON {
  91397. /**
  91398. * Class used to store data that will be store in GPU memory
  91399. */
  91400. export class Buffer {
  91401. private _engine;
  91402. private _buffer;
  91403. /** @hidden */
  91404. _data: Nullable<DataArray>;
  91405. private _updatable;
  91406. private _instanced;
  91407. private _divisor;
  91408. private _isAlreadyOwned;
  91409. /**
  91410. * Gets the byte stride.
  91411. */
  91412. readonly byteStride: number;
  91413. /**
  91414. * Constructor
  91415. * @param engine the engine
  91416. * @param data the data to use for this buffer
  91417. * @param updatable whether the data is updatable
  91418. * @param stride the stride (optional)
  91419. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91420. * @param instanced whether the buffer is instanced (optional)
  91421. * @param useBytes set to true if the stride in in bytes (optional)
  91422. * @param divisor sets an optional divisor for instances (1 by default)
  91423. */
  91424. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  91425. /**
  91426. * Create a new VertexBuffer based on the current buffer
  91427. * @param kind defines the vertex buffer kind (position, normal, etc.)
  91428. * @param offset defines offset in the buffer (0 by default)
  91429. * @param size defines the size in floats of attributes (position is 3 for instance)
  91430. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  91431. * @param instanced defines if the vertex buffer contains indexed data
  91432. * @param useBytes defines if the offset and stride are in bytes *
  91433. * @param divisor sets an optional divisor for instances (1 by default)
  91434. * @returns the new vertex buffer
  91435. */
  91436. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  91437. /**
  91438. * Gets a boolean indicating if the Buffer is updatable?
  91439. * @returns true if the buffer is updatable
  91440. */
  91441. isUpdatable(): boolean;
  91442. /**
  91443. * Gets current buffer's data
  91444. * @returns a DataArray or null
  91445. */
  91446. getData(): Nullable<DataArray>;
  91447. /**
  91448. * Gets underlying native buffer
  91449. * @returns underlying native buffer
  91450. */
  91451. getBuffer(): Nullable<DataBuffer>;
  91452. /**
  91453. * Gets the stride in float32 units (i.e. byte stride / 4).
  91454. * May not be an integer if the byte stride is not divisible by 4.
  91455. * @returns the stride in float32 units
  91456. * @deprecated Please use byteStride instead.
  91457. */
  91458. getStrideSize(): number;
  91459. /**
  91460. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  91461. * @param data defines the data to store
  91462. */
  91463. create(data?: Nullable<DataArray>): void;
  91464. /** @hidden */
  91465. _rebuild(): void;
  91466. /**
  91467. * Update current buffer data
  91468. * @param data defines the data to store
  91469. */
  91470. update(data: DataArray): void;
  91471. /**
  91472. * Updates the data directly.
  91473. * @param data the new data
  91474. * @param offset the new offset
  91475. * @param vertexCount the vertex count (optional)
  91476. * @param useBytes set to true if the offset is in bytes
  91477. */
  91478. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  91479. /** @hidden */
  91480. _increaseReferences(): void;
  91481. /**
  91482. * Release all resources
  91483. */
  91484. dispose(): void;
  91485. }
  91486. /**
  91487. * Specialized buffer used to store vertex data
  91488. */
  91489. export class VertexBuffer {
  91490. /** @hidden */
  91491. _buffer: Buffer;
  91492. private _kind;
  91493. private _size;
  91494. private _ownsBuffer;
  91495. private _instanced;
  91496. private _instanceDivisor;
  91497. /**
  91498. * The byte type.
  91499. */
  91500. static readonly BYTE: number;
  91501. /**
  91502. * The unsigned byte type.
  91503. */
  91504. static readonly UNSIGNED_BYTE: number;
  91505. /**
  91506. * The short type.
  91507. */
  91508. static readonly SHORT: number;
  91509. /**
  91510. * The unsigned short type.
  91511. */
  91512. static readonly UNSIGNED_SHORT: number;
  91513. /**
  91514. * The integer type.
  91515. */
  91516. static readonly INT: number;
  91517. /**
  91518. * The unsigned integer type.
  91519. */
  91520. static readonly UNSIGNED_INT: number;
  91521. /**
  91522. * The float type.
  91523. */
  91524. static readonly FLOAT: number;
  91525. /**
  91526. * Gets or sets the instance divisor when in instanced mode
  91527. */
  91528. get instanceDivisor(): number;
  91529. set instanceDivisor(value: number);
  91530. /**
  91531. * Gets the byte stride.
  91532. */
  91533. readonly byteStride: number;
  91534. /**
  91535. * Gets the byte offset.
  91536. */
  91537. readonly byteOffset: number;
  91538. /**
  91539. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  91540. */
  91541. readonly normalized: boolean;
  91542. /**
  91543. * Gets the data type of each component in the array.
  91544. */
  91545. readonly type: number;
  91546. /**
  91547. * Constructor
  91548. * @param engine the engine
  91549. * @param data the data to use for this vertex buffer
  91550. * @param kind the vertex buffer kind
  91551. * @param updatable whether the data is updatable
  91552. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91553. * @param stride the stride (optional)
  91554. * @param instanced whether the buffer is instanced (optional)
  91555. * @param offset the offset of the data (optional)
  91556. * @param size the number of components (optional)
  91557. * @param type the type of the component (optional)
  91558. * @param normalized whether the data contains normalized data (optional)
  91559. * @param useBytes set to true if stride and offset are in bytes (optional)
  91560. * @param divisor defines the instance divisor to use (1 by default)
  91561. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  91562. */
  91563. 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);
  91564. /** @hidden */
  91565. _rebuild(): void;
  91566. /**
  91567. * Returns the kind of the VertexBuffer (string)
  91568. * @returns a string
  91569. */
  91570. getKind(): string;
  91571. /**
  91572. * Gets a boolean indicating if the VertexBuffer is updatable?
  91573. * @returns true if the buffer is updatable
  91574. */
  91575. isUpdatable(): boolean;
  91576. /**
  91577. * Gets current buffer's data
  91578. * @returns a DataArray or null
  91579. */
  91580. getData(): Nullable<DataArray>;
  91581. /**
  91582. * Gets underlying native buffer
  91583. * @returns underlying native buffer
  91584. */
  91585. getBuffer(): Nullable<DataBuffer>;
  91586. /**
  91587. * Gets the stride in float32 units (i.e. byte stride / 4).
  91588. * May not be an integer if the byte stride is not divisible by 4.
  91589. * @returns the stride in float32 units
  91590. * @deprecated Please use byteStride instead.
  91591. */
  91592. getStrideSize(): number;
  91593. /**
  91594. * Returns the offset as a multiple of the type byte length.
  91595. * @returns the offset in bytes
  91596. * @deprecated Please use byteOffset instead.
  91597. */
  91598. getOffset(): number;
  91599. /**
  91600. * Returns the number of components per vertex attribute (integer)
  91601. * @returns the size in float
  91602. */
  91603. getSize(): number;
  91604. /**
  91605. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  91606. * @returns true if this buffer is instanced
  91607. */
  91608. getIsInstanced(): boolean;
  91609. /**
  91610. * Returns the instancing divisor, zero for non-instanced (integer).
  91611. * @returns a number
  91612. */
  91613. getInstanceDivisor(): number;
  91614. /**
  91615. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  91616. * @param data defines the data to store
  91617. */
  91618. create(data?: DataArray): void;
  91619. /**
  91620. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  91621. * This function will create a new buffer if the current one is not updatable
  91622. * @param data defines the data to store
  91623. */
  91624. update(data: DataArray): void;
  91625. /**
  91626. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  91627. * Returns the directly updated WebGLBuffer.
  91628. * @param data the new data
  91629. * @param offset the new offset
  91630. * @param useBytes set to true if the offset is in bytes
  91631. */
  91632. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  91633. /**
  91634. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  91635. */
  91636. dispose(): void;
  91637. /**
  91638. * Enumerates each value of this vertex buffer as numbers.
  91639. * @param count the number of values to enumerate
  91640. * @param callback the callback function called for each value
  91641. */
  91642. forEach(count: number, callback: (value: number, index: number) => void): void;
  91643. /**
  91644. * Positions
  91645. */
  91646. static readonly PositionKind: string;
  91647. /**
  91648. * Normals
  91649. */
  91650. static readonly NormalKind: string;
  91651. /**
  91652. * Tangents
  91653. */
  91654. static readonly TangentKind: string;
  91655. /**
  91656. * Texture coordinates
  91657. */
  91658. static readonly UVKind: string;
  91659. /**
  91660. * Texture coordinates 2
  91661. */
  91662. static readonly UV2Kind: string;
  91663. /**
  91664. * Texture coordinates 3
  91665. */
  91666. static readonly UV3Kind: string;
  91667. /**
  91668. * Texture coordinates 4
  91669. */
  91670. static readonly UV4Kind: string;
  91671. /**
  91672. * Texture coordinates 5
  91673. */
  91674. static readonly UV5Kind: string;
  91675. /**
  91676. * Texture coordinates 6
  91677. */
  91678. static readonly UV6Kind: string;
  91679. /**
  91680. * Colors
  91681. */
  91682. static readonly ColorKind: string;
  91683. /**
  91684. * Matrix indices (for bones)
  91685. */
  91686. static readonly MatricesIndicesKind: string;
  91687. /**
  91688. * Matrix weights (for bones)
  91689. */
  91690. static readonly MatricesWeightsKind: string;
  91691. /**
  91692. * Additional matrix indices (for bones)
  91693. */
  91694. static readonly MatricesIndicesExtraKind: string;
  91695. /**
  91696. * Additional matrix weights (for bones)
  91697. */
  91698. static readonly MatricesWeightsExtraKind: string;
  91699. /**
  91700. * Deduces the stride given a kind.
  91701. * @param kind The kind string to deduce
  91702. * @returns The deduced stride
  91703. */
  91704. static DeduceStride(kind: string): number;
  91705. /**
  91706. * Gets the byte length of the given type.
  91707. * @param type the type
  91708. * @returns the number of bytes
  91709. */
  91710. static GetTypeByteLength(type: number): number;
  91711. /**
  91712. * Enumerates each value of the given parameters as numbers.
  91713. * @param data the data to enumerate
  91714. * @param byteOffset the byte offset of the data
  91715. * @param byteStride the byte stride of the data
  91716. * @param componentCount the number of components per element
  91717. * @param componentType the type of the component
  91718. * @param count the number of values to enumerate
  91719. * @param normalized whether the data is normalized
  91720. * @param callback the callback function called for each value
  91721. */
  91722. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  91723. private static _GetFloatValue;
  91724. }
  91725. }
  91726. declare module BABYLON {
  91727. /**
  91728. * @hidden
  91729. */
  91730. export class IntersectionInfo {
  91731. bu: Nullable<number>;
  91732. bv: Nullable<number>;
  91733. distance: number;
  91734. faceId: number;
  91735. subMeshId: number;
  91736. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  91737. }
  91738. }
  91739. declare module BABYLON {
  91740. /**
  91741. * Class used to store bounding sphere information
  91742. */
  91743. export class BoundingSphere {
  91744. /**
  91745. * Gets the center of the bounding sphere in local space
  91746. */
  91747. readonly center: Vector3;
  91748. /**
  91749. * Radius of the bounding sphere in local space
  91750. */
  91751. radius: number;
  91752. /**
  91753. * Gets the center of the bounding sphere in world space
  91754. */
  91755. readonly centerWorld: Vector3;
  91756. /**
  91757. * Radius of the bounding sphere in world space
  91758. */
  91759. radiusWorld: number;
  91760. /**
  91761. * Gets the minimum vector in local space
  91762. */
  91763. readonly minimum: Vector3;
  91764. /**
  91765. * Gets the maximum vector in local space
  91766. */
  91767. readonly maximum: Vector3;
  91768. private _worldMatrix;
  91769. private static readonly TmpVector3;
  91770. /**
  91771. * Creates a new bounding sphere
  91772. * @param min defines the minimum vector (in local space)
  91773. * @param max defines the maximum vector (in local space)
  91774. * @param worldMatrix defines the new world matrix
  91775. */
  91776. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  91777. /**
  91778. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  91779. * @param min defines the new minimum vector (in local space)
  91780. * @param max defines the new maximum vector (in local space)
  91781. * @param worldMatrix defines the new world matrix
  91782. */
  91783. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  91784. /**
  91785. * Scale the current bounding sphere by applying a scale factor
  91786. * @param factor defines the scale factor to apply
  91787. * @returns the current bounding box
  91788. */
  91789. scale(factor: number): BoundingSphere;
  91790. /**
  91791. * Gets the world matrix of the bounding box
  91792. * @returns a matrix
  91793. */
  91794. getWorldMatrix(): DeepImmutable<Matrix>;
  91795. /** @hidden */
  91796. _update(worldMatrix: DeepImmutable<Matrix>): void;
  91797. /**
  91798. * Tests if the bounding sphere is intersecting the frustum planes
  91799. * @param frustumPlanes defines the frustum planes to test
  91800. * @returns true if there is an intersection
  91801. */
  91802. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91803. /**
  91804. * Tests if the bounding sphere center is in between the frustum planes.
  91805. * Used for optimistic fast inclusion.
  91806. * @param frustumPlanes defines the frustum planes to test
  91807. * @returns true if the sphere center is in between the frustum planes
  91808. */
  91809. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91810. /**
  91811. * Tests if a point is inside the bounding sphere
  91812. * @param point defines the point to test
  91813. * @returns true if the point is inside the bounding sphere
  91814. */
  91815. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  91816. /**
  91817. * Checks if two sphere intersct
  91818. * @param sphere0 sphere 0
  91819. * @param sphere1 sphere 1
  91820. * @returns true if the speres intersect
  91821. */
  91822. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  91823. }
  91824. }
  91825. declare module BABYLON {
  91826. /**
  91827. * Class used to store bounding box information
  91828. */
  91829. export class BoundingBox implements ICullable {
  91830. /**
  91831. * Gets the 8 vectors representing the bounding box in local space
  91832. */
  91833. readonly vectors: Vector3[];
  91834. /**
  91835. * Gets the center of the bounding box in local space
  91836. */
  91837. readonly center: Vector3;
  91838. /**
  91839. * Gets the center of the bounding box in world space
  91840. */
  91841. readonly centerWorld: Vector3;
  91842. /**
  91843. * Gets the extend size in local space
  91844. */
  91845. readonly extendSize: Vector3;
  91846. /**
  91847. * Gets the extend size in world space
  91848. */
  91849. readonly extendSizeWorld: Vector3;
  91850. /**
  91851. * Gets the OBB (object bounding box) directions
  91852. */
  91853. readonly directions: Vector3[];
  91854. /**
  91855. * Gets the 8 vectors representing the bounding box in world space
  91856. */
  91857. readonly vectorsWorld: Vector3[];
  91858. /**
  91859. * Gets the minimum vector in world space
  91860. */
  91861. readonly minimumWorld: Vector3;
  91862. /**
  91863. * Gets the maximum vector in world space
  91864. */
  91865. readonly maximumWorld: Vector3;
  91866. /**
  91867. * Gets the minimum vector in local space
  91868. */
  91869. readonly minimum: Vector3;
  91870. /**
  91871. * Gets the maximum vector in local space
  91872. */
  91873. readonly maximum: Vector3;
  91874. private _worldMatrix;
  91875. private static readonly TmpVector3;
  91876. /**
  91877. * @hidden
  91878. */
  91879. _tag: number;
  91880. /**
  91881. * Creates a new bounding box
  91882. * @param min defines the minimum vector (in local space)
  91883. * @param max defines the maximum vector (in local space)
  91884. * @param worldMatrix defines the new world matrix
  91885. */
  91886. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  91887. /**
  91888. * Recreates the entire bounding box from scratch as if we call the constructor in place
  91889. * @param min defines the new minimum vector (in local space)
  91890. * @param max defines the new maximum vector (in local space)
  91891. * @param worldMatrix defines the new world matrix
  91892. */
  91893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  91894. /**
  91895. * Scale the current bounding box by applying a scale factor
  91896. * @param factor defines the scale factor to apply
  91897. * @returns the current bounding box
  91898. */
  91899. scale(factor: number): BoundingBox;
  91900. /**
  91901. * Gets the world matrix of the bounding box
  91902. * @returns a matrix
  91903. */
  91904. getWorldMatrix(): DeepImmutable<Matrix>;
  91905. /** @hidden */
  91906. _update(world: DeepImmutable<Matrix>): void;
  91907. /**
  91908. * Tests if the bounding box is intersecting the frustum planes
  91909. * @param frustumPlanes defines the frustum planes to test
  91910. * @returns true if there is an intersection
  91911. */
  91912. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91913. /**
  91914. * Tests if the bounding box is entirely inside the frustum planes
  91915. * @param frustumPlanes defines the frustum planes to test
  91916. * @returns true if there is an inclusion
  91917. */
  91918. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91919. /**
  91920. * Tests if a point is inside the bounding box
  91921. * @param point defines the point to test
  91922. * @returns true if the point is inside the bounding box
  91923. */
  91924. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  91925. /**
  91926. * Tests if the bounding box intersects with a bounding sphere
  91927. * @param sphere defines the sphere to test
  91928. * @returns true if there is an intersection
  91929. */
  91930. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  91931. /**
  91932. * Tests if the bounding box intersects with a box defined by a min and max vectors
  91933. * @param min defines the min vector to use
  91934. * @param max defines the max vector to use
  91935. * @returns true if there is an intersection
  91936. */
  91937. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  91938. /**
  91939. * Tests if two bounding boxes are intersections
  91940. * @param box0 defines the first box to test
  91941. * @param box1 defines the second box to test
  91942. * @returns true if there is an intersection
  91943. */
  91944. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  91945. /**
  91946. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  91947. * @param minPoint defines the minimum vector of the bounding box
  91948. * @param maxPoint defines the maximum vector of the bounding box
  91949. * @param sphereCenter defines the sphere center
  91950. * @param sphereRadius defines the sphere radius
  91951. * @returns true if there is an intersection
  91952. */
  91953. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  91954. /**
  91955. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  91956. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  91957. * @param frustumPlanes defines the frustum planes to test
  91958. * @return true if there is an inclusion
  91959. */
  91960. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91961. /**
  91962. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  91963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  91964. * @param frustumPlanes defines the frustum planes to test
  91965. * @return true if there is an intersection
  91966. */
  91967. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91968. }
  91969. }
  91970. declare module BABYLON {
  91971. /** @hidden */
  91972. export class Collider {
  91973. /** Define if a collision was found */
  91974. collisionFound: boolean;
  91975. /**
  91976. * Define last intersection point in local space
  91977. */
  91978. intersectionPoint: Vector3;
  91979. /**
  91980. * Define last collided mesh
  91981. */
  91982. collidedMesh: Nullable<AbstractMesh>;
  91983. private _collisionPoint;
  91984. private _planeIntersectionPoint;
  91985. private _tempVector;
  91986. private _tempVector2;
  91987. private _tempVector3;
  91988. private _tempVector4;
  91989. private _edge;
  91990. private _baseToVertex;
  91991. private _destinationPoint;
  91992. private _slidePlaneNormal;
  91993. private _displacementVector;
  91994. /** @hidden */
  91995. _radius: Vector3;
  91996. /** @hidden */
  91997. _retry: number;
  91998. private _velocity;
  91999. private _basePoint;
  92000. private _epsilon;
  92001. /** @hidden */
  92002. _velocityWorldLength: number;
  92003. /** @hidden */
  92004. _basePointWorld: Vector3;
  92005. private _velocityWorld;
  92006. private _normalizedVelocity;
  92007. /** @hidden */
  92008. _initialVelocity: Vector3;
  92009. /** @hidden */
  92010. _initialPosition: Vector3;
  92011. private _nearestDistance;
  92012. private _collisionMask;
  92013. get collisionMask(): number;
  92014. set collisionMask(mask: number);
  92015. /**
  92016. * Gets the plane normal used to compute the sliding response (in local space)
  92017. */
  92018. get slidePlaneNormal(): Vector3;
  92019. /** @hidden */
  92020. _initialize(source: Vector3, dir: Vector3, e: number): void;
  92021. /** @hidden */
  92022. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  92023. /** @hidden */
  92024. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  92025. /** @hidden */
  92026. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92027. /** @hidden */
  92028. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92029. /** @hidden */
  92030. _getResponse(pos: Vector3, vel: Vector3): void;
  92031. }
  92032. }
  92033. declare module BABYLON {
  92034. /**
  92035. * Interface for cullable objects
  92036. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  92037. */
  92038. export interface ICullable {
  92039. /**
  92040. * Checks if the object or part of the object is in the frustum
  92041. * @param frustumPlanes Camera near/planes
  92042. * @returns true if the object is in frustum otherwise false
  92043. */
  92044. isInFrustum(frustumPlanes: Plane[]): boolean;
  92045. /**
  92046. * Checks if a cullable object (mesh...) is in the camera frustum
  92047. * Unlike isInFrustum this cheks the full bounding box
  92048. * @param frustumPlanes Camera near/planes
  92049. * @returns true if the object is in frustum otherwise false
  92050. */
  92051. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92052. }
  92053. /**
  92054. * Info for a bounding data of a mesh
  92055. */
  92056. export class BoundingInfo implements ICullable {
  92057. /**
  92058. * Bounding box for the mesh
  92059. */
  92060. readonly boundingBox: BoundingBox;
  92061. /**
  92062. * Bounding sphere for the mesh
  92063. */
  92064. readonly boundingSphere: BoundingSphere;
  92065. private _isLocked;
  92066. private static readonly TmpVector3;
  92067. /**
  92068. * Constructs bounding info
  92069. * @param minimum min vector of the bounding box/sphere
  92070. * @param maximum max vector of the bounding box/sphere
  92071. * @param worldMatrix defines the new world matrix
  92072. */
  92073. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92074. /**
  92075. * Recreates the entire bounding info from scratch as if we call the constructor in place
  92076. * @param min defines the new minimum vector (in local space)
  92077. * @param max defines the new maximum vector (in local space)
  92078. * @param worldMatrix defines the new world matrix
  92079. */
  92080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92081. /**
  92082. * min vector of the bounding box/sphere
  92083. */
  92084. get minimum(): Vector3;
  92085. /**
  92086. * max vector of the bounding box/sphere
  92087. */
  92088. get maximum(): Vector3;
  92089. /**
  92090. * If the info is locked and won't be updated to avoid perf overhead
  92091. */
  92092. get isLocked(): boolean;
  92093. set isLocked(value: boolean);
  92094. /**
  92095. * Updates the bounding sphere and box
  92096. * @param world world matrix to be used to update
  92097. */
  92098. update(world: DeepImmutable<Matrix>): void;
  92099. /**
  92100. * Recreate the bounding info to be centered around a specific point given a specific extend.
  92101. * @param center New center of the bounding info
  92102. * @param extend New extend of the bounding info
  92103. * @returns the current bounding info
  92104. */
  92105. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  92106. /**
  92107. * Scale the current bounding info by applying a scale factor
  92108. * @param factor defines the scale factor to apply
  92109. * @returns the current bounding info
  92110. */
  92111. scale(factor: number): BoundingInfo;
  92112. /**
  92113. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  92114. * @param frustumPlanes defines the frustum to test
  92115. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  92116. * @returns true if the bounding info is in the frustum planes
  92117. */
  92118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  92119. /**
  92120. * Gets the world distance between the min and max points of the bounding box
  92121. */
  92122. get diagonalLength(): number;
  92123. /**
  92124. * Checks if a cullable object (mesh...) is in the camera frustum
  92125. * Unlike isInFrustum this cheks the full bounding box
  92126. * @param frustumPlanes Camera near/planes
  92127. * @returns true if the object is in frustum otherwise false
  92128. */
  92129. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92130. /** @hidden */
  92131. _checkCollision(collider: Collider): boolean;
  92132. /**
  92133. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  92134. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92135. * @param point the point to check intersection with
  92136. * @returns if the point intersects
  92137. */
  92138. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92139. /**
  92140. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  92141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92142. * @param boundingInfo the bounding info to check intersection with
  92143. * @param precise if the intersection should be done using OBB
  92144. * @returns if the bounding info intersects
  92145. */
  92146. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  92147. }
  92148. }
  92149. declare module BABYLON {
  92150. /**
  92151. * Extracts minimum and maximum values from a list of indexed positions
  92152. * @param positions defines the positions to use
  92153. * @param indices defines the indices to the positions
  92154. * @param indexStart defines the start index
  92155. * @param indexCount defines the end index
  92156. * @param bias defines bias value to add to the result
  92157. * @return minimum and maximum values
  92158. */
  92159. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  92160. minimum: Vector3;
  92161. maximum: Vector3;
  92162. };
  92163. /**
  92164. * Extracts minimum and maximum values from a list of positions
  92165. * @param positions defines the positions to use
  92166. * @param start defines the start index in the positions array
  92167. * @param count defines the number of positions to handle
  92168. * @param bias defines bias value to add to the result
  92169. * @param stride defines the stride size to use (distance between two positions in the positions array)
  92170. * @return minimum and maximum values
  92171. */
  92172. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  92173. minimum: Vector3;
  92174. maximum: Vector3;
  92175. };
  92176. }
  92177. declare module BABYLON {
  92178. /**
  92179. * Class used to manipulate GUIDs
  92180. */
  92181. export class GUID {
  92182. /**
  92183. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92184. * Be aware Math.random() could cause collisions, but:
  92185. * "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"
  92186. * @returns a pseudo random id
  92187. */
  92188. static RandomId(): string;
  92189. }
  92190. }
  92191. declare module BABYLON {
  92192. /**
  92193. * Base class of all the textures in babylon.
  92194. * It groups all the common properties the materials, post process, lights... might need
  92195. * in order to make a correct use of the texture.
  92196. */
  92197. export class BaseTexture extends ThinTexture implements IAnimatable {
  92198. /**
  92199. * Default anisotropic filtering level for the application.
  92200. * It is set to 4 as a good tradeoff between perf and quality.
  92201. */
  92202. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92203. /**
  92204. * Gets or sets the unique id of the texture
  92205. */
  92206. uniqueId: number;
  92207. /**
  92208. * Define the name of the texture.
  92209. */
  92210. name: string;
  92211. /**
  92212. * Gets or sets an object used to store user defined information.
  92213. */
  92214. metadata: any;
  92215. /**
  92216. * For internal use only. Please do not use.
  92217. */
  92218. reservedDataStore: any;
  92219. private _hasAlpha;
  92220. /**
  92221. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92222. */
  92223. get hasAlpha(): boolean;
  92224. set hasAlpha(value: boolean);
  92225. /**
  92226. * Defines if the alpha value should be determined via the rgb values.
  92227. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92228. */
  92229. getAlphaFromRGB: boolean;
  92230. /**
  92231. * Intensity or strength of the texture.
  92232. * It is commonly used by materials to fine tune the intensity of the texture
  92233. */
  92234. level: number;
  92235. /**
  92236. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92237. * This is part of the texture as textures usually maps to one uv set.
  92238. */
  92239. coordinatesIndex: number;
  92240. protected _coordinatesMode: number;
  92241. /**
  92242. * How a texture is mapped.
  92243. *
  92244. * | Value | Type | Description |
  92245. * | ----- | ----------------------------------- | ----------- |
  92246. * | 0 | EXPLICIT_MODE | |
  92247. * | 1 | SPHERICAL_MODE | |
  92248. * | 2 | PLANAR_MODE | |
  92249. * | 3 | CUBIC_MODE | |
  92250. * | 4 | PROJECTION_MODE | |
  92251. * | 5 | SKYBOX_MODE | |
  92252. * | 6 | INVCUBIC_MODE | |
  92253. * | 7 | EQUIRECTANGULAR_MODE | |
  92254. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92255. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92256. */
  92257. set coordinatesMode(value: number);
  92258. get coordinatesMode(): number;
  92259. /**
  92260. * | Value | Type | Description |
  92261. * | ----- | ------------------ | ----------- |
  92262. * | 0 | CLAMP_ADDRESSMODE | |
  92263. * | 1 | WRAP_ADDRESSMODE | |
  92264. * | 2 | MIRROR_ADDRESSMODE | |
  92265. */
  92266. get wrapU(): number;
  92267. set wrapU(value: number);
  92268. /**
  92269. * | Value | Type | Description |
  92270. * | ----- | ------------------ | ----------- |
  92271. * | 0 | CLAMP_ADDRESSMODE | |
  92272. * | 1 | WRAP_ADDRESSMODE | |
  92273. * | 2 | MIRROR_ADDRESSMODE | |
  92274. */
  92275. get wrapV(): number;
  92276. set wrapV(value: number);
  92277. /**
  92278. * | Value | Type | Description |
  92279. * | ----- | ------------------ | ----------- |
  92280. * | 0 | CLAMP_ADDRESSMODE | |
  92281. * | 1 | WRAP_ADDRESSMODE | |
  92282. * | 2 | MIRROR_ADDRESSMODE | |
  92283. */
  92284. wrapR: number;
  92285. /**
  92286. * With compliant hardware and browser (supporting anisotropic filtering)
  92287. * this defines the level of anisotropic filtering in the texture.
  92288. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92289. */
  92290. anisotropicFilteringLevel: number;
  92291. private _isCube;
  92292. /**
  92293. * Define if the texture is a cube texture or if false a 2d texture.
  92294. */
  92295. get isCube(): boolean;
  92296. set isCube(value: boolean);
  92297. /**
  92298. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92299. */
  92300. get is3D(): boolean;
  92301. set is3D(value: boolean);
  92302. /**
  92303. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  92304. */
  92305. get is2DArray(): boolean;
  92306. set is2DArray(value: boolean);
  92307. private _gammaSpace;
  92308. /**
  92309. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92310. * HDR texture are usually stored in linear space.
  92311. * This only impacts the PBR and Background materials
  92312. */
  92313. get gammaSpace(): boolean;
  92314. set gammaSpace(gamma: boolean);
  92315. /**
  92316. * Gets or sets whether or not the texture contains RGBD data.
  92317. */
  92318. get isRGBD(): boolean;
  92319. set isRGBD(value: boolean);
  92320. /**
  92321. * Is Z inverted in the texture (useful in a cube texture).
  92322. */
  92323. invertZ: boolean;
  92324. /**
  92325. * Are mip maps generated for this texture or not.
  92326. */
  92327. get noMipmap(): boolean;
  92328. /**
  92329. * @hidden
  92330. */
  92331. lodLevelInAlpha: boolean;
  92332. /**
  92333. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92334. */
  92335. get lodGenerationOffset(): number;
  92336. set lodGenerationOffset(value: number);
  92337. /**
  92338. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92339. */
  92340. get lodGenerationScale(): number;
  92341. set lodGenerationScale(value: number);
  92342. /**
  92343. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92344. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92345. * average roughness values.
  92346. */
  92347. get linearSpecularLOD(): boolean;
  92348. set linearSpecularLOD(value: boolean);
  92349. /**
  92350. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92351. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92352. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92353. */
  92354. get irradianceTexture(): Nullable<BaseTexture>;
  92355. set irradianceTexture(value: Nullable<BaseTexture>);
  92356. /**
  92357. * Define if the texture is a render target.
  92358. */
  92359. isRenderTarget: boolean;
  92360. /**
  92361. * Define the unique id of the texture in the scene.
  92362. */
  92363. get uid(): string;
  92364. /** @hidden */
  92365. _prefiltered: boolean;
  92366. /**
  92367. * Return a string representation of the texture.
  92368. * @returns the texture as a string
  92369. */
  92370. toString(): string;
  92371. /**
  92372. * Get the class name of the texture.
  92373. * @returns "BaseTexture"
  92374. */
  92375. getClassName(): string;
  92376. /**
  92377. * Define the list of animation attached to the texture.
  92378. */
  92379. animations: Animation[];
  92380. /**
  92381. * An event triggered when the texture is disposed.
  92382. */
  92383. onDisposeObservable: Observable<BaseTexture>;
  92384. private _onDisposeObserver;
  92385. /**
  92386. * Callback triggered when the texture has been disposed.
  92387. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92388. */
  92389. set onDispose(callback: () => void);
  92390. protected _scene: Nullable<Scene>;
  92391. /** @hidden */
  92392. _texture: Nullable<InternalTexture>;
  92393. private _uid;
  92394. /**
  92395. * Define if the texture is preventinga material to render or not.
  92396. * If not and the texture is not ready, the engine will use a default black texture instead.
  92397. */
  92398. get isBlocking(): boolean;
  92399. /**
  92400. * Instantiates a new BaseTexture.
  92401. * Base class of all the textures in babylon.
  92402. * It groups all the common properties the materials, post process, lights... might need
  92403. * in order to make a correct use of the texture.
  92404. * @param sceneOrEngine Define the scene or engine the texture blongs to
  92405. */
  92406. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  92407. /**
  92408. * Get the scene the texture belongs to.
  92409. * @returns the scene or null if undefined
  92410. */
  92411. getScene(): Nullable<Scene>;
  92412. /** @hidden */
  92413. protected _getEngine(): Nullable<ThinEngine>;
  92414. /**
  92415. * Checks if the texture has the same transform matrix than another texture
  92416. * @param texture texture to check against
  92417. * @returns true if the transforms are the same, else false
  92418. */
  92419. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  92420. /**
  92421. * Get the texture transform matrix used to offset tile the texture for istance.
  92422. * @returns the transformation matrix
  92423. */
  92424. getTextureMatrix(): Matrix;
  92425. /**
  92426. * Get the texture reflection matrix used to rotate/transform the reflection.
  92427. * @returns the reflection matrix
  92428. */
  92429. getReflectionTextureMatrix(): Matrix;
  92430. /**
  92431. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92432. * @returns true if ready or not blocking
  92433. */
  92434. isReadyOrNotBlocking(): boolean;
  92435. /**
  92436. * Scales the texture if is `canRescale()`
  92437. * @param ratio the resize factor we want to use to rescale
  92438. */
  92439. scale(ratio: number): void;
  92440. /**
  92441. * Get if the texture can rescale.
  92442. */
  92443. get canRescale(): boolean;
  92444. /** @hidden */
  92445. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92446. /** @hidden */
  92447. _rebuild(): void;
  92448. /**
  92449. * Clones the texture.
  92450. * @returns the cloned texture
  92451. */
  92452. clone(): Nullable<BaseTexture>;
  92453. /**
  92454. * Get the texture underlying type (INT, FLOAT...)
  92455. */
  92456. get textureType(): number;
  92457. /**
  92458. * Get the texture underlying format (RGB, RGBA...)
  92459. */
  92460. get textureFormat(): number;
  92461. /**
  92462. * Indicates that textures need to be re-calculated for all materials
  92463. */
  92464. protected _markAllSubMeshesAsTexturesDirty(): void;
  92465. /**
  92466. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92467. * This will returns an RGBA array buffer containing either in values (0-255) or
  92468. * float values (0-1) depending of the underlying buffer type.
  92469. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92470. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92471. * @param buffer defines a user defined buffer to fill with data (can be null)
  92472. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  92473. * @returns The Array buffer promise containing the pixels data.
  92474. */
  92475. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  92476. /** @hidden */
  92477. get _lodTextureHigh(): Nullable<BaseTexture>;
  92478. /** @hidden */
  92479. get _lodTextureMid(): Nullable<BaseTexture>;
  92480. /** @hidden */
  92481. get _lodTextureLow(): Nullable<BaseTexture>;
  92482. /**
  92483. * Dispose the texture and release its associated resources.
  92484. */
  92485. dispose(): void;
  92486. /**
  92487. * Serialize the texture into a JSON representation that can be parsed later on.
  92488. * @returns the JSON representation of the texture
  92489. */
  92490. serialize(): any;
  92491. /**
  92492. * Helper function to be called back once a list of texture contains only ready textures.
  92493. * @param textures Define the list of textures to wait for
  92494. * @param callback Define the callback triggered once the entire list will be ready
  92495. */
  92496. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92497. private static _isScene;
  92498. }
  92499. }
  92500. declare module BABYLON {
  92501. /** @hidden */
  92502. export class WebGLDataBuffer extends DataBuffer {
  92503. private _buffer;
  92504. constructor(resource: WebGLBuffer);
  92505. get underlyingResource(): any;
  92506. }
  92507. }
  92508. declare module BABYLON {
  92509. /** @hidden */
  92510. export class WebGLPipelineContext implements IPipelineContext {
  92511. private _valueCache;
  92512. private _uniforms;
  92513. engine: ThinEngine;
  92514. program: Nullable<WebGLProgram>;
  92515. context?: WebGLRenderingContext;
  92516. vertexShader?: WebGLShader;
  92517. fragmentShader?: WebGLShader;
  92518. isParallelCompiled: boolean;
  92519. onCompiled?: () => void;
  92520. transformFeedback?: WebGLTransformFeedback | null;
  92521. vertexCompilationError: Nullable<string>;
  92522. fragmentCompilationError: Nullable<string>;
  92523. programLinkError: Nullable<string>;
  92524. programValidationError: Nullable<string>;
  92525. get isAsync(): boolean;
  92526. get isReady(): boolean;
  92527. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  92528. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  92529. [key: string]: number;
  92530. }, uniformsNames: string[], uniforms: {
  92531. [key: string]: Nullable<WebGLUniformLocation>;
  92532. }, samplerList: string[], samplers: {
  92533. [key: string]: number;
  92534. }, attributesNames: string[], attributes: number[]): void;
  92535. /**
  92536. * Release all associated resources.
  92537. **/
  92538. dispose(): void;
  92539. /** @hidden */
  92540. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92541. /** @hidden */
  92542. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92543. /** @hidden */
  92544. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92545. /** @hidden */
  92546. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92547. /**
  92548. * Sets an interger value on a uniform variable.
  92549. * @param uniformName Name of the variable.
  92550. * @param value Value to be set.
  92551. */
  92552. setInt(uniformName: string, value: number): void;
  92553. /**
  92554. * Sets a int2 on a uniform variable.
  92555. * @param uniformName Name of the variable.
  92556. * @param x First int in int2.
  92557. * @param y Second int in int2.
  92558. */
  92559. setInt2(uniformName: string, x: number, y: number): void;
  92560. /**
  92561. * Sets a int3 on a uniform variable.
  92562. * @param uniformName Name of the variable.
  92563. * @param x First int in int3.
  92564. * @param y Second int in int3.
  92565. * @param y Third int in int3.
  92566. */
  92567. setInt3(uniformName: string, x: number, y: number, z: number): void;
  92568. /**
  92569. * Sets a int4 on a uniform variable.
  92570. * @param uniformName Name of the variable.
  92571. * @param x First int in int4.
  92572. * @param y Second int in int4.
  92573. * @param y Third int in int4.
  92574. * @param w Fourth int in int4.
  92575. */
  92576. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  92577. /**
  92578. * Sets an int array on a uniform variable.
  92579. * @param uniformName Name of the variable.
  92580. * @param array array to be set.
  92581. */
  92582. setIntArray(uniformName: string, array: Int32Array): void;
  92583. /**
  92584. * 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)
  92585. * @param uniformName Name of the variable.
  92586. * @param array array to be set.
  92587. */
  92588. setIntArray2(uniformName: string, array: Int32Array): void;
  92589. /**
  92590. * 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)
  92591. * @param uniformName Name of the variable.
  92592. * @param array array to be set.
  92593. */
  92594. setIntArray3(uniformName: string, array: Int32Array): void;
  92595. /**
  92596. * 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)
  92597. * @param uniformName Name of the variable.
  92598. * @param array array to be set.
  92599. */
  92600. setIntArray4(uniformName: string, array: Int32Array): void;
  92601. /**
  92602. * Sets an array on a uniform variable.
  92603. * @param uniformName Name of the variable.
  92604. * @param array array to be set.
  92605. */
  92606. setArray(uniformName: string, array: number[]): void;
  92607. /**
  92608. * 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)
  92609. * @param uniformName Name of the variable.
  92610. * @param array array to be set.
  92611. */
  92612. setArray2(uniformName: string, array: number[]): void;
  92613. /**
  92614. * 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)
  92615. * @param uniformName Name of the variable.
  92616. * @param array array to be set.
  92617. * @returns this effect.
  92618. */
  92619. setArray3(uniformName: string, array: number[]): void;
  92620. /**
  92621. * 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)
  92622. * @param uniformName Name of the variable.
  92623. * @param array array to be set.
  92624. */
  92625. setArray4(uniformName: string, array: number[]): void;
  92626. /**
  92627. * Sets matrices on a uniform variable.
  92628. * @param uniformName Name of the variable.
  92629. * @param matrices matrices to be set.
  92630. */
  92631. setMatrices(uniformName: string, matrices: Float32Array): void;
  92632. /**
  92633. * Sets matrix on a uniform variable.
  92634. * @param uniformName Name of the variable.
  92635. * @param matrix matrix to be set.
  92636. */
  92637. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  92638. /**
  92639. * 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)
  92640. * @param uniformName Name of the variable.
  92641. * @param matrix matrix to be set.
  92642. */
  92643. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  92644. /**
  92645. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92646. * @param uniformName Name of the variable.
  92647. * @param matrix matrix to be set.
  92648. */
  92649. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  92650. /**
  92651. * Sets a float on a uniform variable.
  92652. * @param uniformName Name of the variable.
  92653. * @param value value to be set.
  92654. * @returns this effect.
  92655. */
  92656. setFloat(uniformName: string, value: number): void;
  92657. /**
  92658. * Sets a Vector2 on a uniform variable.
  92659. * @param uniformName Name of the variable.
  92660. * @param vector2 vector2 to be set.
  92661. */
  92662. setVector2(uniformName: string, vector2: IVector2Like): void;
  92663. /**
  92664. * Sets a float2 on a uniform variable.
  92665. * @param uniformName Name of the variable.
  92666. * @param x First float in float2.
  92667. * @param y Second float in float2.
  92668. */
  92669. setFloat2(uniformName: string, x: number, y: number): void;
  92670. /**
  92671. * Sets a Vector3 on a uniform variable.
  92672. * @param uniformName Name of the variable.
  92673. * @param vector3 Value to be set.
  92674. */
  92675. setVector3(uniformName: string, vector3: IVector3Like): void;
  92676. /**
  92677. * Sets a float3 on a uniform variable.
  92678. * @param uniformName Name of the variable.
  92679. * @param x First float in float3.
  92680. * @param y Second float in float3.
  92681. * @param z Third float in float3.
  92682. */
  92683. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  92684. /**
  92685. * Sets a Vector4 on a uniform variable.
  92686. * @param uniformName Name of the variable.
  92687. * @param vector4 Value to be set.
  92688. */
  92689. setVector4(uniformName: string, vector4: IVector4Like): void;
  92690. /**
  92691. * Sets a float4 on a uniform variable.
  92692. * @param uniformName Name of the variable.
  92693. * @param x First float in float4.
  92694. * @param y Second float in float4.
  92695. * @param z Third float in float4.
  92696. * @param w Fourth float in float4.
  92697. * @returns this effect.
  92698. */
  92699. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  92700. /**
  92701. * Sets a Color3 on a uniform variable.
  92702. * @param uniformName Name of the variable.
  92703. * @param color3 Value to be set.
  92704. */
  92705. setColor3(uniformName: string, color3: IColor3Like): void;
  92706. /**
  92707. * Sets a Color4 on a uniform variable.
  92708. * @param uniformName Name of the variable.
  92709. * @param color3 Value to be set.
  92710. * @param alpha Alpha value to be set.
  92711. */
  92712. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  92713. /**
  92714. * Sets a Color4 on a uniform variable
  92715. * @param uniformName defines the name of the variable
  92716. * @param color4 defines the value to be set
  92717. */
  92718. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  92719. _getVertexShaderCode(): string | null;
  92720. _getFragmentShaderCode(): string | null;
  92721. }
  92722. }
  92723. declare module BABYLON {
  92724. interface ThinEngine {
  92725. /**
  92726. * Create an uniform buffer
  92727. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  92728. * @param elements defines the content of the uniform buffer
  92729. * @returns the webGL uniform buffer
  92730. */
  92731. createUniformBuffer(elements: FloatArray): DataBuffer;
  92732. /**
  92733. * Create a dynamic uniform buffer
  92734. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  92735. * @param elements defines the content of the uniform buffer
  92736. * @returns the webGL uniform buffer
  92737. */
  92738. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  92739. /**
  92740. * Update an existing uniform buffer
  92741. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  92742. * @param uniformBuffer defines the target uniform buffer
  92743. * @param elements defines the content to update
  92744. * @param offset defines the offset in the uniform buffer where update should start
  92745. * @param count defines the size of the data to update
  92746. */
  92747. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  92748. /**
  92749. * Bind an uniform buffer to the current webGL context
  92750. * @param buffer defines the buffer to bind
  92751. */
  92752. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  92753. /**
  92754. * Bind a buffer to the current webGL context at a given location
  92755. * @param buffer defines the buffer to bind
  92756. * @param location defines the index where to bind the buffer
  92757. * @param name Name of the uniform variable to bind
  92758. */
  92759. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  92760. /**
  92761. * Bind a specific block at a given index in a specific shader program
  92762. * @param pipelineContext defines the pipeline context to use
  92763. * @param blockName defines the block name
  92764. * @param index defines the index where to bind the block
  92765. */
  92766. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  92767. }
  92768. }
  92769. declare module BABYLON {
  92770. /**
  92771. * Uniform buffer objects.
  92772. *
  92773. * Handles blocks of uniform on the GPU.
  92774. *
  92775. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92776. *
  92777. * For more information, please refer to :
  92778. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92779. */
  92780. export class UniformBuffer {
  92781. /** @hidden */
  92782. static _updatedUbosInFrame: {
  92783. [name: string]: number;
  92784. };
  92785. private _engine;
  92786. private _buffer;
  92787. private _buffers;
  92788. private _bufferIndex;
  92789. private _createBufferOnWrite;
  92790. private _data;
  92791. private _bufferData;
  92792. private _dynamic?;
  92793. private _uniformLocations;
  92794. private _uniformSizes;
  92795. private _uniformArraySizes;
  92796. private _uniformLocationPointer;
  92797. private _needSync;
  92798. private _noUBO;
  92799. private _currentEffect;
  92800. private _currentEffectName;
  92801. private _name;
  92802. private _currentFrameId;
  92803. /** @hidden */
  92804. _alreadyBound: boolean;
  92805. private static _MAX_UNIFORM_SIZE;
  92806. private static _tempBuffer;
  92807. private static _tempBufferInt32View;
  92808. /**
  92809. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92810. * This is dynamic to allow compat with webgl 1 and 2.
  92811. * You will need to pass the name of the uniform as well as the value.
  92812. */
  92813. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92814. /**
  92815. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92816. * This is dynamic to allow compat with webgl 1 and 2.
  92817. * You will need to pass the name of the uniform as well as the value.
  92818. */
  92819. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92820. /**
  92821. * Lambda to Update a single float in a uniform buffer.
  92822. * This is dynamic to allow compat with webgl 1 and 2.
  92823. * You will need to pass the name of the uniform as well as the value.
  92824. */
  92825. updateFloat: (name: string, x: number) => void;
  92826. /**
  92827. * Lambda to Update a vec2 of float in a uniform buffer.
  92828. * This is dynamic to allow compat with webgl 1 and 2.
  92829. * You will need to pass the name of the uniform as well as the value.
  92830. */
  92831. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92832. /**
  92833. * Lambda to Update a vec3 of float in a uniform buffer.
  92834. * This is dynamic to allow compat with webgl 1 and 2.
  92835. * You will need to pass the name of the uniform as well as the value.
  92836. */
  92837. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92838. /**
  92839. * Lambda to Update a vec4 of float in a uniform buffer.
  92840. * This is dynamic to allow compat with webgl 1 and 2.
  92841. * You will need to pass the name of the uniform as well as the value.
  92842. */
  92843. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92844. /**
  92845. * Lambda to Update an array of float in a uniform buffer.
  92846. * This is dynamic to allow compat with webgl 1 and 2.
  92847. * You will need to pass the name of the uniform as well as the value.
  92848. */
  92849. updateFloatArray: (name: string, array: Float32Array) => void;
  92850. /**
  92851. * Lambda to Update an array of number in a uniform buffer.
  92852. * This is dynamic to allow compat with webgl 1 and 2.
  92853. * You will need to pass the name of the uniform as well as the value.
  92854. */
  92855. updateArray: (name: string, array: number[]) => void;
  92856. /**
  92857. * Lambda to Update an array of number in a uniform buffer.
  92858. * This is dynamic to allow compat with webgl 1 and 2.
  92859. * You will need to pass the name of the uniform as well as the value.
  92860. */
  92861. updateIntArray: (name: string, array: Int32Array) => void;
  92862. /**
  92863. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92864. * This is dynamic to allow compat with webgl 1 and 2.
  92865. * You will need to pass the name of the uniform as well as the value.
  92866. */
  92867. updateMatrix: (name: string, mat: IMatrixLike) => void;
  92868. /**
  92869. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  92870. * This is dynamic to allow compat with webgl 1 and 2.
  92871. * You will need to pass the name of the uniform as well as the value.
  92872. */
  92873. updateMatrices: (name: string, mat: Float32Array) => void;
  92874. /**
  92875. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92876. * This is dynamic to allow compat with webgl 1 and 2.
  92877. * You will need to pass the name of the uniform as well as the value.
  92878. */
  92879. updateVector3: (name: string, vector: Vector3) => void;
  92880. /**
  92881. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92882. * This is dynamic to allow compat with webgl 1 and 2.
  92883. * You will need to pass the name of the uniform as well as the value.
  92884. */
  92885. updateVector4: (name: string, vector: Vector4) => void;
  92886. /**
  92887. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92888. * This is dynamic to allow compat with webgl 1 and 2.
  92889. * You will need to pass the name of the uniform as well as the value.
  92890. */
  92891. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92892. /**
  92893. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92894. * This is dynamic to allow compat with webgl 1 and 2.
  92895. * You will need to pass the name of the uniform as well as the value.
  92896. */
  92897. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92898. /**
  92899. * Lambda to Update a int a uniform buffer.
  92900. * This is dynamic to allow compat with webgl 1 and 2.
  92901. * You will need to pass the name of the uniform as well as the value.
  92902. */
  92903. updateInt: (name: string, x: number, suffix?: string) => void;
  92904. /**
  92905. * Lambda to Update a vec2 of int in a uniform buffer.
  92906. * This is dynamic to allow compat with webgl 1 and 2.
  92907. * You will need to pass the name of the uniform as well as the value.
  92908. */
  92909. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  92910. /**
  92911. * Lambda to Update a vec3 of int in a uniform buffer.
  92912. * This is dynamic to allow compat with webgl 1 and 2.
  92913. * You will need to pass the name of the uniform as well as the value.
  92914. */
  92915. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92916. /**
  92917. * Lambda to Update a vec4 of int in a uniform buffer.
  92918. * This is dynamic to allow compat with webgl 1 and 2.
  92919. * You will need to pass the name of the uniform as well as the value.
  92920. */
  92921. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92922. /**
  92923. * Instantiates a new Uniform buffer objects.
  92924. *
  92925. * Handles blocks of uniform on the GPU.
  92926. *
  92927. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92928. *
  92929. * For more information, please refer to :
  92930. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92931. * @param engine Define the engine the buffer is associated with
  92932. * @param data Define the data contained in the buffer
  92933. * @param dynamic Define if the buffer is updatable
  92934. * @param name to assign to the buffer (debugging purpose)
  92935. */
  92936. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  92937. /**
  92938. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92939. * or just falling back on setUniformXXX calls.
  92940. */
  92941. get useUbo(): boolean;
  92942. /**
  92943. * Indicates if the WebGL underlying uniform buffer is in sync
  92944. * with the javascript cache data.
  92945. */
  92946. get isSync(): boolean;
  92947. /**
  92948. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92949. * Also, a dynamic UniformBuffer will disable cache verification and always
  92950. * update the underlying WebGL uniform buffer to the GPU.
  92951. * @returns if Dynamic, otherwise false
  92952. */
  92953. isDynamic(): boolean;
  92954. /**
  92955. * The data cache on JS side.
  92956. * @returns the underlying data as a float array
  92957. */
  92958. getData(): Float32Array;
  92959. /**
  92960. * The underlying WebGL Uniform buffer.
  92961. * @returns the webgl buffer
  92962. */
  92963. getBuffer(): Nullable<DataBuffer>;
  92964. /**
  92965. * std140 layout specifies how to align data within an UBO structure.
  92966. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92967. * for specs.
  92968. */
  92969. private _fillAlignment;
  92970. /**
  92971. * Adds an uniform in the buffer.
  92972. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92973. * for the layout to be correct !
  92974. * @param name Name of the uniform, as used in the uniform block in the shader.
  92975. * @param size Data size, or data directly.
  92976. * @param arraySize The number of elements in the array, 0 if not an array.
  92977. */
  92978. addUniform(name: string, size: number | number[], arraySize?: number): void;
  92979. /**
  92980. * Adds a Matrix 4x4 to the uniform buffer.
  92981. * @param name Name of the uniform, as used in the uniform block in the shader.
  92982. * @param mat A 4x4 matrix.
  92983. */
  92984. addMatrix(name: string, mat: Matrix): void;
  92985. /**
  92986. * Adds a vec2 to the uniform buffer.
  92987. * @param name Name of the uniform, as used in the uniform block in the shader.
  92988. * @param x Define the x component value of the vec2
  92989. * @param y Define the y component value of the vec2
  92990. */
  92991. addFloat2(name: string, x: number, y: number): void;
  92992. /**
  92993. * Adds a vec3 to the uniform buffer.
  92994. * @param name Name of the uniform, as used in the uniform block in the shader.
  92995. * @param x Define the x component value of the vec3
  92996. * @param y Define the y component value of the vec3
  92997. * @param z Define the z component value of the vec3
  92998. */
  92999. addFloat3(name: string, x: number, y: number, z: number): void;
  93000. /**
  93001. * Adds a vec3 to the uniform buffer.
  93002. * @param name Name of the uniform, as used in the uniform block in the shader.
  93003. * @param color Define the vec3 from a Color
  93004. */
  93005. addColor3(name: string, color: Color3): void;
  93006. /**
  93007. * Adds a vec4 to the uniform buffer.
  93008. * @param name Name of the uniform, as used in the uniform block in the shader.
  93009. * @param color Define the rgb components from a Color
  93010. * @param alpha Define the a component of the vec4
  93011. */
  93012. addColor4(name: string, color: Color3, alpha: number): void;
  93013. /**
  93014. * Adds a vec3 to the uniform buffer.
  93015. * @param name Name of the uniform, as used in the uniform block in the shader.
  93016. * @param vector Define the vec3 components from a Vector
  93017. */
  93018. addVector3(name: string, vector: Vector3): void;
  93019. /**
  93020. * Adds a Matrix 3x3 to the uniform buffer.
  93021. * @param name Name of the uniform, as used in the uniform block in the shader.
  93022. */
  93023. addMatrix3x3(name: string): void;
  93024. /**
  93025. * Adds a Matrix 2x2 to the uniform buffer.
  93026. * @param name Name of the uniform, as used in the uniform block in the shader.
  93027. */
  93028. addMatrix2x2(name: string): void;
  93029. /**
  93030. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93031. */
  93032. create(): void;
  93033. /** @hidden */
  93034. _rebuild(): void;
  93035. /** @hidden */
  93036. get _numBuffers(): number;
  93037. /** @hidden */
  93038. get _indexBuffer(): number;
  93039. /** Gets the name of this buffer */
  93040. get name(): string;
  93041. /**
  93042. * Updates the WebGL Uniform Buffer on the GPU.
  93043. * If the `dynamic` flag is set to true, no cache comparison is done.
  93044. * Otherwise, the buffer will be updated only if the cache differs.
  93045. */
  93046. update(): void;
  93047. private _createNewBuffer;
  93048. private _checkNewFrame;
  93049. /**
  93050. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93051. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93052. * @param data Define the flattened data
  93053. * @param size Define the size of the data.
  93054. */
  93055. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93056. /**
  93057. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93058. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93059. * @param data Define the flattened data
  93060. * @param size Define the size of the data.
  93061. */
  93062. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  93063. private _valueCache;
  93064. private _cacheMatrix;
  93065. private _updateMatrix3x3ForUniform;
  93066. private _updateMatrix3x3ForEffect;
  93067. private _updateMatrix2x2ForEffect;
  93068. private _updateMatrix2x2ForUniform;
  93069. private _updateFloatForEffect;
  93070. private _updateFloatForUniform;
  93071. private _updateFloat2ForEffect;
  93072. private _updateFloat2ForUniform;
  93073. private _updateFloat3ForEffect;
  93074. private _updateFloat3ForUniform;
  93075. private _updateFloat4ForEffect;
  93076. private _updateFloat4ForUniform;
  93077. private _updateFloatArrayForEffect;
  93078. private _updateFloatArrayForUniform;
  93079. private _updateArrayForEffect;
  93080. private _updateArrayForUniform;
  93081. private _updateIntArrayForEffect;
  93082. private _updateIntArrayForUniform;
  93083. private _updateMatrixForEffect;
  93084. private _updateMatrixForUniform;
  93085. private _updateMatricesForEffect;
  93086. private _updateMatricesForUniform;
  93087. private _updateVector3ForEffect;
  93088. private _updateVector3ForUniform;
  93089. private _updateVector4ForEffect;
  93090. private _updateVector4ForUniform;
  93091. private _updateColor3ForEffect;
  93092. private _updateColor3ForUniform;
  93093. private _updateColor4ForEffect;
  93094. private _updateColor4ForUniform;
  93095. private _updateIntForEffect;
  93096. private _updateIntForUniform;
  93097. private _updateInt2ForEffect;
  93098. private _updateInt2ForUniform;
  93099. private _updateInt3ForEffect;
  93100. private _updateInt3ForUniform;
  93101. private _updateInt4ForEffect;
  93102. private _updateInt4ForUniform;
  93103. /**
  93104. * Sets a sampler uniform on the effect.
  93105. * @param name Define the name of the sampler.
  93106. * @param texture Define the texture to set in the sampler
  93107. */
  93108. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93109. /**
  93110. * Directly updates the value of the uniform in the cache AND on the GPU.
  93111. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93112. * @param data Define the flattened data
  93113. */
  93114. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93115. /**
  93116. * Binds this uniform buffer to an effect.
  93117. * @param effect Define the effect to bind the buffer to
  93118. * @param name Name of the uniform block in the shader.
  93119. */
  93120. bindToEffect(effect: Effect, name: string): void;
  93121. /**
  93122. * Disposes the uniform buffer.
  93123. */
  93124. dispose(): void;
  93125. }
  93126. }
  93127. declare module BABYLON {
  93128. /**
  93129. * Manages the defines for the Material
  93130. */
  93131. export class MaterialDefines {
  93132. /** @hidden */
  93133. protected _keys: string[];
  93134. private _isDirty;
  93135. /** @hidden */
  93136. _renderId: number;
  93137. /** @hidden */
  93138. _areLightsDirty: boolean;
  93139. /** @hidden */
  93140. _areLightsDisposed: boolean;
  93141. /** @hidden */
  93142. _areAttributesDirty: boolean;
  93143. /** @hidden */
  93144. _areTexturesDirty: boolean;
  93145. /** @hidden */
  93146. _areFresnelDirty: boolean;
  93147. /** @hidden */
  93148. _areMiscDirty: boolean;
  93149. /** @hidden */
  93150. _arePrePassDirty: boolean;
  93151. /** @hidden */
  93152. _areImageProcessingDirty: boolean;
  93153. /** @hidden */
  93154. _normals: boolean;
  93155. /** @hidden */
  93156. _uvs: boolean;
  93157. /** @hidden */
  93158. _needNormals: boolean;
  93159. /** @hidden */
  93160. _needUVs: boolean;
  93161. [id: string]: any;
  93162. /**
  93163. * Specifies if the material needs to be re-calculated
  93164. */
  93165. get isDirty(): boolean;
  93166. /**
  93167. * Marks the material to indicate that it has been re-calculated
  93168. */
  93169. markAsProcessed(): void;
  93170. /**
  93171. * Marks the material to indicate that it needs to be re-calculated
  93172. */
  93173. markAsUnprocessed(): void;
  93174. /**
  93175. * Marks the material to indicate all of its defines need to be re-calculated
  93176. */
  93177. markAllAsDirty(): void;
  93178. /**
  93179. * Marks the material to indicate that image processing needs to be re-calculated
  93180. */
  93181. markAsImageProcessingDirty(): void;
  93182. /**
  93183. * Marks the material to indicate the lights need to be re-calculated
  93184. * @param disposed Defines whether the light is dirty due to dispose or not
  93185. */
  93186. markAsLightDirty(disposed?: boolean): void;
  93187. /**
  93188. * Marks the attribute state as changed
  93189. */
  93190. markAsAttributesDirty(): void;
  93191. /**
  93192. * Marks the texture state as changed
  93193. */
  93194. markAsTexturesDirty(): void;
  93195. /**
  93196. * Marks the fresnel state as changed
  93197. */
  93198. markAsFresnelDirty(): void;
  93199. /**
  93200. * Marks the misc state as changed
  93201. */
  93202. markAsMiscDirty(): void;
  93203. /**
  93204. * Marks the prepass state as changed
  93205. */
  93206. markAsPrePassDirty(): void;
  93207. /**
  93208. * Rebuilds the material defines
  93209. */
  93210. rebuild(): void;
  93211. /**
  93212. * Specifies if two material defines are equal
  93213. * @param other - A material define instance to compare to
  93214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  93215. */
  93216. isEqual(other: MaterialDefines): boolean;
  93217. /**
  93218. * Clones this instance's defines to another instance
  93219. * @param other - material defines to clone values to
  93220. */
  93221. cloneTo(other: MaterialDefines): void;
  93222. /**
  93223. * Resets the material define values
  93224. */
  93225. reset(): void;
  93226. /**
  93227. * Converts the material define values to a string
  93228. * @returns - String of material define information
  93229. */
  93230. toString(): string;
  93231. }
  93232. }
  93233. declare module BABYLON {
  93234. /**
  93235. * Enum that determines the text-wrapping mode to use.
  93236. */
  93237. export enum InspectableType {
  93238. /**
  93239. * Checkbox for booleans
  93240. */
  93241. Checkbox = 0,
  93242. /**
  93243. * Sliders for numbers
  93244. */
  93245. Slider = 1,
  93246. /**
  93247. * Vector3
  93248. */
  93249. Vector3 = 2,
  93250. /**
  93251. * Quaternions
  93252. */
  93253. Quaternion = 3,
  93254. /**
  93255. * Color3
  93256. */
  93257. Color3 = 4,
  93258. /**
  93259. * String
  93260. */
  93261. String = 5
  93262. }
  93263. /**
  93264. * Interface used to define custom inspectable properties.
  93265. * This interface is used by the inspector to display custom property grids
  93266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93267. */
  93268. export interface IInspectable {
  93269. /**
  93270. * Gets the label to display
  93271. */
  93272. label: string;
  93273. /**
  93274. * Gets the name of the property to edit
  93275. */
  93276. propertyName: string;
  93277. /**
  93278. * Gets the type of the editor to use
  93279. */
  93280. type: InspectableType;
  93281. /**
  93282. * Gets the minimum value of the property when using in "slider" mode
  93283. */
  93284. min?: number;
  93285. /**
  93286. * Gets the maximum value of the property when using in "slider" mode
  93287. */
  93288. max?: number;
  93289. /**
  93290. * Gets the setp to use when using in "slider" mode
  93291. */
  93292. step?: number;
  93293. }
  93294. }
  93295. declare module BABYLON {
  93296. /**
  93297. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  93298. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  93299. * 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.
  93300. */
  93301. export abstract class Light extends Node {
  93302. /**
  93303. * Falloff Default: light is falling off following the material specification:
  93304. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  93305. */
  93306. static readonly FALLOFF_DEFAULT: number;
  93307. /**
  93308. * Falloff Physical: light is falling off following the inverse squared distance law.
  93309. */
  93310. static readonly FALLOFF_PHYSICAL: number;
  93311. /**
  93312. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  93313. * to enhance interoperability with other engines.
  93314. */
  93315. static readonly FALLOFF_GLTF: number;
  93316. /**
  93317. * Falloff Standard: light is falling off like in the standard material
  93318. * to enhance interoperability with other materials.
  93319. */
  93320. static readonly FALLOFF_STANDARD: number;
  93321. /**
  93322. * If every light affecting the material is in this lightmapMode,
  93323. * material.lightmapTexture adds or multiplies
  93324. * (depends on material.useLightmapAsShadowmap)
  93325. * after every other light calculations.
  93326. */
  93327. static readonly LIGHTMAP_DEFAULT: number;
  93328. /**
  93329. * material.lightmapTexture as only diffuse lighting from this light
  93330. * adds only specular lighting from this light
  93331. * adds dynamic shadows
  93332. */
  93333. static readonly LIGHTMAP_SPECULAR: number;
  93334. /**
  93335. * material.lightmapTexture as only lighting
  93336. * no light calculation from this light
  93337. * only adds dynamic shadows from this light
  93338. */
  93339. static readonly LIGHTMAP_SHADOWSONLY: number;
  93340. /**
  93341. * Each light type uses the default quantity according to its type:
  93342. * point/spot lights use luminous intensity
  93343. * directional lights use illuminance
  93344. */
  93345. static readonly INTENSITYMODE_AUTOMATIC: number;
  93346. /**
  93347. * lumen (lm)
  93348. */
  93349. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  93350. /**
  93351. * candela (lm/sr)
  93352. */
  93353. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  93354. /**
  93355. * lux (lm/m^2)
  93356. */
  93357. static readonly INTENSITYMODE_ILLUMINANCE: number;
  93358. /**
  93359. * nit (cd/m^2)
  93360. */
  93361. static readonly INTENSITYMODE_LUMINANCE: number;
  93362. /**
  93363. * Light type const id of the point light.
  93364. */
  93365. static readonly LIGHTTYPEID_POINTLIGHT: number;
  93366. /**
  93367. * Light type const id of the directional light.
  93368. */
  93369. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  93370. /**
  93371. * Light type const id of the spot light.
  93372. */
  93373. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  93374. /**
  93375. * Light type const id of the hemispheric light.
  93376. */
  93377. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  93378. /**
  93379. * Diffuse gives the basic color to an object.
  93380. */
  93381. diffuse: Color3;
  93382. /**
  93383. * Specular produces a highlight color on an object.
  93384. * Note: This is note affecting PBR materials.
  93385. */
  93386. specular: Color3;
  93387. /**
  93388. * Defines the falloff type for this light. This lets overrriding how punctual light are
  93389. * falling off base on range or angle.
  93390. * This can be set to any values in Light.FALLOFF_x.
  93391. *
  93392. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  93393. * other types of materials.
  93394. */
  93395. falloffType: number;
  93396. /**
  93397. * Strength of the light.
  93398. * Note: By default it is define in the framework own unit.
  93399. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  93400. */
  93401. intensity: number;
  93402. private _range;
  93403. protected _inverseSquaredRange: number;
  93404. /**
  93405. * Defines how far from the source the light is impacting in scene units.
  93406. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93407. */
  93408. get range(): number;
  93409. /**
  93410. * Defines how far from the source the light is impacting in scene units.
  93411. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93412. */
  93413. set range(value: number);
  93414. /**
  93415. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93416. * of light.
  93417. */
  93418. private _photometricScale;
  93419. private _intensityMode;
  93420. /**
  93421. * Gets the photometric scale used to interpret the intensity.
  93422. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93423. */
  93424. get intensityMode(): number;
  93425. /**
  93426. * Sets the photometric scale used to interpret the intensity.
  93427. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93428. */
  93429. set intensityMode(value: number);
  93430. private _radius;
  93431. /**
  93432. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93433. */
  93434. get radius(): number;
  93435. /**
  93436. * sets the light radius used by PBR Materials to simulate soft area lights.
  93437. */
  93438. set radius(value: number);
  93439. private _renderPriority;
  93440. /**
  93441. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93442. * exceeding the number allowed of the materials.
  93443. */
  93444. renderPriority: number;
  93445. private _shadowEnabled;
  93446. /**
  93447. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93448. * the current shadow generator.
  93449. */
  93450. get shadowEnabled(): boolean;
  93451. /**
  93452. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93453. * the current shadow generator.
  93454. */
  93455. set shadowEnabled(value: boolean);
  93456. private _includedOnlyMeshes;
  93457. /**
  93458. * Gets the only meshes impacted by this light.
  93459. */
  93460. get includedOnlyMeshes(): AbstractMesh[];
  93461. /**
  93462. * Sets the only meshes impacted by this light.
  93463. */
  93464. set includedOnlyMeshes(value: AbstractMesh[]);
  93465. private _excludedMeshes;
  93466. /**
  93467. * Gets the meshes not impacted by this light.
  93468. */
  93469. get excludedMeshes(): AbstractMesh[];
  93470. /**
  93471. * Sets the meshes not impacted by this light.
  93472. */
  93473. set excludedMeshes(value: AbstractMesh[]);
  93474. private _excludeWithLayerMask;
  93475. /**
  93476. * Gets the layer id use to find what meshes are not impacted by the light.
  93477. * Inactive if 0
  93478. */
  93479. get excludeWithLayerMask(): number;
  93480. /**
  93481. * Sets the layer id use to find what meshes are not impacted by the light.
  93482. * Inactive if 0
  93483. */
  93484. set excludeWithLayerMask(value: number);
  93485. private _includeOnlyWithLayerMask;
  93486. /**
  93487. * Gets the layer id use to find what meshes are impacted by the light.
  93488. * Inactive if 0
  93489. */
  93490. get includeOnlyWithLayerMask(): number;
  93491. /**
  93492. * Sets the layer id use to find what meshes are impacted by the light.
  93493. * Inactive if 0
  93494. */
  93495. set includeOnlyWithLayerMask(value: number);
  93496. private _lightmapMode;
  93497. /**
  93498. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93499. */
  93500. get lightmapMode(): number;
  93501. /**
  93502. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93503. */
  93504. set lightmapMode(value: number);
  93505. /**
  93506. * Shadow generator associted to the light.
  93507. * @hidden Internal use only.
  93508. */
  93509. _shadowGenerator: Nullable<IShadowGenerator>;
  93510. /**
  93511. * @hidden Internal use only.
  93512. */
  93513. _excludedMeshesIds: string[];
  93514. /**
  93515. * @hidden Internal use only.
  93516. */
  93517. _includedOnlyMeshesIds: string[];
  93518. /**
  93519. * The current light unifom buffer.
  93520. * @hidden Internal use only.
  93521. */
  93522. _uniformBuffer: UniformBuffer;
  93523. /** @hidden */
  93524. _renderId: number;
  93525. /**
  93526. * Creates a Light object in the scene.
  93527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93528. * @param name The firendly name of the light
  93529. * @param scene The scene the light belongs too
  93530. */
  93531. constructor(name: string, scene: Scene);
  93532. protected abstract _buildUniformLayout(): void;
  93533. /**
  93534. * Sets the passed Effect "effect" with the Light information.
  93535. * @param effect The effect to update
  93536. * @param lightIndex The index of the light in the effect to update
  93537. * @returns The light
  93538. */
  93539. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93540. /**
  93541. * Sets the passed Effect "effect" with the Light textures.
  93542. * @param effect The effect to update
  93543. * @param lightIndex The index of the light in the effect to update
  93544. * @returns The light
  93545. */
  93546. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93547. /**
  93548. * Binds the lights information from the scene to the effect for the given mesh.
  93549. * @param lightIndex Light index
  93550. * @param scene The scene where the light belongs to
  93551. * @param effect The effect we are binding the data to
  93552. * @param useSpecular Defines if specular is supported
  93553. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93554. */
  93555. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93556. /**
  93557. * Sets the passed Effect "effect" with the Light information.
  93558. * @param effect The effect to update
  93559. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93560. * @returns The light
  93561. */
  93562. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93563. /**
  93564. * Returns the string "Light".
  93565. * @returns the class name
  93566. */
  93567. getClassName(): string;
  93568. /** @hidden */
  93569. readonly _isLight: boolean;
  93570. /**
  93571. * Converts the light information to a readable string for debug purpose.
  93572. * @param fullDetails Supports for multiple levels of logging within scene loading
  93573. * @returns the human readable light info
  93574. */
  93575. toString(fullDetails?: boolean): string;
  93576. /** @hidden */
  93577. protected _syncParentEnabledState(): void;
  93578. /**
  93579. * Set the enabled state of this node.
  93580. * @param value - the new enabled state
  93581. */
  93582. setEnabled(value: boolean): void;
  93583. /**
  93584. * Returns the Light associated shadow generator if any.
  93585. * @return the associated shadow generator.
  93586. */
  93587. getShadowGenerator(): Nullable<IShadowGenerator>;
  93588. /**
  93589. * Returns a Vector3, the absolute light position in the World.
  93590. * @returns the world space position of the light
  93591. */
  93592. getAbsolutePosition(): Vector3;
  93593. /**
  93594. * Specifies if the light will affect the passed mesh.
  93595. * @param mesh The mesh to test against the light
  93596. * @return true the mesh is affected otherwise, false.
  93597. */
  93598. canAffectMesh(mesh: AbstractMesh): boolean;
  93599. /**
  93600. * Sort function to order lights for rendering.
  93601. * @param a First Light object to compare to second.
  93602. * @param b Second Light object to compare first.
  93603. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  93604. */
  93605. static CompareLightsPriority(a: Light, b: Light): number;
  93606. /**
  93607. * Releases resources associated with this node.
  93608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93610. */
  93611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93612. /**
  93613. * Returns the light type ID (integer).
  93614. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93615. */
  93616. getTypeID(): number;
  93617. /**
  93618. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93619. * @returns the scaled intensity in intensity mode unit
  93620. */
  93621. getScaledIntensity(): number;
  93622. /**
  93623. * Returns a new Light object, named "name", from the current one.
  93624. * @param name The name of the cloned light
  93625. * @param newParent The parent of this light, if it has one
  93626. * @returns the new created light
  93627. */
  93628. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  93629. /**
  93630. * Serializes the current light into a Serialization object.
  93631. * @returns the serialized object.
  93632. */
  93633. serialize(): any;
  93634. /**
  93635. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93636. * This new light is named "name" and added to the passed scene.
  93637. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93638. * @param name The friendly name of the light
  93639. * @param scene The scene the new light will belong to
  93640. * @returns the constructor function
  93641. */
  93642. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93643. /**
  93644. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93645. * @param parsedLight The JSON representation of the light
  93646. * @param scene The scene to create the parsed light in
  93647. * @returns the created light after parsing
  93648. */
  93649. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93650. private _hookArrayForExcluded;
  93651. private _hookArrayForIncludedOnly;
  93652. private _resyncMeshes;
  93653. /**
  93654. * Forces the meshes to update their light related information in their rendering used effects
  93655. * @hidden Internal Use Only
  93656. */
  93657. _markMeshesAsLightDirty(): void;
  93658. /**
  93659. * Recomputes the cached photometric scale if needed.
  93660. */
  93661. private _computePhotometricScale;
  93662. /**
  93663. * Returns the Photometric Scale according to the light type and intensity mode.
  93664. */
  93665. private _getPhotometricScale;
  93666. /**
  93667. * Reorder the light in the scene according to their defined priority.
  93668. * @hidden Internal Use Only
  93669. */
  93670. _reorderLightsInScene(): void;
  93671. /**
  93672. * Prepares the list of defines specific to the light type.
  93673. * @param defines the list of defines
  93674. * @param lightIndex defines the index of the light for the effect
  93675. */
  93676. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93677. }
  93678. }
  93679. declare module BABYLON {
  93680. /** Defines supported spaces */
  93681. export enum Space {
  93682. /** Local (object) space */
  93683. LOCAL = 0,
  93684. /** World space */
  93685. WORLD = 1,
  93686. /** Bone space */
  93687. BONE = 2
  93688. }
  93689. /** Defines the 3 main axes */
  93690. export class Axis {
  93691. /** X axis */
  93692. static X: Vector3;
  93693. /** Y axis */
  93694. static Y: Vector3;
  93695. /** Z axis */
  93696. static Z: Vector3;
  93697. }
  93698. /**
  93699. * Defines cartesian components.
  93700. */
  93701. export enum Coordinate {
  93702. /** X axis */
  93703. X = 0,
  93704. /** Y axis */
  93705. Y = 1,
  93706. /** Z axis */
  93707. Z = 2
  93708. }
  93709. }
  93710. declare module BABYLON {
  93711. /**
  93712. * Interface describing all the common properties and methods a shadow light needs to implement.
  93713. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  93714. * as well as binding the different shadow properties to the effects.
  93715. */
  93716. export interface IShadowLight extends Light {
  93717. /**
  93718. * The light id in the scene (used in scene.findLighById for instance)
  93719. */
  93720. id: string;
  93721. /**
  93722. * The position the shdow will be casted from.
  93723. */
  93724. position: Vector3;
  93725. /**
  93726. * In 2d mode (needCube being false), the direction used to cast the shadow.
  93727. */
  93728. direction: Vector3;
  93729. /**
  93730. * The transformed position. Position of the light in world space taking parenting in account.
  93731. */
  93732. transformedPosition: Vector3;
  93733. /**
  93734. * The transformed direction. Direction of the light in world space taking parenting in account.
  93735. */
  93736. transformedDirection: Vector3;
  93737. /**
  93738. * The friendly name of the light in the scene.
  93739. */
  93740. name: string;
  93741. /**
  93742. * Defines the shadow projection clipping minimum z value.
  93743. */
  93744. shadowMinZ: number;
  93745. /**
  93746. * Defines the shadow projection clipping maximum z value.
  93747. */
  93748. shadowMaxZ: number;
  93749. /**
  93750. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  93751. * @returns true if the information has been computed, false if it does not need to (no parenting)
  93752. */
  93753. computeTransformedInformation(): boolean;
  93754. /**
  93755. * Gets the scene the light belongs to.
  93756. * @returns The scene
  93757. */
  93758. getScene(): Scene;
  93759. /**
  93760. * Callback defining a custom Projection Matrix Builder.
  93761. * This can be used to override the default projection matrix computation.
  93762. */
  93763. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  93764. /**
  93765. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  93766. * @param matrix The materix to updated with the projection information
  93767. * @param viewMatrix The transform matrix of the light
  93768. * @param renderList The list of mesh to render in the map
  93769. * @returns The current light
  93770. */
  93771. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  93772. /**
  93773. * Gets the current depth scale used in ESM.
  93774. * @returns The scale
  93775. */
  93776. getDepthScale(): number;
  93777. /**
  93778. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  93779. * @returns true if a cube texture needs to be use
  93780. */
  93781. needCube(): boolean;
  93782. /**
  93783. * Detects if the projection matrix requires to be recomputed this frame.
  93784. * @returns true if it requires to be recomputed otherwise, false.
  93785. */
  93786. needProjectionMatrixCompute(): boolean;
  93787. /**
  93788. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  93789. */
  93790. forceProjectionMatrixCompute(): void;
  93791. /**
  93792. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  93793. * @param faceIndex The index of the face we are computed the direction to generate shadow
  93794. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  93795. */
  93796. getShadowDirection(faceIndex?: number): Vector3;
  93797. /**
  93798. * Gets the minZ used for shadow according to both the scene and the light.
  93799. * @param activeCamera The camera we are returning the min for
  93800. * @returns the depth min z
  93801. */
  93802. getDepthMinZ(activeCamera: Camera): number;
  93803. /**
  93804. * Gets the maxZ used for shadow according to both the scene and the light.
  93805. * @param activeCamera The camera we are returning the max for
  93806. * @returns the depth max z
  93807. */
  93808. getDepthMaxZ(activeCamera: Camera): number;
  93809. }
  93810. /**
  93811. * Base implementation IShadowLight
  93812. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  93813. */
  93814. export abstract class ShadowLight extends Light implements IShadowLight {
  93815. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  93816. protected _position: Vector3;
  93817. protected _setPosition(value: Vector3): void;
  93818. /**
  93819. * Sets the position the shadow will be casted from. Also use as the light position for both
  93820. * point and spot lights.
  93821. */
  93822. get position(): Vector3;
  93823. /**
  93824. * Sets the position the shadow will be casted from. Also use as the light position for both
  93825. * point and spot lights.
  93826. */
  93827. set position(value: Vector3);
  93828. protected _direction: Vector3;
  93829. protected _setDirection(value: Vector3): void;
  93830. /**
  93831. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  93832. * Also use as the light direction on spot and directional lights.
  93833. */
  93834. get direction(): Vector3;
  93835. /**
  93836. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  93837. * Also use as the light direction on spot and directional lights.
  93838. */
  93839. set direction(value: Vector3);
  93840. protected _shadowMinZ: number;
  93841. /**
  93842. * Gets the shadow projection clipping minimum z value.
  93843. */
  93844. get shadowMinZ(): number;
  93845. /**
  93846. * Sets the shadow projection clipping minimum z value.
  93847. */
  93848. set shadowMinZ(value: number);
  93849. protected _shadowMaxZ: number;
  93850. /**
  93851. * Sets the shadow projection clipping maximum z value.
  93852. */
  93853. get shadowMaxZ(): number;
  93854. /**
  93855. * Gets the shadow projection clipping maximum z value.
  93856. */
  93857. set shadowMaxZ(value: number);
  93858. /**
  93859. * Callback defining a custom Projection Matrix Builder.
  93860. * This can be used to override the default projection matrix computation.
  93861. */
  93862. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  93863. /**
  93864. * The transformed position. Position of the light in world space taking parenting in account.
  93865. */
  93866. transformedPosition: Vector3;
  93867. /**
  93868. * The transformed direction. Direction of the light in world space taking parenting in account.
  93869. */
  93870. transformedDirection: Vector3;
  93871. private _needProjectionMatrixCompute;
  93872. /**
  93873. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  93874. * @returns true if the information has been computed, false if it does not need to (no parenting)
  93875. */
  93876. computeTransformedInformation(): boolean;
  93877. /**
  93878. * Return the depth scale used for the shadow map.
  93879. * @returns the depth scale.
  93880. */
  93881. getDepthScale(): number;
  93882. /**
  93883. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  93884. * @param faceIndex The index of the face we are computed the direction to generate shadow
  93885. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  93886. */
  93887. getShadowDirection(faceIndex?: number): Vector3;
  93888. /**
  93889. * Returns the ShadowLight absolute position in the World.
  93890. * @returns the position vector in world space
  93891. */
  93892. getAbsolutePosition(): Vector3;
  93893. /**
  93894. * Sets the ShadowLight direction toward the passed target.
  93895. * @param target The point to target in local space
  93896. * @returns the updated ShadowLight direction
  93897. */
  93898. setDirectionToTarget(target: Vector3): Vector3;
  93899. /**
  93900. * Returns the light rotation in euler definition.
  93901. * @returns the x y z rotation in local space.
  93902. */
  93903. getRotation(): Vector3;
  93904. /**
  93905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  93906. * @returns true if a cube texture needs to be use
  93907. */
  93908. needCube(): boolean;
  93909. /**
  93910. * Detects if the projection matrix requires to be recomputed this frame.
  93911. * @returns true if it requires to be recomputed otherwise, false.
  93912. */
  93913. needProjectionMatrixCompute(): boolean;
  93914. /**
  93915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  93916. */
  93917. forceProjectionMatrixCompute(): void;
  93918. /** @hidden */
  93919. _initCache(): void;
  93920. /** @hidden */
  93921. _isSynchronized(): boolean;
  93922. /**
  93923. * Computes the world matrix of the node
  93924. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93925. * @returns the world matrix
  93926. */
  93927. computeWorldMatrix(force?: boolean): Matrix;
  93928. /**
  93929. * Gets the minZ used for shadow according to both the scene and the light.
  93930. * @param activeCamera The camera we are returning the min for
  93931. * @returns the depth min z
  93932. */
  93933. getDepthMinZ(activeCamera: Camera): number;
  93934. /**
  93935. * Gets the maxZ used for shadow according to both the scene and the light.
  93936. * @param activeCamera The camera we are returning the max for
  93937. * @returns the depth max z
  93938. */
  93939. getDepthMaxZ(activeCamera: Camera): number;
  93940. /**
  93941. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  93942. * @param matrix The materix to updated with the projection information
  93943. * @param viewMatrix The transform matrix of the light
  93944. * @param renderList The list of mesh to render in the map
  93945. * @returns The current light
  93946. */
  93947. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  93948. }
  93949. }
  93950. declare module BABYLON {
  93951. /**
  93952. * Configuration needed for prepass-capable materials
  93953. */
  93954. export class PrePassConfiguration {
  93955. /**
  93956. * Previous world matrices of meshes carrying this material
  93957. * Used for computing velocity
  93958. */
  93959. previousWorldMatrices: {
  93960. [index: number]: Matrix;
  93961. };
  93962. /**
  93963. * Previous view project matrix
  93964. * Used for computing velocity
  93965. */
  93966. previousViewProjection: Matrix;
  93967. /**
  93968. * Previous bones of meshes carrying this material
  93969. * Used for computing velocity
  93970. */
  93971. previousBones: {
  93972. [index: number]: Float32Array;
  93973. };
  93974. /**
  93975. * Add the required uniforms to the current list.
  93976. * @param uniforms defines the current uniform list.
  93977. */
  93978. static AddUniforms(uniforms: string[]): void;
  93979. /**
  93980. * Add the required samplers to the current list.
  93981. * @param samplers defines the current sampler list.
  93982. */
  93983. static AddSamplers(samplers: string[]): void;
  93984. /**
  93985. * Binds the material data.
  93986. * @param effect defines the effect to update
  93987. * @param scene defines the scene the material belongs to.
  93988. * @param mesh The mesh
  93989. * @param world World matrix of this mesh
  93990. * @param isFrozen Is the material frozen
  93991. */
  93992. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  93993. }
  93994. }
  93995. declare module BABYLON {
  93996. /**
  93997. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  93998. * This is the base of the follow, arc rotate cameras and Free camera
  93999. * @see https://doc.babylonjs.com/features/cameras
  94000. */
  94001. export class TargetCamera extends Camera {
  94002. private static _RigCamTransformMatrix;
  94003. private static _TargetTransformMatrix;
  94004. private static _TargetFocalPoint;
  94005. private _tmpUpVector;
  94006. private _tmpTargetVector;
  94007. /**
  94008. * Define the current direction the camera is moving to
  94009. */
  94010. cameraDirection: Vector3;
  94011. /**
  94012. * Define the current rotation the camera is rotating to
  94013. */
  94014. cameraRotation: Vector2;
  94015. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  94016. ignoreParentScaling: boolean;
  94017. /**
  94018. * When set, the up vector of the camera will be updated by the rotation of the camera
  94019. */
  94020. updateUpVectorFromRotation: boolean;
  94021. private _tmpQuaternion;
  94022. /**
  94023. * Define the current rotation of the camera
  94024. */
  94025. rotation: Vector3;
  94026. /**
  94027. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  94028. */
  94029. rotationQuaternion: Quaternion;
  94030. /**
  94031. * Define the current speed of the camera
  94032. */
  94033. speed: number;
  94034. /**
  94035. * Add constraint to the camera to prevent it to move freely in all directions and
  94036. * around all axis.
  94037. */
  94038. noRotationConstraint: boolean;
  94039. /**
  94040. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  94041. * panning
  94042. */
  94043. invertRotation: boolean;
  94044. /**
  94045. * Speed multiplier for inverse camera panning
  94046. */
  94047. inverseRotationSpeed: number;
  94048. /**
  94049. * Define the current target of the camera as an object or a position.
  94050. */
  94051. lockedTarget: any;
  94052. /** @hidden */
  94053. _currentTarget: Vector3;
  94054. /** @hidden */
  94055. _initialFocalDistance: number;
  94056. /** @hidden */
  94057. _viewMatrix: Matrix;
  94058. /** @hidden */
  94059. _camMatrix: Matrix;
  94060. /** @hidden */
  94061. _cameraTransformMatrix: Matrix;
  94062. /** @hidden */
  94063. _cameraRotationMatrix: Matrix;
  94064. /** @hidden */
  94065. _referencePoint: Vector3;
  94066. /** @hidden */
  94067. _transformedReferencePoint: Vector3;
  94068. /** @hidden */
  94069. _reset: () => void;
  94070. private _defaultUp;
  94071. /**
  94072. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  94073. * This is the base of the follow, arc rotate cameras and Free camera
  94074. * @see https://doc.babylonjs.com/features/cameras
  94075. * @param name Defines the name of the camera in the scene
  94076. * @param position Defines the start position of the camera in the scene
  94077. * @param scene Defines the scene the camera belongs to
  94078. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94079. */
  94080. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94081. /**
  94082. * Gets the position in front of the camera at a given distance.
  94083. * @param distance The distance from the camera we want the position to be
  94084. * @returns the position
  94085. */
  94086. getFrontPosition(distance: number): Vector3;
  94087. /** @hidden */
  94088. _getLockedTargetPosition(): Nullable<Vector3>;
  94089. private _storedPosition;
  94090. private _storedRotation;
  94091. private _storedRotationQuaternion;
  94092. /**
  94093. * Store current camera state of the camera (fov, position, rotation, etc..)
  94094. * @returns the camera
  94095. */
  94096. storeState(): Camera;
  94097. /**
  94098. * Restored camera state. You must call storeState() first
  94099. * @returns whether it was successful or not
  94100. * @hidden
  94101. */
  94102. _restoreStateValues(): boolean;
  94103. /** @hidden */
  94104. _initCache(): void;
  94105. /** @hidden */
  94106. _updateCache(ignoreParentClass?: boolean): void;
  94107. /** @hidden */
  94108. _isSynchronizedViewMatrix(): boolean;
  94109. /** @hidden */
  94110. _computeLocalCameraSpeed(): number;
  94111. /**
  94112. * Defines the target the camera should look at.
  94113. * @param target Defines the new target as a Vector or a mesh
  94114. */
  94115. setTarget(target: Vector3): void;
  94116. /**
  94117. * Defines the target point of the camera.
  94118. * The camera looks towards it form the radius distance.
  94119. */
  94120. get target(): Vector3;
  94121. set target(value: Vector3);
  94122. /**
  94123. * Return the current target position of the camera. This value is expressed in local space.
  94124. * @returns the target position
  94125. */
  94126. getTarget(): Vector3;
  94127. /** @hidden */
  94128. _decideIfNeedsToMove(): boolean;
  94129. /** @hidden */
  94130. _updatePosition(): void;
  94131. /** @hidden */
  94132. _checkInputs(): void;
  94133. protected _updateCameraRotationMatrix(): void;
  94134. /**
  94135. * 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)
  94136. * @returns the current camera
  94137. */
  94138. private _rotateUpVectorWithCameraRotationMatrix;
  94139. private _cachedRotationZ;
  94140. private _cachedQuaternionRotationZ;
  94141. /** @hidden */
  94142. _getViewMatrix(): Matrix;
  94143. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  94144. /**
  94145. * @hidden
  94146. */
  94147. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94148. /**
  94149. * @hidden
  94150. */
  94151. _updateRigCameras(): void;
  94152. private _getRigCamPositionAndTarget;
  94153. /**
  94154. * Gets the current object class name.
  94155. * @return the class name
  94156. */
  94157. getClassName(): string;
  94158. }
  94159. }
  94160. declare module BABYLON {
  94161. /**
  94162. * @ignore
  94163. * This is a list of all the different input types that are available in the application.
  94164. * Fo instance: ArcRotateCameraGamepadInput...
  94165. */
  94166. export var CameraInputTypes: {};
  94167. /**
  94168. * This is the contract to implement in order to create a new input class.
  94169. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  94170. */
  94171. export interface ICameraInput<TCamera extends Camera> {
  94172. /**
  94173. * Defines the camera the input is attached to.
  94174. */
  94175. camera: Nullable<TCamera>;
  94176. /**
  94177. * Gets the class name of the current intput.
  94178. * @returns the class name
  94179. */
  94180. getClassName(): string;
  94181. /**
  94182. * Get the friendly name associated with the input class.
  94183. * @returns the input friendly name
  94184. */
  94185. getSimpleName(): string;
  94186. /**
  94187. * Attach the input controls to a specific dom element to get the input from.
  94188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94189. */
  94190. attachControl(noPreventDefault?: boolean): void;
  94191. /**
  94192. * Detach the current controls from the specified dom element.
  94193. */
  94194. detachControl(): void;
  94195. /**
  94196. * Update the current camera state depending on the inputs that have been used this frame.
  94197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94198. */
  94199. checkInputs?: () => void;
  94200. }
  94201. /**
  94202. * Represents a map of input types to input instance or input index to input instance.
  94203. */
  94204. export interface CameraInputsMap<TCamera extends Camera> {
  94205. /**
  94206. * Accessor to the input by input type.
  94207. */
  94208. [name: string]: ICameraInput<TCamera>;
  94209. /**
  94210. * Accessor to the input by input index.
  94211. */
  94212. [idx: number]: ICameraInput<TCamera>;
  94213. }
  94214. /**
  94215. * This represents the input manager used within a camera.
  94216. * It helps dealing with all the different kind of input attached to a camera.
  94217. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94218. */
  94219. export class CameraInputsManager<TCamera extends Camera> {
  94220. /**
  94221. * Defines the list of inputs attahed to the camera.
  94222. */
  94223. attached: CameraInputsMap<TCamera>;
  94224. /**
  94225. * Defines the dom element the camera is collecting inputs from.
  94226. * This is null if the controls have not been attached.
  94227. */
  94228. attachedToElement: boolean;
  94229. /**
  94230. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94231. */
  94232. noPreventDefault: boolean;
  94233. /**
  94234. * Defined the camera the input manager belongs to.
  94235. */
  94236. camera: TCamera;
  94237. /**
  94238. * Update the current camera state depending on the inputs that have been used this frame.
  94239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94240. */
  94241. checkInputs: () => void;
  94242. /**
  94243. * Instantiate a new Camera Input Manager.
  94244. * @param camera Defines the camera the input manager blongs to
  94245. */
  94246. constructor(camera: TCamera);
  94247. /**
  94248. * Add an input method to a camera
  94249. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94250. * @param input camera input method
  94251. */
  94252. add(input: ICameraInput<TCamera>): void;
  94253. /**
  94254. * Remove a specific input method from a camera
  94255. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  94256. * @param inputToRemove camera input method
  94257. */
  94258. remove(inputToRemove: ICameraInput<TCamera>): void;
  94259. /**
  94260. * Remove a specific input type from a camera
  94261. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  94262. * @param inputType the type of the input to remove
  94263. */
  94264. removeByType(inputType: string): void;
  94265. private _addCheckInputs;
  94266. /**
  94267. * Attach the input controls to the currently attached dom element to listen the events from.
  94268. * @param input Defines the input to attach
  94269. */
  94270. attachInput(input: ICameraInput<TCamera>): void;
  94271. /**
  94272. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  94273. * @param element Defines the dom element to collect the events from
  94274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94275. */
  94276. attachElement(noPreventDefault?: boolean): void;
  94277. /**
  94278. * Detach the current manager inputs controls from a specific dom element.
  94279. * @param element Defines the dom element to collect the events from
  94280. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  94281. */
  94282. detachElement(disconnect?: boolean): void;
  94283. /**
  94284. * Rebuild the dynamic inputCheck function from the current list of
  94285. * defined inputs in the manager.
  94286. */
  94287. rebuildInputCheck(): void;
  94288. /**
  94289. * Remove all attached input methods from a camera
  94290. */
  94291. clear(): void;
  94292. /**
  94293. * Serialize the current input manager attached to a camera.
  94294. * This ensures than once parsed,
  94295. * the input associated to the camera will be identical to the current ones
  94296. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  94297. */
  94298. serialize(serializedCamera: any): void;
  94299. /**
  94300. * Parses an input manager serialized JSON to restore the previous list of inputs
  94301. * and states associated to a camera.
  94302. * @param parsedCamera Defines the JSON to parse
  94303. */
  94304. parse(parsedCamera: any): void;
  94305. }
  94306. }
  94307. declare module BABYLON {
  94308. /**
  94309. * Gather the list of keyboard event types as constants.
  94310. */
  94311. export class KeyboardEventTypes {
  94312. /**
  94313. * The keydown event is fired when a key becomes active (pressed).
  94314. */
  94315. static readonly KEYDOWN: number;
  94316. /**
  94317. * The keyup event is fired when a key has been released.
  94318. */
  94319. static readonly KEYUP: number;
  94320. }
  94321. /**
  94322. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94323. */
  94324. export class KeyboardInfo {
  94325. /**
  94326. * Defines the type of event (KeyboardEventTypes)
  94327. */
  94328. type: number;
  94329. /**
  94330. * Defines the related dom event
  94331. */
  94332. event: KeyboardEvent;
  94333. /**
  94334. * Instantiates a new keyboard info.
  94335. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94336. * @param type Defines the type of event (KeyboardEventTypes)
  94337. * @param event Defines the related dom event
  94338. */
  94339. constructor(
  94340. /**
  94341. * Defines the type of event (KeyboardEventTypes)
  94342. */
  94343. type: number,
  94344. /**
  94345. * Defines the related dom event
  94346. */
  94347. event: KeyboardEvent);
  94348. }
  94349. /**
  94350. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94351. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  94352. */
  94353. export class KeyboardInfoPre extends KeyboardInfo {
  94354. /**
  94355. * Defines the type of event (KeyboardEventTypes)
  94356. */
  94357. type: number;
  94358. /**
  94359. * Defines the related dom event
  94360. */
  94361. event: KeyboardEvent;
  94362. /**
  94363. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  94364. */
  94365. skipOnPointerObservable: boolean;
  94366. /**
  94367. * Instantiates a new keyboard pre info.
  94368. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94369. * @param type Defines the type of event (KeyboardEventTypes)
  94370. * @param event Defines the related dom event
  94371. */
  94372. constructor(
  94373. /**
  94374. * Defines the type of event (KeyboardEventTypes)
  94375. */
  94376. type: number,
  94377. /**
  94378. * Defines the related dom event
  94379. */
  94380. event: KeyboardEvent);
  94381. }
  94382. }
  94383. declare module BABYLON {
  94384. /**
  94385. * Manage the keyboard inputs to control the movement of a free camera.
  94386. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94387. */
  94388. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  94389. /**
  94390. * Defines the camera the input is attached to.
  94391. */
  94392. camera: FreeCamera;
  94393. /**
  94394. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94395. */
  94396. keysUp: number[];
  94397. /**
  94398. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94399. */
  94400. keysUpward: number[];
  94401. /**
  94402. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94403. */
  94404. keysDown: number[];
  94405. /**
  94406. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94407. */
  94408. keysDownward: number[];
  94409. /**
  94410. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94411. */
  94412. keysLeft: number[];
  94413. /**
  94414. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94415. */
  94416. keysRight: number[];
  94417. private _keys;
  94418. private _onCanvasBlurObserver;
  94419. private _onKeyboardObserver;
  94420. private _engine;
  94421. private _scene;
  94422. /**
  94423. * Attach the input controls to a specific dom element to get the input from.
  94424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94425. */
  94426. attachControl(noPreventDefault?: boolean): void;
  94427. /**
  94428. * Detach the current controls from the specified dom element.
  94429. */
  94430. detachControl(): void;
  94431. /**
  94432. * Update the current camera state depending on the inputs that have been used this frame.
  94433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94434. */
  94435. checkInputs(): void;
  94436. /**
  94437. * Gets the class name of the current intput.
  94438. * @returns the class name
  94439. */
  94440. getClassName(): string;
  94441. /** @hidden */
  94442. _onLostFocus(): void;
  94443. /**
  94444. * Get the friendly name associated with the input class.
  94445. * @returns the input friendly name
  94446. */
  94447. getSimpleName(): string;
  94448. }
  94449. }
  94450. declare module BABYLON {
  94451. /**
  94452. * Interface used to define Action
  94453. */
  94454. export interface IAction {
  94455. /**
  94456. * Trigger for the action
  94457. */
  94458. trigger: number;
  94459. /** Options of the trigger */
  94460. triggerOptions: any;
  94461. /**
  94462. * Gets the trigger parameters
  94463. * @returns the trigger parameters
  94464. */
  94465. getTriggerParameter(): any;
  94466. /**
  94467. * Internal only - executes current action event
  94468. * @hidden
  94469. */
  94470. _executeCurrent(evt?: ActionEvent): void;
  94471. /**
  94472. * Serialize placeholder for child classes
  94473. * @param parent of child
  94474. * @returns the serialized object
  94475. */
  94476. serialize(parent: any): any;
  94477. /**
  94478. * Internal only
  94479. * @hidden
  94480. */
  94481. _prepare(): void;
  94482. /**
  94483. * Internal only - manager for action
  94484. * @hidden
  94485. */
  94486. _actionManager: Nullable<AbstractActionManager>;
  94487. /**
  94488. * Adds action to chain of actions, may be a DoNothingAction
  94489. * @param action defines the next action to execute
  94490. * @returns The action passed in
  94491. * @see https://www.babylonjs-playground.com/#1T30HR#0
  94492. */
  94493. then(action: IAction): IAction;
  94494. }
  94495. /**
  94496. * The action to be carried out following a trigger
  94497. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  94498. */
  94499. export class Action implements IAction {
  94500. /** the trigger, with or without parameters, for the action */
  94501. triggerOptions: any;
  94502. /**
  94503. * Trigger for the action
  94504. */
  94505. trigger: number;
  94506. /**
  94507. * Internal only - manager for action
  94508. * @hidden
  94509. */
  94510. _actionManager: ActionManager;
  94511. private _nextActiveAction;
  94512. private _child;
  94513. private _condition?;
  94514. private _triggerParameter;
  94515. /**
  94516. * An event triggered prior to action being executed.
  94517. */
  94518. onBeforeExecuteObservable: Observable<Action>;
  94519. /**
  94520. * Creates a new Action
  94521. * @param triggerOptions the trigger, with or without parameters, for the action
  94522. * @param condition an optional determinant of action
  94523. */
  94524. constructor(
  94525. /** the trigger, with or without parameters, for the action */
  94526. triggerOptions: any, condition?: Condition);
  94527. /**
  94528. * Internal only
  94529. * @hidden
  94530. */
  94531. _prepare(): void;
  94532. /**
  94533. * Gets the trigger parameter
  94534. * @returns the trigger parameter
  94535. */
  94536. getTriggerParameter(): any;
  94537. /**
  94538. * Sets the trigger parameter
  94539. * @param value defines the new trigger parameter
  94540. */
  94541. setTriggerParameter(value: any): void;
  94542. /**
  94543. * Internal only - executes current action event
  94544. * @hidden
  94545. */
  94546. _executeCurrent(evt?: ActionEvent): void;
  94547. /**
  94548. * Execute placeholder for child classes
  94549. * @param evt optional action event
  94550. */
  94551. execute(evt?: ActionEvent): void;
  94552. /**
  94553. * Skips to next active action
  94554. */
  94555. skipToNextActiveAction(): void;
  94556. /**
  94557. * Adds action to chain of actions, may be a DoNothingAction
  94558. * @param action defines the next action to execute
  94559. * @returns The action passed in
  94560. * @see https://www.babylonjs-playground.com/#1T30HR#0
  94561. */
  94562. then(action: Action): Action;
  94563. /**
  94564. * Internal only
  94565. * @hidden
  94566. */
  94567. _getProperty(propertyPath: string): string;
  94568. /**
  94569. * Internal only
  94570. * @hidden
  94571. */
  94572. _getEffectiveTarget(target: any, propertyPath: string): any;
  94573. /**
  94574. * Serialize placeholder for child classes
  94575. * @param parent of child
  94576. * @returns the serialized object
  94577. */
  94578. serialize(parent: any): any;
  94579. /**
  94580. * Internal only called by serialize
  94581. * @hidden
  94582. */
  94583. protected _serialize(serializedAction: any, parent?: any): any;
  94584. /**
  94585. * Internal only
  94586. * @hidden
  94587. */
  94588. static _SerializeValueAsString: (value: any) => string;
  94589. /**
  94590. * Internal only
  94591. * @hidden
  94592. */
  94593. static _GetTargetProperty: (target: Scene | Node) => {
  94594. name: string;
  94595. targetType: string;
  94596. value: string;
  94597. };
  94598. }
  94599. }
  94600. declare module BABYLON {
  94601. /**
  94602. * A Condition applied to an Action
  94603. */
  94604. export class Condition {
  94605. /**
  94606. * Internal only - manager for action
  94607. * @hidden
  94608. */
  94609. _actionManager: ActionManager;
  94610. /**
  94611. * Internal only
  94612. * @hidden
  94613. */
  94614. _evaluationId: number;
  94615. /**
  94616. * Internal only
  94617. * @hidden
  94618. */
  94619. _currentResult: boolean;
  94620. /**
  94621. * Creates a new Condition
  94622. * @param actionManager the manager of the action the condition is applied to
  94623. */
  94624. constructor(actionManager: ActionManager);
  94625. /**
  94626. * Check if the current condition is valid
  94627. * @returns a boolean
  94628. */
  94629. isValid(): boolean;
  94630. /**
  94631. * Internal only
  94632. * @hidden
  94633. */
  94634. _getProperty(propertyPath: string): string;
  94635. /**
  94636. * Internal only
  94637. * @hidden
  94638. */
  94639. _getEffectiveTarget(target: any, propertyPath: string): any;
  94640. /**
  94641. * Serialize placeholder for child classes
  94642. * @returns the serialized object
  94643. */
  94644. serialize(): any;
  94645. /**
  94646. * Internal only
  94647. * @hidden
  94648. */
  94649. protected _serialize(serializedCondition: any): any;
  94650. }
  94651. /**
  94652. * Defines specific conditional operators as extensions of Condition
  94653. */
  94654. export class ValueCondition extends Condition {
  94655. /** path to specify the property of the target the conditional operator uses */
  94656. propertyPath: string;
  94657. /** the value compared by the conditional operator against the current value of the property */
  94658. value: any;
  94659. /** the conditional operator, default ValueCondition.IsEqual */
  94660. operator: number;
  94661. /**
  94662. * Internal only
  94663. * @hidden
  94664. */
  94665. private static _IsEqual;
  94666. /**
  94667. * Internal only
  94668. * @hidden
  94669. */
  94670. private static _IsDifferent;
  94671. /**
  94672. * Internal only
  94673. * @hidden
  94674. */
  94675. private static _IsGreater;
  94676. /**
  94677. * Internal only
  94678. * @hidden
  94679. */
  94680. private static _IsLesser;
  94681. /**
  94682. * returns the number for IsEqual
  94683. */
  94684. static get IsEqual(): number;
  94685. /**
  94686. * Returns the number for IsDifferent
  94687. */
  94688. static get IsDifferent(): number;
  94689. /**
  94690. * Returns the number for IsGreater
  94691. */
  94692. static get IsGreater(): number;
  94693. /**
  94694. * Returns the number for IsLesser
  94695. */
  94696. static get IsLesser(): number;
  94697. /**
  94698. * Internal only The action manager for the condition
  94699. * @hidden
  94700. */
  94701. _actionManager: ActionManager;
  94702. /**
  94703. * Internal only
  94704. * @hidden
  94705. */
  94706. private _target;
  94707. /**
  94708. * Internal only
  94709. * @hidden
  94710. */
  94711. private _effectiveTarget;
  94712. /**
  94713. * Internal only
  94714. * @hidden
  94715. */
  94716. private _property;
  94717. /**
  94718. * Creates a new ValueCondition
  94719. * @param actionManager manager for the action the condition applies to
  94720. * @param target for the action
  94721. * @param propertyPath path to specify the property of the target the conditional operator uses
  94722. * @param value the value compared by the conditional operator against the current value of the property
  94723. * @param operator the conditional operator, default ValueCondition.IsEqual
  94724. */
  94725. constructor(actionManager: ActionManager, target: any,
  94726. /** path to specify the property of the target the conditional operator uses */
  94727. propertyPath: string,
  94728. /** the value compared by the conditional operator against the current value of the property */
  94729. value: any,
  94730. /** the conditional operator, default ValueCondition.IsEqual */
  94731. operator?: number);
  94732. /**
  94733. * Compares the given value with the property value for the specified conditional operator
  94734. * @returns the result of the comparison
  94735. */
  94736. isValid(): boolean;
  94737. /**
  94738. * Serialize the ValueCondition into a JSON compatible object
  94739. * @returns serialization object
  94740. */
  94741. serialize(): any;
  94742. /**
  94743. * Gets the name of the conditional operator for the ValueCondition
  94744. * @param operator the conditional operator
  94745. * @returns the name
  94746. */
  94747. static GetOperatorName(operator: number): string;
  94748. }
  94749. /**
  94750. * Defines a predicate condition as an extension of Condition
  94751. */
  94752. export class PredicateCondition extends Condition {
  94753. /** defines the predicate function used to validate the condition */
  94754. predicate: () => boolean;
  94755. /**
  94756. * Internal only - manager for action
  94757. * @hidden
  94758. */
  94759. _actionManager: ActionManager;
  94760. /**
  94761. * Creates a new PredicateCondition
  94762. * @param actionManager manager for the action the condition applies to
  94763. * @param predicate defines the predicate function used to validate the condition
  94764. */
  94765. constructor(actionManager: ActionManager,
  94766. /** defines the predicate function used to validate the condition */
  94767. predicate: () => boolean);
  94768. /**
  94769. * @returns the validity of the predicate condition
  94770. */
  94771. isValid(): boolean;
  94772. }
  94773. /**
  94774. * Defines a state condition as an extension of Condition
  94775. */
  94776. export class StateCondition extends Condition {
  94777. /** Value to compare with target state */
  94778. value: string;
  94779. /**
  94780. * Internal only - manager for action
  94781. * @hidden
  94782. */
  94783. _actionManager: ActionManager;
  94784. /**
  94785. * Internal only
  94786. * @hidden
  94787. */
  94788. private _target;
  94789. /**
  94790. * Creates a new StateCondition
  94791. * @param actionManager manager for the action the condition applies to
  94792. * @param target of the condition
  94793. * @param value to compare with target state
  94794. */
  94795. constructor(actionManager: ActionManager, target: any,
  94796. /** Value to compare with target state */
  94797. value: string);
  94798. /**
  94799. * Gets a boolean indicating if the current condition is met
  94800. * @returns the validity of the state
  94801. */
  94802. isValid(): boolean;
  94803. /**
  94804. * Serialize the StateCondition into a JSON compatible object
  94805. * @returns serialization object
  94806. */
  94807. serialize(): any;
  94808. }
  94809. }
  94810. declare module BABYLON {
  94811. /**
  94812. * This defines an action responsible to toggle a boolean once triggered.
  94813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94814. */
  94815. export class SwitchBooleanAction extends Action {
  94816. /**
  94817. * The path to the boolean property in the target object
  94818. */
  94819. propertyPath: string;
  94820. private _target;
  94821. private _effectiveTarget;
  94822. private _property;
  94823. /**
  94824. * Instantiate the action
  94825. * @param triggerOptions defines the trigger options
  94826. * @param target defines the object containing the boolean
  94827. * @param propertyPath defines the path to the boolean property in the target object
  94828. * @param condition defines the trigger related conditions
  94829. */
  94830. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  94831. /** @hidden */
  94832. _prepare(): void;
  94833. /**
  94834. * Execute the action toggle the boolean value.
  94835. */
  94836. execute(): void;
  94837. /**
  94838. * Serializes the actions and its related information.
  94839. * @param parent defines the object to serialize in
  94840. * @returns the serialized object
  94841. */
  94842. serialize(parent: any): any;
  94843. }
  94844. /**
  94845. * This defines an action responsible to set a the state field of the target
  94846. * to a desired value once triggered.
  94847. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94848. */
  94849. export class SetStateAction extends Action {
  94850. /**
  94851. * The value to store in the state field.
  94852. */
  94853. value: string;
  94854. private _target;
  94855. /**
  94856. * Instantiate the action
  94857. * @param triggerOptions defines the trigger options
  94858. * @param target defines the object containing the state property
  94859. * @param value defines the value to store in the state field
  94860. * @param condition defines the trigger related conditions
  94861. */
  94862. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  94863. /**
  94864. * Execute the action and store the value on the target state property.
  94865. */
  94866. execute(): void;
  94867. /**
  94868. * Serializes the actions and its related information.
  94869. * @param parent defines the object to serialize in
  94870. * @returns the serialized object
  94871. */
  94872. serialize(parent: any): any;
  94873. }
  94874. /**
  94875. * This defines an action responsible to set a property of the target
  94876. * to a desired value once triggered.
  94877. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94878. */
  94879. export class SetValueAction extends Action {
  94880. /**
  94881. * The path of the property to set in the target.
  94882. */
  94883. propertyPath: string;
  94884. /**
  94885. * The value to set in the property
  94886. */
  94887. value: any;
  94888. private _target;
  94889. private _effectiveTarget;
  94890. private _property;
  94891. /**
  94892. * Instantiate the action
  94893. * @param triggerOptions defines the trigger options
  94894. * @param target defines the object containing the property
  94895. * @param propertyPath defines the path of the property to set in the target
  94896. * @param value defines the value to set in the property
  94897. * @param condition defines the trigger related conditions
  94898. */
  94899. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  94900. /** @hidden */
  94901. _prepare(): void;
  94902. /**
  94903. * Execute the action and set the targetted property to the desired value.
  94904. */
  94905. execute(): void;
  94906. /**
  94907. * Serializes the actions and its related information.
  94908. * @param parent defines the object to serialize in
  94909. * @returns the serialized object
  94910. */
  94911. serialize(parent: any): any;
  94912. }
  94913. /**
  94914. * This defines an action responsible to increment the target value
  94915. * to a desired value once triggered.
  94916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94917. */
  94918. export class IncrementValueAction extends Action {
  94919. /**
  94920. * The path of the property to increment in the target.
  94921. */
  94922. propertyPath: string;
  94923. /**
  94924. * The value we should increment the property by.
  94925. */
  94926. value: any;
  94927. private _target;
  94928. private _effectiveTarget;
  94929. private _property;
  94930. /**
  94931. * Instantiate the action
  94932. * @param triggerOptions defines the trigger options
  94933. * @param target defines the object containing the property
  94934. * @param propertyPath defines the path of the property to increment in the target
  94935. * @param value defines the value value we should increment the property by
  94936. * @param condition defines the trigger related conditions
  94937. */
  94938. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  94939. /** @hidden */
  94940. _prepare(): void;
  94941. /**
  94942. * Execute the action and increment the target of the value amount.
  94943. */
  94944. execute(): void;
  94945. /**
  94946. * Serializes the actions and its related information.
  94947. * @param parent defines the object to serialize in
  94948. * @returns the serialized object
  94949. */
  94950. serialize(parent: any): any;
  94951. }
  94952. /**
  94953. * This defines an action responsible to start an animation once triggered.
  94954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94955. */
  94956. export class PlayAnimationAction extends Action {
  94957. /**
  94958. * Where the animation should start (animation frame)
  94959. */
  94960. from: number;
  94961. /**
  94962. * Where the animation should stop (animation frame)
  94963. */
  94964. to: number;
  94965. /**
  94966. * Define if the animation should loop or stop after the first play.
  94967. */
  94968. loop?: boolean;
  94969. private _target;
  94970. /**
  94971. * Instantiate the action
  94972. * @param triggerOptions defines the trigger options
  94973. * @param target defines the target animation or animation name
  94974. * @param from defines from where the animation should start (animation frame)
  94975. * @param end defines where the animation should stop (animation frame)
  94976. * @param loop defines if the animation should loop or stop after the first play
  94977. * @param condition defines the trigger related conditions
  94978. */
  94979. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  94980. /** @hidden */
  94981. _prepare(): void;
  94982. /**
  94983. * Execute the action and play the animation.
  94984. */
  94985. execute(): void;
  94986. /**
  94987. * Serializes the actions and its related information.
  94988. * @param parent defines the object to serialize in
  94989. * @returns the serialized object
  94990. */
  94991. serialize(parent: any): any;
  94992. }
  94993. /**
  94994. * This defines an action responsible to stop an animation once triggered.
  94995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94996. */
  94997. export class StopAnimationAction extends Action {
  94998. private _target;
  94999. /**
  95000. * Instantiate the action
  95001. * @param triggerOptions defines the trigger options
  95002. * @param target defines the target animation or animation name
  95003. * @param condition defines the trigger related conditions
  95004. */
  95005. constructor(triggerOptions: any, target: any, condition?: Condition);
  95006. /** @hidden */
  95007. _prepare(): void;
  95008. /**
  95009. * Execute the action and stop the animation.
  95010. */
  95011. execute(): void;
  95012. /**
  95013. * Serializes the actions and its related information.
  95014. * @param parent defines the object to serialize in
  95015. * @returns the serialized object
  95016. */
  95017. serialize(parent: any): any;
  95018. }
  95019. /**
  95020. * This defines an action responsible that does nothing once triggered.
  95021. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95022. */
  95023. export class DoNothingAction extends Action {
  95024. /**
  95025. * Instantiate the action
  95026. * @param triggerOptions defines the trigger options
  95027. * @param condition defines the trigger related conditions
  95028. */
  95029. constructor(triggerOptions?: any, condition?: Condition);
  95030. /**
  95031. * Execute the action and do nothing.
  95032. */
  95033. execute(): void;
  95034. /**
  95035. * Serializes the actions and its related information.
  95036. * @param parent defines the object to serialize in
  95037. * @returns the serialized object
  95038. */
  95039. serialize(parent: any): any;
  95040. }
  95041. /**
  95042. * This defines an action responsible to trigger several actions once triggered.
  95043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95044. */
  95045. export class CombineAction extends Action {
  95046. /**
  95047. * The list of aggregated animations to run.
  95048. */
  95049. children: Action[];
  95050. /**
  95051. * Instantiate the action
  95052. * @param triggerOptions defines the trigger options
  95053. * @param children defines the list of aggregated animations to run
  95054. * @param condition defines the trigger related conditions
  95055. */
  95056. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  95057. /** @hidden */
  95058. _prepare(): void;
  95059. /**
  95060. * Execute the action and executes all the aggregated actions.
  95061. */
  95062. execute(evt: ActionEvent): void;
  95063. /**
  95064. * Serializes the actions and its related information.
  95065. * @param parent defines the object to serialize in
  95066. * @returns the serialized object
  95067. */
  95068. serialize(parent: any): any;
  95069. }
  95070. /**
  95071. * This defines an action responsible to run code (external event) once triggered.
  95072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95073. */
  95074. export class ExecuteCodeAction extends Action {
  95075. /**
  95076. * The callback function to run.
  95077. */
  95078. func: (evt: ActionEvent) => void;
  95079. /**
  95080. * Instantiate the action
  95081. * @param triggerOptions defines the trigger options
  95082. * @param func defines the callback function to run
  95083. * @param condition defines the trigger related conditions
  95084. */
  95085. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  95086. /**
  95087. * Execute the action and run the attached code.
  95088. */
  95089. execute(evt: ActionEvent): void;
  95090. }
  95091. /**
  95092. * This defines an action responsible to set the parent property of the target once triggered.
  95093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95094. */
  95095. export class SetParentAction extends Action {
  95096. private _parent;
  95097. private _target;
  95098. /**
  95099. * Instantiate the action
  95100. * @param triggerOptions defines the trigger options
  95101. * @param target defines the target containing the parent property
  95102. * @param parent defines from where the animation should start (animation frame)
  95103. * @param condition defines the trigger related conditions
  95104. */
  95105. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  95106. /** @hidden */
  95107. _prepare(): void;
  95108. /**
  95109. * Execute the action and set the parent property.
  95110. */
  95111. execute(): void;
  95112. /**
  95113. * Serializes the actions and its related information.
  95114. * @param parent defines the object to serialize in
  95115. * @returns the serialized object
  95116. */
  95117. serialize(parent: any): any;
  95118. }
  95119. }
  95120. declare module BABYLON {
  95121. /**
  95122. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  95123. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  95124. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95125. */
  95126. export class ActionManager extends AbstractActionManager {
  95127. /**
  95128. * Nothing
  95129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95130. */
  95131. static readonly NothingTrigger: number;
  95132. /**
  95133. * On pick
  95134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95135. */
  95136. static readonly OnPickTrigger: number;
  95137. /**
  95138. * On left pick
  95139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95140. */
  95141. static readonly OnLeftPickTrigger: number;
  95142. /**
  95143. * On right pick
  95144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95145. */
  95146. static readonly OnRightPickTrigger: number;
  95147. /**
  95148. * On center pick
  95149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95150. */
  95151. static readonly OnCenterPickTrigger: number;
  95152. /**
  95153. * On pick down
  95154. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95155. */
  95156. static readonly OnPickDownTrigger: number;
  95157. /**
  95158. * On double pick
  95159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95160. */
  95161. static readonly OnDoublePickTrigger: number;
  95162. /**
  95163. * On pick up
  95164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95165. */
  95166. static readonly OnPickUpTrigger: number;
  95167. /**
  95168. * On pick out.
  95169. * This trigger will only be raised if you also declared a OnPickDown
  95170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95171. */
  95172. static readonly OnPickOutTrigger: number;
  95173. /**
  95174. * On long press
  95175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95176. */
  95177. static readonly OnLongPressTrigger: number;
  95178. /**
  95179. * On pointer over
  95180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95181. */
  95182. static readonly OnPointerOverTrigger: number;
  95183. /**
  95184. * On pointer out
  95185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95186. */
  95187. static readonly OnPointerOutTrigger: number;
  95188. /**
  95189. * On every frame
  95190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95191. */
  95192. static readonly OnEveryFrameTrigger: number;
  95193. /**
  95194. * On intersection enter
  95195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95196. */
  95197. static readonly OnIntersectionEnterTrigger: number;
  95198. /**
  95199. * On intersection exit
  95200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95201. */
  95202. static readonly OnIntersectionExitTrigger: number;
  95203. /**
  95204. * On key down
  95205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95206. */
  95207. static readonly OnKeyDownTrigger: number;
  95208. /**
  95209. * On key up
  95210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95211. */
  95212. static readonly OnKeyUpTrigger: number;
  95213. private _scene;
  95214. /**
  95215. * Creates a new action manager
  95216. * @param scene defines the hosting scene
  95217. */
  95218. constructor(scene: Scene);
  95219. /**
  95220. * Releases all associated resources
  95221. */
  95222. dispose(): void;
  95223. /**
  95224. * Gets hosting scene
  95225. * @returns the hosting scene
  95226. */
  95227. getScene(): Scene;
  95228. /**
  95229. * Does this action manager handles actions of any of the given triggers
  95230. * @param triggers defines the triggers to be tested
  95231. * @return a boolean indicating whether one (or more) of the triggers is handled
  95232. */
  95233. hasSpecificTriggers(triggers: number[]): boolean;
  95234. /**
  95235. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95236. * speed.
  95237. * @param triggerA defines the trigger to be tested
  95238. * @param triggerB defines the trigger to be tested
  95239. * @return a boolean indicating whether one (or more) of the triggers is handled
  95240. */
  95241. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95242. /**
  95243. * Does this action manager handles actions of a given trigger
  95244. * @param trigger defines the trigger to be tested
  95245. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95246. * @return whether the trigger is handled
  95247. */
  95248. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95249. /**
  95250. * Does this action manager has pointer triggers
  95251. */
  95252. get hasPointerTriggers(): boolean;
  95253. /**
  95254. * Does this action manager has pick triggers
  95255. */
  95256. get hasPickTriggers(): boolean;
  95257. /**
  95258. * Registers an action to this action manager
  95259. * @param action defines the action to be registered
  95260. * @return the action amended (prepared) after registration
  95261. */
  95262. registerAction(action: IAction): Nullable<IAction>;
  95263. /**
  95264. * Unregisters an action to this action manager
  95265. * @param action defines the action to be unregistered
  95266. * @return a boolean indicating whether the action has been unregistered
  95267. */
  95268. unregisterAction(action: IAction): Boolean;
  95269. /**
  95270. * Process a specific trigger
  95271. * @param trigger defines the trigger to process
  95272. * @param evt defines the event details to be processed
  95273. */
  95274. processTrigger(trigger: number, evt?: IActionEvent): void;
  95275. /** @hidden */
  95276. _getEffectiveTarget(target: any, propertyPath: string): any;
  95277. /** @hidden */
  95278. _getProperty(propertyPath: string): string;
  95279. /**
  95280. * Serialize this manager to a JSON object
  95281. * @param name defines the property name to store this manager
  95282. * @returns a JSON representation of this manager
  95283. */
  95284. serialize(name: string): any;
  95285. /**
  95286. * Creates a new ActionManager from a JSON data
  95287. * @param parsedActions defines the JSON data to read from
  95288. * @param object defines the hosting mesh
  95289. * @param scene defines the hosting scene
  95290. */
  95291. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  95292. /**
  95293. * Get a trigger name by index
  95294. * @param trigger defines the trigger index
  95295. * @returns a trigger name
  95296. */
  95297. static GetTriggerName(trigger: number): string;
  95298. }
  95299. }
  95300. declare module BABYLON {
  95301. /**
  95302. * Class representing a ray with position and direction
  95303. */
  95304. export class Ray {
  95305. /** origin point */
  95306. origin: Vector3;
  95307. /** direction */
  95308. direction: Vector3;
  95309. /** length of the ray */
  95310. length: number;
  95311. private static readonly _TmpVector3;
  95312. private _tmpRay;
  95313. /**
  95314. * Creates a new ray
  95315. * @param origin origin point
  95316. * @param direction direction
  95317. * @param length length of the ray
  95318. */
  95319. constructor(
  95320. /** origin point */
  95321. origin: Vector3,
  95322. /** direction */
  95323. direction: Vector3,
  95324. /** length of the ray */
  95325. length?: number);
  95326. /**
  95327. * Checks if the ray intersects a box
  95328. * This does not account for the ray lenght by design to improve perfs.
  95329. * @param minimum bound of the box
  95330. * @param maximum bound of the box
  95331. * @param intersectionTreshold extra extend to be added to the box in all direction
  95332. * @returns if the box was hit
  95333. */
  95334. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  95335. /**
  95336. * Checks if the ray intersects a box
  95337. * This does not account for the ray lenght by design to improve perfs.
  95338. * @param box the bounding box to check
  95339. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  95340. * @returns if the box was hit
  95341. */
  95342. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  95343. /**
  95344. * If the ray hits a sphere
  95345. * @param sphere the bounding sphere to check
  95346. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  95347. * @returns true if it hits the sphere
  95348. */
  95349. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  95350. /**
  95351. * If the ray hits a triange
  95352. * @param vertex0 triangle vertex
  95353. * @param vertex1 triangle vertex
  95354. * @param vertex2 triangle vertex
  95355. * @returns intersection information if hit
  95356. */
  95357. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  95358. /**
  95359. * Checks if ray intersects a plane
  95360. * @param plane the plane to check
  95361. * @returns the distance away it was hit
  95362. */
  95363. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  95364. /**
  95365. * Calculate the intercept of a ray on a given axis
  95366. * @param axis to check 'x' | 'y' | 'z'
  95367. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  95368. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  95369. */
  95370. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  95371. /**
  95372. * Checks if ray intersects a mesh
  95373. * @param mesh the mesh to check
  95374. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95375. * @returns picking info of the intersecton
  95376. */
  95377. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  95378. /**
  95379. * Checks if ray intersects a mesh
  95380. * @param meshes the meshes to check
  95381. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95382. * @param results array to store result in
  95383. * @returns Array of picking infos
  95384. */
  95385. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  95386. private _comparePickingInfo;
  95387. private static smallnum;
  95388. private static rayl;
  95389. /**
  95390. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  95391. * @param sega the first point of the segment to test the intersection against
  95392. * @param segb the second point of the segment to test the intersection against
  95393. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  95394. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  95395. */
  95396. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  95397. /**
  95398. * Update the ray from viewport position
  95399. * @param x position
  95400. * @param y y position
  95401. * @param viewportWidth viewport width
  95402. * @param viewportHeight viewport height
  95403. * @param world world matrix
  95404. * @param view view matrix
  95405. * @param projection projection matrix
  95406. * @returns this ray updated
  95407. */
  95408. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  95409. /**
  95410. * Creates a ray with origin and direction of 0,0,0
  95411. * @returns the new ray
  95412. */
  95413. static Zero(): Ray;
  95414. /**
  95415. * Creates a new ray from screen space and viewport
  95416. * @param x position
  95417. * @param y y position
  95418. * @param viewportWidth viewport width
  95419. * @param viewportHeight viewport height
  95420. * @param world world matrix
  95421. * @param view view matrix
  95422. * @param projection projection matrix
  95423. * @returns new ray
  95424. */
  95425. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  95426. /**
  95427. * 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
  95428. * transformed to the given world matrix.
  95429. * @param origin The origin point
  95430. * @param end The end point
  95431. * @param world a matrix to transform the ray to. Default is the identity matrix.
  95432. * @returns the new ray
  95433. */
  95434. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  95435. /**
  95436. * Transforms a ray by a matrix
  95437. * @param ray ray to transform
  95438. * @param matrix matrix to apply
  95439. * @returns the resulting new ray
  95440. */
  95441. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  95442. /**
  95443. * Transforms a ray by a matrix
  95444. * @param ray ray to transform
  95445. * @param matrix matrix to apply
  95446. * @param result ray to store result in
  95447. */
  95448. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  95449. /**
  95450. * Unproject a ray from screen space to object space
  95451. * @param sourceX defines the screen space x coordinate to use
  95452. * @param sourceY defines the screen space y coordinate to use
  95453. * @param viewportWidth defines the current width of the viewport
  95454. * @param viewportHeight defines the current height of the viewport
  95455. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  95456. * @param view defines the view matrix to use
  95457. * @param projection defines the projection matrix to use
  95458. */
  95459. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  95460. }
  95461. /**
  95462. * Type used to define predicate used to select faces when a mesh intersection is detected
  95463. */
  95464. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  95465. interface Scene {
  95466. /** @hidden */
  95467. _tempPickingRay: Nullable<Ray>;
  95468. /** @hidden */
  95469. _cachedRayForTransform: Ray;
  95470. /** @hidden */
  95471. _pickWithRayInverseMatrix: Matrix;
  95472. /** @hidden */
  95473. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  95474. /** @hidden */
  95475. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95476. /** @hidden */
  95477. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  95478. }
  95479. }
  95480. declare module BABYLON {
  95481. /**
  95482. * Groups all the scene component constants in one place to ease maintenance.
  95483. * @hidden
  95484. */
  95485. export class SceneComponentConstants {
  95486. static readonly NAME_EFFECTLAYER: string;
  95487. static readonly NAME_LAYER: string;
  95488. static readonly NAME_LENSFLARESYSTEM: string;
  95489. static readonly NAME_BOUNDINGBOXRENDERER: string;
  95490. static readonly NAME_PARTICLESYSTEM: string;
  95491. static readonly NAME_GAMEPAD: string;
  95492. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  95493. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  95494. static readonly NAME_PREPASSRENDERER: string;
  95495. static readonly NAME_DEPTHRENDERER: string;
  95496. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  95497. static readonly NAME_SPRITE: string;
  95498. static readonly NAME_SUBSURFACE: string;
  95499. static readonly NAME_OUTLINERENDERER: string;
  95500. static readonly NAME_PROCEDURALTEXTURE: string;
  95501. static readonly NAME_SHADOWGENERATOR: string;
  95502. static readonly NAME_OCTREE: string;
  95503. static readonly NAME_PHYSICSENGINE: string;
  95504. static readonly NAME_AUDIO: string;
  95505. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  95506. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  95507. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  95508. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  95509. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  95510. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  95511. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  95512. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  95513. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  95514. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  95515. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  95516. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  95517. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  95518. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  95519. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  95520. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  95521. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  95522. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  95523. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  95524. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  95525. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  95526. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  95527. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  95528. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  95529. static readonly STEP_AFTERRENDER_AUDIO: number;
  95530. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  95531. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  95532. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  95533. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  95534. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  95535. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  95536. static readonly STEP_POINTERMOVE_SPRITE: number;
  95537. static readonly STEP_POINTERDOWN_SPRITE: number;
  95538. static readonly STEP_POINTERUP_SPRITE: number;
  95539. }
  95540. /**
  95541. * This represents a scene component.
  95542. *
  95543. * This is used to decouple the dependency the scene is having on the different workloads like
  95544. * layers, post processes...
  95545. */
  95546. export interface ISceneComponent {
  95547. /**
  95548. * The name of the component. Each component must have a unique name.
  95549. */
  95550. name: string;
  95551. /**
  95552. * The scene the component belongs to.
  95553. */
  95554. scene: Scene;
  95555. /**
  95556. * Register the component to one instance of a scene.
  95557. */
  95558. register(): void;
  95559. /**
  95560. * Rebuilds the elements related to this component in case of
  95561. * context lost for instance.
  95562. */
  95563. rebuild(): void;
  95564. /**
  95565. * Disposes the component and the associated ressources.
  95566. */
  95567. dispose(): void;
  95568. }
  95569. /**
  95570. * This represents a SERIALIZABLE scene component.
  95571. *
  95572. * This extends Scene Component to add Serialization methods on top.
  95573. */
  95574. export interface ISceneSerializableComponent extends ISceneComponent {
  95575. /**
  95576. * Adds all the elements from the container to the scene
  95577. * @param container the container holding the elements
  95578. */
  95579. addFromContainer(container: AbstractScene): void;
  95580. /**
  95581. * Removes all the elements in the container from the scene
  95582. * @param container contains the elements to remove
  95583. * @param dispose if the removed element should be disposed (default: false)
  95584. */
  95585. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  95586. /**
  95587. * Serializes the component data to the specified json object
  95588. * @param serializationObject The object to serialize to
  95589. */
  95590. serialize(serializationObject: any): void;
  95591. }
  95592. /**
  95593. * Strong typing of a Mesh related stage step action
  95594. */
  95595. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  95596. /**
  95597. * Strong typing of a Evaluate Sub Mesh related stage step action
  95598. */
  95599. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  95600. /**
  95601. * Strong typing of a pre active Mesh related stage step action
  95602. */
  95603. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  95604. /**
  95605. * Strong typing of a Camera related stage step action
  95606. */
  95607. export type CameraStageAction = (camera: Camera) => void;
  95608. /**
  95609. * Strong typing of a Camera Frame buffer related stage step action
  95610. */
  95611. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  95612. /**
  95613. * Strong typing of a Render Target related stage step action
  95614. */
  95615. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  95616. /**
  95617. * Strong typing of a RenderingGroup related stage step action
  95618. */
  95619. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  95620. /**
  95621. * Strong typing of a Mesh Render related stage step action
  95622. */
  95623. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  95624. /**
  95625. * Strong typing of a simple stage step action
  95626. */
  95627. export type SimpleStageAction = () => void;
  95628. /**
  95629. * Strong typing of a render target action.
  95630. */
  95631. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  95632. /**
  95633. * Strong typing of a pointer move action.
  95634. */
  95635. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  95636. /**
  95637. * Strong typing of a pointer up/down action.
  95638. */
  95639. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  95640. /**
  95641. * Representation of a stage in the scene (Basically a list of ordered steps)
  95642. * @hidden
  95643. */
  95644. export class Stage<T extends Function> extends Array<{
  95645. index: number;
  95646. component: ISceneComponent;
  95647. action: T;
  95648. }> {
  95649. /**
  95650. * Hide ctor from the rest of the world.
  95651. * @param items The items to add.
  95652. */
  95653. private constructor();
  95654. /**
  95655. * Creates a new Stage.
  95656. * @returns A new instance of a Stage
  95657. */
  95658. static Create<T extends Function>(): Stage<T>;
  95659. /**
  95660. * Registers a step in an ordered way in the targeted stage.
  95661. * @param index Defines the position to register the step in
  95662. * @param component Defines the component attached to the step
  95663. * @param action Defines the action to launch during the step
  95664. */
  95665. registerStep(index: number, component: ISceneComponent, action: T): void;
  95666. /**
  95667. * Clears all the steps from the stage.
  95668. */
  95669. clear(): void;
  95670. }
  95671. }
  95672. declare module BABYLON {
  95673. interface Scene {
  95674. /** @hidden */
  95675. _pointerOverSprite: Nullable<Sprite>;
  95676. /** @hidden */
  95677. _pickedDownSprite: Nullable<Sprite>;
  95678. /** @hidden */
  95679. _tempSpritePickingRay: Nullable<Ray>;
  95680. /**
  95681. * All of the sprite managers added to this scene
  95682. * @see https://doc.babylonjs.com/babylon101/sprites
  95683. */
  95684. spriteManagers: Array<ISpriteManager>;
  95685. /**
  95686. * An event triggered when sprites rendering is about to start
  95687. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  95688. */
  95689. onBeforeSpritesRenderingObservable: Observable<Scene>;
  95690. /**
  95691. * An event triggered when sprites rendering is done
  95692. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  95693. */
  95694. onAfterSpritesRenderingObservable: Observable<Scene>;
  95695. /** @hidden */
  95696. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  95697. /** Launch a ray to try to pick a sprite in the scene
  95698. * @param x position on screen
  95699. * @param y position on screen
  95700. * @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
  95701. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95702. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95703. * @returns a PickingInfo
  95704. */
  95705. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  95706. /** Use the given ray to pick a sprite in the scene
  95707. * @param ray The ray (in world space) to use to pick meshes
  95708. * @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
  95709. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95710. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  95711. * @returns a PickingInfo
  95712. */
  95713. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  95714. /** @hidden */
  95715. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  95716. /** Launch a ray to try to pick sprites in the scene
  95717. * @param x position on screen
  95718. * @param y position on screen
  95719. * @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
  95720. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95721. * @returns a PickingInfo array
  95722. */
  95723. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  95724. /** Use the given ray to pick sprites in the scene
  95725. * @param ray The ray (in world space) to use to pick meshes
  95726. * @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
  95727. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  95728. * @returns a PickingInfo array
  95729. */
  95730. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  95731. /**
  95732. * Force the sprite under the pointer
  95733. * @param sprite defines the sprite to use
  95734. */
  95735. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  95736. /**
  95737. * Gets the sprite under the pointer
  95738. * @returns a Sprite or null if no sprite is under the pointer
  95739. */
  95740. getPointerOverSprite(): Nullable<Sprite>;
  95741. }
  95742. /**
  95743. * Defines the sprite scene component responsible to manage sprites
  95744. * in a given scene.
  95745. */
  95746. export class SpriteSceneComponent implements ISceneComponent {
  95747. /**
  95748. * The component name helpfull to identify the component in the list of scene components.
  95749. */
  95750. readonly name: string;
  95751. /**
  95752. * The scene the component belongs to.
  95753. */
  95754. scene: Scene;
  95755. /** @hidden */
  95756. private _spritePredicate;
  95757. /**
  95758. * Creates a new instance of the component for the given scene
  95759. * @param scene Defines the scene to register the component in
  95760. */
  95761. constructor(scene: Scene);
  95762. /**
  95763. * Registers the component in a given scene
  95764. */
  95765. register(): void;
  95766. /**
  95767. * Rebuilds the elements related to this component in case of
  95768. * context lost for instance.
  95769. */
  95770. rebuild(): void;
  95771. /**
  95772. * Disposes the component and the associated ressources.
  95773. */
  95774. dispose(): void;
  95775. private _pickSpriteButKeepRay;
  95776. private _pointerMove;
  95777. private _pointerDown;
  95778. private _pointerUp;
  95779. }
  95780. }
  95781. declare module BABYLON {
  95782. /**
  95783. * Class used to provide helper for timing
  95784. */
  95785. export class TimingTools {
  95786. /**
  95787. * Polyfill for setImmediate
  95788. * @param action defines the action to execute after the current execution block
  95789. */
  95790. static SetImmediate(action: () => void): void;
  95791. }
  95792. }
  95793. declare module BABYLON {
  95794. /**
  95795. * Class used to enable instatition of objects by class name
  95796. */
  95797. export class InstantiationTools {
  95798. /**
  95799. * Use this object to register external classes like custom textures or material
  95800. * to allow the laoders to instantiate them
  95801. */
  95802. static RegisteredExternalClasses: {
  95803. [key: string]: Object;
  95804. };
  95805. /**
  95806. * Tries to instantiate a new object from a given class name
  95807. * @param className defines the class name to instantiate
  95808. * @returns the new object or null if the system was not able to do the instantiation
  95809. */
  95810. static Instantiate(className: string): any;
  95811. }
  95812. }
  95813. declare module BABYLON {
  95814. /**
  95815. * Class used to host copy specific utilities
  95816. */
  95817. export class CopyTools {
  95818. /**
  95819. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  95820. * @param texture defines the texture to read pixels from
  95821. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95822. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95823. * @returns The base64 encoded string or null
  95824. */
  95825. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  95826. }
  95827. }
  95828. declare module BABYLON {
  95829. /**
  95830. * Define options used to create a depth texture
  95831. */
  95832. export class DepthTextureCreationOptions {
  95833. /** Specifies whether or not a stencil should be allocated in the texture */
  95834. generateStencil?: boolean;
  95835. /** Specifies whether or not bilinear filtering is enable on the texture */
  95836. bilinearFiltering?: boolean;
  95837. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95838. comparisonFunction?: number;
  95839. /** Specifies if the created texture is a cube texture */
  95840. isCube?: boolean;
  95841. /** Specifies the sample count of the depth/stencil texture texture */
  95842. samples?: number;
  95843. }
  95844. }
  95845. declare module BABYLON {
  95846. interface ThinEngine {
  95847. /**
  95848. * Creates a depth stencil cube texture.
  95849. * This is only available in WebGL 2.
  95850. * @param size The size of face edge in the cube texture.
  95851. * @param options The options defining the cube texture.
  95852. * @returns The cube texture
  95853. */
  95854. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  95855. /**
  95856. * Creates a cube texture
  95857. * @param rootUrl defines the url where the files to load is located
  95858. * @param scene defines the current scene
  95859. * @param files defines the list of files to load (1 per face)
  95860. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  95861. * @param onLoad defines an optional callback raised when the texture is loaded
  95862. * @param onError defines an optional callback raised if there is an issue to load the texture
  95863. * @param format defines the format of the data
  95864. * @param forcedExtension defines the extension to use to pick the right loader
  95865. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  95866. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  95867. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  95868. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  95869. * @param loaderOptions options to be passed to the loader
  95870. * @returns the cube texture as an InternalTexture
  95871. */
  95872. 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;
  95873. /**
  95874. * Creates a cube texture
  95875. * @param rootUrl defines the url where the files to load is located
  95876. * @param scene defines the current scene
  95877. * @param files defines the list of files to load (1 per face)
  95878. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  95879. * @param onLoad defines an optional callback raised when the texture is loaded
  95880. * @param onError defines an optional callback raised if there is an issue to load the texture
  95881. * @param format defines the format of the data
  95882. * @param forcedExtension defines the extension to use to pick the right loader
  95883. * @returns the cube texture as an InternalTexture
  95884. */
  95885. 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;
  95886. /**
  95887. * Creates a cube texture
  95888. * @param rootUrl defines the url where the files to load is located
  95889. * @param scene defines the current scene
  95890. * @param files defines the list of files to load (1 per face)
  95891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  95892. * @param onLoad defines an optional callback raised when the texture is loaded
  95893. * @param onError defines an optional callback raised if there is an issue to load the texture
  95894. * @param format defines the format of the data
  95895. * @param forcedExtension defines the extension to use to pick the right loader
  95896. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  95897. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  95898. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  95899. * @returns the cube texture as an InternalTexture
  95900. */
  95901. 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;
  95902. /** @hidden */
  95903. 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;
  95904. /** @hidden */
  95905. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  95906. /** @hidden */
  95907. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  95908. /** @hidden */
  95909. _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;
  95910. /** @hidden */
  95911. _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;
  95912. /**
  95913. * @hidden
  95914. */
  95915. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  95916. }
  95917. }
  95918. declare module BABYLON {
  95919. /**
  95920. * Class for creating a cube texture
  95921. */
  95922. export class CubeTexture extends BaseTexture {
  95923. private _delayedOnLoad;
  95924. /**
  95925. * Observable triggered once the texture has been loaded.
  95926. */
  95927. onLoadObservable: Observable<CubeTexture>;
  95928. /**
  95929. * The url of the texture
  95930. */
  95931. url: string;
  95932. /**
  95933. * Gets or sets the center of the bounding box associated with the cube texture.
  95934. * It must define where the camera used to render the texture was set
  95935. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  95936. */
  95937. boundingBoxPosition: Vector3;
  95938. private _boundingBoxSize;
  95939. /**
  95940. * Gets or sets the size of the bounding box associated with the cube texture
  95941. * When defined, the cubemap will switch to local mode
  95942. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95943. * @example https://www.babylonjs-playground.com/#RNASML
  95944. */
  95945. set boundingBoxSize(value: Vector3);
  95946. /**
  95947. * Returns the bounding box size
  95948. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  95949. */
  95950. get boundingBoxSize(): Vector3;
  95951. protected _rotationY: number;
  95952. /**
  95953. * Sets texture matrix rotation angle around Y axis in radians.
  95954. */
  95955. set rotationY(value: number);
  95956. /**
  95957. * Gets texture matrix rotation angle around Y axis radians.
  95958. */
  95959. get rotationY(): number;
  95960. /**
  95961. * Are mip maps generated for this texture or not.
  95962. */
  95963. get noMipmap(): boolean;
  95964. private _noMipmap;
  95965. private _files;
  95966. protected _forcedExtension: Nullable<string>;
  95967. private _extensions;
  95968. private _textureMatrix;
  95969. private _format;
  95970. private _createPolynomials;
  95971. private _loaderOptions;
  95972. /**
  95973. * Creates a cube texture from an array of image urls
  95974. * @param files defines an array of image urls
  95975. * @param scene defines the hosting scene
  95976. * @param noMipmap specifies if mip maps are not used
  95977. * @returns a cube texture
  95978. */
  95979. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  95980. /**
  95981. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  95982. * @param url defines the url of the prefiltered texture
  95983. * @param scene defines the scene the texture is attached to
  95984. * @param forcedExtension defines the extension of the file if different from the url
  95985. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  95986. * @return the prefiltered texture
  95987. */
  95988. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  95989. /**
  95990. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  95991. * as prefiltered data.
  95992. * @param rootUrl defines the url of the texture or the root name of the six images
  95993. * @param null defines the scene or engine the texture is attached to
  95994. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  95995. * @param noMipmap defines if mipmaps should be created or not
  95996. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  95997. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  95998. * @param onError defines a callback triggered in case of error during load
  95999. * @param format defines the internal format to use for the texture once loaded
  96000. * @param prefiltered defines whether or not the texture is created from prefiltered data
  96001. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  96002. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96005. * @param loaderOptions options to be passed to the loader
  96006. * @return the cube texture
  96007. */
  96008. 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);
  96009. /**
  96010. * Get the current class name of the texture useful for serialization or dynamic coding.
  96011. * @returns "CubeTexture"
  96012. */
  96013. getClassName(): string;
  96014. /**
  96015. * Update the url (and optional buffer) of this texture if url was null during construction.
  96016. * @param url the url of the texture
  96017. * @param forcedExtension defines the extension to use
  96018. * @param onLoad callback called when the texture is loaded (defaults to null)
  96019. * @param prefiltered Defines whether the updated texture is prefiltered or not
  96020. */
  96021. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  96022. /**
  96023. * Delays loading of the cube texture
  96024. * @param forcedExtension defines the extension to use
  96025. */
  96026. delayLoad(forcedExtension?: string): void;
  96027. /**
  96028. * Returns the reflection texture matrix
  96029. * @returns the reflection texture matrix
  96030. */
  96031. getReflectionTextureMatrix(): Matrix;
  96032. /**
  96033. * Sets the reflection texture matrix
  96034. * @param value Reflection texture matrix
  96035. */
  96036. setReflectionTextureMatrix(value: Matrix): void;
  96037. /**
  96038. * Parses text to create a cube texture
  96039. * @param parsedTexture define the serialized text to read from
  96040. * @param scene defines the hosting scene
  96041. * @param rootUrl defines the root url of the cube texture
  96042. * @returns a cube texture
  96043. */
  96044. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  96045. /**
  96046. * Makes a clone, or deep copy, of the cube texture
  96047. * @returns a new cube texture
  96048. */
  96049. clone(): CubeTexture;
  96050. }
  96051. }
  96052. declare module BABYLON {
  96053. /**
  96054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96056. * 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;
  96057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96058. */
  96059. export class ColorCurves {
  96060. private _dirty;
  96061. private _tempColor;
  96062. private _globalCurve;
  96063. private _highlightsCurve;
  96064. private _midtonesCurve;
  96065. private _shadowsCurve;
  96066. private _positiveCurve;
  96067. private _negativeCurve;
  96068. private _globalHue;
  96069. private _globalDensity;
  96070. private _globalSaturation;
  96071. private _globalExposure;
  96072. /**
  96073. * Gets the global Hue value.
  96074. * 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).
  96075. */
  96076. get globalHue(): number;
  96077. /**
  96078. * Sets the global Hue value.
  96079. * 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).
  96080. */
  96081. set globalHue(value: number);
  96082. /**
  96083. * Gets the global Density value.
  96084. * 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.
  96085. * Values less than zero provide a filter of opposite hue.
  96086. */
  96087. get globalDensity(): number;
  96088. /**
  96089. * Sets the global Density value.
  96090. * 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.
  96091. * Values less than zero provide a filter of opposite hue.
  96092. */
  96093. set globalDensity(value: number);
  96094. /**
  96095. * Gets the global Saturation value.
  96096. * 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.
  96097. */
  96098. get globalSaturation(): number;
  96099. /**
  96100. * Sets the global Saturation value.
  96101. * 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.
  96102. */
  96103. set globalSaturation(value: number);
  96104. /**
  96105. * Gets the global Exposure value.
  96106. * 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.
  96107. */
  96108. get globalExposure(): number;
  96109. /**
  96110. * Sets the global Exposure value.
  96111. * 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.
  96112. */
  96113. set globalExposure(value: number);
  96114. private _highlightsHue;
  96115. private _highlightsDensity;
  96116. private _highlightsSaturation;
  96117. private _highlightsExposure;
  96118. /**
  96119. * Gets the highlights Hue value.
  96120. * 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).
  96121. */
  96122. get highlightsHue(): number;
  96123. /**
  96124. * Sets the highlights Hue value.
  96125. * 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).
  96126. */
  96127. set highlightsHue(value: number);
  96128. /**
  96129. * Gets the highlights Density value.
  96130. * 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.
  96131. * Values less than zero provide a filter of opposite hue.
  96132. */
  96133. get highlightsDensity(): number;
  96134. /**
  96135. * Sets the highlights Density value.
  96136. * 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.
  96137. * Values less than zero provide a filter of opposite hue.
  96138. */
  96139. set highlightsDensity(value: number);
  96140. /**
  96141. * Gets the highlights Saturation value.
  96142. * 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.
  96143. */
  96144. get highlightsSaturation(): number;
  96145. /**
  96146. * Sets the highlights Saturation value.
  96147. * 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.
  96148. */
  96149. set highlightsSaturation(value: number);
  96150. /**
  96151. * Gets the highlights Exposure value.
  96152. * 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.
  96153. */
  96154. get highlightsExposure(): number;
  96155. /**
  96156. * Sets the highlights Exposure value.
  96157. * 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.
  96158. */
  96159. set highlightsExposure(value: number);
  96160. private _midtonesHue;
  96161. private _midtonesDensity;
  96162. private _midtonesSaturation;
  96163. private _midtonesExposure;
  96164. /**
  96165. * Gets the midtones Hue value.
  96166. * 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).
  96167. */
  96168. get midtonesHue(): number;
  96169. /**
  96170. * Sets the midtones Hue value.
  96171. * 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).
  96172. */
  96173. set midtonesHue(value: number);
  96174. /**
  96175. * Gets the midtones Density value.
  96176. * 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.
  96177. * Values less than zero provide a filter of opposite hue.
  96178. */
  96179. get midtonesDensity(): number;
  96180. /**
  96181. * Sets the midtones Density value.
  96182. * 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.
  96183. * Values less than zero provide a filter of opposite hue.
  96184. */
  96185. set midtonesDensity(value: number);
  96186. /**
  96187. * Gets the midtones Saturation value.
  96188. * 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.
  96189. */
  96190. get midtonesSaturation(): number;
  96191. /**
  96192. * Sets the midtones Saturation value.
  96193. * 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.
  96194. */
  96195. set midtonesSaturation(value: number);
  96196. /**
  96197. * Gets the midtones Exposure value.
  96198. * 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.
  96199. */
  96200. get midtonesExposure(): number;
  96201. /**
  96202. * Sets the midtones Exposure value.
  96203. * 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.
  96204. */
  96205. set midtonesExposure(value: number);
  96206. private _shadowsHue;
  96207. private _shadowsDensity;
  96208. private _shadowsSaturation;
  96209. private _shadowsExposure;
  96210. /**
  96211. * Gets the shadows Hue value.
  96212. * 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).
  96213. */
  96214. get shadowsHue(): number;
  96215. /**
  96216. * Sets the shadows Hue value.
  96217. * 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).
  96218. */
  96219. set shadowsHue(value: number);
  96220. /**
  96221. * Gets the shadows Density value.
  96222. * 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.
  96223. * Values less than zero provide a filter of opposite hue.
  96224. */
  96225. get shadowsDensity(): number;
  96226. /**
  96227. * Sets the shadows Density value.
  96228. * 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.
  96229. * Values less than zero provide a filter of opposite hue.
  96230. */
  96231. set shadowsDensity(value: number);
  96232. /**
  96233. * Gets the shadows Saturation value.
  96234. * 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.
  96235. */
  96236. get shadowsSaturation(): number;
  96237. /**
  96238. * Sets the shadows Saturation value.
  96239. * 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.
  96240. */
  96241. set shadowsSaturation(value: number);
  96242. /**
  96243. * Gets the shadows Exposure value.
  96244. * 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.
  96245. */
  96246. get shadowsExposure(): number;
  96247. /**
  96248. * Sets the shadows Exposure value.
  96249. * 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.
  96250. */
  96251. set shadowsExposure(value: number);
  96252. /**
  96253. * Returns the class name
  96254. * @returns The class name
  96255. */
  96256. getClassName(): string;
  96257. /**
  96258. * Binds the color curves to the shader.
  96259. * @param colorCurves The color curve to bind
  96260. * @param effect The effect to bind to
  96261. * @param positiveUniform The positive uniform shader parameter
  96262. * @param neutralUniform The neutral uniform shader parameter
  96263. * @param negativeUniform The negative uniform shader parameter
  96264. */
  96265. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  96266. /**
  96267. * Prepare the list of uniforms associated with the ColorCurves effects.
  96268. * @param uniformsList The list of uniforms used in the effect
  96269. */
  96270. static PrepareUniforms(uniformsList: string[]): void;
  96271. /**
  96272. * Returns color grading data based on a hue, density, saturation and exposure value.
  96273. * @param filterHue The hue of the color filter.
  96274. * @param filterDensity The density of the color filter.
  96275. * @param saturation The saturation.
  96276. * @param exposure The exposure.
  96277. * @param result The result data container.
  96278. */
  96279. private getColorGradingDataToRef;
  96280. /**
  96281. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  96282. * @param value The input slider value in range [-100,100].
  96283. * @returns Adjusted value.
  96284. */
  96285. private static applyColorGradingSliderNonlinear;
  96286. /**
  96287. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  96288. * @param hue The hue (H) input.
  96289. * @param saturation The saturation (S) input.
  96290. * @param brightness The brightness (B) input.
  96291. * @result An RGBA color represented as Vector4.
  96292. */
  96293. private static fromHSBToRef;
  96294. /**
  96295. * Returns a value clamped between min and max
  96296. * @param value The value to clamp
  96297. * @param min The minimum of value
  96298. * @param max The maximum of value
  96299. * @returns The clamped value.
  96300. */
  96301. private static clamp;
  96302. /**
  96303. * Clones the current color curve instance.
  96304. * @return The cloned curves
  96305. */
  96306. clone(): ColorCurves;
  96307. /**
  96308. * Serializes the current color curve instance to a json representation.
  96309. * @return a JSON representation
  96310. */
  96311. serialize(): any;
  96312. /**
  96313. * Parses the color curve from a json representation.
  96314. * @param source the JSON source to parse
  96315. * @return The parsed curves
  96316. */
  96317. static Parse(source: any): ColorCurves;
  96318. }
  96319. }
  96320. declare module BABYLON {
  96321. /**
  96322. * Interface to follow in your material defines to integrate easily the
  96323. * Image proccessing functions.
  96324. * @hidden
  96325. */
  96326. export interface IImageProcessingConfigurationDefines {
  96327. IMAGEPROCESSING: boolean;
  96328. VIGNETTE: boolean;
  96329. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96330. VIGNETTEBLENDMODEOPAQUE: boolean;
  96331. TONEMAPPING: boolean;
  96332. TONEMAPPING_ACES: boolean;
  96333. CONTRAST: boolean;
  96334. EXPOSURE: boolean;
  96335. COLORCURVES: boolean;
  96336. COLORGRADING: boolean;
  96337. COLORGRADING3D: boolean;
  96338. SAMPLER3DGREENDEPTH: boolean;
  96339. SAMPLER3DBGRMAP: boolean;
  96340. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96341. }
  96342. /**
  96343. * @hidden
  96344. */
  96345. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96346. IMAGEPROCESSING: boolean;
  96347. VIGNETTE: boolean;
  96348. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96349. VIGNETTEBLENDMODEOPAQUE: boolean;
  96350. TONEMAPPING: boolean;
  96351. TONEMAPPING_ACES: boolean;
  96352. CONTRAST: boolean;
  96353. COLORCURVES: boolean;
  96354. COLORGRADING: boolean;
  96355. COLORGRADING3D: boolean;
  96356. SAMPLER3DGREENDEPTH: boolean;
  96357. SAMPLER3DBGRMAP: boolean;
  96358. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96359. EXPOSURE: boolean;
  96360. constructor();
  96361. }
  96362. /**
  96363. * This groups together the common properties used for image processing either in direct forward pass
  96364. * or through post processing effect depending on the use of the image processing pipeline in your scene
  96365. * or not.
  96366. */
  96367. export class ImageProcessingConfiguration {
  96368. /**
  96369. * Default tone mapping applied in BabylonJS.
  96370. */
  96371. static readonly TONEMAPPING_STANDARD: number;
  96372. /**
  96373. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  96374. * to other engines rendering to increase portability.
  96375. */
  96376. static readonly TONEMAPPING_ACES: number;
  96377. /**
  96378. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  96379. */
  96380. colorCurves: Nullable<ColorCurves>;
  96381. private _colorCurvesEnabled;
  96382. /**
  96383. * Gets wether the color curves effect is enabled.
  96384. */
  96385. get colorCurvesEnabled(): boolean;
  96386. /**
  96387. * Sets wether the color curves effect is enabled.
  96388. */
  96389. set colorCurvesEnabled(value: boolean);
  96390. private _colorGradingTexture;
  96391. /**
  96392. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  96393. */
  96394. get colorGradingTexture(): Nullable<BaseTexture>;
  96395. /**
  96396. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  96397. */
  96398. set colorGradingTexture(value: Nullable<BaseTexture>);
  96399. private _colorGradingEnabled;
  96400. /**
  96401. * Gets wether the color grading effect is enabled.
  96402. */
  96403. get colorGradingEnabled(): boolean;
  96404. /**
  96405. * Sets wether the color grading effect is enabled.
  96406. */
  96407. set colorGradingEnabled(value: boolean);
  96408. private _colorGradingWithGreenDepth;
  96409. /**
  96410. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  96411. */
  96412. get colorGradingWithGreenDepth(): boolean;
  96413. /**
  96414. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  96415. */
  96416. set colorGradingWithGreenDepth(value: boolean);
  96417. private _colorGradingBGR;
  96418. /**
  96419. * Gets wether the color grading texture contains BGR values.
  96420. */
  96421. get colorGradingBGR(): boolean;
  96422. /**
  96423. * Sets wether the color grading texture contains BGR values.
  96424. */
  96425. set colorGradingBGR(value: boolean);
  96426. /** @hidden */
  96427. _exposure: number;
  96428. /**
  96429. * Gets the Exposure used in the effect.
  96430. */
  96431. get exposure(): number;
  96432. /**
  96433. * Sets the Exposure used in the effect.
  96434. */
  96435. set exposure(value: number);
  96436. private _toneMappingEnabled;
  96437. /**
  96438. * Gets wether the tone mapping effect is enabled.
  96439. */
  96440. get toneMappingEnabled(): boolean;
  96441. /**
  96442. * Sets wether the tone mapping effect is enabled.
  96443. */
  96444. set toneMappingEnabled(value: boolean);
  96445. private _toneMappingType;
  96446. /**
  96447. * Gets the type of tone mapping effect.
  96448. */
  96449. get toneMappingType(): number;
  96450. /**
  96451. * Sets the type of tone mapping effect used in BabylonJS.
  96452. */
  96453. set toneMappingType(value: number);
  96454. protected _contrast: number;
  96455. /**
  96456. * Gets the contrast used in the effect.
  96457. */
  96458. get contrast(): number;
  96459. /**
  96460. * Sets the contrast used in the effect.
  96461. */
  96462. set contrast(value: number);
  96463. /**
  96464. * Vignette stretch size.
  96465. */
  96466. vignetteStretch: number;
  96467. /**
  96468. * Vignette centre X Offset.
  96469. */
  96470. vignetteCentreX: number;
  96471. /**
  96472. * Vignette centre Y Offset.
  96473. */
  96474. vignetteCentreY: number;
  96475. /**
  96476. * Vignette weight or intensity of the vignette effect.
  96477. */
  96478. vignetteWeight: number;
  96479. /**
  96480. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96481. * if vignetteEnabled is set to true.
  96482. */
  96483. vignetteColor: Color4;
  96484. /**
  96485. * Camera field of view used by the Vignette effect.
  96486. */
  96487. vignetteCameraFov: number;
  96488. private _vignetteBlendMode;
  96489. /**
  96490. * Gets the vignette blend mode allowing different kind of effect.
  96491. */
  96492. get vignetteBlendMode(): number;
  96493. /**
  96494. * Sets the vignette blend mode allowing different kind of effect.
  96495. */
  96496. set vignetteBlendMode(value: number);
  96497. private _vignetteEnabled;
  96498. /**
  96499. * Gets wether the vignette effect is enabled.
  96500. */
  96501. get vignetteEnabled(): boolean;
  96502. /**
  96503. * Sets wether the vignette effect is enabled.
  96504. */
  96505. set vignetteEnabled(value: boolean);
  96506. private _applyByPostProcess;
  96507. /**
  96508. * Gets wether the image processing is applied through a post process or not.
  96509. */
  96510. get applyByPostProcess(): boolean;
  96511. /**
  96512. * Sets wether the image processing is applied through a post process or not.
  96513. */
  96514. set applyByPostProcess(value: boolean);
  96515. private _isEnabled;
  96516. /**
  96517. * Gets wether the image processing is enabled or not.
  96518. */
  96519. get isEnabled(): boolean;
  96520. /**
  96521. * Sets wether the image processing is enabled or not.
  96522. */
  96523. set isEnabled(value: boolean);
  96524. /**
  96525. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  96526. */
  96527. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  96528. /**
  96529. * Method called each time the image processing information changes requires to recompile the effect.
  96530. */
  96531. protected _updateParameters(): void;
  96532. /**
  96533. * Gets the current class name.
  96534. * @return "ImageProcessingConfiguration"
  96535. */
  96536. getClassName(): string;
  96537. /**
  96538. * Prepare the list of uniforms associated with the Image Processing effects.
  96539. * @param uniforms The list of uniforms used in the effect
  96540. * @param defines the list of defines currently in use
  96541. */
  96542. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  96543. /**
  96544. * Prepare the list of samplers associated with the Image Processing effects.
  96545. * @param samplersList The list of uniforms used in the effect
  96546. * @param defines the list of defines currently in use
  96547. */
  96548. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  96549. /**
  96550. * Prepare the list of defines associated to the shader.
  96551. * @param defines the list of defines to complete
  96552. * @param forPostProcess Define if we are currently in post process mode or not
  96553. */
  96554. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  96555. /**
  96556. * Returns true if all the image processing information are ready.
  96557. * @returns True if ready, otherwise, false
  96558. */
  96559. isReady(): boolean;
  96560. /**
  96561. * Binds the image processing to the shader.
  96562. * @param effect The effect to bind to
  96563. * @param overrideAspectRatio Override the aspect ratio of the effect
  96564. */
  96565. bind(effect: Effect, overrideAspectRatio?: number): void;
  96566. /**
  96567. * Clones the current image processing instance.
  96568. * @return The cloned image processing
  96569. */
  96570. clone(): ImageProcessingConfiguration;
  96571. /**
  96572. * Serializes the current image processing instance to a json representation.
  96573. * @return a JSON representation
  96574. */
  96575. serialize(): any;
  96576. /**
  96577. * Parses the image processing from a json representation.
  96578. * @param source the JSON source to parse
  96579. * @return The parsed image processing
  96580. */
  96581. static Parse(source: any): ImageProcessingConfiguration;
  96582. private static _VIGNETTEMODE_MULTIPLY;
  96583. private static _VIGNETTEMODE_OPAQUE;
  96584. /**
  96585. * Used to apply the vignette as a mix with the pixel color.
  96586. */
  96587. static get VIGNETTEMODE_MULTIPLY(): number;
  96588. /**
  96589. * Used to apply the vignette as a replacement of the pixel color.
  96590. */
  96591. static get VIGNETTEMODE_OPAQUE(): number;
  96592. }
  96593. }
  96594. declare module BABYLON {
  96595. /** @hidden */
  96596. export var postprocessVertexShader: {
  96597. name: string;
  96598. shader: string;
  96599. };
  96600. }
  96601. declare module BABYLON {
  96602. /**
  96603. * Type used to define a render target texture size (either with a number or with a rect width and height)
  96604. */
  96605. export type RenderTargetTextureSize = number | {
  96606. width: number;
  96607. height: number;
  96608. layers?: number;
  96609. };
  96610. interface ThinEngine {
  96611. /**
  96612. * Creates a new render target texture
  96613. * @param size defines the size of the texture
  96614. * @param options defines the options used to create the texture
  96615. * @returns a new render target texture stored in an InternalTexture
  96616. */
  96617. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96618. /**
  96619. * Creates a depth stencil texture.
  96620. * This is only available in WebGL 2 or with the depth texture extension available.
  96621. * @param size The size of face edge in the texture.
  96622. * @param options The options defining the texture.
  96623. * @returns The texture
  96624. */
  96625. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  96626. /** @hidden */
  96627. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  96628. }
  96629. }
  96630. declare module BABYLON {
  96631. /**
  96632. * Defines the kind of connection point for node based material
  96633. */
  96634. export enum NodeMaterialBlockConnectionPointTypes {
  96635. /** Float */
  96636. Float = 1,
  96637. /** Int */
  96638. Int = 2,
  96639. /** Vector2 */
  96640. Vector2 = 4,
  96641. /** Vector3 */
  96642. Vector3 = 8,
  96643. /** Vector4 */
  96644. Vector4 = 16,
  96645. /** Color3 */
  96646. Color3 = 32,
  96647. /** Color4 */
  96648. Color4 = 64,
  96649. /** Matrix */
  96650. Matrix = 128,
  96651. /** Custom object */
  96652. Object = 256,
  96653. /** Detect type based on connection */
  96654. AutoDetect = 1024,
  96655. /** Output type that will be defined by input type */
  96656. BasedOnInput = 2048
  96657. }
  96658. }
  96659. declare module BABYLON {
  96660. /**
  96661. * Enum used to define the target of a block
  96662. */
  96663. export enum NodeMaterialBlockTargets {
  96664. /** Vertex shader */
  96665. Vertex = 1,
  96666. /** Fragment shader */
  96667. Fragment = 2,
  96668. /** Neutral */
  96669. Neutral = 4,
  96670. /** Vertex and Fragment */
  96671. VertexAndFragment = 3
  96672. }
  96673. }
  96674. declare module BABYLON {
  96675. /**
  96676. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  96677. */
  96678. export enum NodeMaterialBlockConnectionPointMode {
  96679. /** Value is an uniform */
  96680. Uniform = 0,
  96681. /** Value is a mesh attribute */
  96682. Attribute = 1,
  96683. /** Value is a varying between vertex and fragment shaders */
  96684. Varying = 2,
  96685. /** Mode is undefined */
  96686. Undefined = 3
  96687. }
  96688. }
  96689. declare module BABYLON {
  96690. /**
  96691. * Enum used to define system values e.g. values automatically provided by the system
  96692. */
  96693. export enum NodeMaterialSystemValues {
  96694. /** World */
  96695. World = 1,
  96696. /** View */
  96697. View = 2,
  96698. /** Projection */
  96699. Projection = 3,
  96700. /** ViewProjection */
  96701. ViewProjection = 4,
  96702. /** WorldView */
  96703. WorldView = 5,
  96704. /** WorldViewProjection */
  96705. WorldViewProjection = 6,
  96706. /** CameraPosition */
  96707. CameraPosition = 7,
  96708. /** Fog Color */
  96709. FogColor = 8,
  96710. /** Delta time */
  96711. DeltaTime = 9
  96712. }
  96713. }
  96714. declare module BABYLON {
  96715. /**
  96716. * Represents a camera frustum
  96717. */
  96718. export class Frustum {
  96719. /**
  96720. * Gets the planes representing the frustum
  96721. * @param transform matrix to be applied to the returned planes
  96722. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  96723. */
  96724. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  96725. /**
  96726. * Gets the near frustum plane transformed by the transform matrix
  96727. * @param transform transformation matrix to be applied to the resulting frustum plane
  96728. * @param frustumPlane the resuling frustum plane
  96729. */
  96730. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96731. /**
  96732. * Gets the far frustum plane transformed by the transform matrix
  96733. * @param transform transformation matrix to be applied to the resulting frustum plane
  96734. * @param frustumPlane the resuling frustum plane
  96735. */
  96736. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96737. /**
  96738. * Gets the left frustum plane transformed by the transform matrix
  96739. * @param transform transformation matrix to be applied to the resulting frustum plane
  96740. * @param frustumPlane the resuling frustum plane
  96741. */
  96742. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96743. /**
  96744. * Gets the right frustum plane transformed by the transform matrix
  96745. * @param transform transformation matrix to be applied to the resulting frustum plane
  96746. * @param frustumPlane the resuling frustum plane
  96747. */
  96748. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96749. /**
  96750. * Gets the top frustum plane transformed by the transform matrix
  96751. * @param transform transformation matrix to be applied to the resulting frustum plane
  96752. * @param frustumPlane the resuling frustum plane
  96753. */
  96754. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96755. /**
  96756. * Gets the bottom frustum plane transformed by the transform matrix
  96757. * @param transform transformation matrix to be applied to the resulting frustum plane
  96758. * @param frustumPlane the resuling frustum plane
  96759. */
  96760. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96761. /**
  96762. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  96763. * @param transform transformation matrix to be applied to the resulting frustum planes
  96764. * @param frustumPlanes the resuling frustum planes
  96765. */
  96766. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  96767. }
  96768. }
  96769. declare module BABYLON {
  96770. /**
  96771. * Contains position and normal vectors for a vertex
  96772. */
  96773. export class PositionNormalVertex {
  96774. /** the position of the vertex (defaut: 0,0,0) */
  96775. position: Vector3;
  96776. /** the normal of the vertex (defaut: 0,1,0) */
  96777. normal: Vector3;
  96778. /**
  96779. * Creates a PositionNormalVertex
  96780. * @param position the position of the vertex (defaut: 0,0,0)
  96781. * @param normal the normal of the vertex (defaut: 0,1,0)
  96782. */
  96783. constructor(
  96784. /** the position of the vertex (defaut: 0,0,0) */
  96785. position?: Vector3,
  96786. /** the normal of the vertex (defaut: 0,1,0) */
  96787. normal?: Vector3);
  96788. /**
  96789. * Clones the PositionNormalVertex
  96790. * @returns the cloned PositionNormalVertex
  96791. */
  96792. clone(): PositionNormalVertex;
  96793. }
  96794. /**
  96795. * Contains position, normal and uv vectors for a vertex
  96796. */
  96797. export class PositionNormalTextureVertex {
  96798. /** the position of the vertex (defaut: 0,0,0) */
  96799. position: Vector3;
  96800. /** the normal of the vertex (defaut: 0,1,0) */
  96801. normal: Vector3;
  96802. /** the uv of the vertex (default: 0,0) */
  96803. uv: Vector2;
  96804. /**
  96805. * Creates a PositionNormalTextureVertex
  96806. * @param position the position of the vertex (defaut: 0,0,0)
  96807. * @param normal the normal of the vertex (defaut: 0,1,0)
  96808. * @param uv the uv of the vertex (default: 0,0)
  96809. */
  96810. constructor(
  96811. /** the position of the vertex (defaut: 0,0,0) */
  96812. position?: Vector3,
  96813. /** the normal of the vertex (defaut: 0,1,0) */
  96814. normal?: Vector3,
  96815. /** the uv of the vertex (default: 0,0) */
  96816. uv?: Vector2);
  96817. /**
  96818. * Clones the PositionNormalTextureVertex
  96819. * @returns the cloned PositionNormalTextureVertex
  96820. */
  96821. clone(): PositionNormalTextureVertex;
  96822. }
  96823. }
  96824. declare module BABYLON {
  96825. /**
  96826. * Enum defining the type of animations supported by InputBlock
  96827. */
  96828. export enum AnimatedInputBlockTypes {
  96829. /** No animation */
  96830. None = 0,
  96831. /** Time based animation. Will only work for floats */
  96832. Time = 1
  96833. }
  96834. }
  96835. declare module BABYLON {
  96836. /**
  96837. * Block used to expose an input value
  96838. */
  96839. export class InputBlock extends NodeMaterialBlock {
  96840. private _mode;
  96841. private _associatedVariableName;
  96842. private _storedValue;
  96843. private _valueCallback;
  96844. private _type;
  96845. private _animationType;
  96846. /** Gets or set a value used to limit the range of float values */
  96847. min: number;
  96848. /** Gets or set a value used to limit the range of float values */
  96849. max: number;
  96850. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  96851. isBoolean: boolean;
  96852. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  96853. matrixMode: number;
  96854. /** @hidden */
  96855. _systemValue: Nullable<NodeMaterialSystemValues>;
  96856. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  96857. isConstant: boolean;
  96858. /** Gets or sets the group to use to display this block in the Inspector */
  96859. groupInInspector: string;
  96860. /** Gets an observable raised when the value is changed */
  96861. onValueChangedObservable: Observable<InputBlock>;
  96862. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  96863. convertToGammaSpace: boolean;
  96864. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  96865. convertToLinearSpace: boolean;
  96866. /**
  96867. * Gets or sets the connection point type (default is float)
  96868. */
  96869. get type(): NodeMaterialBlockConnectionPointTypes;
  96870. /**
  96871. * Creates a new InputBlock
  96872. * @param name defines the block name
  96873. * @param target defines the target of that block (Vertex by default)
  96874. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  96875. */
  96876. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  96877. /**
  96878. * Validates if a name is a reserve word.
  96879. * @param newName the new name to be given to the node.
  96880. * @returns false if the name is a reserve word, else true.
  96881. */
  96882. validateBlockName(newName: string): boolean;
  96883. /**
  96884. * Gets the output component
  96885. */
  96886. get output(): NodeMaterialConnectionPoint;
  96887. /**
  96888. * Set the source of this connection point to a vertex attribute
  96889. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  96890. * @returns the current connection point
  96891. */
  96892. setAsAttribute(attributeName?: string): InputBlock;
  96893. /**
  96894. * Set the source of this connection point to a system value
  96895. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  96896. * @returns the current connection point
  96897. */
  96898. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  96899. /**
  96900. * Gets or sets the value of that point.
  96901. * Please note that this value will be ignored if valueCallback is defined
  96902. */
  96903. get value(): any;
  96904. set value(value: any);
  96905. /**
  96906. * Gets or sets a callback used to get the value of that point.
  96907. * Please note that setting this value will force the connection point to ignore the value property
  96908. */
  96909. get valueCallback(): () => any;
  96910. set valueCallback(value: () => any);
  96911. /**
  96912. * Gets or sets the associated variable name in the shader
  96913. */
  96914. get associatedVariableName(): string;
  96915. set associatedVariableName(value: string);
  96916. /** Gets or sets the type of animation applied to the input */
  96917. get animationType(): AnimatedInputBlockTypes;
  96918. set animationType(value: AnimatedInputBlockTypes);
  96919. /**
  96920. * Gets a boolean indicating that this connection point not defined yet
  96921. */
  96922. get isUndefined(): boolean;
  96923. /**
  96924. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  96925. * In this case the connection point name must be the name of the uniform to use.
  96926. * Can only be set on inputs
  96927. */
  96928. get isUniform(): boolean;
  96929. set isUniform(value: boolean);
  96930. /**
  96931. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  96932. * In this case the connection point name must be the name of the attribute to use
  96933. * Can only be set on inputs
  96934. */
  96935. get isAttribute(): boolean;
  96936. set isAttribute(value: boolean);
  96937. /**
  96938. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  96939. * Can only be set on exit points
  96940. */
  96941. get isVarying(): boolean;
  96942. set isVarying(value: boolean);
  96943. /**
  96944. * Gets a boolean indicating that the current connection point is a system value
  96945. */
  96946. get isSystemValue(): boolean;
  96947. /**
  96948. * Gets or sets the current well known value or null if not defined as a system value
  96949. */
  96950. get systemValue(): Nullable<NodeMaterialSystemValues>;
  96951. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  96952. /**
  96953. * Gets the current class name
  96954. * @returns the class name
  96955. */
  96956. getClassName(): string;
  96957. /**
  96958. * Animate the input if animationType !== None
  96959. * @param scene defines the rendering scene
  96960. */
  96961. animate(scene: Scene): void;
  96962. private _emitDefine;
  96963. initialize(state: NodeMaterialBuildState): void;
  96964. /**
  96965. * Set the input block to its default value (based on its type)
  96966. */
  96967. setDefaultValue(): void;
  96968. private _emitConstant;
  96969. /** @hidden */
  96970. get _noContextSwitch(): boolean;
  96971. private _emit;
  96972. /** @hidden */
  96973. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  96974. /** @hidden */
  96975. _transmit(effect: Effect, scene: Scene): void;
  96976. protected _buildBlock(state: NodeMaterialBuildState): void;
  96977. protected _dumpPropertiesCode(): string;
  96978. dispose(): void;
  96979. serialize(): any;
  96980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  96981. }
  96982. }
  96983. declare module BABYLON {
  96984. /**
  96985. * Enum used to define the compatibility state between two connection points
  96986. */
  96987. export enum NodeMaterialConnectionPointCompatibilityStates {
  96988. /** Points are compatibles */
  96989. Compatible = 0,
  96990. /** Points are incompatible because of their types */
  96991. TypeIncompatible = 1,
  96992. /** Points are incompatible because of their targets (vertex vs fragment) */
  96993. TargetIncompatible = 2
  96994. }
  96995. /**
  96996. * Defines the direction of a connection point
  96997. */
  96998. export enum NodeMaterialConnectionPointDirection {
  96999. /** Input */
  97000. Input = 0,
  97001. /** Output */
  97002. Output = 1
  97003. }
  97004. /**
  97005. * Defines a connection point for a block
  97006. */
  97007. export class NodeMaterialConnectionPoint {
  97008. /**
  97009. * Checks if two types are equivalent
  97010. * @param type1 type 1 to check
  97011. * @param type2 type 2 to check
  97012. * @returns true if both types are equivalent, else false
  97013. */
  97014. static AreEquivalentTypes(type1: number, type2: number): boolean;
  97015. /** @hidden */
  97016. _ownerBlock: NodeMaterialBlock;
  97017. /** @hidden */
  97018. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97019. private _endpoints;
  97020. private _associatedVariableName;
  97021. private _direction;
  97022. /** @hidden */
  97023. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97024. /** @hidden */
  97025. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97026. /** @hidden */
  97027. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  97028. private _type;
  97029. /** @hidden */
  97030. _enforceAssociatedVariableName: boolean;
  97031. /** Gets the direction of the point */
  97032. get direction(): NodeMaterialConnectionPointDirection;
  97033. /** Indicates that this connection point needs dual validation before being connected to another point */
  97034. needDualDirectionValidation: boolean;
  97035. /**
  97036. * Gets or sets the additional types supported by this connection point
  97037. */
  97038. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97039. /**
  97040. * Gets or sets the additional types excluded by this connection point
  97041. */
  97042. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97043. /**
  97044. * Observable triggered when this point is connected
  97045. */
  97046. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97047. /**
  97048. * Gets or sets the associated variable name in the shader
  97049. */
  97050. get associatedVariableName(): string;
  97051. set associatedVariableName(value: string);
  97052. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97053. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97054. /**
  97055. * Gets or sets the connection point type (default is float)
  97056. */
  97057. get type(): NodeMaterialBlockConnectionPointTypes;
  97058. set type(value: NodeMaterialBlockConnectionPointTypes);
  97059. /**
  97060. * Gets or sets the connection point name
  97061. */
  97062. name: string;
  97063. /**
  97064. * Gets or sets the connection point name
  97065. */
  97066. displayName: string;
  97067. /**
  97068. * Gets or sets a boolean indicating that this connection point can be omitted
  97069. */
  97070. isOptional: boolean;
  97071. /**
  97072. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  97073. */
  97074. isExposedOnFrame: boolean;
  97075. /**
  97076. * Gets or sets number indicating the position that the port is exposed to on a frame
  97077. */
  97078. exposedPortPosition: number;
  97079. /**
  97080. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97081. */
  97082. define: string;
  97083. /** @hidden */
  97084. _prioritizeVertex: boolean;
  97085. private _target;
  97086. /** Gets or sets the target of that connection point */
  97087. get target(): NodeMaterialBlockTargets;
  97088. set target(value: NodeMaterialBlockTargets);
  97089. /**
  97090. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97091. */
  97092. get isConnected(): boolean;
  97093. /**
  97094. * Gets a boolean indicating that the current point is connected to an input block
  97095. */
  97096. get isConnectedToInputBlock(): boolean;
  97097. /**
  97098. * Gets a the connected input block (if any)
  97099. */
  97100. get connectInputBlock(): Nullable<InputBlock>;
  97101. /** Get the other side of the connection (if any) */
  97102. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97103. /** Get the block that owns this connection point */
  97104. get ownerBlock(): NodeMaterialBlock;
  97105. /** Get the block connected on the other side of this connection (if any) */
  97106. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97107. /** Get the block connected on the endpoints of this connection (if any) */
  97108. get connectedBlocks(): Array<NodeMaterialBlock>;
  97109. /** Gets the list of connected endpoints */
  97110. get endpoints(): NodeMaterialConnectionPoint[];
  97111. /** Gets a boolean indicating if that output point is connected to at least one input */
  97112. get hasEndpoints(): boolean;
  97113. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97114. get isConnectedInVertexShader(): boolean;
  97115. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97116. get isConnectedInFragmentShader(): boolean;
  97117. /**
  97118. * Creates a block suitable to be used as an input for this input point.
  97119. * If null is returned, a block based on the point type will be created.
  97120. * @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
  97121. */
  97122. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97123. /**
  97124. * Creates a new connection point
  97125. * @param name defines the connection point name
  97126. * @param ownerBlock defines the block hosting this connection point
  97127. * @param direction defines the direction of the connection point
  97128. */
  97129. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97130. /**
  97131. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97132. * @returns the class name
  97133. */
  97134. getClassName(): string;
  97135. /**
  97136. * Gets a boolean indicating if the current point can be connected to another point
  97137. * @param connectionPoint defines the other connection point
  97138. * @returns a boolean
  97139. */
  97140. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97141. /**
  97142. * Gets a number indicating if the current point can be connected to another point
  97143. * @param connectionPoint defines the other connection point
  97144. * @returns a number defining the compatibility state
  97145. */
  97146. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97147. /**
  97148. * Connect this point to another connection point
  97149. * @param connectionPoint defines the other connection point
  97150. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97151. * @returns the current connection point
  97152. */
  97153. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97154. /**
  97155. * Disconnect this point from one of his endpoint
  97156. * @param endpoint defines the other connection point
  97157. * @returns the current connection point
  97158. */
  97159. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97160. /**
  97161. * Serializes this point in a JSON representation
  97162. * @param isInput defines if the connection point is an input (default is true)
  97163. * @returns the serialized point object
  97164. */
  97165. serialize(isInput?: boolean): any;
  97166. /**
  97167. * Release resources
  97168. */
  97169. dispose(): void;
  97170. }
  97171. }
  97172. declare module BABYLON {
  97173. /**
  97174. * Enum used to define the material modes
  97175. */
  97176. export enum NodeMaterialModes {
  97177. /** Regular material */
  97178. Material = 0,
  97179. /** For post process */
  97180. PostProcess = 1,
  97181. /** For particle system */
  97182. Particle = 2,
  97183. /** For procedural texture */
  97184. ProceduralTexture = 3
  97185. }
  97186. }
  97187. declare module BABYLON {
  97188. /** @hidden */
  97189. export var helperFunctions: {
  97190. name: string;
  97191. shader: string;
  97192. };
  97193. }
  97194. declare module BABYLON {
  97195. /**
  97196. * Block used to read a texture from a sampler
  97197. */
  97198. export class TextureBlock extends NodeMaterialBlock {
  97199. private _defineName;
  97200. private _linearDefineName;
  97201. private _gammaDefineName;
  97202. private _tempTextureRead;
  97203. private _samplerName;
  97204. private _transformedUVName;
  97205. private _textureTransformName;
  97206. private _textureInfoName;
  97207. private _mainUVName;
  97208. private _mainUVDefineName;
  97209. private _fragmentOnly;
  97210. /**
  97211. * Gets or sets the texture associated with the node
  97212. */
  97213. texture: Nullable<Texture>;
  97214. /**
  97215. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97216. */
  97217. convertToGammaSpace: boolean;
  97218. /**
  97219. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97220. */
  97221. convertToLinearSpace: boolean;
  97222. /**
  97223. * Create a new TextureBlock
  97224. * @param name defines the block name
  97225. */
  97226. constructor(name: string, fragmentOnly?: boolean);
  97227. /**
  97228. * Gets the current class name
  97229. * @returns the class name
  97230. */
  97231. getClassName(): string;
  97232. /**
  97233. * Gets the uv input component
  97234. */
  97235. get uv(): NodeMaterialConnectionPoint;
  97236. /**
  97237. * Gets the rgba output component
  97238. */
  97239. get rgba(): NodeMaterialConnectionPoint;
  97240. /**
  97241. * Gets the rgb output component
  97242. */
  97243. get rgb(): NodeMaterialConnectionPoint;
  97244. /**
  97245. * Gets the r output component
  97246. */
  97247. get r(): NodeMaterialConnectionPoint;
  97248. /**
  97249. * Gets the g output component
  97250. */
  97251. get g(): NodeMaterialConnectionPoint;
  97252. /**
  97253. * Gets the b output component
  97254. */
  97255. get b(): NodeMaterialConnectionPoint;
  97256. /**
  97257. * Gets the a output component
  97258. */
  97259. get a(): NodeMaterialConnectionPoint;
  97260. get target(): NodeMaterialBlockTargets;
  97261. autoConfigure(material: NodeMaterial): void;
  97262. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97264. isReady(): boolean;
  97265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97266. private get _isMixed();
  97267. private _injectVertexCode;
  97268. private _writeTextureRead;
  97269. private _writeOutput;
  97270. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97271. protected _dumpPropertiesCode(): string;
  97272. serialize(): any;
  97273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97274. }
  97275. }
  97276. declare module BABYLON {
  97277. /** @hidden */
  97278. export var reflectionFunction: {
  97279. name: string;
  97280. shader: string;
  97281. };
  97282. }
  97283. declare module BABYLON {
  97284. /**
  97285. * Base block used to read a reflection texture from a sampler
  97286. */
  97287. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97288. /** @hidden */
  97289. _define3DName: string;
  97290. /** @hidden */
  97291. _defineCubicName: string;
  97292. /** @hidden */
  97293. _defineExplicitName: string;
  97294. /** @hidden */
  97295. _defineProjectionName: string;
  97296. /** @hidden */
  97297. _defineLocalCubicName: string;
  97298. /** @hidden */
  97299. _defineSphericalName: string;
  97300. /** @hidden */
  97301. _definePlanarName: string;
  97302. /** @hidden */
  97303. _defineEquirectangularName: string;
  97304. /** @hidden */
  97305. _defineMirroredEquirectangularFixedName: string;
  97306. /** @hidden */
  97307. _defineEquirectangularFixedName: string;
  97308. /** @hidden */
  97309. _defineSkyboxName: string;
  97310. /** @hidden */
  97311. _defineOppositeZ: string;
  97312. /** @hidden */
  97313. _cubeSamplerName: string;
  97314. /** @hidden */
  97315. _2DSamplerName: string;
  97316. protected _positionUVWName: string;
  97317. protected _directionWName: string;
  97318. protected _reflectionVectorName: string;
  97319. /** @hidden */
  97320. _reflectionCoordsName: string;
  97321. /** @hidden */
  97322. _reflectionMatrixName: string;
  97323. protected _reflectionColorName: string;
  97324. /**
  97325. * Gets or sets the texture associated with the node
  97326. */
  97327. texture: Nullable<BaseTexture>;
  97328. /**
  97329. * Create a new ReflectionTextureBaseBlock
  97330. * @param name defines the block name
  97331. */
  97332. constructor(name: string);
  97333. /**
  97334. * Gets the current class name
  97335. * @returns the class name
  97336. */
  97337. getClassName(): string;
  97338. /**
  97339. * Gets the world position input component
  97340. */
  97341. abstract get position(): NodeMaterialConnectionPoint;
  97342. /**
  97343. * Gets the world position input component
  97344. */
  97345. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97346. /**
  97347. * Gets the world normal input component
  97348. */
  97349. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97350. /**
  97351. * Gets the world input component
  97352. */
  97353. abstract get world(): NodeMaterialConnectionPoint;
  97354. /**
  97355. * Gets the camera (or eye) position component
  97356. */
  97357. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97358. /**
  97359. * Gets the view input component
  97360. */
  97361. abstract get view(): NodeMaterialConnectionPoint;
  97362. protected _getTexture(): Nullable<BaseTexture>;
  97363. autoConfigure(material: NodeMaterial): void;
  97364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97365. isReady(): boolean;
  97366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97367. /**
  97368. * Gets the code to inject in the vertex shader
  97369. * @param state current state of the node material building
  97370. * @returns the shader code
  97371. */
  97372. handleVertexSide(state: NodeMaterialBuildState): string;
  97373. /**
  97374. * Handles the inits for the fragment code path
  97375. * @param state node material build state
  97376. */
  97377. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97378. /**
  97379. * Generates the reflection coords code for the fragment code path
  97380. * @param worldNormalVarName name of the world normal variable
  97381. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97382. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97383. * @returns the shader code
  97384. */
  97385. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97386. /**
  97387. * Generates the reflection color code for the fragment code path
  97388. * @param lodVarName name of the lod variable
  97389. * @param swizzleLookupTexture swizzle to use for the final color variable
  97390. * @returns the shader code
  97391. */
  97392. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97393. /**
  97394. * Generates the code corresponding to the connected output points
  97395. * @param state node material build state
  97396. * @param varName name of the variable to output
  97397. * @returns the shader code
  97398. */
  97399. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97400. protected _buildBlock(state: NodeMaterialBuildState): this;
  97401. protected _dumpPropertiesCode(): string;
  97402. serialize(): any;
  97403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97404. }
  97405. }
  97406. declare module BABYLON {
  97407. /**
  97408. * Defines a connection point to be used for points with a custom object type
  97409. */
  97410. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97411. private _blockType;
  97412. private _blockName;
  97413. private _nameForCheking?;
  97414. /**
  97415. * Creates a new connection point
  97416. * @param name defines the connection point name
  97417. * @param ownerBlock defines the block hosting this connection point
  97418. * @param direction defines the direction of the connection point
  97419. */
  97420. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97421. /**
  97422. * Gets a number indicating if the current point can be connected to another point
  97423. * @param connectionPoint defines the other connection point
  97424. * @returns a number defining the compatibility state
  97425. */
  97426. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97427. /**
  97428. * Creates a block suitable to be used as an input for this input point.
  97429. * If null is returned, a block based on the point type will be created.
  97430. * @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
  97431. */
  97432. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97433. }
  97434. }
  97435. declare module BABYLON {
  97436. /**
  97437. * Enum defining the type of properties that can be edited in the property pages in the NME
  97438. */
  97439. export enum PropertyTypeForEdition {
  97440. /** property is a boolean */
  97441. Boolean = 0,
  97442. /** property is a float */
  97443. Float = 1,
  97444. /** property is a Vector2 */
  97445. Vector2 = 2,
  97446. /** property is a list of values */
  97447. List = 3
  97448. }
  97449. /**
  97450. * Interface that defines an option in a variable of type list
  97451. */
  97452. export interface IEditablePropertyListOption {
  97453. /** label of the option */
  97454. "label": string;
  97455. /** value of the option */
  97456. "value": number;
  97457. }
  97458. /**
  97459. * Interface that defines the options available for an editable property
  97460. */
  97461. export interface IEditablePropertyOption {
  97462. /** min value */
  97463. "min"?: number;
  97464. /** max value */
  97465. "max"?: number;
  97466. /** notifiers: indicates which actions to take when the property is changed */
  97467. "notifiers"?: {
  97468. /** the material should be rebuilt */
  97469. "rebuild"?: boolean;
  97470. /** the preview should be updated */
  97471. "update"?: boolean;
  97472. };
  97473. /** list of the options for a variable of type list */
  97474. "options"?: IEditablePropertyListOption[];
  97475. }
  97476. /**
  97477. * Interface that describes an editable property
  97478. */
  97479. export interface IPropertyDescriptionForEdition {
  97480. /** name of the property */
  97481. "propertyName": string;
  97482. /** display name of the property */
  97483. "displayName": string;
  97484. /** type of the property */
  97485. "type": PropertyTypeForEdition;
  97486. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97487. "groupName": string;
  97488. /** options for the property */
  97489. "options": IEditablePropertyOption;
  97490. }
  97491. /**
  97492. * Decorator that flags a property in a node material block as being editable
  97493. */
  97494. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97495. }
  97496. declare module BABYLON {
  97497. /**
  97498. * Block used to implement the refraction part of the sub surface module of the PBR material
  97499. */
  97500. export class RefractionBlock extends NodeMaterialBlock {
  97501. /** @hidden */
  97502. _define3DName: string;
  97503. /** @hidden */
  97504. _refractionMatrixName: string;
  97505. /** @hidden */
  97506. _defineLODRefractionAlpha: string;
  97507. /** @hidden */
  97508. _defineLinearSpecularRefraction: string;
  97509. /** @hidden */
  97510. _defineOppositeZ: string;
  97511. /** @hidden */
  97512. _cubeSamplerName: string;
  97513. /** @hidden */
  97514. _2DSamplerName: string;
  97515. /** @hidden */
  97516. _vRefractionMicrosurfaceInfosName: string;
  97517. /** @hidden */
  97518. _vRefractionInfosName: string;
  97519. /** @hidden */
  97520. _vRefractionFilteringInfoName: string;
  97521. private _scene;
  97522. /**
  97523. * The properties below are set by the main PBR block prior to calling methods of this class.
  97524. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  97525. * It's less burden on the user side in the editor part.
  97526. */
  97527. /** @hidden */
  97528. viewConnectionPoint: NodeMaterialConnectionPoint;
  97529. /** @hidden */
  97530. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  97531. /**
  97532. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  97533. * Materials half opaque for instance using refraction could benefit from this control.
  97534. */
  97535. linkRefractionWithTransparency: boolean;
  97536. /**
  97537. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  97538. */
  97539. invertRefractionY: boolean;
  97540. /**
  97541. * Gets or sets the texture associated with the node
  97542. */
  97543. texture: Nullable<BaseTexture>;
  97544. /**
  97545. * Create a new RefractionBlock
  97546. * @param name defines the block name
  97547. */
  97548. constructor(name: string);
  97549. /**
  97550. * Gets the current class name
  97551. * @returns the class name
  97552. */
  97553. getClassName(): string;
  97554. /**
  97555. * Gets the intensity input component
  97556. */
  97557. get intensity(): NodeMaterialConnectionPoint;
  97558. /**
  97559. * Gets the tint at distance input component
  97560. */
  97561. get tintAtDistance(): NodeMaterialConnectionPoint;
  97562. /**
  97563. * Gets the view input component
  97564. */
  97565. get view(): NodeMaterialConnectionPoint;
  97566. /**
  97567. * Gets the refraction object output component
  97568. */
  97569. get refraction(): NodeMaterialConnectionPoint;
  97570. /**
  97571. * Returns true if the block has a texture
  97572. */
  97573. get hasTexture(): boolean;
  97574. protected _getTexture(): Nullable<BaseTexture>;
  97575. autoConfigure(material: NodeMaterial): void;
  97576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97577. isReady(): boolean;
  97578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  97579. /**
  97580. * Gets the main code of the block (fragment side)
  97581. * @param state current state of the node material building
  97582. * @returns the shader code
  97583. */
  97584. getCode(state: NodeMaterialBuildState): string;
  97585. protected _buildBlock(state: NodeMaterialBuildState): this;
  97586. protected _dumpPropertiesCode(): string;
  97587. serialize(): any;
  97588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97589. }
  97590. }
  97591. declare module BABYLON {
  97592. /**
  97593. * Base block used as input for post process
  97594. */
  97595. export class CurrentScreenBlock extends NodeMaterialBlock {
  97596. private _samplerName;
  97597. private _linearDefineName;
  97598. private _gammaDefineName;
  97599. private _mainUVName;
  97600. private _tempTextureRead;
  97601. /**
  97602. * Gets or sets the texture associated with the node
  97603. */
  97604. texture: Nullable<BaseTexture>;
  97605. /**
  97606. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97607. */
  97608. convertToGammaSpace: boolean;
  97609. /**
  97610. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97611. */
  97612. convertToLinearSpace: boolean;
  97613. /**
  97614. * Create a new CurrentScreenBlock
  97615. * @param name defines the block name
  97616. */
  97617. constructor(name: string);
  97618. /**
  97619. * Gets the current class name
  97620. * @returns the class name
  97621. */
  97622. getClassName(): string;
  97623. /**
  97624. * Gets the uv input component
  97625. */
  97626. get uv(): NodeMaterialConnectionPoint;
  97627. /**
  97628. * Gets the rgba output component
  97629. */
  97630. get rgba(): NodeMaterialConnectionPoint;
  97631. /**
  97632. * Gets the rgb output component
  97633. */
  97634. get rgb(): NodeMaterialConnectionPoint;
  97635. /**
  97636. * Gets the r output component
  97637. */
  97638. get r(): NodeMaterialConnectionPoint;
  97639. /**
  97640. * Gets the g output component
  97641. */
  97642. get g(): NodeMaterialConnectionPoint;
  97643. /**
  97644. * Gets the b output component
  97645. */
  97646. get b(): NodeMaterialConnectionPoint;
  97647. /**
  97648. * Gets the a output component
  97649. */
  97650. get a(): NodeMaterialConnectionPoint;
  97651. /**
  97652. * Initialize the block and prepare the context for build
  97653. * @param state defines the state that will be used for the build
  97654. */
  97655. initialize(state: NodeMaterialBuildState): void;
  97656. get target(): NodeMaterialBlockTargets;
  97657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97658. isReady(): boolean;
  97659. private _injectVertexCode;
  97660. private _writeTextureRead;
  97661. private _writeOutput;
  97662. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97663. serialize(): any;
  97664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97665. }
  97666. }
  97667. declare module BABYLON {
  97668. /**
  97669. * Base block used for the particle texture
  97670. */
  97671. export class ParticleTextureBlock extends NodeMaterialBlock {
  97672. private _samplerName;
  97673. private _linearDefineName;
  97674. private _gammaDefineName;
  97675. private _tempTextureRead;
  97676. /**
  97677. * Gets or sets the texture associated with the node
  97678. */
  97679. texture: Nullable<BaseTexture>;
  97680. /**
  97681. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97682. */
  97683. convertToGammaSpace: boolean;
  97684. /**
  97685. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97686. */
  97687. convertToLinearSpace: boolean;
  97688. /**
  97689. * Create a new ParticleTextureBlock
  97690. * @param name defines the block name
  97691. */
  97692. constructor(name: string);
  97693. /**
  97694. * Gets the current class name
  97695. * @returns the class name
  97696. */
  97697. getClassName(): string;
  97698. /**
  97699. * Gets the uv input component
  97700. */
  97701. get uv(): NodeMaterialConnectionPoint;
  97702. /**
  97703. * Gets the rgba output component
  97704. */
  97705. get rgba(): NodeMaterialConnectionPoint;
  97706. /**
  97707. * Gets the rgb output component
  97708. */
  97709. get rgb(): NodeMaterialConnectionPoint;
  97710. /**
  97711. * Gets the r output component
  97712. */
  97713. get r(): NodeMaterialConnectionPoint;
  97714. /**
  97715. * Gets the g output component
  97716. */
  97717. get g(): NodeMaterialConnectionPoint;
  97718. /**
  97719. * Gets the b output component
  97720. */
  97721. get b(): NodeMaterialConnectionPoint;
  97722. /**
  97723. * Gets the a output component
  97724. */
  97725. get a(): NodeMaterialConnectionPoint;
  97726. /**
  97727. * Initialize the block and prepare the context for build
  97728. * @param state defines the state that will be used for the build
  97729. */
  97730. initialize(state: NodeMaterialBuildState): void;
  97731. autoConfigure(material: NodeMaterial): void;
  97732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97733. isReady(): boolean;
  97734. private _writeOutput;
  97735. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97736. serialize(): any;
  97737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97738. }
  97739. }
  97740. declare module BABYLON {
  97741. /**
  97742. * Class used to store shared data between 2 NodeMaterialBuildState
  97743. */
  97744. export class NodeMaterialBuildStateSharedData {
  97745. /**
  97746. * Gets the list of emitted varyings
  97747. */
  97748. temps: string[];
  97749. /**
  97750. * Gets the list of emitted varyings
  97751. */
  97752. varyings: string[];
  97753. /**
  97754. * Gets the varying declaration string
  97755. */
  97756. varyingDeclaration: string;
  97757. /**
  97758. * Input blocks
  97759. */
  97760. inputBlocks: InputBlock[];
  97761. /**
  97762. * Input blocks
  97763. */
  97764. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  97765. /**
  97766. * Bindable blocks (Blocks that need to set data to the effect)
  97767. */
  97768. bindableBlocks: NodeMaterialBlock[];
  97769. /**
  97770. * List of blocks that can provide a compilation fallback
  97771. */
  97772. blocksWithFallbacks: NodeMaterialBlock[];
  97773. /**
  97774. * List of blocks that can provide a define update
  97775. */
  97776. blocksWithDefines: NodeMaterialBlock[];
  97777. /**
  97778. * List of blocks that can provide a repeatable content
  97779. */
  97780. repeatableContentBlocks: NodeMaterialBlock[];
  97781. /**
  97782. * List of blocks that can provide a dynamic list of uniforms
  97783. */
  97784. dynamicUniformBlocks: NodeMaterialBlock[];
  97785. /**
  97786. * List of blocks that can block the isReady function for the material
  97787. */
  97788. blockingBlocks: NodeMaterialBlock[];
  97789. /**
  97790. * Gets the list of animated inputs
  97791. */
  97792. animatedInputs: InputBlock[];
  97793. /**
  97794. * Build Id used to avoid multiple recompilations
  97795. */
  97796. buildId: number;
  97797. /** List of emitted variables */
  97798. variableNames: {
  97799. [key: string]: number;
  97800. };
  97801. /** List of emitted defines */
  97802. defineNames: {
  97803. [key: string]: number;
  97804. };
  97805. /** Should emit comments? */
  97806. emitComments: boolean;
  97807. /** Emit build activity */
  97808. verbose: boolean;
  97809. /** Gets or sets the hosting scene */
  97810. scene: Scene;
  97811. /**
  97812. * Gets the compilation hints emitted at compilation time
  97813. */
  97814. hints: {
  97815. needWorldViewMatrix: boolean;
  97816. needWorldViewProjectionMatrix: boolean;
  97817. needAlphaBlending: boolean;
  97818. needAlphaTesting: boolean;
  97819. };
  97820. /**
  97821. * List of compilation checks
  97822. */
  97823. checks: {
  97824. emitVertex: boolean;
  97825. emitFragment: boolean;
  97826. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  97827. };
  97828. /**
  97829. * Is vertex program allowed to be empty?
  97830. */
  97831. allowEmptyVertexProgram: boolean;
  97832. /** Creates a new shared data */
  97833. constructor();
  97834. /**
  97835. * Emits console errors and exceptions if there is a failing check
  97836. */
  97837. emitErrors(): void;
  97838. }
  97839. }
  97840. declare module BABYLON {
  97841. /**
  97842. * Class used to store node based material build state
  97843. */
  97844. export class NodeMaterialBuildState {
  97845. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  97846. supportUniformBuffers: boolean;
  97847. /**
  97848. * Gets the list of emitted attributes
  97849. */
  97850. attributes: string[];
  97851. /**
  97852. * Gets the list of emitted uniforms
  97853. */
  97854. uniforms: string[];
  97855. /**
  97856. * Gets the list of emitted constants
  97857. */
  97858. constants: string[];
  97859. /**
  97860. * Gets the list of emitted samplers
  97861. */
  97862. samplers: string[];
  97863. /**
  97864. * Gets the list of emitted functions
  97865. */
  97866. functions: {
  97867. [key: string]: string;
  97868. };
  97869. /**
  97870. * Gets the list of emitted extensions
  97871. */
  97872. extensions: {
  97873. [key: string]: string;
  97874. };
  97875. /**
  97876. * Gets the target of the compilation state
  97877. */
  97878. target: NodeMaterialBlockTargets;
  97879. /**
  97880. * Gets the list of emitted counters
  97881. */
  97882. counters: {
  97883. [key: string]: number;
  97884. };
  97885. /**
  97886. * Shared data between multiple NodeMaterialBuildState instances
  97887. */
  97888. sharedData: NodeMaterialBuildStateSharedData;
  97889. /** @hidden */
  97890. _vertexState: NodeMaterialBuildState;
  97891. /** @hidden */
  97892. _attributeDeclaration: string;
  97893. /** @hidden */
  97894. _uniformDeclaration: string;
  97895. /** @hidden */
  97896. _constantDeclaration: string;
  97897. /** @hidden */
  97898. _samplerDeclaration: string;
  97899. /** @hidden */
  97900. _varyingTransfer: string;
  97901. /** @hidden */
  97902. _injectAtEnd: string;
  97903. private _repeatableContentAnchorIndex;
  97904. /** @hidden */
  97905. _builtCompilationString: string;
  97906. /**
  97907. * Gets the emitted compilation strings
  97908. */
  97909. compilationString: string;
  97910. /**
  97911. * Finalize the compilation strings
  97912. * @param state defines the current compilation state
  97913. */
  97914. finalize(state: NodeMaterialBuildState): void;
  97915. /** @hidden */
  97916. get _repeatableContentAnchor(): string;
  97917. /** @hidden */
  97918. _getFreeVariableName(prefix: string): string;
  97919. /** @hidden */
  97920. _getFreeDefineName(prefix: string): string;
  97921. /** @hidden */
  97922. _excludeVariableName(name: string): void;
  97923. /** @hidden */
  97924. _emit2DSampler(name: string): void;
  97925. /** @hidden */
  97926. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  97927. /** @hidden */
  97928. _emitExtension(name: string, extension: string, define?: string): void;
  97929. /** @hidden */
  97930. _emitFunction(name: string, code: string, comments: string): void;
  97931. /** @hidden */
  97932. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  97933. replaceStrings?: {
  97934. search: RegExp;
  97935. replace: string;
  97936. }[];
  97937. repeatKey?: string;
  97938. }): string;
  97939. /** @hidden */
  97940. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  97941. repeatKey?: string;
  97942. removeAttributes?: boolean;
  97943. removeUniforms?: boolean;
  97944. removeVaryings?: boolean;
  97945. removeIfDef?: boolean;
  97946. replaceStrings?: {
  97947. search: RegExp;
  97948. replace: string;
  97949. }[];
  97950. }, storeKey?: string): void;
  97951. /** @hidden */
  97952. _registerTempVariable(name: string): boolean;
  97953. /** @hidden */
  97954. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  97955. /** @hidden */
  97956. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  97957. /** @hidden */
  97958. _emitFloat(value: number): string;
  97959. }
  97960. }
  97961. declare module BABYLON {
  97962. /**
  97963. * Helper class used to generate session unique ID
  97964. */
  97965. export class UniqueIdGenerator {
  97966. private static _UniqueIdCounter;
  97967. /**
  97968. * Gets an unique (relatively to the current scene) Id
  97969. */
  97970. static get UniqueId(): number;
  97971. }
  97972. }
  97973. declare module BABYLON {
  97974. /**
  97975. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  97976. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  97977. */
  97978. export class EffectFallbacks implements IEffectFallbacks {
  97979. private _defines;
  97980. private _currentRank;
  97981. private _maxRank;
  97982. private _mesh;
  97983. /**
  97984. * Removes the fallback from the bound mesh.
  97985. */
  97986. unBindMesh(): void;
  97987. /**
  97988. * Adds a fallback on the specified property.
  97989. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  97990. * @param define The name of the define in the shader
  97991. */
  97992. addFallback(rank: number, define: string): void;
  97993. /**
  97994. * Sets the mesh to use CPU skinning when needing to fallback.
  97995. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  97996. * @param mesh The mesh to use the fallbacks.
  97997. */
  97998. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  97999. /**
  98000. * Checks to see if more fallbacks are still availible.
  98001. */
  98002. get hasMoreFallbacks(): boolean;
  98003. /**
  98004. * Removes the defines that should be removed when falling back.
  98005. * @param currentDefines defines the current define statements for the shader.
  98006. * @param effect defines the current effect we try to compile
  98007. * @returns The resulting defines with defines of the current rank removed.
  98008. */
  98009. reduce(currentDefines: string, effect: Effect): string;
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * Defines a block that can be used inside a node based material
  98015. */
  98016. export class NodeMaterialBlock {
  98017. private _buildId;
  98018. private _buildTarget;
  98019. private _target;
  98020. private _isFinalMerger;
  98021. private _isInput;
  98022. private _name;
  98023. protected _isUnique: boolean;
  98024. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98025. inputsAreExclusive: boolean;
  98026. /** @hidden */
  98027. _codeVariableName: string;
  98028. /** @hidden */
  98029. _inputs: NodeMaterialConnectionPoint[];
  98030. /** @hidden */
  98031. _outputs: NodeMaterialConnectionPoint[];
  98032. /** @hidden */
  98033. _preparationId: number;
  98034. /**
  98035. * Gets the name of the block
  98036. */
  98037. get name(): string;
  98038. /**
  98039. * Sets the name of the block. Will check if the name is valid.
  98040. */
  98041. set name(newName: string);
  98042. /**
  98043. * Gets or sets the unique id of the node
  98044. */
  98045. uniqueId: number;
  98046. /**
  98047. * Gets or sets the comments associated with this block
  98048. */
  98049. comments: string;
  98050. /**
  98051. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98052. */
  98053. get isUnique(): boolean;
  98054. /**
  98055. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98056. */
  98057. get isFinalMerger(): boolean;
  98058. /**
  98059. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98060. */
  98061. get isInput(): boolean;
  98062. /**
  98063. * Gets or sets the build Id
  98064. */
  98065. get buildId(): number;
  98066. set buildId(value: number);
  98067. /**
  98068. * Gets or sets the target of the block
  98069. */
  98070. get target(): NodeMaterialBlockTargets;
  98071. set target(value: NodeMaterialBlockTargets);
  98072. /**
  98073. * Gets the list of input points
  98074. */
  98075. get inputs(): NodeMaterialConnectionPoint[];
  98076. /** Gets the list of output points */
  98077. get outputs(): NodeMaterialConnectionPoint[];
  98078. /**
  98079. * Find an input by its name
  98080. * @param name defines the name of the input to look for
  98081. * @returns the input or null if not found
  98082. */
  98083. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98084. /**
  98085. * Find an output by its name
  98086. * @param name defines the name of the outputto look for
  98087. * @returns the output or null if not found
  98088. */
  98089. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98090. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98091. visibleInInspector: boolean;
  98092. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  98093. visibleOnFrame: boolean;
  98094. /**
  98095. * Creates a new NodeMaterialBlock
  98096. * @param name defines the block name
  98097. * @param target defines the target of that block (Vertex by default)
  98098. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98099. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98100. */
  98101. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98102. /**
  98103. * Initialize the block and prepare the context for build
  98104. * @param state defines the state that will be used for the build
  98105. */
  98106. initialize(state: NodeMaterialBuildState): void;
  98107. /**
  98108. * Bind data to effect. Will only be called for blocks with isBindable === true
  98109. * @param effect defines the effect to bind data to
  98110. * @param nodeMaterial defines the hosting NodeMaterial
  98111. * @param mesh defines the mesh that will be rendered
  98112. * @param subMesh defines the submesh that will be rendered
  98113. */
  98114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98115. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98116. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98117. protected _writeFloat(value: number): string;
  98118. /**
  98119. * Gets the current class name e.g. "NodeMaterialBlock"
  98120. * @returns the class name
  98121. */
  98122. getClassName(): string;
  98123. /**
  98124. * Register a new input. Must be called inside a block constructor
  98125. * @param name defines the connection point name
  98126. * @param type defines the connection point type
  98127. * @param isOptional defines a boolean indicating that this input can be omitted
  98128. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98129. * @param point an already created connection point. If not provided, create a new one
  98130. * @returns the current block
  98131. */
  98132. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98133. /**
  98134. * Register a new output. Must be called inside a block constructor
  98135. * @param name defines the connection point name
  98136. * @param type defines the connection point type
  98137. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98138. * @param point an already created connection point. If not provided, create a new one
  98139. * @returns the current block
  98140. */
  98141. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98142. /**
  98143. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98144. * @param forOutput defines an optional connection point to check compatibility with
  98145. * @returns the first available input or null
  98146. */
  98147. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98148. /**
  98149. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98150. * @param forBlock defines an optional block to check compatibility with
  98151. * @returns the first available input or null
  98152. */
  98153. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98154. /**
  98155. * Gets the sibling of the given output
  98156. * @param current defines the current output
  98157. * @returns the next output in the list or null
  98158. */
  98159. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98160. /**
  98161. * Connect current block with another block
  98162. * @param other defines the block to connect with
  98163. * @param options define the various options to help pick the right connections
  98164. * @returns the current block
  98165. */
  98166. connectTo(other: NodeMaterialBlock, options?: {
  98167. input?: string;
  98168. output?: string;
  98169. outputSwizzle?: string;
  98170. }): this | undefined;
  98171. protected _buildBlock(state: NodeMaterialBuildState): void;
  98172. /**
  98173. * Add uniforms, samplers and uniform buffers at compilation time
  98174. * @param state defines the state to update
  98175. * @param nodeMaterial defines the node material requesting the update
  98176. * @param defines defines the material defines to update
  98177. * @param uniformBuffers defines the list of uniform buffer names
  98178. */
  98179. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98180. /**
  98181. * Add potential fallbacks if shader compilation fails
  98182. * @param mesh defines the mesh to be rendered
  98183. * @param fallbacks defines the current prioritized list of fallbacks
  98184. */
  98185. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98186. /**
  98187. * Initialize defines for shader compilation
  98188. * @param mesh defines the mesh to be rendered
  98189. * @param nodeMaterial defines the node material requesting the update
  98190. * @param defines defines the material defines to update
  98191. * @param useInstances specifies that instances should be used
  98192. */
  98193. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98194. /**
  98195. * Update defines for shader compilation
  98196. * @param mesh defines the mesh to be rendered
  98197. * @param nodeMaterial defines the node material requesting the update
  98198. * @param defines defines the material defines to update
  98199. * @param useInstances specifies that instances should be used
  98200. * @param subMesh defines which submesh to render
  98201. */
  98202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98203. /**
  98204. * Lets the block try to connect some inputs automatically
  98205. * @param material defines the hosting NodeMaterial
  98206. */
  98207. autoConfigure(material: NodeMaterial): void;
  98208. /**
  98209. * Function called when a block is declared as repeatable content generator
  98210. * @param vertexShaderState defines the current compilation state for the vertex shader
  98211. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98212. * @param mesh defines the mesh to be rendered
  98213. * @param defines defines the material defines to update
  98214. */
  98215. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98216. /**
  98217. * Checks if the block is ready
  98218. * @param mesh defines the mesh to be rendered
  98219. * @param nodeMaterial defines the node material requesting the update
  98220. * @param defines defines the material defines to update
  98221. * @param useInstances specifies that instances should be used
  98222. * @returns true if the block is ready
  98223. */
  98224. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98225. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  98226. private _processBuild;
  98227. /**
  98228. * Validates the new name for the block node.
  98229. * @param newName the new name to be given to the node.
  98230. * @returns false if the name is a reserve word, else true.
  98231. */
  98232. validateBlockName(newName: string): boolean;
  98233. /**
  98234. * Compile the current node and generate the shader code
  98235. * @param state defines the current compilation state (uniforms, samplers, current string)
  98236. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98237. * @returns true if already built
  98238. */
  98239. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98240. protected _inputRename(name: string): string;
  98241. protected _outputRename(name: string): string;
  98242. protected _dumpPropertiesCode(): string;
  98243. /** @hidden */
  98244. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98245. /** @hidden */
  98246. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98247. /**
  98248. * Clone the current block to a new identical block
  98249. * @param scene defines the hosting scene
  98250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98251. * @returns a copy of the current block
  98252. */
  98253. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98254. /**
  98255. * Serializes this block in a JSON representation
  98256. * @returns the serialized block object
  98257. */
  98258. serialize(): any;
  98259. /** @hidden */
  98260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98261. private _deserializePortDisplayNamesAndExposedOnFrame;
  98262. /**
  98263. * Release resources
  98264. */
  98265. dispose(): void;
  98266. }
  98267. }
  98268. declare module BABYLON {
  98269. /**
  98270. * Base class of materials working in push mode in babylon JS
  98271. * @hidden
  98272. */
  98273. export class PushMaterial extends Material {
  98274. protected _activeEffect: Effect;
  98275. protected _normalMatrix: Matrix;
  98276. constructor(name: string, scene: Scene);
  98277. getEffect(): Effect;
  98278. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98279. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98280. /**
  98281. * Binds the given world matrix to the active effect
  98282. *
  98283. * @param world the matrix to bind
  98284. */
  98285. bindOnlyWorldMatrix(world: Matrix): void;
  98286. /**
  98287. * Binds the given normal matrix to the active effect
  98288. *
  98289. * @param normalMatrix the matrix to bind
  98290. */
  98291. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98292. bind(world: Matrix, mesh?: Mesh): void;
  98293. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98294. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98295. }
  98296. }
  98297. declare module BABYLON {
  98298. /**
  98299. * Root class for all node material optimizers
  98300. */
  98301. export class NodeMaterialOptimizer {
  98302. /**
  98303. * Function used to optimize a NodeMaterial graph
  98304. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98305. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98306. */
  98307. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98308. }
  98309. }
  98310. declare module BABYLON {
  98311. /**
  98312. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98313. */
  98314. export class TransformBlock extends NodeMaterialBlock {
  98315. /**
  98316. * Defines the value to use to complement W value to transform it to a Vector4
  98317. */
  98318. complementW: number;
  98319. /**
  98320. * Defines the value to use to complement z value to transform it to a Vector4
  98321. */
  98322. complementZ: number;
  98323. /**
  98324. * Creates a new TransformBlock
  98325. * @param name defines the block name
  98326. */
  98327. constructor(name: string);
  98328. /**
  98329. * Gets the current class name
  98330. * @returns the class name
  98331. */
  98332. getClassName(): string;
  98333. /**
  98334. * Gets the vector input
  98335. */
  98336. get vector(): NodeMaterialConnectionPoint;
  98337. /**
  98338. * Gets the output component
  98339. */
  98340. get output(): NodeMaterialConnectionPoint;
  98341. /**
  98342. * Gets the xyz output component
  98343. */
  98344. get xyz(): NodeMaterialConnectionPoint;
  98345. /**
  98346. * Gets the matrix transform input
  98347. */
  98348. get transform(): NodeMaterialConnectionPoint;
  98349. protected _buildBlock(state: NodeMaterialBuildState): this;
  98350. /**
  98351. * Update defines for shader compilation
  98352. * @param mesh defines the mesh to be rendered
  98353. * @param nodeMaterial defines the node material requesting the update
  98354. * @param defines defines the material defines to update
  98355. * @param useInstances specifies that instances should be used
  98356. * @param subMesh defines which submesh to render
  98357. */
  98358. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98359. serialize(): any;
  98360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98361. protected _dumpPropertiesCode(): string;
  98362. }
  98363. }
  98364. declare module BABYLON {
  98365. /**
  98366. * Block used to output the vertex position
  98367. */
  98368. export class VertexOutputBlock extends NodeMaterialBlock {
  98369. /**
  98370. * Creates a new VertexOutputBlock
  98371. * @param name defines the block name
  98372. */
  98373. constructor(name: string);
  98374. /**
  98375. * Gets the current class name
  98376. * @returns the class name
  98377. */
  98378. getClassName(): string;
  98379. /**
  98380. * Gets the vector input component
  98381. */
  98382. get vector(): NodeMaterialConnectionPoint;
  98383. protected _buildBlock(state: NodeMaterialBuildState): this;
  98384. }
  98385. }
  98386. declare module BABYLON {
  98387. /**
  98388. * Block used to output the final color
  98389. */
  98390. export class FragmentOutputBlock extends NodeMaterialBlock {
  98391. /**
  98392. * Create a new FragmentOutputBlock
  98393. * @param name defines the block name
  98394. */
  98395. constructor(name: string);
  98396. /**
  98397. * Gets the current class name
  98398. * @returns the class name
  98399. */
  98400. getClassName(): string;
  98401. /**
  98402. * Gets the rgba input component
  98403. */
  98404. get rgba(): NodeMaterialConnectionPoint;
  98405. /**
  98406. * Gets the rgb input component
  98407. */
  98408. get rgb(): NodeMaterialConnectionPoint;
  98409. /**
  98410. * Gets the a input component
  98411. */
  98412. get a(): NodeMaterialConnectionPoint;
  98413. protected _buildBlock(state: NodeMaterialBuildState): this;
  98414. }
  98415. }
  98416. declare module BABYLON {
  98417. /**
  98418. * Block used for the particle ramp gradient section
  98419. */
  98420. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98421. /**
  98422. * Create a new ParticleRampGradientBlock
  98423. * @param name defines the block name
  98424. */
  98425. constructor(name: string);
  98426. /**
  98427. * Gets the current class name
  98428. * @returns the class name
  98429. */
  98430. getClassName(): string;
  98431. /**
  98432. * Gets the color input component
  98433. */
  98434. get color(): NodeMaterialConnectionPoint;
  98435. /**
  98436. * Gets the rampColor output component
  98437. */
  98438. get rampColor(): NodeMaterialConnectionPoint;
  98439. /**
  98440. * Initialize the block and prepare the context for build
  98441. * @param state defines the state that will be used for the build
  98442. */
  98443. initialize(state: NodeMaterialBuildState): void;
  98444. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98445. }
  98446. }
  98447. declare module BABYLON {
  98448. /**
  98449. * Block used for the particle blend multiply section
  98450. */
  98451. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98452. /**
  98453. * Create a new ParticleBlendMultiplyBlock
  98454. * @param name defines the block name
  98455. */
  98456. constructor(name: string);
  98457. /**
  98458. * Gets the current class name
  98459. * @returns the class name
  98460. */
  98461. getClassName(): string;
  98462. /**
  98463. * Gets the color input component
  98464. */
  98465. get color(): NodeMaterialConnectionPoint;
  98466. /**
  98467. * Gets the alphaTexture input component
  98468. */
  98469. get alphaTexture(): NodeMaterialConnectionPoint;
  98470. /**
  98471. * Gets the alphaColor input component
  98472. */
  98473. get alphaColor(): NodeMaterialConnectionPoint;
  98474. /**
  98475. * Gets the blendColor output component
  98476. */
  98477. get blendColor(): NodeMaterialConnectionPoint;
  98478. /**
  98479. * Initialize the block and prepare the context for build
  98480. * @param state defines the state that will be used for the build
  98481. */
  98482. initialize(state: NodeMaterialBuildState): void;
  98483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98484. }
  98485. }
  98486. declare module BABYLON {
  98487. /**
  98488. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98489. */
  98490. export class VectorMergerBlock extends NodeMaterialBlock {
  98491. /**
  98492. * Create a new VectorMergerBlock
  98493. * @param name defines the block name
  98494. */
  98495. constructor(name: string);
  98496. /**
  98497. * Gets the current class name
  98498. * @returns the class name
  98499. */
  98500. getClassName(): string;
  98501. /**
  98502. * Gets the xyz component (input)
  98503. */
  98504. get xyzIn(): NodeMaterialConnectionPoint;
  98505. /**
  98506. * Gets the xy component (input)
  98507. */
  98508. get xyIn(): NodeMaterialConnectionPoint;
  98509. /**
  98510. * Gets the x component (input)
  98511. */
  98512. get x(): NodeMaterialConnectionPoint;
  98513. /**
  98514. * Gets the y component (input)
  98515. */
  98516. get y(): NodeMaterialConnectionPoint;
  98517. /**
  98518. * Gets the z component (input)
  98519. */
  98520. get z(): NodeMaterialConnectionPoint;
  98521. /**
  98522. * Gets the w component (input)
  98523. */
  98524. get w(): NodeMaterialConnectionPoint;
  98525. /**
  98526. * Gets the xyzw component (output)
  98527. */
  98528. get xyzw(): NodeMaterialConnectionPoint;
  98529. /**
  98530. * Gets the xyz component (output)
  98531. */
  98532. get xyzOut(): NodeMaterialConnectionPoint;
  98533. /**
  98534. * Gets the xy component (output)
  98535. */
  98536. get xyOut(): NodeMaterialConnectionPoint;
  98537. /**
  98538. * Gets the xy component (output)
  98539. * @deprecated Please use xyOut instead.
  98540. */
  98541. get xy(): NodeMaterialConnectionPoint;
  98542. /**
  98543. * Gets the xyz component (output)
  98544. * @deprecated Please use xyzOut instead.
  98545. */
  98546. get xyz(): NodeMaterialConnectionPoint;
  98547. protected _buildBlock(state: NodeMaterialBuildState): this;
  98548. }
  98549. }
  98550. declare module BABYLON {
  98551. /**
  98552. * Block used to remap a float from a range to a new one
  98553. */
  98554. export class RemapBlock extends NodeMaterialBlock {
  98555. /**
  98556. * Gets or sets the source range
  98557. */
  98558. sourceRange: Vector2;
  98559. /**
  98560. * Gets or sets the target range
  98561. */
  98562. targetRange: Vector2;
  98563. /**
  98564. * Creates a new RemapBlock
  98565. * @param name defines the block name
  98566. */
  98567. constructor(name: string);
  98568. /**
  98569. * Gets the current class name
  98570. * @returns the class name
  98571. */
  98572. getClassName(): string;
  98573. /**
  98574. * Gets the input component
  98575. */
  98576. get input(): NodeMaterialConnectionPoint;
  98577. /**
  98578. * Gets the source min input component
  98579. */
  98580. get sourceMin(): NodeMaterialConnectionPoint;
  98581. /**
  98582. * Gets the source max input component
  98583. */
  98584. get sourceMax(): NodeMaterialConnectionPoint;
  98585. /**
  98586. * Gets the target min input component
  98587. */
  98588. get targetMin(): NodeMaterialConnectionPoint;
  98589. /**
  98590. * Gets the target max input component
  98591. */
  98592. get targetMax(): NodeMaterialConnectionPoint;
  98593. /**
  98594. * Gets the output component
  98595. */
  98596. get output(): NodeMaterialConnectionPoint;
  98597. protected _buildBlock(state: NodeMaterialBuildState): this;
  98598. protected _dumpPropertiesCode(): string;
  98599. serialize(): any;
  98600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98601. }
  98602. }
  98603. declare module BABYLON {
  98604. /**
  98605. * Block used to multiply 2 values
  98606. */
  98607. export class MultiplyBlock extends NodeMaterialBlock {
  98608. /**
  98609. * Creates a new MultiplyBlock
  98610. * @param name defines the block name
  98611. */
  98612. constructor(name: string);
  98613. /**
  98614. * Gets the current class name
  98615. * @returns the class name
  98616. */
  98617. getClassName(): string;
  98618. /**
  98619. * Gets the left operand input component
  98620. */
  98621. get left(): NodeMaterialConnectionPoint;
  98622. /**
  98623. * Gets the right operand input component
  98624. */
  98625. get right(): NodeMaterialConnectionPoint;
  98626. /**
  98627. * Gets the output component
  98628. */
  98629. get output(): NodeMaterialConnectionPoint;
  98630. protected _buildBlock(state: NodeMaterialBuildState): this;
  98631. }
  98632. }
  98633. declare module BABYLON {
  98634. /** Interface used by value gradients (color, factor, ...) */
  98635. export interface IValueGradient {
  98636. /**
  98637. * Gets or sets the gradient value (between 0 and 1)
  98638. */
  98639. gradient: number;
  98640. }
  98641. /** Class used to store color4 gradient */
  98642. export class ColorGradient implements IValueGradient {
  98643. /**
  98644. * Gets or sets the gradient value (between 0 and 1)
  98645. */
  98646. gradient: number;
  98647. /**
  98648. * Gets or sets first associated color
  98649. */
  98650. color1: Color4;
  98651. /**
  98652. * Gets or sets second associated color
  98653. */
  98654. color2?: Color4 | undefined;
  98655. /**
  98656. * Creates a new color4 gradient
  98657. * @param gradient gets or sets the gradient value (between 0 and 1)
  98658. * @param color1 gets or sets first associated color
  98659. * @param color2 gets or sets first second color
  98660. */
  98661. constructor(
  98662. /**
  98663. * Gets or sets the gradient value (between 0 and 1)
  98664. */
  98665. gradient: number,
  98666. /**
  98667. * Gets or sets first associated color
  98668. */
  98669. color1: Color4,
  98670. /**
  98671. * Gets or sets second associated color
  98672. */
  98673. color2?: Color4 | undefined);
  98674. /**
  98675. * Will get a color picked randomly between color1 and color2.
  98676. * If color2 is undefined then color1 will be used
  98677. * @param result defines the target Color4 to store the result in
  98678. */
  98679. getColorToRef(result: Color4): void;
  98680. }
  98681. /** Class used to store color 3 gradient */
  98682. export class Color3Gradient implements IValueGradient {
  98683. /**
  98684. * Gets or sets the gradient value (between 0 and 1)
  98685. */
  98686. gradient: number;
  98687. /**
  98688. * Gets or sets the associated color
  98689. */
  98690. color: Color3;
  98691. /**
  98692. * Creates a new color3 gradient
  98693. * @param gradient gets or sets the gradient value (between 0 and 1)
  98694. * @param color gets or sets associated color
  98695. */
  98696. constructor(
  98697. /**
  98698. * Gets or sets the gradient value (between 0 and 1)
  98699. */
  98700. gradient: number,
  98701. /**
  98702. * Gets or sets the associated color
  98703. */
  98704. color: Color3);
  98705. }
  98706. /** Class used to store factor gradient */
  98707. export class FactorGradient implements IValueGradient {
  98708. /**
  98709. * Gets or sets the gradient value (between 0 and 1)
  98710. */
  98711. gradient: number;
  98712. /**
  98713. * Gets or sets first associated factor
  98714. */
  98715. factor1: number;
  98716. /**
  98717. * Gets or sets second associated factor
  98718. */
  98719. factor2?: number | undefined;
  98720. /**
  98721. * Creates a new factor gradient
  98722. * @param gradient gets or sets the gradient value (between 0 and 1)
  98723. * @param factor1 gets or sets first associated factor
  98724. * @param factor2 gets or sets second associated factor
  98725. */
  98726. constructor(
  98727. /**
  98728. * Gets or sets the gradient value (between 0 and 1)
  98729. */
  98730. gradient: number,
  98731. /**
  98732. * Gets or sets first associated factor
  98733. */
  98734. factor1: number,
  98735. /**
  98736. * Gets or sets second associated factor
  98737. */
  98738. factor2?: number | undefined);
  98739. /**
  98740. * Will get a number picked randomly between factor1 and factor2.
  98741. * If factor2 is undefined then factor1 will be used
  98742. * @returns the picked number
  98743. */
  98744. getFactor(): number;
  98745. }
  98746. /**
  98747. * Helper used to simplify some generic gradient tasks
  98748. */
  98749. export class GradientHelper {
  98750. /**
  98751. * Gets the current gradient from an array of IValueGradient
  98752. * @param ratio defines the current ratio to get
  98753. * @param gradients defines the array of IValueGradient
  98754. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  98755. */
  98756. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  98757. }
  98758. }
  98759. declare module BABYLON {
  98760. interface ThinEngine {
  98761. /**
  98762. * Creates a raw texture
  98763. * @param data defines the data to store in the texture
  98764. * @param width defines the width of the texture
  98765. * @param height defines the height of the texture
  98766. * @param format defines the format of the data
  98767. * @param generateMipMaps defines if the engine should generate the mip levels
  98768. * @param invertY defines if data must be stored with Y axis inverted
  98769. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98770. * @param compression defines the compression used (null by default)
  98771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98772. * @returns the raw texture inside an InternalTexture
  98773. */
  98774. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  98775. /**
  98776. * Update a raw texture
  98777. * @param texture defines the texture to update
  98778. * @param data defines the data to store in the texture
  98779. * @param format defines the format of the data
  98780. * @param invertY defines if data must be stored with Y axis inverted
  98781. */
  98782. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  98783. /**
  98784. * Update a raw texture
  98785. * @param texture defines the texture to update
  98786. * @param data defines the data to store in the texture
  98787. * @param format defines the format of the data
  98788. * @param invertY defines if data must be stored with Y axis inverted
  98789. * @param compression defines the compression used (null by default)
  98790. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98791. */
  98792. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  98793. /**
  98794. * Creates a new raw cube texture
  98795. * @param data defines the array of data to use to create each face
  98796. * @param size defines the size of the textures
  98797. * @param format defines the format of the data
  98798. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98799. * @param generateMipMaps defines if the engine should generate the mip levels
  98800. * @param invertY defines if data must be stored with Y axis inverted
  98801. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98802. * @param compression defines the compression used (null by default)
  98803. * @returns the cube texture as an InternalTexture
  98804. */
  98805. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  98806. /**
  98807. * Update a raw cube texture
  98808. * @param texture defines the texture to udpdate
  98809. * @param data defines the data to store
  98810. * @param format defines the data format
  98811. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98812. * @param invertY defines if data must be stored with Y axis inverted
  98813. */
  98814. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  98815. /**
  98816. * Update a raw cube texture
  98817. * @param texture defines the texture to udpdate
  98818. * @param data defines the data to store
  98819. * @param format defines the data format
  98820. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98821. * @param invertY defines if data must be stored with Y axis inverted
  98822. * @param compression defines the compression used (null by default)
  98823. */
  98824. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  98825. /**
  98826. * Update a raw cube texture
  98827. * @param texture defines the texture to udpdate
  98828. * @param data defines the data to store
  98829. * @param format defines the data format
  98830. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98831. * @param invertY defines if data must be stored with Y axis inverted
  98832. * @param compression defines the compression used (null by default)
  98833. * @param level defines which level of the texture to update
  98834. */
  98835. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  98836. /**
  98837. * Creates a new raw cube texture from a specified url
  98838. * @param url defines the url where the data is located
  98839. * @param scene defines the current scene
  98840. * @param size defines the size of the textures
  98841. * @param format defines the format of the data
  98842. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98843. * @param noMipmap defines if the engine should avoid generating the mip levels
  98844. * @param callback defines a callback used to extract texture data from loaded data
  98845. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  98846. * @param onLoad defines a callback called when texture is loaded
  98847. * @param onError defines a callback called if there is an error
  98848. * @returns the cube texture as an InternalTexture
  98849. */
  98850. 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;
  98851. /**
  98852. * Creates a new raw cube texture from a specified url
  98853. * @param url defines the url where the data is located
  98854. * @param scene defines the current scene
  98855. * @param size defines the size of the textures
  98856. * @param format defines the format of the data
  98857. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98858. * @param noMipmap defines if the engine should avoid generating the mip levels
  98859. * @param callback defines a callback used to extract texture data from loaded data
  98860. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  98861. * @param onLoad defines a callback called when texture is loaded
  98862. * @param onError defines a callback called if there is an error
  98863. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98864. * @param invertY defines if data must be stored with Y axis inverted
  98865. * @returns the cube texture as an InternalTexture
  98866. */
  98867. 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;
  98868. /**
  98869. * Creates a new raw 3D texture
  98870. * @param data defines the data used to create the texture
  98871. * @param width defines the width of the texture
  98872. * @param height defines the height of the texture
  98873. * @param depth defines the depth of the texture
  98874. * @param format defines the format of the texture
  98875. * @param generateMipMaps defines if the engine must generate mip levels
  98876. * @param invertY defines if data must be stored with Y axis inverted
  98877. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98878. * @param compression defines the compressed used (can be null)
  98879. * @param textureType defines the compressed used (can be null)
  98880. * @returns a new raw 3D texture (stored in an InternalTexture)
  98881. */
  98882. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  98883. /**
  98884. * Update a raw 3D texture
  98885. * @param texture defines the texture to update
  98886. * @param data defines the data to store
  98887. * @param format defines the data format
  98888. * @param invertY defines if data must be stored with Y axis inverted
  98889. */
  98890. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  98891. /**
  98892. * Update a raw 3D texture
  98893. * @param texture defines the texture to update
  98894. * @param data defines the data to store
  98895. * @param format defines the data format
  98896. * @param invertY defines if data must be stored with Y axis inverted
  98897. * @param compression defines the used compression (can be null)
  98898. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  98899. */
  98900. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  98901. /**
  98902. * Creates a new raw 2D array texture
  98903. * @param data defines the data used to create the texture
  98904. * @param width defines the width of the texture
  98905. * @param height defines the height of the texture
  98906. * @param depth defines the number of layers of the texture
  98907. * @param format defines the format of the texture
  98908. * @param generateMipMaps defines if the engine must generate mip levels
  98909. * @param invertY defines if data must be stored with Y axis inverted
  98910. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98911. * @param compression defines the compressed used (can be null)
  98912. * @param textureType defines the compressed used (can be null)
  98913. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98914. */
  98915. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  98916. /**
  98917. * Update a raw 2D array texture
  98918. * @param texture defines the texture to update
  98919. * @param data defines the data to store
  98920. * @param format defines the data format
  98921. * @param invertY defines if data must be stored with Y axis inverted
  98922. */
  98923. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  98924. /**
  98925. * Update a raw 2D array texture
  98926. * @param texture defines the texture to update
  98927. * @param data defines the data to store
  98928. * @param format defines the data format
  98929. * @param invertY defines if data must be stored with Y axis inverted
  98930. * @param compression defines the used compression (can be null)
  98931. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  98932. */
  98933. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  98934. }
  98935. }
  98936. declare module BABYLON {
  98937. /**
  98938. * Raw texture can help creating a texture directly from an array of data.
  98939. * This can be super useful if you either get the data from an uncompressed source or
  98940. * if you wish to create your texture pixel by pixel.
  98941. */
  98942. export class RawTexture extends Texture {
  98943. /**
  98944. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  98945. */
  98946. format: number;
  98947. /**
  98948. * Instantiates a new RawTexture.
  98949. * Raw texture can help creating a texture directly from an array of data.
  98950. * This can be super useful if you either get the data from an uncompressed source or
  98951. * if you wish to create your texture pixel by pixel.
  98952. * @param data define the array of data to use to create the texture
  98953. * @param width define the width of the texture
  98954. * @param height define the height of the texture
  98955. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  98956. * @param sceneOrEngine defines the scene or engine the texture will belong to
  98957. * @param generateMipMaps define whether mip maps should be generated or not
  98958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  98959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  98960. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  98961. */
  98962. constructor(data: ArrayBufferView, width: number, height: number,
  98963. /**
  98964. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  98965. */
  98966. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  98967. /**
  98968. * Updates the texture underlying data.
  98969. * @param data Define the new data of the texture
  98970. */
  98971. update(data: ArrayBufferView): void;
  98972. /**
  98973. * Creates a luminance texture from some data.
  98974. * @param data Define the texture data
  98975. * @param width Define the width of the texture
  98976. * @param height Define the height of the texture
  98977. * @param sceneOrEngine defines the scene or engine the texture will belong to
  98978. * @param generateMipMaps Define whether or not to create mip maps for the texture
  98979. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  98980. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  98981. * @returns the luminance texture
  98982. */
  98983. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  98984. /**
  98985. * Creates a luminance alpha texture from some data.
  98986. * @param data Define the texture data
  98987. * @param width Define the width of the texture
  98988. * @param height Define the height of the texture
  98989. * @param sceneOrEngine defines the scene or engine the texture will belong to
  98990. * @param generateMipMaps Define whether or not to create mip maps for the texture
  98991. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  98992. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  98993. * @returns the luminance alpha texture
  98994. */
  98995. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  98996. /**
  98997. * Creates an alpha texture from some data.
  98998. * @param data Define the texture data
  98999. * @param width Define the width of the texture
  99000. * @param height Define the height of the texture
  99001. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99005. * @returns the alpha texture
  99006. */
  99007. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99008. /**
  99009. * Creates a RGB texture from some data.
  99010. * @param data Define the texture data
  99011. * @param width Define the width of the texture
  99012. * @param height Define the height of the texture
  99013. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99014. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99015. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99016. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99017. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99018. * @returns the RGB alpha texture
  99019. */
  99020. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99021. /**
  99022. * Creates a RGBA texture from some data.
  99023. * @param data Define the texture data
  99024. * @param width Define the width of the texture
  99025. * @param height Define the height of the texture
  99026. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99027. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99028. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99029. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99030. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99031. * @returns the RGBA texture
  99032. */
  99033. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99034. /**
  99035. * Creates a R texture from some data.
  99036. * @param data Define the texture data
  99037. * @param width Define the width of the texture
  99038. * @param height Define the height of the texture
  99039. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99040. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99041. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99042. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99043. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99044. * @returns the R texture
  99045. */
  99046. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99047. }
  99048. }
  99049. declare module BABYLON {
  99050. interface ThinEngine {
  99051. /**
  99052. * Update a dynamic index buffer
  99053. * @param indexBuffer defines the target index buffer
  99054. * @param indices defines the data to update
  99055. * @param offset defines the offset in the target index buffer where update should start
  99056. */
  99057. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99058. /**
  99059. * Updates a dynamic vertex buffer.
  99060. * @param vertexBuffer the vertex buffer to update
  99061. * @param data the data used to update the vertex buffer
  99062. * @param byteOffset the byte offset of the data
  99063. * @param byteLength the byte length of the data
  99064. */
  99065. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99066. }
  99067. }
  99068. declare module BABYLON {
  99069. interface AbstractScene {
  99070. /**
  99071. * The list of procedural textures added to the scene
  99072. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99073. */
  99074. proceduralTextures: Array<ProceduralTexture>;
  99075. }
  99076. /**
  99077. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  99078. * in a given scene.
  99079. */
  99080. export class ProceduralTextureSceneComponent implements ISceneComponent {
  99081. /**
  99082. * The component name helpfull to identify the component in the list of scene components.
  99083. */
  99084. readonly name: string;
  99085. /**
  99086. * The scene the component belongs to.
  99087. */
  99088. scene: Scene;
  99089. /**
  99090. * Creates a new instance of the component for the given scene
  99091. * @param scene Defines the scene to register the component in
  99092. */
  99093. constructor(scene: Scene);
  99094. /**
  99095. * Registers the component in a given scene
  99096. */
  99097. register(): void;
  99098. /**
  99099. * Rebuilds the elements related to this component in case of
  99100. * context lost for instance.
  99101. */
  99102. rebuild(): void;
  99103. /**
  99104. * Disposes the component and the associated ressources.
  99105. */
  99106. dispose(): void;
  99107. private _beforeClear;
  99108. }
  99109. }
  99110. declare module BABYLON {
  99111. interface ThinEngine {
  99112. /**
  99113. * Creates a new render target cube texture
  99114. * @param size defines the size of the texture
  99115. * @param options defines the options used to create the texture
  99116. * @returns a new render target cube texture stored in an InternalTexture
  99117. */
  99118. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  99119. }
  99120. }
  99121. declare module BABYLON {
  99122. /** @hidden */
  99123. export var proceduralVertexShader: {
  99124. name: string;
  99125. shader: string;
  99126. };
  99127. }
  99128. declare module BABYLON {
  99129. /**
  99130. * 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.
  99131. * This is the base class of any Procedural texture and contains most of the shareable code.
  99132. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99133. */
  99134. export class ProceduralTexture extends Texture {
  99135. /**
  99136. * Define if the texture is enabled or not (disabled texture will not render)
  99137. */
  99138. isEnabled: boolean;
  99139. /**
  99140. * Define if the texture must be cleared before rendering (default is true)
  99141. */
  99142. autoClear: boolean;
  99143. /**
  99144. * Callback called when the texture is generated
  99145. */
  99146. onGenerated: () => void;
  99147. /**
  99148. * Event raised when the texture is generated
  99149. */
  99150. onGeneratedObservable: Observable<ProceduralTexture>;
  99151. /**
  99152. * Event raised before the texture is generated
  99153. */
  99154. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  99155. /**
  99156. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  99157. */
  99158. nodeMaterialSource: Nullable<NodeMaterial>;
  99159. /** @hidden */
  99160. _generateMipMaps: boolean;
  99161. /** @hidden **/
  99162. _effect: Effect;
  99163. /** @hidden */
  99164. _textures: {
  99165. [key: string]: Texture;
  99166. };
  99167. /** @hidden */
  99168. protected _fallbackTexture: Nullable<Texture>;
  99169. private _size;
  99170. private _textureType;
  99171. private _currentRefreshId;
  99172. private _frameId;
  99173. private _refreshRate;
  99174. private _vertexBuffers;
  99175. private _indexBuffer;
  99176. private _uniforms;
  99177. private _samplers;
  99178. private _fragment;
  99179. private _floats;
  99180. private _ints;
  99181. private _floatsArrays;
  99182. private _colors3;
  99183. private _colors4;
  99184. private _vectors2;
  99185. private _vectors3;
  99186. private _matrices;
  99187. private _fallbackTextureUsed;
  99188. private _fullEngine;
  99189. private _cachedDefines;
  99190. private _contentUpdateId;
  99191. private _contentData;
  99192. /**
  99193. * Instantiates a new procedural texture.
  99194. * 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.
  99195. * This is the base class of any Procedural texture and contains most of the shareable code.
  99196. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99197. * @param name Define the name of the texture
  99198. * @param size Define the size of the texture to create
  99199. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  99200. * @param scene Define the scene the texture belongs to
  99201. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  99202. * @param generateMipMaps Define if the texture should creates mip maps or not
  99203. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  99204. * @param textureType The FBO internal texture type
  99205. */
  99206. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  99207. /**
  99208. * The effect that is created when initializing the post process.
  99209. * @returns The created effect corresponding the the postprocess.
  99210. */
  99211. getEffect(): Effect;
  99212. /**
  99213. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  99214. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  99215. */
  99216. getContent(): Nullable<Promise<ArrayBufferView>>;
  99217. private _createIndexBuffer;
  99218. /** @hidden */
  99219. _rebuild(): void;
  99220. /**
  99221. * Resets the texture in order to recreate its associated resources.
  99222. * This can be called in case of context loss
  99223. */
  99224. reset(): void;
  99225. protected _getDefines(): string;
  99226. /**
  99227. * Is the texture ready to be used ? (rendered at least once)
  99228. * @returns true if ready, otherwise, false.
  99229. */
  99230. isReady(): boolean;
  99231. /**
  99232. * Resets the refresh counter of the texture and start bak from scratch.
  99233. * Could be useful to regenerate the texture if it is setup to render only once.
  99234. */
  99235. resetRefreshCounter(): void;
  99236. /**
  99237. * Set the fragment shader to use in order to render the texture.
  99238. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  99239. */
  99240. setFragment(fragment: any): void;
  99241. /**
  99242. * Define the refresh rate of the texture or the rendering frequency.
  99243. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  99244. */
  99245. get refreshRate(): number;
  99246. set refreshRate(value: number);
  99247. /** @hidden */
  99248. _shouldRender(): boolean;
  99249. /**
  99250. * Get the size the texture is rendering at.
  99251. * @returns the size (on cube texture it is always squared)
  99252. */
  99253. getRenderSize(): RenderTargetTextureSize;
  99254. /**
  99255. * Resize the texture to new value.
  99256. * @param size Define the new size the texture should have
  99257. * @param generateMipMaps Define whether the new texture should create mip maps
  99258. */
  99259. resize(size: number, generateMipMaps: boolean): void;
  99260. private _checkUniform;
  99261. /**
  99262. * Set a texture in the shader program used to render.
  99263. * @param name Define the name of the uniform samplers as defined in the shader
  99264. * @param texture Define the texture to bind to this sampler
  99265. * @return the texture itself allowing "fluent" like uniform updates
  99266. */
  99267. setTexture(name: string, texture: Texture): ProceduralTexture;
  99268. /**
  99269. * Set a float in the shader.
  99270. * @param name Define the name of the uniform as defined in the shader
  99271. * @param value Define the value to give to the uniform
  99272. * @return the texture itself allowing "fluent" like uniform updates
  99273. */
  99274. setFloat(name: string, value: number): ProceduralTexture;
  99275. /**
  99276. * Set a int in the shader.
  99277. * @param name Define the name of the uniform as defined in the shader
  99278. * @param value Define the value to give to the uniform
  99279. * @return the texture itself allowing "fluent" like uniform updates
  99280. */
  99281. setInt(name: string, value: number): ProceduralTexture;
  99282. /**
  99283. * Set an array of floats in the shader.
  99284. * @param name Define the name of the uniform as defined in the shader
  99285. * @param value Define the value to give to the uniform
  99286. * @return the texture itself allowing "fluent" like uniform updates
  99287. */
  99288. setFloats(name: string, value: number[]): ProceduralTexture;
  99289. /**
  99290. * Set a vec3 in the shader from a Color3.
  99291. * @param name Define the name of the uniform as defined in the shader
  99292. * @param value Define the value to give to the uniform
  99293. * @return the texture itself allowing "fluent" like uniform updates
  99294. */
  99295. setColor3(name: string, value: Color3): ProceduralTexture;
  99296. /**
  99297. * Set a vec4 in the shader from a Color4.
  99298. * @param name Define the name of the uniform as defined in the shader
  99299. * @param value Define the value to give to the uniform
  99300. * @return the texture itself allowing "fluent" like uniform updates
  99301. */
  99302. setColor4(name: string, value: Color4): ProceduralTexture;
  99303. /**
  99304. * Set a vec2 in the shader from a Vector2.
  99305. * @param name Define the name of the uniform as defined in the shader
  99306. * @param value Define the value to give to the uniform
  99307. * @return the texture itself allowing "fluent" like uniform updates
  99308. */
  99309. setVector2(name: string, value: Vector2): ProceduralTexture;
  99310. /**
  99311. * Set a vec3 in the shader from a Vector3.
  99312. * @param name Define the name of the uniform as defined in the shader
  99313. * @param value Define the value to give to the uniform
  99314. * @return the texture itself allowing "fluent" like uniform updates
  99315. */
  99316. setVector3(name: string, value: Vector3): ProceduralTexture;
  99317. /**
  99318. * Set a mat4 in the shader from a MAtrix.
  99319. * @param name Define the name of the uniform as defined in the shader
  99320. * @param value Define the value to give to the uniform
  99321. * @return the texture itself allowing "fluent" like uniform updates
  99322. */
  99323. setMatrix(name: string, value: Matrix): ProceduralTexture;
  99324. /**
  99325. * Render the texture to its associated render target.
  99326. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  99327. */
  99328. render(useCameraPostProcess?: boolean): void;
  99329. /**
  99330. * Clone the texture.
  99331. * @returns the cloned texture
  99332. */
  99333. clone(): ProceduralTexture;
  99334. /**
  99335. * Dispose the texture and release its asoociated resources.
  99336. */
  99337. dispose(): void;
  99338. }
  99339. }
  99340. declare module BABYLON {
  99341. /**
  99342. * This represents the base class for particle system in Babylon.
  99343. * 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.
  99344. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  99345. * @example https://doc.babylonjs.com/babylon101/particles
  99346. */
  99347. export class BaseParticleSystem {
  99348. /**
  99349. * Source color is added to the destination color without alpha affecting the result
  99350. */
  99351. static BLENDMODE_ONEONE: number;
  99352. /**
  99353. * Blend current color and particle color using particle’s alpha
  99354. */
  99355. static BLENDMODE_STANDARD: number;
  99356. /**
  99357. * Add current color and particle color multiplied by particle’s alpha
  99358. */
  99359. static BLENDMODE_ADD: number;
  99360. /**
  99361. * Multiply current color with particle color
  99362. */
  99363. static BLENDMODE_MULTIPLY: number;
  99364. /**
  99365. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  99366. */
  99367. static BLENDMODE_MULTIPLYADD: number;
  99368. /**
  99369. * List of animations used by the particle system.
  99370. */
  99371. animations: Animation[];
  99372. /**
  99373. * Gets or sets the unique id of the particle system
  99374. */
  99375. uniqueId: number;
  99376. /**
  99377. * The id of the Particle system.
  99378. */
  99379. id: string;
  99380. /**
  99381. * The friendly name of the Particle system.
  99382. */
  99383. name: string;
  99384. /**
  99385. * Snippet ID if the particle system was created from the snippet server
  99386. */
  99387. snippetId: string;
  99388. /**
  99389. * The rendering group used by the Particle system to chose when to render.
  99390. */
  99391. renderingGroupId: number;
  99392. /**
  99393. * The emitter represents the Mesh or position we are attaching the particle system to.
  99394. */
  99395. emitter: Nullable<AbstractMesh | Vector3>;
  99396. /**
  99397. * The maximum number of particles to emit per frame
  99398. */
  99399. emitRate: number;
  99400. /**
  99401. * If you want to launch only a few particles at once, that can be done, as well.
  99402. */
  99403. manualEmitCount: number;
  99404. /**
  99405. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  99406. */
  99407. updateSpeed: number;
  99408. /**
  99409. * The amount of time the particle system is running (depends of the overall update speed).
  99410. */
  99411. targetStopDuration: number;
  99412. /**
  99413. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  99414. */
  99415. disposeOnStop: boolean;
  99416. /**
  99417. * Minimum power of emitting particles.
  99418. */
  99419. minEmitPower: number;
  99420. /**
  99421. * Maximum power of emitting particles.
  99422. */
  99423. maxEmitPower: number;
  99424. /**
  99425. * Minimum life time of emitting particles.
  99426. */
  99427. minLifeTime: number;
  99428. /**
  99429. * Maximum life time of emitting particles.
  99430. */
  99431. maxLifeTime: number;
  99432. /**
  99433. * Minimum Size of emitting particles.
  99434. */
  99435. minSize: number;
  99436. /**
  99437. * Maximum Size of emitting particles.
  99438. */
  99439. maxSize: number;
  99440. /**
  99441. * Minimum scale of emitting particles on X axis.
  99442. */
  99443. minScaleX: number;
  99444. /**
  99445. * Maximum scale of emitting particles on X axis.
  99446. */
  99447. maxScaleX: number;
  99448. /**
  99449. * Minimum scale of emitting particles on Y axis.
  99450. */
  99451. minScaleY: number;
  99452. /**
  99453. * Maximum scale of emitting particles on Y axis.
  99454. */
  99455. maxScaleY: number;
  99456. /**
  99457. * Gets or sets the minimal initial rotation in radians.
  99458. */
  99459. minInitialRotation: number;
  99460. /**
  99461. * Gets or sets the maximal initial rotation in radians.
  99462. */
  99463. maxInitialRotation: number;
  99464. /**
  99465. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  99466. */
  99467. minAngularSpeed: number;
  99468. /**
  99469. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  99470. */
  99471. maxAngularSpeed: number;
  99472. /**
  99473. * The texture used to render each particle. (this can be a spritesheet)
  99474. */
  99475. particleTexture: Nullable<BaseTexture>;
  99476. /**
  99477. * The layer mask we are rendering the particles through.
  99478. */
  99479. layerMask: number;
  99480. /**
  99481. * This can help using your own shader to render the particle system.
  99482. * The according effect will be created
  99483. */
  99484. customShader: any;
  99485. /**
  99486. * By default particle system starts as soon as they are created. This prevents the
  99487. * automatic start to happen and let you decide when to start emitting particles.
  99488. */
  99489. preventAutoStart: boolean;
  99490. private _noiseTexture;
  99491. /**
  99492. * Gets or sets a texture used to add random noise to particle positions
  99493. */
  99494. get noiseTexture(): Nullable<ProceduralTexture>;
  99495. set noiseTexture(value: Nullable<ProceduralTexture>);
  99496. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  99497. noiseStrength: Vector3;
  99498. /**
  99499. * Callback triggered when the particle animation is ending.
  99500. */
  99501. onAnimationEnd: Nullable<() => void>;
  99502. /**
  99503. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  99504. */
  99505. blendMode: number;
  99506. /**
  99507. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  99508. * to override the particles.
  99509. */
  99510. forceDepthWrite: boolean;
  99511. /** 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 */
  99512. preWarmCycles: number;
  99513. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  99514. preWarmStepOffset: number;
  99515. /**
  99516. * 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)
  99517. */
  99518. spriteCellChangeSpeed: number;
  99519. /**
  99520. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  99521. */
  99522. startSpriteCellID: number;
  99523. /**
  99524. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  99525. */
  99526. endSpriteCellID: number;
  99527. /**
  99528. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  99529. */
  99530. spriteCellWidth: number;
  99531. /**
  99532. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  99533. */
  99534. spriteCellHeight: number;
  99535. /**
  99536. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  99537. */
  99538. spriteRandomStartCell: boolean;
  99539. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  99540. translationPivot: Vector2;
  99541. /** @hidden */
  99542. protected _isAnimationSheetEnabled: boolean;
  99543. /**
  99544. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  99545. */
  99546. beginAnimationOnStart: boolean;
  99547. /**
  99548. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  99549. */
  99550. beginAnimationFrom: number;
  99551. /**
  99552. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  99553. */
  99554. beginAnimationTo: number;
  99555. /**
  99556. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  99557. */
  99558. beginAnimationLoop: boolean;
  99559. /**
  99560. * Gets or sets a world offset applied to all particles
  99561. */
  99562. worldOffset: Vector3;
  99563. /**
  99564. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  99565. */
  99566. get isAnimationSheetEnabled(): boolean;
  99567. set isAnimationSheetEnabled(value: boolean);
  99568. /**
  99569. * Get hosting scene
  99570. * @returns the scene
  99571. */
  99572. getScene(): Nullable<Scene>;
  99573. /**
  99574. * You can use gravity if you want to give an orientation to your particles.
  99575. */
  99576. gravity: Vector3;
  99577. protected _colorGradients: Nullable<Array<ColorGradient>>;
  99578. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  99579. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  99580. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  99581. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  99582. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  99583. protected _dragGradients: Nullable<Array<FactorGradient>>;
  99584. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  99585. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  99586. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  99587. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  99588. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  99589. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  99590. /**
  99591. * Defines the delay in milliseconds before starting the system (0 by default)
  99592. */
  99593. startDelay: number;
  99594. /**
  99595. * Gets the current list of drag gradients.
  99596. * You must use addDragGradient and removeDragGradient to udpate this list
  99597. * @returns the list of drag gradients
  99598. */
  99599. getDragGradients(): Nullable<Array<FactorGradient>>;
  99600. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  99601. limitVelocityDamping: number;
  99602. /**
  99603. * Gets the current list of limit velocity gradients.
  99604. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  99605. * @returns the list of limit velocity gradients
  99606. */
  99607. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  99608. /**
  99609. * Gets the current list of color gradients.
  99610. * You must use addColorGradient and removeColorGradient to udpate this list
  99611. * @returns the list of color gradients
  99612. */
  99613. getColorGradients(): Nullable<Array<ColorGradient>>;
  99614. /**
  99615. * Gets the current list of size gradients.
  99616. * You must use addSizeGradient and removeSizeGradient to udpate this list
  99617. * @returns the list of size gradients
  99618. */
  99619. getSizeGradients(): Nullable<Array<FactorGradient>>;
  99620. /**
  99621. * Gets the current list of color remap gradients.
  99622. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  99623. * @returns the list of color remap gradients
  99624. */
  99625. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  99626. /**
  99627. * Gets the current list of alpha remap gradients.
  99628. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  99629. * @returns the list of alpha remap gradients
  99630. */
  99631. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  99632. /**
  99633. * Gets the current list of life time gradients.
  99634. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  99635. * @returns the list of life time gradients
  99636. */
  99637. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  99638. /**
  99639. * Gets the current list of angular speed gradients.
  99640. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  99641. * @returns the list of angular speed gradients
  99642. */
  99643. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  99644. /**
  99645. * Gets the current list of velocity gradients.
  99646. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  99647. * @returns the list of velocity gradients
  99648. */
  99649. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  99650. /**
  99651. * Gets the current list of start size gradients.
  99652. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  99653. * @returns the list of start size gradients
  99654. */
  99655. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  99656. /**
  99657. * Gets the current list of emit rate gradients.
  99658. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  99659. * @returns the list of emit rate gradients
  99660. */
  99661. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  99662. /**
  99663. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  99664. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99665. */
  99666. get direction1(): Vector3;
  99667. set direction1(value: Vector3);
  99668. /**
  99669. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  99670. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99671. */
  99672. get direction2(): Vector3;
  99673. set direction2(value: Vector3);
  99674. /**
  99675. * 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.
  99676. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99677. */
  99678. get minEmitBox(): Vector3;
  99679. set minEmitBox(value: Vector3);
  99680. /**
  99681. * 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.
  99682. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99683. */
  99684. get maxEmitBox(): Vector3;
  99685. set maxEmitBox(value: Vector3);
  99686. /**
  99687. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  99688. */
  99689. color1: Color4;
  99690. /**
  99691. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  99692. */
  99693. color2: Color4;
  99694. /**
  99695. * Color the particle will have at the end of its lifetime
  99696. */
  99697. colorDead: Color4;
  99698. /**
  99699. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  99700. */
  99701. textureMask: Color4;
  99702. /**
  99703. * The particle emitter type defines the emitter used by the particle system.
  99704. * It can be for example box, sphere, or cone...
  99705. */
  99706. particleEmitterType: IParticleEmitterType;
  99707. /** @hidden */
  99708. _isSubEmitter: boolean;
  99709. /**
  99710. * Gets or sets the billboard mode to use when isBillboardBased = true.
  99711. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  99712. */
  99713. billboardMode: number;
  99714. protected _isBillboardBased: boolean;
  99715. /**
  99716. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  99717. */
  99718. get isBillboardBased(): boolean;
  99719. set isBillboardBased(value: boolean);
  99720. /**
  99721. * The scene the particle system belongs to.
  99722. */
  99723. protected _scene: Nullable<Scene>;
  99724. /**
  99725. * The engine the particle system belongs to.
  99726. */
  99727. protected _engine: ThinEngine;
  99728. /**
  99729. * Local cache of defines for image processing.
  99730. */
  99731. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  99732. /**
  99733. * Default configuration related to image processing available in the standard Material.
  99734. */
  99735. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99736. /**
  99737. * Gets the image processing configuration used either in this material.
  99738. */
  99739. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  99740. /**
  99741. * Sets the Default image processing configuration used either in the this material.
  99742. *
  99743. * If sets to null, the scene one is in use.
  99744. */
  99745. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  99746. /**
  99747. * Attaches a new image processing configuration to the Standard Material.
  99748. * @param configuration
  99749. */
  99750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99751. /** @hidden */
  99752. protected _reset(): void;
  99753. /** @hidden */
  99754. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  99755. /**
  99756. * Instantiates a particle system.
  99757. * 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.
  99758. * @param name The name of the particle system
  99759. */
  99760. constructor(name: string);
  99761. /**
  99762. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  99763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  99764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  99765. * @returns the emitter
  99766. */
  99767. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  99768. /**
  99769. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  99770. * @param radius The radius of the hemisphere to emit from
  99771. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  99772. * @returns the emitter
  99773. */
  99774. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  99775. /**
  99776. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  99777. * @param radius The radius of the sphere to emit from
  99778. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  99779. * @returns the emitter
  99780. */
  99781. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  99782. /**
  99783. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  99784. * @param radius The radius of the sphere to emit from
  99785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  99786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  99787. * @returns the emitter
  99788. */
  99789. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  99790. /**
  99791. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  99792. * @param radius The radius of the emission cylinder
  99793. * @param height The height of the emission cylinder
  99794. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  99795. * @param directionRandomizer How much to randomize the particle direction [0-1]
  99796. * @returns the emitter
  99797. */
  99798. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  99799. /**
  99800. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  99801. * @param radius The radius of the cylinder to emit from
  99802. * @param height The height of the emission cylinder
  99803. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  99804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  99805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  99806. * @returns the emitter
  99807. */
  99808. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  99809. /**
  99810. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  99811. * @param radius The radius of the cone to emit from
  99812. * @param angle The base angle of the cone
  99813. * @returns the emitter
  99814. */
  99815. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  99816. /**
  99817. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  99818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  99819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  99820. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  99821. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  99822. * @returns the emitter
  99823. */
  99824. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  99825. }
  99826. }
  99827. declare module BABYLON {
  99828. /**
  99829. * Type of sub emitter
  99830. */
  99831. export enum SubEmitterType {
  99832. /**
  99833. * Attached to the particle over it's lifetime
  99834. */
  99835. ATTACHED = 0,
  99836. /**
  99837. * Created when the particle dies
  99838. */
  99839. END = 1
  99840. }
  99841. /**
  99842. * Sub emitter class used to emit particles from an existing particle
  99843. */
  99844. export class SubEmitter {
  99845. /**
  99846. * the particle system to be used by the sub emitter
  99847. */
  99848. particleSystem: ParticleSystem;
  99849. /**
  99850. * Type of the submitter (Default: END)
  99851. */
  99852. type: SubEmitterType;
  99853. /**
  99854. * 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)
  99855. * Note: This only is supported when using an emitter of type Mesh
  99856. */
  99857. inheritDirection: boolean;
  99858. /**
  99859. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  99860. */
  99861. inheritedVelocityAmount: number;
  99862. /**
  99863. * Creates a sub emitter
  99864. * @param particleSystem the particle system to be used by the sub emitter
  99865. */
  99866. constructor(
  99867. /**
  99868. * the particle system to be used by the sub emitter
  99869. */
  99870. particleSystem: ParticleSystem);
  99871. /**
  99872. * Clones the sub emitter
  99873. * @returns the cloned sub emitter
  99874. */
  99875. clone(): SubEmitter;
  99876. /**
  99877. * Serialize current object to a JSON object
  99878. * @returns the serialized object
  99879. */
  99880. serialize(): any;
  99881. /** @hidden */
  99882. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  99883. /**
  99884. * Creates a new SubEmitter from a serialized JSON version
  99885. * @param serializationObject defines the JSON object to read from
  99886. * @param sceneOrEngine defines the hosting scene or the hosting engine
  99887. * @param rootUrl defines the rootUrl for data loading
  99888. * @returns a new SubEmitter
  99889. */
  99890. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  99891. /** Release associated resources */
  99892. dispose(): void;
  99893. }
  99894. }
  99895. declare module BABYLON {
  99896. /** @hidden */
  99897. export var clipPlaneFragmentDeclaration: {
  99898. name: string;
  99899. shader: string;
  99900. };
  99901. }
  99902. declare module BABYLON {
  99903. /** @hidden */
  99904. export var imageProcessingDeclaration: {
  99905. name: string;
  99906. shader: string;
  99907. };
  99908. }
  99909. declare module BABYLON {
  99910. /** @hidden */
  99911. export var imageProcessingFunctions: {
  99912. name: string;
  99913. shader: string;
  99914. };
  99915. }
  99916. declare module BABYLON {
  99917. /** @hidden */
  99918. export var clipPlaneFragment: {
  99919. name: string;
  99920. shader: string;
  99921. };
  99922. }
  99923. declare module BABYLON {
  99924. /** @hidden */
  99925. export var particlesPixelShader: {
  99926. name: string;
  99927. shader: string;
  99928. };
  99929. }
  99930. declare module BABYLON {
  99931. /** @hidden */
  99932. export var clipPlaneVertexDeclaration: {
  99933. name: string;
  99934. shader: string;
  99935. };
  99936. }
  99937. declare module BABYLON {
  99938. /** @hidden */
  99939. export var clipPlaneVertex: {
  99940. name: string;
  99941. shader: string;
  99942. };
  99943. }
  99944. declare module BABYLON {
  99945. /** @hidden */
  99946. export var particlesVertexShader: {
  99947. name: string;
  99948. shader: string;
  99949. };
  99950. }
  99951. declare module BABYLON {
  99952. /**
  99953. * Interface used to define entities containing multiple clip planes
  99954. */
  99955. export interface IClipPlanesHolder {
  99956. /**
  99957. * Gets or sets the active clipplane 1
  99958. */
  99959. clipPlane: Nullable<Plane>;
  99960. /**
  99961. * Gets or sets the active clipplane 2
  99962. */
  99963. clipPlane2: Nullable<Plane>;
  99964. /**
  99965. * Gets or sets the active clipplane 3
  99966. */
  99967. clipPlane3: Nullable<Plane>;
  99968. /**
  99969. * Gets or sets the active clipplane 4
  99970. */
  99971. clipPlane4: Nullable<Plane>;
  99972. /**
  99973. * Gets or sets the active clipplane 5
  99974. */
  99975. clipPlane5: Nullable<Plane>;
  99976. /**
  99977. * Gets or sets the active clipplane 6
  99978. */
  99979. clipPlane6: Nullable<Plane>;
  99980. }
  99981. }
  99982. declare module BABYLON {
  99983. /**
  99984. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  99985. *
  99986. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  99987. *
  99988. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99989. */
  99990. export class ThinMaterialHelper {
  99991. /**
  99992. * Binds the clip plane information from the holder to the effect.
  99993. * @param effect The effect we are binding the data to
  99994. * @param holder The entity containing the clip plane information
  99995. */
  99996. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  99997. }
  99998. }
  99999. declare module BABYLON {
  100000. interface ThinEngine {
  100001. /**
  100002. * Sets alpha constants used by some alpha blending modes
  100003. * @param r defines the red component
  100004. * @param g defines the green component
  100005. * @param b defines the blue component
  100006. * @param a defines the alpha component
  100007. */
  100008. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100009. /**
  100010. * Sets the current alpha mode
  100011. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100012. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100013. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100014. */
  100015. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100016. /**
  100017. * Gets the current alpha mode
  100018. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100019. * @returns the current alpha mode
  100020. */
  100021. getAlphaMode(): number;
  100022. /**
  100023. * Sets the current alpha equation
  100024. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100025. */
  100026. setAlphaEquation(equation: number): void;
  100027. /**
  100028. * Gets the current alpha equation.
  100029. * @returns the current alpha equation
  100030. */
  100031. getAlphaEquation(): number;
  100032. }
  100033. }
  100034. declare module BABYLON {
  100035. /**
  100036. * This represents a particle system in Babylon.
  100037. * 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.
  100038. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  100039. * @example https://doc.babylonjs.com/babylon101/particles
  100040. */
  100041. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  100042. /**
  100043. * Billboard mode will only apply to Y axis
  100044. */
  100045. static readonly BILLBOARDMODE_Y: number;
  100046. /**
  100047. * Billboard mode will apply to all axes
  100048. */
  100049. static readonly BILLBOARDMODE_ALL: number;
  100050. /**
  100051. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  100052. */
  100053. static readonly BILLBOARDMODE_STRETCHED: number;
  100054. /**
  100055. * This function can be defined to provide custom update for active particles.
  100056. * This function will be called instead of regular update (age, position, color, etc.).
  100057. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  100058. */
  100059. updateFunction: (particles: Particle[]) => void;
  100060. private _emitterWorldMatrix;
  100061. /**
  100062. * This function can be defined to specify initial direction for every new particle.
  100063. * It by default use the emitterType defined function
  100064. */
  100065. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100066. /**
  100067. * This function can be defined to specify initial position for every new particle.
  100068. * It by default use the emitterType defined function
  100069. */
  100070. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100071. /**
  100072. * @hidden
  100073. */
  100074. _inheritedVelocityOffset: Vector3;
  100075. /**
  100076. * An event triggered when the system is disposed
  100077. */
  100078. onDisposeObservable: Observable<IParticleSystem>;
  100079. /**
  100080. * An event triggered when the system is stopped
  100081. */
  100082. onStoppedObservable: Observable<IParticleSystem>;
  100083. private _onDisposeObserver;
  100084. /**
  100085. * Sets a callback that will be triggered when the system is disposed
  100086. */
  100087. set onDispose(callback: () => void);
  100088. private _particles;
  100089. private _epsilon;
  100090. private _capacity;
  100091. private _stockParticles;
  100092. private _newPartsExcess;
  100093. private _vertexData;
  100094. private _vertexBuffer;
  100095. private _vertexBuffers;
  100096. private _spriteBuffer;
  100097. private _indexBuffer;
  100098. private _effect;
  100099. private _customEffect;
  100100. private _cachedDefines;
  100101. private _scaledColorStep;
  100102. private _colorDiff;
  100103. private _scaledDirection;
  100104. private _scaledGravity;
  100105. private _currentRenderId;
  100106. private _alive;
  100107. private _useInstancing;
  100108. private _vertexArrayObject;
  100109. private _started;
  100110. private _stopped;
  100111. private _actualFrame;
  100112. private _scaledUpdateSpeed;
  100113. private _vertexBufferSize;
  100114. /** @hidden */
  100115. _currentEmitRateGradient: Nullable<FactorGradient>;
  100116. /** @hidden */
  100117. _currentEmitRate1: number;
  100118. /** @hidden */
  100119. _currentEmitRate2: number;
  100120. /** @hidden */
  100121. _currentStartSizeGradient: Nullable<FactorGradient>;
  100122. /** @hidden */
  100123. _currentStartSize1: number;
  100124. /** @hidden */
  100125. _currentStartSize2: number;
  100126. private readonly _rawTextureWidth;
  100127. private _rampGradientsTexture;
  100128. private _useRampGradients;
  100129. /** Gets or sets a matrix to use to compute projection */
  100130. defaultProjectionMatrix: Matrix;
  100131. /** Gets or sets a matrix to use to compute view */
  100132. defaultViewMatrix: Matrix;
  100133. /** Gets or sets a boolean indicating that ramp gradients must be used
  100134. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  100135. */
  100136. get useRampGradients(): boolean;
  100137. set useRampGradients(value: boolean);
  100138. /**
  100139. * 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.
  100140. * 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: [])
  100141. */
  100142. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  100143. private _subEmitters;
  100144. /**
  100145. * @hidden
  100146. * If the particle systems emitter should be disposed when the particle system is disposed
  100147. */
  100148. _disposeEmitterOnDispose: boolean;
  100149. /**
  100150. * The current active Sub-systems, this property is used by the root particle system only.
  100151. */
  100152. activeSubSystems: Array<ParticleSystem>;
  100153. /**
  100154. * Specifies if the particles are updated in emitter local space or world space
  100155. */
  100156. isLocal: boolean;
  100157. private _rootParticleSystem;
  100158. /**
  100159. * Gets the current list of active particles
  100160. */
  100161. get particles(): Particle[];
  100162. /**
  100163. * Gets the number of particles active at the same time.
  100164. * @returns The number of active particles.
  100165. */
  100166. getActiveCount(): number;
  100167. /**
  100168. * Returns the string "ParticleSystem"
  100169. * @returns a string containing the class name
  100170. */
  100171. getClassName(): string;
  100172. /**
  100173. * Gets a boolean indicating that the system is stopping
  100174. * @returns true if the system is currently stopping
  100175. */
  100176. isStopping(): boolean;
  100177. /**
  100178. * Gets the custom effect used to render the particles
  100179. * @param blendMode Blend mode for which the effect should be retrieved
  100180. * @returns The effect
  100181. */
  100182. getCustomEffect(blendMode?: number): Nullable<Effect>;
  100183. /**
  100184. * Sets the custom effect used to render the particles
  100185. * @param effect The effect to set
  100186. * @param blendMode Blend mode for which the effect should be set
  100187. */
  100188. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  100189. /** @hidden */
  100190. private _onBeforeDrawParticlesObservable;
  100191. /**
  100192. * Observable that will be called just before the particles are drawn
  100193. */
  100194. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  100195. /**
  100196. * Gets the name of the particle vertex shader
  100197. */
  100198. get vertexShaderName(): string;
  100199. /**
  100200. * Instantiates a particle system.
  100201. * 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.
  100202. * @param name The name of the particle system
  100203. * @param capacity The max number of particles alive at the same time
  100204. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  100205. * @param customEffect a custom effect used to change the way particles are rendered by default
  100206. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  100207. * @param epsilon Offset used to render the particles
  100208. */
  100209. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  100210. private _addFactorGradient;
  100211. private _removeFactorGradient;
  100212. /**
  100213. * Adds a new life time gradient
  100214. * @param gradient defines the gradient to use (between 0 and 1)
  100215. * @param factor defines the life time factor to affect to the specified gradient
  100216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100217. * @returns the current particle system
  100218. */
  100219. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100220. /**
  100221. * Remove a specific life time gradient
  100222. * @param gradient defines the gradient to remove
  100223. * @returns the current particle system
  100224. */
  100225. removeLifeTimeGradient(gradient: number): IParticleSystem;
  100226. /**
  100227. * Adds a new size gradient
  100228. * @param gradient defines the gradient to use (between 0 and 1)
  100229. * @param factor defines the size factor to affect to the specified gradient
  100230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100231. * @returns the current particle system
  100232. */
  100233. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100234. /**
  100235. * Remove a specific size gradient
  100236. * @param gradient defines the gradient to remove
  100237. * @returns the current particle system
  100238. */
  100239. removeSizeGradient(gradient: number): IParticleSystem;
  100240. /**
  100241. * Adds a new color remap gradient
  100242. * @param gradient defines the gradient to use (between 0 and 1)
  100243. * @param min defines the color remap minimal range
  100244. * @param max defines the color remap maximal range
  100245. * @returns the current particle system
  100246. */
  100247. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100248. /**
  100249. * Remove a specific color remap gradient
  100250. * @param gradient defines the gradient to remove
  100251. * @returns the current particle system
  100252. */
  100253. removeColorRemapGradient(gradient: number): IParticleSystem;
  100254. /**
  100255. * Adds a new alpha remap gradient
  100256. * @param gradient defines the gradient to use (between 0 and 1)
  100257. * @param min defines the alpha remap minimal range
  100258. * @param max defines the alpha remap maximal range
  100259. * @returns the current particle system
  100260. */
  100261. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100262. /**
  100263. * Remove a specific alpha remap gradient
  100264. * @param gradient defines the gradient to remove
  100265. * @returns the current particle system
  100266. */
  100267. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  100268. /**
  100269. * Adds a new angular speed gradient
  100270. * @param gradient defines the gradient to use (between 0 and 1)
  100271. * @param factor defines the angular speed to affect to the specified gradient
  100272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100273. * @returns the current particle system
  100274. */
  100275. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100276. /**
  100277. * Remove a specific angular speed gradient
  100278. * @param gradient defines the gradient to remove
  100279. * @returns the current particle system
  100280. */
  100281. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  100282. /**
  100283. * Adds a new velocity gradient
  100284. * @param gradient defines the gradient to use (between 0 and 1)
  100285. * @param factor defines the velocity to affect to the specified gradient
  100286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100287. * @returns the current particle system
  100288. */
  100289. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100290. /**
  100291. * Remove a specific velocity gradient
  100292. * @param gradient defines the gradient to remove
  100293. * @returns the current particle system
  100294. */
  100295. removeVelocityGradient(gradient: number): IParticleSystem;
  100296. /**
  100297. * Adds a new limit velocity gradient
  100298. * @param gradient defines the gradient to use (between 0 and 1)
  100299. * @param factor defines the limit velocity value to affect to the specified gradient
  100300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100301. * @returns the current particle system
  100302. */
  100303. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100304. /**
  100305. * Remove a specific limit velocity gradient
  100306. * @param gradient defines the gradient to remove
  100307. * @returns the current particle system
  100308. */
  100309. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  100310. /**
  100311. * Adds a new drag gradient
  100312. * @param gradient defines the gradient to use (between 0 and 1)
  100313. * @param factor defines the drag value to affect to the specified gradient
  100314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100315. * @returns the current particle system
  100316. */
  100317. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100318. /**
  100319. * Remove a specific drag gradient
  100320. * @param gradient defines the gradient to remove
  100321. * @returns the current particle system
  100322. */
  100323. removeDragGradient(gradient: number): IParticleSystem;
  100324. /**
  100325. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  100326. * @param gradient defines the gradient to use (between 0 and 1)
  100327. * @param factor defines the emit rate value to affect to the specified gradient
  100328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100329. * @returns the current particle system
  100330. */
  100331. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100332. /**
  100333. * Remove a specific emit rate gradient
  100334. * @param gradient defines the gradient to remove
  100335. * @returns the current particle system
  100336. */
  100337. removeEmitRateGradient(gradient: number): IParticleSystem;
  100338. /**
  100339. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  100340. * @param gradient defines the gradient to use (between 0 and 1)
  100341. * @param factor defines the start size value to affect to the specified gradient
  100342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100343. * @returns the current particle system
  100344. */
  100345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100346. /**
  100347. * Remove a specific start size gradient
  100348. * @param gradient defines the gradient to remove
  100349. * @returns the current particle system
  100350. */
  100351. removeStartSizeGradient(gradient: number): IParticleSystem;
  100352. private _createRampGradientTexture;
  100353. /**
  100354. * Gets the current list of ramp gradients.
  100355. * You must use addRampGradient and removeRampGradient to udpate this list
  100356. * @returns the list of ramp gradients
  100357. */
  100358. getRampGradients(): Nullable<Array<Color3Gradient>>;
  100359. /** Force the system to rebuild all gradients that need to be resync */
  100360. forceRefreshGradients(): void;
  100361. private _syncRampGradientTexture;
  100362. /**
  100363. * Adds a new ramp gradient used to remap particle colors
  100364. * @param gradient defines the gradient to use (between 0 and 1)
  100365. * @param color defines the color to affect to the specified gradient
  100366. * @returns the current particle system
  100367. */
  100368. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  100369. /**
  100370. * Remove a specific ramp gradient
  100371. * @param gradient defines the gradient to remove
  100372. * @returns the current particle system
  100373. */
  100374. removeRampGradient(gradient: number): ParticleSystem;
  100375. /**
  100376. * Adds a new color gradient
  100377. * @param gradient defines the gradient to use (between 0 and 1)
  100378. * @param color1 defines the color to affect to the specified gradient
  100379. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  100380. * @returns this particle system
  100381. */
  100382. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  100383. /**
  100384. * Remove a specific color gradient
  100385. * @param gradient defines the gradient to remove
  100386. * @returns this particle system
  100387. */
  100388. removeColorGradient(gradient: number): IParticleSystem;
  100389. private _fetchR;
  100390. protected _reset(): void;
  100391. private _resetEffect;
  100392. private _createVertexBuffers;
  100393. private _createIndexBuffer;
  100394. /**
  100395. * Gets the maximum number of particles active at the same time.
  100396. * @returns The max number of active particles.
  100397. */
  100398. getCapacity(): number;
  100399. /**
  100400. * Gets whether there are still active particles in the system.
  100401. * @returns True if it is alive, otherwise false.
  100402. */
  100403. isAlive(): boolean;
  100404. /**
  100405. * Gets if the system has been started. (Note: this will still be true after stop is called)
  100406. * @returns True if it has been started, otherwise false.
  100407. */
  100408. isStarted(): boolean;
  100409. private _prepareSubEmitterInternalArray;
  100410. /**
  100411. * Starts the particle system and begins to emit
  100412. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  100413. */
  100414. start(delay?: number): void;
  100415. /**
  100416. * Stops the particle system.
  100417. * @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.
  100418. */
  100419. stop(stopSubEmitters?: boolean): void;
  100420. /**
  100421. * Remove all active particles
  100422. */
  100423. reset(): void;
  100424. /**
  100425. * @hidden (for internal use only)
  100426. */
  100427. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  100428. /**
  100429. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  100430. * Its lifetime will start back at 0.
  100431. */
  100432. recycleParticle: (particle: Particle) => void;
  100433. private _stopSubEmitters;
  100434. private _createParticle;
  100435. private _removeFromRoot;
  100436. private _emitFromParticle;
  100437. private _update;
  100438. /** @hidden */
  100439. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  100440. /** @hidden */
  100441. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  100442. /**
  100443. * Fill the defines array according to the current settings of the particle system
  100444. * @param defines Array to be updated
  100445. * @param blendMode blend mode to take into account when updating the array
  100446. */
  100447. fillDefines(defines: Array<string>, blendMode: number): void;
  100448. /**
  100449. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  100450. * @param uniforms Uniforms array to fill
  100451. * @param attributes Attributes array to fill
  100452. * @param samplers Samplers array to fill
  100453. */
  100454. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  100455. /** @hidden */
  100456. private _getEffect;
  100457. /**
  100458. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  100459. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  100460. */
  100461. animate(preWarmOnly?: boolean): void;
  100462. private _appendParticleVertices;
  100463. /**
  100464. * Rebuilds the particle system.
  100465. */
  100466. rebuild(): void;
  100467. /**
  100468. * Is this system ready to be used/rendered
  100469. * @return true if the system is ready
  100470. */
  100471. isReady(): boolean;
  100472. private _render;
  100473. /**
  100474. * Renders the particle system in its current state.
  100475. * @returns the current number of particles
  100476. */
  100477. render(): number;
  100478. /**
  100479. * Disposes the particle system and free the associated resources
  100480. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  100481. */
  100482. dispose(disposeTexture?: boolean): void;
  100483. /**
  100484. * Clones the particle system.
  100485. * @param name The name of the cloned object
  100486. * @param newEmitter The new emitter to use
  100487. * @returns the cloned particle system
  100488. */
  100489. clone(name: string, newEmitter: any): ParticleSystem;
  100490. /**
  100491. * Serializes the particle system to a JSON object
  100492. * @param serializeTexture defines if the texture must be serialized as well
  100493. * @returns the JSON object
  100494. */
  100495. serialize(serializeTexture?: boolean): any;
  100496. /** @hidden */
  100497. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  100498. /** @hidden */
  100499. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  100500. /**
  100501. * Parses a JSON object to create a particle system.
  100502. * @param parsedParticleSystem The JSON object to parse
  100503. * @param sceneOrEngine The scene or the engine to create the particle system in
  100504. * @param rootUrl The root url to use to load external dependencies like texture
  100505. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  100506. * @returns the Parsed particle system
  100507. */
  100508. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  100509. }
  100510. }
  100511. declare module BABYLON {
  100512. /**
  100513. * A particle represents one of the element emitted by a particle system.
  100514. * This is mainly define by its coordinates, direction, velocity and age.
  100515. */
  100516. export class Particle {
  100517. /**
  100518. * The particle system the particle belongs to.
  100519. */
  100520. particleSystem: ParticleSystem;
  100521. private static _Count;
  100522. /**
  100523. * Unique ID of the particle
  100524. */
  100525. id: number;
  100526. /**
  100527. * The world position of the particle in the scene.
  100528. */
  100529. position: Vector3;
  100530. /**
  100531. * The world direction of the particle in the scene.
  100532. */
  100533. direction: Vector3;
  100534. /**
  100535. * The color of the particle.
  100536. */
  100537. color: Color4;
  100538. /**
  100539. * The color change of the particle per step.
  100540. */
  100541. colorStep: Color4;
  100542. /**
  100543. * Defines how long will the life of the particle be.
  100544. */
  100545. lifeTime: number;
  100546. /**
  100547. * The current age of the particle.
  100548. */
  100549. age: number;
  100550. /**
  100551. * The current size of the particle.
  100552. */
  100553. size: number;
  100554. /**
  100555. * The current scale of the particle.
  100556. */
  100557. scale: Vector2;
  100558. /**
  100559. * The current angle of the particle.
  100560. */
  100561. angle: number;
  100562. /**
  100563. * Defines how fast is the angle changing.
  100564. */
  100565. angularSpeed: number;
  100566. /**
  100567. * Defines the cell index used by the particle to be rendered from a sprite.
  100568. */
  100569. cellIndex: number;
  100570. /**
  100571. * The information required to support color remapping
  100572. */
  100573. remapData: Vector4;
  100574. /** @hidden */
  100575. _randomCellOffset?: number;
  100576. /** @hidden */
  100577. _initialDirection: Nullable<Vector3>;
  100578. /** @hidden */
  100579. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  100580. /** @hidden */
  100581. _initialStartSpriteCellID: number;
  100582. /** @hidden */
  100583. _initialEndSpriteCellID: number;
  100584. /** @hidden */
  100585. _currentColorGradient: Nullable<ColorGradient>;
  100586. /** @hidden */
  100587. _currentColor1: Color4;
  100588. /** @hidden */
  100589. _currentColor2: Color4;
  100590. /** @hidden */
  100591. _currentSizeGradient: Nullable<FactorGradient>;
  100592. /** @hidden */
  100593. _currentSize1: number;
  100594. /** @hidden */
  100595. _currentSize2: number;
  100596. /** @hidden */
  100597. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  100598. /** @hidden */
  100599. _currentAngularSpeed1: number;
  100600. /** @hidden */
  100601. _currentAngularSpeed2: number;
  100602. /** @hidden */
  100603. _currentVelocityGradient: Nullable<FactorGradient>;
  100604. /** @hidden */
  100605. _currentVelocity1: number;
  100606. /** @hidden */
  100607. _currentVelocity2: number;
  100608. /** @hidden */
  100609. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  100610. /** @hidden */
  100611. _currentLimitVelocity1: number;
  100612. /** @hidden */
  100613. _currentLimitVelocity2: number;
  100614. /** @hidden */
  100615. _currentDragGradient: Nullable<FactorGradient>;
  100616. /** @hidden */
  100617. _currentDrag1: number;
  100618. /** @hidden */
  100619. _currentDrag2: number;
  100620. /** @hidden */
  100621. _randomNoiseCoordinates1: Vector3;
  100622. /** @hidden */
  100623. _randomNoiseCoordinates2: Vector3;
  100624. /** @hidden */
  100625. _localPosition?: Vector3;
  100626. /**
  100627. * Creates a new instance Particle
  100628. * @param particleSystem the particle system the particle belongs to
  100629. */
  100630. constructor(
  100631. /**
  100632. * The particle system the particle belongs to.
  100633. */
  100634. particleSystem: ParticleSystem);
  100635. private updateCellInfoFromSystem;
  100636. /**
  100637. * Defines how the sprite cell index is updated for the particle
  100638. */
  100639. updateCellIndex(): void;
  100640. /** @hidden */
  100641. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  100642. /** @hidden */
  100643. _inheritParticleInfoToSubEmitters(): void;
  100644. /** @hidden */
  100645. _reset(): void;
  100646. /**
  100647. * Copy the properties of particle to another one.
  100648. * @param other the particle to copy the information to.
  100649. */
  100650. copyTo(other: Particle): void;
  100651. }
  100652. }
  100653. declare module BABYLON {
  100654. /**
  100655. * Particle emitter represents a volume emitting particles.
  100656. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  100657. */
  100658. export interface IParticleEmitterType {
  100659. /**
  100660. * Called by the particle System when the direction is computed for the created particle.
  100661. * @param worldMatrix is the world matrix of the particle system
  100662. * @param directionToUpdate is the direction vector to update with the result
  100663. * @param particle is the particle we are computed the direction for
  100664. * @param isLocal defines if the direction should be set in local space
  100665. */
  100666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100667. /**
  100668. * Called by the particle System when the position is computed for the created particle.
  100669. * @param worldMatrix is the world matrix of the particle system
  100670. * @param positionToUpdate is the position vector to update with the result
  100671. * @param particle is the particle we are computed the position for
  100672. * @param isLocal defines if the position should be set in local space
  100673. */
  100674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100675. /**
  100676. * Clones the current emitter and returns a copy of it
  100677. * @returns the new emitter
  100678. */
  100679. clone(): IParticleEmitterType;
  100680. /**
  100681. * Called by the GPUParticleSystem to setup the update shader
  100682. * @param effect defines the update shader
  100683. */
  100684. applyToShader(effect: Effect): void;
  100685. /**
  100686. * Returns a string to use to update the GPU particles update shader
  100687. * @returns the effect defines string
  100688. */
  100689. getEffectDefines(): string;
  100690. /**
  100691. * Returns a string representing the class name
  100692. * @returns a string containing the class name
  100693. */
  100694. getClassName(): string;
  100695. /**
  100696. * Serializes the particle system to a JSON object.
  100697. * @returns the JSON object
  100698. */
  100699. serialize(): any;
  100700. /**
  100701. * Parse properties from a JSON object
  100702. * @param serializationObject defines the JSON object
  100703. * @param scene defines the hosting scene
  100704. */
  100705. parse(serializationObject: any, scene: Nullable<Scene>): void;
  100706. }
  100707. }
  100708. declare module BABYLON {
  100709. /**
  100710. * Particle emitter emitting particles from the inside of a box.
  100711. * It emits the particles randomly between 2 given directions.
  100712. */
  100713. export class BoxParticleEmitter implements IParticleEmitterType {
  100714. /**
  100715. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100716. */
  100717. direction1: Vector3;
  100718. /**
  100719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100720. */
  100721. direction2: Vector3;
  100722. /**
  100723. * 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.
  100724. */
  100725. minEmitBox: Vector3;
  100726. /**
  100727. * 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.
  100728. */
  100729. maxEmitBox: Vector3;
  100730. /**
  100731. * Creates a new instance BoxParticleEmitter
  100732. */
  100733. constructor();
  100734. /**
  100735. * Called by the particle System when the direction is computed for the created particle.
  100736. * @param worldMatrix is the world matrix of the particle system
  100737. * @param directionToUpdate is the direction vector to update with the result
  100738. * @param particle is the particle we are computed the direction for
  100739. * @param isLocal defines if the direction should be set in local space
  100740. */
  100741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100742. /**
  100743. * Called by the particle System when the position is computed for the created particle.
  100744. * @param worldMatrix is the world matrix of the particle system
  100745. * @param positionToUpdate is the position vector to update with the result
  100746. * @param particle is the particle we are computed the position for
  100747. * @param isLocal defines if the position should be set in local space
  100748. */
  100749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100750. /**
  100751. * Clones the current emitter and returns a copy of it
  100752. * @returns the new emitter
  100753. */
  100754. clone(): BoxParticleEmitter;
  100755. /**
  100756. * Called by the GPUParticleSystem to setup the update shader
  100757. * @param effect defines the update shader
  100758. */
  100759. applyToShader(effect: Effect): void;
  100760. /**
  100761. * Returns a string to use to update the GPU particles update shader
  100762. * @returns a string containng the defines string
  100763. */
  100764. getEffectDefines(): string;
  100765. /**
  100766. * Returns the string "BoxParticleEmitter"
  100767. * @returns a string containing the class name
  100768. */
  100769. getClassName(): string;
  100770. /**
  100771. * Serializes the particle system to a JSON object.
  100772. * @returns the JSON object
  100773. */
  100774. serialize(): any;
  100775. /**
  100776. * Parse properties from a JSON object
  100777. * @param serializationObject defines the JSON object
  100778. */
  100779. parse(serializationObject: any): void;
  100780. }
  100781. }
  100782. declare module BABYLON {
  100783. /**
  100784. * Particle emitter emitting particles from the inside of a cone.
  100785. * It emits the particles alongside the cone volume from the base to the particle.
  100786. * The emission direction might be randomized.
  100787. */
  100788. export class ConeParticleEmitter implements IParticleEmitterType {
  100789. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100790. directionRandomizer: number;
  100791. private _radius;
  100792. private _angle;
  100793. private _height;
  100794. /**
  100795. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  100796. */
  100797. radiusRange: number;
  100798. /**
  100799. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  100800. */
  100801. heightRange: number;
  100802. /**
  100803. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  100804. */
  100805. emitFromSpawnPointOnly: boolean;
  100806. /**
  100807. * Gets or sets the radius of the emission cone
  100808. */
  100809. get radius(): number;
  100810. set radius(value: number);
  100811. /**
  100812. * Gets or sets the angle of the emission cone
  100813. */
  100814. get angle(): number;
  100815. set angle(value: number);
  100816. private _buildHeight;
  100817. /**
  100818. * Creates a new instance ConeParticleEmitter
  100819. * @param radius the radius of the emission cone (1 by default)
  100820. * @param angle the cone base angle (PI by default)
  100821. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  100822. */
  100823. constructor(radius?: number, angle?: number,
  100824. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100825. directionRandomizer?: number);
  100826. /**
  100827. * Called by the particle System when the direction is computed for the created particle.
  100828. * @param worldMatrix is the world matrix of the particle system
  100829. * @param directionToUpdate is the direction vector to update with the result
  100830. * @param particle is the particle we are computed the direction for
  100831. * @param isLocal defines if the direction should be set in local space
  100832. */
  100833. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100834. /**
  100835. * Called by the particle System when the position is computed for the created particle.
  100836. * @param worldMatrix is the world matrix of the particle system
  100837. * @param positionToUpdate is the position vector to update with the result
  100838. * @param particle is the particle we are computed the position for
  100839. * @param isLocal defines if the position should be set in local space
  100840. */
  100841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100842. /**
  100843. * Clones the current emitter and returns a copy of it
  100844. * @returns the new emitter
  100845. */
  100846. clone(): ConeParticleEmitter;
  100847. /**
  100848. * Called by the GPUParticleSystem to setup the update shader
  100849. * @param effect defines the update shader
  100850. */
  100851. applyToShader(effect: Effect): void;
  100852. /**
  100853. * Returns a string to use to update the GPU particles update shader
  100854. * @returns a string containng the defines string
  100855. */
  100856. getEffectDefines(): string;
  100857. /**
  100858. * Returns the string "ConeParticleEmitter"
  100859. * @returns a string containing the class name
  100860. */
  100861. getClassName(): string;
  100862. /**
  100863. * Serializes the particle system to a JSON object.
  100864. * @returns the JSON object
  100865. */
  100866. serialize(): any;
  100867. /**
  100868. * Parse properties from a JSON object
  100869. * @param serializationObject defines the JSON object
  100870. */
  100871. parse(serializationObject: any): void;
  100872. }
  100873. }
  100874. declare module BABYLON {
  100875. /**
  100876. * Particle emitter emitting particles from the inside of a cylinder.
  100877. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  100878. */
  100879. export class CylinderParticleEmitter implements IParticleEmitterType {
  100880. /**
  100881. * The radius of the emission cylinder.
  100882. */
  100883. radius: number;
  100884. /**
  100885. * The height of the emission cylinder.
  100886. */
  100887. height: number;
  100888. /**
  100889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  100890. */
  100891. radiusRange: number;
  100892. /**
  100893. * How much to randomize the particle direction [0-1].
  100894. */
  100895. directionRandomizer: number;
  100896. /**
  100897. * Creates a new instance CylinderParticleEmitter
  100898. * @param radius the radius of the emission cylinder (1 by default)
  100899. * @param height the height of the emission cylinder (1 by default)
  100900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100901. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  100902. */
  100903. constructor(
  100904. /**
  100905. * The radius of the emission cylinder.
  100906. */
  100907. radius?: number,
  100908. /**
  100909. * The height of the emission cylinder.
  100910. */
  100911. height?: number,
  100912. /**
  100913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  100914. */
  100915. radiusRange?: number,
  100916. /**
  100917. * How much to randomize the particle direction [0-1].
  100918. */
  100919. directionRandomizer?: number);
  100920. /**
  100921. * Called by the particle System when the direction is computed for the created particle.
  100922. * @param worldMatrix is the world matrix of the particle system
  100923. * @param directionToUpdate is the direction vector to update with the result
  100924. * @param particle is the particle we are computed the direction for
  100925. * @param isLocal defines if the direction should be set in local space
  100926. */
  100927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100928. /**
  100929. * Called by the particle System when the position is computed for the created particle.
  100930. * @param worldMatrix is the world matrix of the particle system
  100931. * @param positionToUpdate is the position vector to update with the result
  100932. * @param particle is the particle we are computed the position for
  100933. * @param isLocal defines if the position should be set in local space
  100934. */
  100935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100936. /**
  100937. * Clones the current emitter and returns a copy of it
  100938. * @returns the new emitter
  100939. */
  100940. clone(): CylinderParticleEmitter;
  100941. /**
  100942. * Called by the GPUParticleSystem to setup the update shader
  100943. * @param effect defines the update shader
  100944. */
  100945. applyToShader(effect: Effect): void;
  100946. /**
  100947. * Returns a string to use to update the GPU particles update shader
  100948. * @returns a string containng the defines string
  100949. */
  100950. getEffectDefines(): string;
  100951. /**
  100952. * Returns the string "CylinderParticleEmitter"
  100953. * @returns a string containing the class name
  100954. */
  100955. getClassName(): string;
  100956. /**
  100957. * Serializes the particle system to a JSON object.
  100958. * @returns the JSON object
  100959. */
  100960. serialize(): any;
  100961. /**
  100962. * Parse properties from a JSON object
  100963. * @param serializationObject defines the JSON object
  100964. */
  100965. parse(serializationObject: any): void;
  100966. }
  100967. /**
  100968. * Particle emitter emitting particles from the inside of a cylinder.
  100969. * It emits the particles randomly between two vectors.
  100970. */
  100971. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  100972. /**
  100973. * The min limit of the emission direction.
  100974. */
  100975. direction1: Vector3;
  100976. /**
  100977. * The max limit of the emission direction.
  100978. */
  100979. direction2: Vector3;
  100980. /**
  100981. * Creates a new instance CylinderDirectedParticleEmitter
  100982. * @param radius the radius of the emission cylinder (1 by default)
  100983. * @param height the height of the emission cylinder (1 by default)
  100984. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100985. * @param direction1 the min limit of the emission direction (up vector by default)
  100986. * @param direction2 the max limit of the emission direction (up vector by default)
  100987. */
  100988. constructor(radius?: number, height?: number, radiusRange?: number,
  100989. /**
  100990. * The min limit of the emission direction.
  100991. */
  100992. direction1?: Vector3,
  100993. /**
  100994. * The max limit of the emission direction.
  100995. */
  100996. direction2?: Vector3);
  100997. /**
  100998. * Called by the particle System when the direction is computed for the created particle.
  100999. * @param worldMatrix is the world matrix of the particle system
  101000. * @param directionToUpdate is the direction vector to update with the result
  101001. * @param particle is the particle we are computed the direction for
  101002. */
  101003. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101004. /**
  101005. * Clones the current emitter and returns a copy of it
  101006. * @returns the new emitter
  101007. */
  101008. clone(): CylinderDirectedParticleEmitter;
  101009. /**
  101010. * Called by the GPUParticleSystem to setup the update shader
  101011. * @param effect defines the update shader
  101012. */
  101013. applyToShader(effect: Effect): void;
  101014. /**
  101015. * Returns a string to use to update the GPU particles update shader
  101016. * @returns a string containng the defines string
  101017. */
  101018. getEffectDefines(): string;
  101019. /**
  101020. * Returns the string "CylinderDirectedParticleEmitter"
  101021. * @returns a string containing the class name
  101022. */
  101023. getClassName(): string;
  101024. /**
  101025. * Serializes the particle system to a JSON object.
  101026. * @returns the JSON object
  101027. */
  101028. serialize(): any;
  101029. /**
  101030. * Parse properties from a JSON object
  101031. * @param serializationObject defines the JSON object
  101032. */
  101033. parse(serializationObject: any): void;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * Particle emitter emitting particles from the inside of a hemisphere.
  101039. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101040. */
  101041. export class HemisphericParticleEmitter implements IParticleEmitterType {
  101042. /**
  101043. * The radius of the emission hemisphere.
  101044. */
  101045. radius: number;
  101046. /**
  101047. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101048. */
  101049. radiusRange: number;
  101050. /**
  101051. * How much to randomize the particle direction [0-1].
  101052. */
  101053. directionRandomizer: number;
  101054. /**
  101055. * Creates a new instance HemisphericParticleEmitter
  101056. * @param radius the radius of the emission hemisphere (1 by default)
  101057. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101058. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101059. */
  101060. constructor(
  101061. /**
  101062. * The radius of the emission hemisphere.
  101063. */
  101064. radius?: number,
  101065. /**
  101066. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101067. */
  101068. radiusRange?: number,
  101069. /**
  101070. * How much to randomize the particle direction [0-1].
  101071. */
  101072. directionRandomizer?: number);
  101073. /**
  101074. * Called by the particle System when the direction is computed for the created particle.
  101075. * @param worldMatrix is the world matrix of the particle system
  101076. * @param directionToUpdate is the direction vector to update with the result
  101077. * @param particle is the particle we are computed the direction for
  101078. * @param isLocal defines if the direction should be set in local space
  101079. */
  101080. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101081. /**
  101082. * Called by the particle System when the position is computed for the created particle.
  101083. * @param worldMatrix is the world matrix of the particle system
  101084. * @param positionToUpdate is the position vector to update with the result
  101085. * @param particle is the particle we are computed the position for
  101086. * @param isLocal defines if the position should be set in local space
  101087. */
  101088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101089. /**
  101090. * Clones the current emitter and returns a copy of it
  101091. * @returns the new emitter
  101092. */
  101093. clone(): HemisphericParticleEmitter;
  101094. /**
  101095. * Called by the GPUParticleSystem to setup the update shader
  101096. * @param effect defines the update shader
  101097. */
  101098. applyToShader(effect: Effect): void;
  101099. /**
  101100. * Returns a string to use to update the GPU particles update shader
  101101. * @returns a string containng the defines string
  101102. */
  101103. getEffectDefines(): string;
  101104. /**
  101105. * Returns the string "HemisphericParticleEmitter"
  101106. * @returns a string containing the class name
  101107. */
  101108. getClassName(): string;
  101109. /**
  101110. * Serializes the particle system to a JSON object.
  101111. * @returns the JSON object
  101112. */
  101113. serialize(): any;
  101114. /**
  101115. * Parse properties from a JSON object
  101116. * @param serializationObject defines the JSON object
  101117. */
  101118. parse(serializationObject: any): void;
  101119. }
  101120. }
  101121. declare module BABYLON {
  101122. /**
  101123. * Particle emitter emitting particles from a point.
  101124. * It emits the particles randomly between 2 given directions.
  101125. */
  101126. export class PointParticleEmitter implements IParticleEmitterType {
  101127. /**
  101128. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101129. */
  101130. direction1: Vector3;
  101131. /**
  101132. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101133. */
  101134. direction2: Vector3;
  101135. /**
  101136. * Creates a new instance PointParticleEmitter
  101137. */
  101138. constructor();
  101139. /**
  101140. * Called by the particle System when the direction is computed for the created particle.
  101141. * @param worldMatrix is the world matrix of the particle system
  101142. * @param directionToUpdate is the direction vector to update with the result
  101143. * @param particle is the particle we are computed the direction for
  101144. * @param isLocal defines if the direction should be set in local space
  101145. */
  101146. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101147. /**
  101148. * Called by the particle System when the position is computed for the created particle.
  101149. * @param worldMatrix is the world matrix of the particle system
  101150. * @param positionToUpdate is the position vector to update with the result
  101151. * @param particle is the particle we are computed the position for
  101152. * @param isLocal defines if the position should be set in local space
  101153. */
  101154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101155. /**
  101156. * Clones the current emitter and returns a copy of it
  101157. * @returns the new emitter
  101158. */
  101159. clone(): PointParticleEmitter;
  101160. /**
  101161. * Called by the GPUParticleSystem to setup the update shader
  101162. * @param effect defines the update shader
  101163. */
  101164. applyToShader(effect: Effect): void;
  101165. /**
  101166. * Returns a string to use to update the GPU particles update shader
  101167. * @returns a string containng the defines string
  101168. */
  101169. getEffectDefines(): string;
  101170. /**
  101171. * Returns the string "PointParticleEmitter"
  101172. * @returns a string containing the class name
  101173. */
  101174. getClassName(): string;
  101175. /**
  101176. * Serializes the particle system to a JSON object.
  101177. * @returns the JSON object
  101178. */
  101179. serialize(): any;
  101180. /**
  101181. * Parse properties from a JSON object
  101182. * @param serializationObject defines the JSON object
  101183. */
  101184. parse(serializationObject: any): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * Particle emitter emitting particles from the inside of a sphere.
  101190. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101191. */
  101192. export class SphereParticleEmitter implements IParticleEmitterType {
  101193. /**
  101194. * The radius of the emission sphere.
  101195. */
  101196. radius: number;
  101197. /**
  101198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101199. */
  101200. radiusRange: number;
  101201. /**
  101202. * How much to randomize the particle direction [0-1].
  101203. */
  101204. directionRandomizer: number;
  101205. /**
  101206. * Creates a new instance SphereParticleEmitter
  101207. * @param radius the radius of the emission sphere (1 by default)
  101208. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101209. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101210. */
  101211. constructor(
  101212. /**
  101213. * The radius of the emission sphere.
  101214. */
  101215. radius?: number,
  101216. /**
  101217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101218. */
  101219. radiusRange?: number,
  101220. /**
  101221. * How much to randomize the particle direction [0-1].
  101222. */
  101223. directionRandomizer?: number);
  101224. /**
  101225. * Called by the particle System when the direction is computed for the created particle.
  101226. * @param worldMatrix is the world matrix of the particle system
  101227. * @param directionToUpdate is the direction vector to update with the result
  101228. * @param particle is the particle we are computed the direction for
  101229. * @param isLocal defines if the direction should be set in local space
  101230. */
  101231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101232. /**
  101233. * Called by the particle System when the position is computed for the created particle.
  101234. * @param worldMatrix is the world matrix of the particle system
  101235. * @param positionToUpdate is the position vector to update with the result
  101236. * @param particle is the particle we are computed the position for
  101237. * @param isLocal defines if the position should be set in local space
  101238. */
  101239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101240. /**
  101241. * Clones the current emitter and returns a copy of it
  101242. * @returns the new emitter
  101243. */
  101244. clone(): SphereParticleEmitter;
  101245. /**
  101246. * Called by the GPUParticleSystem to setup the update shader
  101247. * @param effect defines the update shader
  101248. */
  101249. applyToShader(effect: Effect): void;
  101250. /**
  101251. * Returns a string to use to update the GPU particles update shader
  101252. * @returns a string containng the defines string
  101253. */
  101254. getEffectDefines(): string;
  101255. /**
  101256. * Returns the string "SphereParticleEmitter"
  101257. * @returns a string containing the class name
  101258. */
  101259. getClassName(): string;
  101260. /**
  101261. * Serializes the particle system to a JSON object.
  101262. * @returns the JSON object
  101263. */
  101264. serialize(): any;
  101265. /**
  101266. * Parse properties from a JSON object
  101267. * @param serializationObject defines the JSON object
  101268. */
  101269. parse(serializationObject: any): void;
  101270. }
  101271. /**
  101272. * Particle emitter emitting particles from the inside of a sphere.
  101273. * It emits the particles randomly between two vectors.
  101274. */
  101275. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  101276. /**
  101277. * The min limit of the emission direction.
  101278. */
  101279. direction1: Vector3;
  101280. /**
  101281. * The max limit of the emission direction.
  101282. */
  101283. direction2: Vector3;
  101284. /**
  101285. * Creates a new instance SphereDirectedParticleEmitter
  101286. * @param radius the radius of the emission sphere (1 by default)
  101287. * @param direction1 the min limit of the emission direction (up vector by default)
  101288. * @param direction2 the max limit of the emission direction (up vector by default)
  101289. */
  101290. constructor(radius?: number,
  101291. /**
  101292. * The min limit of the emission direction.
  101293. */
  101294. direction1?: Vector3,
  101295. /**
  101296. * The max limit of the emission direction.
  101297. */
  101298. direction2?: Vector3);
  101299. /**
  101300. * Called by the particle System when the direction is computed for the created particle.
  101301. * @param worldMatrix is the world matrix of the particle system
  101302. * @param directionToUpdate is the direction vector to update with the result
  101303. * @param particle is the particle we are computed the direction for
  101304. */
  101305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101306. /**
  101307. * Clones the current emitter and returns a copy of it
  101308. * @returns the new emitter
  101309. */
  101310. clone(): SphereDirectedParticleEmitter;
  101311. /**
  101312. * Called by the GPUParticleSystem to setup the update shader
  101313. * @param effect defines the update shader
  101314. */
  101315. applyToShader(effect: Effect): void;
  101316. /**
  101317. * Returns a string to use to update the GPU particles update shader
  101318. * @returns a string containng the defines string
  101319. */
  101320. getEffectDefines(): string;
  101321. /**
  101322. * Returns the string "SphereDirectedParticleEmitter"
  101323. * @returns a string containing the class name
  101324. */
  101325. getClassName(): string;
  101326. /**
  101327. * Serializes the particle system to a JSON object.
  101328. * @returns the JSON object
  101329. */
  101330. serialize(): any;
  101331. /**
  101332. * Parse properties from a JSON object
  101333. * @param serializationObject defines the JSON object
  101334. */
  101335. parse(serializationObject: any): void;
  101336. }
  101337. }
  101338. declare module BABYLON {
  101339. /**
  101340. * Particle emitter emitting particles from a custom list of positions.
  101341. */
  101342. export class CustomParticleEmitter implements IParticleEmitterType {
  101343. /**
  101344. * Gets or sets the position generator that will create the inital position of each particle.
  101345. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101346. */
  101347. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  101348. /**
  101349. * Gets or sets the destination generator that will create the final destination of each particle.
  101350. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101351. */
  101352. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  101353. /**
  101354. * Creates a new instance CustomParticleEmitter
  101355. */
  101356. constructor();
  101357. /**
  101358. * Called by the particle System when the direction is computed for the created particle.
  101359. * @param worldMatrix is the world matrix of the particle system
  101360. * @param directionToUpdate is the direction vector to update with the result
  101361. * @param particle is the particle we are computed the direction for
  101362. * @param isLocal defines if the direction should be set in local space
  101363. */
  101364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101365. /**
  101366. * Called by the particle System when the position is computed for the created particle.
  101367. * @param worldMatrix is the world matrix of the particle system
  101368. * @param positionToUpdate is the position vector to update with the result
  101369. * @param particle is the particle we are computed the position for
  101370. * @param isLocal defines if the position should be set in local space
  101371. */
  101372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101373. /**
  101374. * Clones the current emitter and returns a copy of it
  101375. * @returns the new emitter
  101376. */
  101377. clone(): CustomParticleEmitter;
  101378. /**
  101379. * Called by the GPUParticleSystem to setup the update shader
  101380. * @param effect defines the update shader
  101381. */
  101382. applyToShader(effect: Effect): void;
  101383. /**
  101384. * Returns a string to use to update the GPU particles update shader
  101385. * @returns a string containng the defines string
  101386. */
  101387. getEffectDefines(): string;
  101388. /**
  101389. * Returns the string "PointParticleEmitter"
  101390. * @returns a string containing the class name
  101391. */
  101392. getClassName(): string;
  101393. /**
  101394. * Serializes the particle system to a JSON object.
  101395. * @returns the JSON object
  101396. */
  101397. serialize(): any;
  101398. /**
  101399. * Parse properties from a JSON object
  101400. * @param serializationObject defines the JSON object
  101401. */
  101402. parse(serializationObject: any): void;
  101403. }
  101404. }
  101405. declare module BABYLON {
  101406. /**
  101407. * Particle emitter emitting particles from the inside of a box.
  101408. * It emits the particles randomly between 2 given directions.
  101409. */
  101410. export class MeshParticleEmitter implements IParticleEmitterType {
  101411. private _indices;
  101412. private _positions;
  101413. private _normals;
  101414. private _storedNormal;
  101415. private _mesh;
  101416. /**
  101417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101418. */
  101419. direction1: Vector3;
  101420. /**
  101421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101422. */
  101423. direction2: Vector3;
  101424. /**
  101425. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  101426. */
  101427. useMeshNormalsForDirection: boolean;
  101428. /** Defines the mesh to use as source */
  101429. get mesh(): Nullable<AbstractMesh>;
  101430. set mesh(value: Nullable<AbstractMesh>);
  101431. /**
  101432. * Creates a new instance MeshParticleEmitter
  101433. * @param mesh defines the mesh to use as source
  101434. */
  101435. constructor(mesh?: Nullable<AbstractMesh>);
  101436. /**
  101437. * Called by the particle System when the direction is computed for the created particle.
  101438. * @param worldMatrix is the world matrix of the particle system
  101439. * @param directionToUpdate is the direction vector to update with the result
  101440. * @param particle is the particle we are computed the direction for
  101441. * @param isLocal defines if the direction should be set in local space
  101442. */
  101443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101444. /**
  101445. * Called by the particle System when the position is computed for the created particle.
  101446. * @param worldMatrix is the world matrix of the particle system
  101447. * @param positionToUpdate is the position vector to update with the result
  101448. * @param particle is the particle we are computed the position for
  101449. * @param isLocal defines if the position should be set in local space
  101450. */
  101451. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101452. /**
  101453. * Clones the current emitter and returns a copy of it
  101454. * @returns the new emitter
  101455. */
  101456. clone(): MeshParticleEmitter;
  101457. /**
  101458. * Called by the GPUParticleSystem to setup the update shader
  101459. * @param effect defines the update shader
  101460. */
  101461. applyToShader(effect: Effect): void;
  101462. /**
  101463. * Returns a string to use to update the GPU particles update shader
  101464. * @returns a string containng the defines string
  101465. */
  101466. getEffectDefines(): string;
  101467. /**
  101468. * Returns the string "BoxParticleEmitter"
  101469. * @returns a string containing the class name
  101470. */
  101471. getClassName(): string;
  101472. /**
  101473. * Serializes the particle system to a JSON object.
  101474. * @returns the JSON object
  101475. */
  101476. serialize(): any;
  101477. /**
  101478. * Parse properties from a JSON object
  101479. * @param serializationObject defines the JSON object
  101480. * @param scene defines the hosting scene
  101481. */
  101482. parse(serializationObject: any, scene: Nullable<Scene>): void;
  101483. }
  101484. }
  101485. declare module BABYLON {
  101486. /**
  101487. * Interface representing a particle system in Babylon.js.
  101488. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  101489. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  101490. */
  101491. export interface IParticleSystem {
  101492. /**
  101493. * List of animations used by the particle system.
  101494. */
  101495. animations: Animation[];
  101496. /**
  101497. * The id of the Particle system.
  101498. */
  101499. id: string;
  101500. /**
  101501. * The name of the Particle system.
  101502. */
  101503. name: string;
  101504. /**
  101505. * The emitter represents the Mesh or position we are attaching the particle system to.
  101506. */
  101507. emitter: Nullable<AbstractMesh | Vector3>;
  101508. /**
  101509. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  101510. */
  101511. isBillboardBased: boolean;
  101512. /**
  101513. * The rendering group used by the Particle system to chose when to render.
  101514. */
  101515. renderingGroupId: number;
  101516. /**
  101517. * The layer mask we are rendering the particles through.
  101518. */
  101519. layerMask: number;
  101520. /**
  101521. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  101522. */
  101523. updateSpeed: number;
  101524. /**
  101525. * The amount of time the particle system is running (depends of the overall update speed).
  101526. */
  101527. targetStopDuration: number;
  101528. /**
  101529. * The texture used to render each particle. (this can be a spritesheet)
  101530. */
  101531. particleTexture: Nullable<BaseTexture>;
  101532. /**
  101533. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  101534. */
  101535. blendMode: number;
  101536. /**
  101537. * Minimum life time of emitting particles.
  101538. */
  101539. minLifeTime: number;
  101540. /**
  101541. * Maximum life time of emitting particles.
  101542. */
  101543. maxLifeTime: number;
  101544. /**
  101545. * Minimum Size of emitting particles.
  101546. */
  101547. minSize: number;
  101548. /**
  101549. * Maximum Size of emitting particles.
  101550. */
  101551. maxSize: number;
  101552. /**
  101553. * Minimum scale of emitting particles on X axis.
  101554. */
  101555. minScaleX: number;
  101556. /**
  101557. * Maximum scale of emitting particles on X axis.
  101558. */
  101559. maxScaleX: number;
  101560. /**
  101561. * Minimum scale of emitting particles on Y axis.
  101562. */
  101563. minScaleY: number;
  101564. /**
  101565. * Maximum scale of emitting particles on Y axis.
  101566. */
  101567. maxScaleY: number;
  101568. /**
  101569. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  101570. */
  101571. color1: Color4;
  101572. /**
  101573. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  101574. */
  101575. color2: Color4;
  101576. /**
  101577. * Color the particle will have at the end of its lifetime.
  101578. */
  101579. colorDead: Color4;
  101580. /**
  101581. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  101582. */
  101583. emitRate: number;
  101584. /**
  101585. * You can use gravity if you want to give an orientation to your particles.
  101586. */
  101587. gravity: Vector3;
  101588. /**
  101589. * Minimum power of emitting particles.
  101590. */
  101591. minEmitPower: number;
  101592. /**
  101593. * Maximum power of emitting particles.
  101594. */
  101595. maxEmitPower: number;
  101596. /**
  101597. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  101598. */
  101599. minAngularSpeed: number;
  101600. /**
  101601. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  101602. */
  101603. maxAngularSpeed: number;
  101604. /**
  101605. * Gets or sets the minimal initial rotation in radians.
  101606. */
  101607. minInitialRotation: number;
  101608. /**
  101609. * Gets or sets the maximal initial rotation in radians.
  101610. */
  101611. maxInitialRotation: number;
  101612. /**
  101613. * The particle emitter type defines the emitter used by the particle system.
  101614. * It can be for example box, sphere, or cone...
  101615. */
  101616. particleEmitterType: Nullable<IParticleEmitterType>;
  101617. /**
  101618. * Defines the delay in milliseconds before starting the system (0 by default)
  101619. */
  101620. startDelay: number;
  101621. /**
  101622. * 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
  101623. */
  101624. preWarmCycles: number;
  101625. /**
  101626. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  101627. */
  101628. preWarmStepOffset: number;
  101629. /**
  101630. * 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)
  101631. */
  101632. spriteCellChangeSpeed: number;
  101633. /**
  101634. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  101635. */
  101636. startSpriteCellID: number;
  101637. /**
  101638. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  101639. */
  101640. endSpriteCellID: number;
  101641. /**
  101642. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  101643. */
  101644. spriteCellWidth: number;
  101645. /**
  101646. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  101647. */
  101648. spriteCellHeight: number;
  101649. /**
  101650. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  101651. */
  101652. spriteRandomStartCell: boolean;
  101653. /**
  101654. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  101655. */
  101656. isAnimationSheetEnabled: boolean;
  101657. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  101658. translationPivot: Vector2;
  101659. /**
  101660. * Gets or sets a texture used to add random noise to particle positions
  101661. */
  101662. noiseTexture: Nullable<BaseTexture>;
  101663. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  101664. noiseStrength: Vector3;
  101665. /**
  101666. * Gets or sets the billboard mode to use when isBillboardBased = true.
  101667. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  101668. */
  101669. billboardMode: number;
  101670. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  101671. limitVelocityDamping: number;
  101672. /**
  101673. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  101674. */
  101675. beginAnimationOnStart: boolean;
  101676. /**
  101677. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  101678. */
  101679. beginAnimationFrom: number;
  101680. /**
  101681. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  101682. */
  101683. beginAnimationTo: number;
  101684. /**
  101685. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  101686. */
  101687. beginAnimationLoop: boolean;
  101688. /**
  101689. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  101690. */
  101691. disposeOnStop: boolean;
  101692. /**
  101693. * Specifies if the particles are updated in emitter local space or world space
  101694. */
  101695. isLocal: boolean;
  101696. /** Snippet ID if the particle system was created from the snippet server */
  101697. snippetId: string;
  101698. /** Gets or sets a matrix to use to compute projection */
  101699. defaultProjectionMatrix: Matrix;
  101700. /**
  101701. * Gets the maximum number of particles active at the same time.
  101702. * @returns The max number of active particles.
  101703. */
  101704. getCapacity(): number;
  101705. /**
  101706. * Gets the number of particles active at the same time.
  101707. * @returns The number of active particles.
  101708. */
  101709. getActiveCount(): number;
  101710. /**
  101711. * Gets if the system has been started. (Note: this will still be true after stop is called)
  101712. * @returns True if it has been started, otherwise false.
  101713. */
  101714. isStarted(): boolean;
  101715. /**
  101716. * Animates the particle system for this frame.
  101717. */
  101718. animate(): void;
  101719. /**
  101720. * Renders the particle system in its current state.
  101721. * @returns the current number of particles
  101722. */
  101723. render(): number;
  101724. /**
  101725. * Dispose the particle system and frees its associated resources.
  101726. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  101727. */
  101728. dispose(disposeTexture?: boolean): void;
  101729. /**
  101730. * An event triggered when the system is disposed
  101731. */
  101732. onDisposeObservable: Observable<IParticleSystem>;
  101733. /**
  101734. * An event triggered when the system is stopped
  101735. */
  101736. onStoppedObservable: Observable<IParticleSystem>;
  101737. /**
  101738. * Clones the particle system.
  101739. * @param name The name of the cloned object
  101740. * @param newEmitter The new emitter to use
  101741. * @returns the cloned particle system
  101742. */
  101743. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  101744. /**
  101745. * Serializes the particle system to a JSON object
  101746. * @param serializeTexture defines if the texture must be serialized as well
  101747. * @returns the JSON object
  101748. */
  101749. serialize(serializeTexture: boolean): any;
  101750. /**
  101751. * Rebuild the particle system
  101752. */
  101753. rebuild(): void;
  101754. /** Force the system to rebuild all gradients that need to be resync */
  101755. forceRefreshGradients(): void;
  101756. /**
  101757. * Starts the particle system and begins to emit
  101758. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  101759. */
  101760. start(delay?: number): void;
  101761. /**
  101762. * Stops the particle system.
  101763. */
  101764. stop(): void;
  101765. /**
  101766. * Remove all active particles
  101767. */
  101768. reset(): void;
  101769. /**
  101770. * Gets a boolean indicating that the system is stopping
  101771. * @returns true if the system is currently stopping
  101772. */
  101773. isStopping(): boolean;
  101774. /**
  101775. * Is this system ready to be used/rendered
  101776. * @return true if the system is ready
  101777. */
  101778. isReady(): boolean;
  101779. /**
  101780. * Returns the string "ParticleSystem"
  101781. * @returns a string containing the class name
  101782. */
  101783. getClassName(): string;
  101784. /**
  101785. * Gets the custom effect used to render the particles
  101786. * @param blendMode Blend mode for which the effect should be retrieved
  101787. * @returns The effect
  101788. */
  101789. getCustomEffect(blendMode: number): Nullable<Effect>;
  101790. /**
  101791. * Sets the custom effect used to render the particles
  101792. * @param effect The effect to set
  101793. * @param blendMode Blend mode for which the effect should be set
  101794. */
  101795. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  101796. /**
  101797. * Fill the defines array according to the current settings of the particle system
  101798. * @param defines Array to be updated
  101799. * @param blendMode blend mode to take into account when updating the array
  101800. */
  101801. fillDefines(defines: Array<string>, blendMode: number): void;
  101802. /**
  101803. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  101804. * @param uniforms Uniforms array to fill
  101805. * @param attributes Attributes array to fill
  101806. * @param samplers Samplers array to fill
  101807. */
  101808. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  101809. /**
  101810. * Observable that will be called just before the particles are drawn
  101811. */
  101812. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  101813. /**
  101814. * Gets the name of the particle vertex shader
  101815. */
  101816. vertexShaderName: string;
  101817. /**
  101818. * Adds a new color gradient
  101819. * @param gradient defines the gradient to use (between 0 and 1)
  101820. * @param color1 defines the color to affect to the specified gradient
  101821. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  101822. * @returns the current particle system
  101823. */
  101824. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  101825. /**
  101826. * Remove a specific color gradient
  101827. * @param gradient defines the gradient to remove
  101828. * @returns the current particle system
  101829. */
  101830. removeColorGradient(gradient: number): IParticleSystem;
  101831. /**
  101832. * Adds a new size gradient
  101833. * @param gradient defines the gradient to use (between 0 and 1)
  101834. * @param factor defines the size factor to affect to the specified gradient
  101835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101836. * @returns the current particle system
  101837. */
  101838. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101839. /**
  101840. * Remove a specific size gradient
  101841. * @param gradient defines the gradient to remove
  101842. * @returns the current particle system
  101843. */
  101844. removeSizeGradient(gradient: number): IParticleSystem;
  101845. /**
  101846. * Gets the current list of color gradients.
  101847. * You must use addColorGradient and removeColorGradient to udpate this list
  101848. * @returns the list of color gradients
  101849. */
  101850. getColorGradients(): Nullable<Array<ColorGradient>>;
  101851. /**
  101852. * Gets the current list of size gradients.
  101853. * You must use addSizeGradient and removeSizeGradient to udpate this list
  101854. * @returns the list of size gradients
  101855. */
  101856. getSizeGradients(): Nullable<Array<FactorGradient>>;
  101857. /**
  101858. * Gets the current list of angular speed gradients.
  101859. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  101860. * @returns the list of angular speed gradients
  101861. */
  101862. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  101863. /**
  101864. * Adds a new angular speed gradient
  101865. * @param gradient defines the gradient to use (between 0 and 1)
  101866. * @param factor defines the angular speed to affect to the specified gradient
  101867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101868. * @returns the current particle system
  101869. */
  101870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101871. /**
  101872. * Remove a specific angular speed gradient
  101873. * @param gradient defines the gradient to remove
  101874. * @returns the current particle system
  101875. */
  101876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  101877. /**
  101878. * Gets the current list of velocity gradients.
  101879. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  101880. * @returns the list of velocity gradients
  101881. */
  101882. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  101883. /**
  101884. * Adds a new velocity gradient
  101885. * @param gradient defines the gradient to use (between 0 and 1)
  101886. * @param factor defines the velocity to affect to the specified gradient
  101887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101888. * @returns the current particle system
  101889. */
  101890. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101891. /**
  101892. * Remove a specific velocity gradient
  101893. * @param gradient defines the gradient to remove
  101894. * @returns the current particle system
  101895. */
  101896. removeVelocityGradient(gradient: number): IParticleSystem;
  101897. /**
  101898. * Gets the current list of limit velocity gradients.
  101899. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  101900. * @returns the list of limit velocity gradients
  101901. */
  101902. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  101903. /**
  101904. * Adds a new limit velocity gradient
  101905. * @param gradient defines the gradient to use (between 0 and 1)
  101906. * @param factor defines the limit velocity to affect to the specified gradient
  101907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101908. * @returns the current particle system
  101909. */
  101910. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101911. /**
  101912. * Remove a specific limit velocity gradient
  101913. * @param gradient defines the gradient to remove
  101914. * @returns the current particle system
  101915. */
  101916. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  101917. /**
  101918. * Adds a new drag gradient
  101919. * @param gradient defines the gradient to use (between 0 and 1)
  101920. * @param factor defines the drag to affect to the specified gradient
  101921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101922. * @returns the current particle system
  101923. */
  101924. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101925. /**
  101926. * Remove a specific drag gradient
  101927. * @param gradient defines the gradient to remove
  101928. * @returns the current particle system
  101929. */
  101930. removeDragGradient(gradient: number): IParticleSystem;
  101931. /**
  101932. * Gets the current list of drag gradients.
  101933. * You must use addDragGradient and removeDragGradient to udpate this list
  101934. * @returns the list of drag gradients
  101935. */
  101936. getDragGradients(): Nullable<Array<FactorGradient>>;
  101937. /**
  101938. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  101939. * @param gradient defines the gradient to use (between 0 and 1)
  101940. * @param factor defines the emit rate to affect to the specified gradient
  101941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101942. * @returns the current particle system
  101943. */
  101944. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101945. /**
  101946. * Remove a specific emit rate gradient
  101947. * @param gradient defines the gradient to remove
  101948. * @returns the current particle system
  101949. */
  101950. removeEmitRateGradient(gradient: number): IParticleSystem;
  101951. /**
  101952. * Gets the current list of emit rate gradients.
  101953. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  101954. * @returns the list of emit rate gradients
  101955. */
  101956. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  101957. /**
  101958. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  101959. * @param gradient defines the gradient to use (between 0 and 1)
  101960. * @param factor defines the start size to affect to the specified gradient
  101961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101962. * @returns the current particle system
  101963. */
  101964. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101965. /**
  101966. * Remove a specific start size gradient
  101967. * @param gradient defines the gradient to remove
  101968. * @returns the current particle system
  101969. */
  101970. removeStartSizeGradient(gradient: number): IParticleSystem;
  101971. /**
  101972. * Gets the current list of start size gradients.
  101973. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  101974. * @returns the list of start size gradients
  101975. */
  101976. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  101977. /**
  101978. * Adds a new life time gradient
  101979. * @param gradient defines the gradient to use (between 0 and 1)
  101980. * @param factor defines the life time factor to affect to the specified gradient
  101981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101982. * @returns the current particle system
  101983. */
  101984. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101985. /**
  101986. * Remove a specific life time gradient
  101987. * @param gradient defines the gradient to remove
  101988. * @returns the current particle system
  101989. */
  101990. removeLifeTimeGradient(gradient: number): IParticleSystem;
  101991. /**
  101992. * Gets the current list of life time gradients.
  101993. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  101994. * @returns the list of life time gradients
  101995. */
  101996. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  101997. /**
  101998. * Gets the current list of color gradients.
  101999. * You must use addColorGradient and removeColorGradient to udpate this list
  102000. * @returns the list of color gradients
  102001. */
  102002. getColorGradients(): Nullable<Array<ColorGradient>>;
  102003. /**
  102004. * Adds a new ramp gradient used to remap particle colors
  102005. * @param gradient defines the gradient to use (between 0 and 1)
  102006. * @param color defines the color to affect to the specified gradient
  102007. * @returns the current particle system
  102008. */
  102009. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  102010. /**
  102011. * Gets the current list of ramp gradients.
  102012. * You must use addRampGradient and removeRampGradient to udpate this list
  102013. * @returns the list of ramp gradients
  102014. */
  102015. getRampGradients(): Nullable<Array<Color3Gradient>>;
  102016. /** Gets or sets a boolean indicating that ramp gradients must be used
  102017. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  102018. */
  102019. useRampGradients: boolean;
  102020. /**
  102021. * Adds a new color remap gradient
  102022. * @param gradient defines the gradient to use (between 0 and 1)
  102023. * @param min defines the color remap minimal range
  102024. * @param max defines the color remap maximal range
  102025. * @returns the current particle system
  102026. */
  102027. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102028. /**
  102029. * Gets the current list of color remap gradients.
  102030. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102031. * @returns the list of color remap gradients
  102032. */
  102033. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  102034. /**
  102035. * Adds a new alpha remap gradient
  102036. * @param gradient defines the gradient to use (between 0 and 1)
  102037. * @param min defines the alpha remap minimal range
  102038. * @param max defines the alpha remap maximal range
  102039. * @returns the current particle system
  102040. */
  102041. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102042. /**
  102043. * Gets the current list of alpha remap gradients.
  102044. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102045. * @returns the list of alpha remap gradients
  102046. */
  102047. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  102048. /**
  102049. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102050. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102051. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102052. * @returns the emitter
  102053. */
  102054. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  102055. /**
  102056. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102057. * @param radius The radius of the hemisphere to emit from
  102058. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102059. * @returns the emitter
  102060. */
  102061. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  102062. /**
  102063. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102064. * @param radius The radius of the sphere to emit from
  102065. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102066. * @returns the emitter
  102067. */
  102068. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  102069. /**
  102070. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102071. * @param radius The radius of the sphere to emit from
  102072. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102073. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102074. * @returns the emitter
  102075. */
  102076. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102077. /**
  102078. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102079. * @param radius The radius of the emission cylinder
  102080. * @param height The height of the emission cylinder
  102081. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102082. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102083. * @returns the emitter
  102084. */
  102085. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  102086. /**
  102087. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102088. * @param radius The radius of the cylinder to emit from
  102089. * @param height The height of the emission cylinder
  102090. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102091. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102092. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102093. * @returns the emitter
  102094. */
  102095. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102096. /**
  102097. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102098. * @param radius The radius of the cone to emit from
  102099. * @param angle The base angle of the cone
  102100. * @returns the emitter
  102101. */
  102102. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  102103. /**
  102104. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102105. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102106. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102107. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102108. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102109. * @returns the emitter
  102110. */
  102111. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  102112. /**
  102113. * Get hosting scene
  102114. * @returns the scene
  102115. */
  102116. getScene(): Nullable<Scene>;
  102117. }
  102118. }
  102119. declare module BABYLON {
  102120. /**
  102121. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102122. */
  102123. export class ColorSplitterBlock extends NodeMaterialBlock {
  102124. /**
  102125. * Create a new ColorSplitterBlock
  102126. * @param name defines the block name
  102127. */
  102128. constructor(name: string);
  102129. /**
  102130. * Gets the current class name
  102131. * @returns the class name
  102132. */
  102133. getClassName(): string;
  102134. /**
  102135. * Gets the rgba component (input)
  102136. */
  102137. get rgba(): NodeMaterialConnectionPoint;
  102138. /**
  102139. * Gets the rgb component (input)
  102140. */
  102141. get rgbIn(): NodeMaterialConnectionPoint;
  102142. /**
  102143. * Gets the rgb component (output)
  102144. */
  102145. get rgbOut(): NodeMaterialConnectionPoint;
  102146. /**
  102147. * Gets the r component (output)
  102148. */
  102149. get r(): NodeMaterialConnectionPoint;
  102150. /**
  102151. * Gets the g component (output)
  102152. */
  102153. get g(): NodeMaterialConnectionPoint;
  102154. /**
  102155. * Gets the b component (output)
  102156. */
  102157. get b(): NodeMaterialConnectionPoint;
  102158. /**
  102159. * Gets the a component (output)
  102160. */
  102161. get a(): NodeMaterialConnectionPoint;
  102162. protected _inputRename(name: string): string;
  102163. protected _outputRename(name: string): string;
  102164. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102165. }
  102166. }
  102167. declare module BABYLON {
  102168. /**
  102169. * Operations supported by the Trigonometry block
  102170. */
  102171. export enum TrigonometryBlockOperations {
  102172. /** Cos */
  102173. Cos = 0,
  102174. /** Sin */
  102175. Sin = 1,
  102176. /** Abs */
  102177. Abs = 2,
  102178. /** Exp */
  102179. Exp = 3,
  102180. /** Exp2 */
  102181. Exp2 = 4,
  102182. /** Round */
  102183. Round = 5,
  102184. /** Floor */
  102185. Floor = 6,
  102186. /** Ceiling */
  102187. Ceiling = 7,
  102188. /** Square root */
  102189. Sqrt = 8,
  102190. /** Log */
  102191. Log = 9,
  102192. /** Tangent */
  102193. Tan = 10,
  102194. /** Arc tangent */
  102195. ArcTan = 11,
  102196. /** Arc cosinus */
  102197. ArcCos = 12,
  102198. /** Arc sinus */
  102199. ArcSin = 13,
  102200. /** Fraction */
  102201. Fract = 14,
  102202. /** Sign */
  102203. Sign = 15,
  102204. /** To radians (from degrees) */
  102205. Radians = 16,
  102206. /** To degrees (from radians) */
  102207. Degrees = 17
  102208. }
  102209. /**
  102210. * Block used to apply trigonometry operation to floats
  102211. */
  102212. export class TrigonometryBlock extends NodeMaterialBlock {
  102213. /**
  102214. * Gets or sets the operation applied by the block
  102215. */
  102216. operation: TrigonometryBlockOperations;
  102217. /**
  102218. * Creates a new TrigonometryBlock
  102219. * @param name defines the block name
  102220. */
  102221. constructor(name: string);
  102222. /**
  102223. * Gets the current class name
  102224. * @returns the class name
  102225. */
  102226. getClassName(): string;
  102227. /**
  102228. * Gets the input component
  102229. */
  102230. get input(): NodeMaterialConnectionPoint;
  102231. /**
  102232. * Gets the output component
  102233. */
  102234. get output(): NodeMaterialConnectionPoint;
  102235. protected _buildBlock(state: NodeMaterialBuildState): this;
  102236. serialize(): any;
  102237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102238. protected _dumpPropertiesCode(): string;
  102239. }
  102240. }
  102241. declare module BABYLON {
  102242. /**
  102243. * Interface used to configure the node material editor
  102244. */
  102245. export interface INodeMaterialEditorOptions {
  102246. /** Define the URl to load node editor script */
  102247. editorURL?: string;
  102248. }
  102249. /** @hidden */
  102250. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102251. NORMAL: boolean;
  102252. TANGENT: boolean;
  102253. UV1: boolean;
  102254. /** BONES */
  102255. NUM_BONE_INFLUENCERS: number;
  102256. BonesPerMesh: number;
  102257. BONETEXTURE: boolean;
  102258. /** MORPH TARGETS */
  102259. MORPHTARGETS: boolean;
  102260. MORPHTARGETS_NORMAL: boolean;
  102261. MORPHTARGETS_TANGENT: boolean;
  102262. MORPHTARGETS_UV: boolean;
  102263. NUM_MORPH_INFLUENCERS: number;
  102264. /** IMAGE PROCESSING */
  102265. IMAGEPROCESSING: boolean;
  102266. VIGNETTE: boolean;
  102267. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102268. VIGNETTEBLENDMODEOPAQUE: boolean;
  102269. TONEMAPPING: boolean;
  102270. TONEMAPPING_ACES: boolean;
  102271. CONTRAST: boolean;
  102272. EXPOSURE: boolean;
  102273. COLORCURVES: boolean;
  102274. COLORGRADING: boolean;
  102275. COLORGRADING3D: boolean;
  102276. SAMPLER3DGREENDEPTH: boolean;
  102277. SAMPLER3DBGRMAP: boolean;
  102278. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102279. /** MISC. */
  102280. BUMPDIRECTUV: number;
  102281. constructor();
  102282. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102283. }
  102284. /**
  102285. * Class used to configure NodeMaterial
  102286. */
  102287. export interface INodeMaterialOptions {
  102288. /**
  102289. * Defines if blocks should emit comments
  102290. */
  102291. emitComments: boolean;
  102292. }
  102293. /**
  102294. * Class used to create a node based material built by assembling shader blocks
  102295. */
  102296. export class NodeMaterial extends PushMaterial {
  102297. private static _BuildIdGenerator;
  102298. private _options;
  102299. private _vertexCompilationState;
  102300. private _fragmentCompilationState;
  102301. private _sharedData;
  102302. private _buildId;
  102303. private _buildWasSuccessful;
  102304. private _cachedWorldViewMatrix;
  102305. private _cachedWorldViewProjectionMatrix;
  102306. private _optimizers;
  102307. private _animationFrame;
  102308. /** Define the Url to load node editor script */
  102309. static EditorURL: string;
  102310. /** Define the Url to load snippets */
  102311. static SnippetUrl: string;
  102312. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102313. static IgnoreTexturesAtLoadTime: boolean;
  102314. private BJSNODEMATERIALEDITOR;
  102315. /** Get the inspector from bundle or global */
  102316. private _getGlobalNodeMaterialEditor;
  102317. /**
  102318. * Snippet ID if the material was created from the snippet server
  102319. */
  102320. snippetId: string;
  102321. /**
  102322. * Gets or sets data used by visual editor
  102323. * @see https://nme.babylonjs.com
  102324. */
  102325. editorData: any;
  102326. /**
  102327. * 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)
  102328. */
  102329. ignoreAlpha: boolean;
  102330. /**
  102331. * Defines the maximum number of lights that can be used in the material
  102332. */
  102333. maxSimultaneousLights: number;
  102334. /**
  102335. * Observable raised when the material is built
  102336. */
  102337. onBuildObservable: Observable<NodeMaterial>;
  102338. /**
  102339. * Gets or sets the root nodes of the material vertex shader
  102340. */
  102341. _vertexOutputNodes: NodeMaterialBlock[];
  102342. /**
  102343. * Gets or sets the root nodes of the material fragment (pixel) shader
  102344. */
  102345. _fragmentOutputNodes: NodeMaterialBlock[];
  102346. /** Gets or sets options to control the node material overall behavior */
  102347. get options(): INodeMaterialOptions;
  102348. set options(options: INodeMaterialOptions);
  102349. /**
  102350. * Default configuration related to image processing available in the standard Material.
  102351. */
  102352. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102353. /**
  102354. * Gets the image processing configuration used either in this material.
  102355. */
  102356. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102357. /**
  102358. * Sets the Default image processing configuration used either in the this material.
  102359. *
  102360. * If sets to null, the scene one is in use.
  102361. */
  102362. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102363. /**
  102364. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102365. */
  102366. attachedBlocks: NodeMaterialBlock[];
  102367. /**
  102368. * Specifies the mode of the node material
  102369. * @hidden
  102370. */
  102371. _mode: NodeMaterialModes;
  102372. /**
  102373. * Gets the mode property
  102374. */
  102375. get mode(): NodeMaterialModes;
  102376. /**
  102377. * A free comment about the material
  102378. */
  102379. comment: string;
  102380. /**
  102381. * Create a new node based material
  102382. * @param name defines the material name
  102383. * @param scene defines the hosting scene
  102384. * @param options defines creation option
  102385. */
  102386. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102387. /**
  102388. * Gets the current class name of the material e.g. "NodeMaterial"
  102389. * @returns the class name
  102390. */
  102391. getClassName(): string;
  102392. /**
  102393. * Keep track of the image processing observer to allow dispose and replace.
  102394. */
  102395. private _imageProcessingObserver;
  102396. /**
  102397. * Attaches a new image processing configuration to the Standard Material.
  102398. * @param configuration
  102399. */
  102400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102401. /**
  102402. * Get a block by its name
  102403. * @param name defines the name of the block to retrieve
  102404. * @returns the required block or null if not found
  102405. */
  102406. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102407. /**
  102408. * Get a block by its name
  102409. * @param predicate defines the predicate used to find the good candidate
  102410. * @returns the required block or null if not found
  102411. */
  102412. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102413. /**
  102414. * Get an input block by its name
  102415. * @param predicate defines the predicate used to find the good candidate
  102416. * @returns the required input block or null if not found
  102417. */
  102418. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102419. /**
  102420. * Gets the list of input blocks attached to this material
  102421. * @returns an array of InputBlocks
  102422. */
  102423. getInputBlocks(): InputBlock[];
  102424. /**
  102425. * Adds a new optimizer to the list of optimizers
  102426. * @param optimizer defines the optimizers to add
  102427. * @returns the current material
  102428. */
  102429. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102430. /**
  102431. * Remove an optimizer from the list of optimizers
  102432. * @param optimizer defines the optimizers to remove
  102433. * @returns the current material
  102434. */
  102435. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102436. /**
  102437. * Add a new block to the list of output nodes
  102438. * @param node defines the node to add
  102439. * @returns the current material
  102440. */
  102441. addOutputNode(node: NodeMaterialBlock): this;
  102442. /**
  102443. * Remove a block from the list of root nodes
  102444. * @param node defines the node to remove
  102445. * @returns the current material
  102446. */
  102447. removeOutputNode(node: NodeMaterialBlock): this;
  102448. private _addVertexOutputNode;
  102449. private _removeVertexOutputNode;
  102450. private _addFragmentOutputNode;
  102451. private _removeFragmentOutputNode;
  102452. /**
  102453. * Specifies if the material will require alpha blending
  102454. * @returns a boolean specifying if alpha blending is needed
  102455. */
  102456. needAlphaBlending(): boolean;
  102457. /**
  102458. * Specifies if this material should be rendered in alpha test mode
  102459. * @returns a boolean specifying if an alpha test is needed.
  102460. */
  102461. needAlphaTesting(): boolean;
  102462. private _initializeBlock;
  102463. private _resetDualBlocks;
  102464. /**
  102465. * Remove a block from the current node material
  102466. * @param block defines the block to remove
  102467. */
  102468. removeBlock(block: NodeMaterialBlock): void;
  102469. /**
  102470. * Build the material and generates the inner effect
  102471. * @param verbose defines if the build should log activity
  102472. */
  102473. build(verbose?: boolean): void;
  102474. /**
  102475. * Runs an otpimization phase to try to improve the shader code
  102476. */
  102477. optimize(): void;
  102478. private _prepareDefinesForAttributes;
  102479. /**
  102480. * Create a post process from the material
  102481. * @param camera The camera to apply the render pass to.
  102482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102484. * @param engine The engine which the post process will be applied. (default: current engine)
  102485. * @param reusable If the post process can be reused on the same frame. (default: false)
  102486. * @param textureType Type of textures used when performing the post process. (default: 0)
  102487. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102488. * @returns the post process created
  102489. */
  102490. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102491. /**
  102492. * Create the post process effect from the material
  102493. * @param postProcess The post process to create the effect for
  102494. */
  102495. createEffectForPostProcess(postProcess: PostProcess): void;
  102496. private _createEffectForPostProcess;
  102497. /**
  102498. * Create a new procedural texture based on this node material
  102499. * @param size defines the size of the texture
  102500. * @param scene defines the hosting scene
  102501. * @returns the new procedural texture attached to this node material
  102502. */
  102503. createProceduralTexture(size: number | {
  102504. width: number;
  102505. height: number;
  102506. layers?: number;
  102507. }, scene: Scene): Nullable<ProceduralTexture>;
  102508. private _createEffectForParticles;
  102509. private _checkInternals;
  102510. /**
  102511. * Create the effect to be used as the custom effect for a particle system
  102512. * @param particleSystem Particle system to create the effect for
  102513. * @param onCompiled defines a function to call when the effect creation is successful
  102514. * @param onError defines a function to call when the effect creation has failed
  102515. */
  102516. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102517. private _processDefines;
  102518. /**
  102519. * Get if the submesh is ready to be used and all its information available.
  102520. * Child classes can use it to update shaders
  102521. * @param mesh defines the mesh to check
  102522. * @param subMesh defines which submesh to check
  102523. * @param useInstances specifies that instances should be used
  102524. * @returns a boolean indicating that the submesh is ready or not
  102525. */
  102526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102527. /**
  102528. * Get a string representing the shaders built by the current node graph
  102529. */
  102530. get compiledShaders(): string;
  102531. /**
  102532. * Binds the world matrix to the material
  102533. * @param world defines the world transformation matrix
  102534. */
  102535. bindOnlyWorldMatrix(world: Matrix): void;
  102536. /**
  102537. * Binds the submesh to this material by preparing the effect and shader to draw
  102538. * @param world defines the world transformation matrix
  102539. * @param mesh defines the mesh containing the submesh
  102540. * @param subMesh defines the submesh to bind the material to
  102541. */
  102542. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102543. /**
  102544. * Gets the active textures from the material
  102545. * @returns an array of textures
  102546. */
  102547. getActiveTextures(): BaseTexture[];
  102548. /**
  102549. * Gets the list of texture blocks
  102550. * @returns an array of texture blocks
  102551. */
  102552. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102553. /**
  102554. * Specifies if the material uses a texture
  102555. * @param texture defines the texture to check against the material
  102556. * @returns a boolean specifying if the material uses the texture
  102557. */
  102558. hasTexture(texture: BaseTexture): boolean;
  102559. /**
  102560. * Disposes the material
  102561. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102562. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102563. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102564. */
  102565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102566. /** Creates the node editor window. */
  102567. private _createNodeEditor;
  102568. /**
  102569. * Launch the node material editor
  102570. * @param config Define the configuration of the editor
  102571. * @return a promise fulfilled when the node editor is visible
  102572. */
  102573. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102574. /**
  102575. * Clear the current material
  102576. */
  102577. clear(): void;
  102578. /**
  102579. * Clear the current material and set it to a default state
  102580. */
  102581. setToDefault(): void;
  102582. /**
  102583. * Clear the current material and set it to a default state for post process
  102584. */
  102585. setToDefaultPostProcess(): void;
  102586. /**
  102587. * Clear the current material and set it to a default state for procedural texture
  102588. */
  102589. setToDefaultProceduralTexture(): void;
  102590. /**
  102591. * Clear the current material and set it to a default state for particle
  102592. */
  102593. setToDefaultParticle(): void;
  102594. /**
  102595. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102596. * @param url defines the url to load from
  102597. * @returns a promise that will fullfil when the material is fully loaded
  102598. */
  102599. loadAsync(url: string): Promise<void>;
  102600. private _gatherBlocks;
  102601. /**
  102602. * Generate a string containing the code declaration required to create an equivalent of this material
  102603. * @returns a string
  102604. */
  102605. generateCode(): string;
  102606. /**
  102607. * Serializes this material in a JSON representation
  102608. * @returns the serialized material object
  102609. */
  102610. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102611. private _restoreConnections;
  102612. /**
  102613. * Clear the current graph and load a new one from a serialization object
  102614. * @param source defines the JSON representation of the material
  102615. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102616. * @param merge defines whether or not the source must be merged or replace the current content
  102617. */
  102618. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102619. /**
  102620. * Makes a duplicate of the current material.
  102621. * @param name - name to use for the new material.
  102622. */
  102623. clone(name: string): NodeMaterial;
  102624. /**
  102625. * Creates a node material from parsed material data
  102626. * @param source defines the JSON representation of the material
  102627. * @param scene defines the hosting scene
  102628. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102629. * @returns a new node material
  102630. */
  102631. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102632. /**
  102633. * Creates a node material from a snippet saved in a remote file
  102634. * @param name defines the name of the material to create
  102635. * @param url defines the url to load from
  102636. * @param scene defines the hosting scene
  102637. * @returns a promise that will resolve to the new node material
  102638. */
  102639. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102640. /**
  102641. * Creates a node material from a snippet saved by the node material editor
  102642. * @param snippetId defines the snippet to load
  102643. * @param scene defines the hosting scene
  102644. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102645. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102646. * @returns a promise that will resolve to the new node material
  102647. */
  102648. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102649. /**
  102650. * Creates a new node material set to default basic configuration
  102651. * @param name defines the name of the material
  102652. * @param scene defines the hosting scene
  102653. * @returns a new NodeMaterial
  102654. */
  102655. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102656. }
  102657. }
  102658. declare module BABYLON {
  102659. interface ThinEngine {
  102660. /**
  102661. * Unbind a list of render target textures from the webGL context
  102662. * This is used only when drawBuffer extension or webGL2 are active
  102663. * @param textures defines the render target textures to unbind
  102664. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102665. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102666. */
  102667. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102668. /**
  102669. * Create a multi render target texture
  102670. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102671. * @param size defines the size of the texture
  102672. * @param options defines the creation options
  102673. * @returns the cube texture as an InternalTexture
  102674. */
  102675. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102676. /**
  102677. * Update the sample count for a given multiple render target texture
  102678. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102679. * @param textures defines the textures to update
  102680. * @param samples defines the sample count to set
  102681. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102682. */
  102683. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102684. /**
  102685. * Select a subsets of attachments to draw to.
  102686. * @param attachments gl attachments
  102687. */
  102688. bindAttachments(attachments: number[]): void;
  102689. /**
  102690. * Creates a layout object to draw/clear on specific textures in a MRT
  102691. * @param textureStatus textureStatus[i] indicates if the i-th is active
  102692. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  102693. */
  102694. buildTextureLayout(textureStatus: boolean[]): number[];
  102695. /**
  102696. * Restores the webgl state to only draw on the main color attachment
  102697. */
  102698. restoreSingleAttachment(): void;
  102699. }
  102700. }
  102701. declare module BABYLON {
  102702. /**
  102703. * Creation options of the multi render target texture.
  102704. */
  102705. export interface IMultiRenderTargetOptions {
  102706. /**
  102707. * Define if the texture needs to create mip maps after render.
  102708. */
  102709. generateMipMaps?: boolean;
  102710. /**
  102711. * Define the types of all the draw buffers we want to create
  102712. */
  102713. types?: number[];
  102714. /**
  102715. * Define the sampling modes of all the draw buffers we want to create
  102716. */
  102717. samplingModes?: number[];
  102718. /**
  102719. * Define if a depth buffer is required
  102720. */
  102721. generateDepthBuffer?: boolean;
  102722. /**
  102723. * Define if a stencil buffer is required
  102724. */
  102725. generateStencilBuffer?: boolean;
  102726. /**
  102727. * Define if a depth texture is required instead of a depth buffer
  102728. */
  102729. generateDepthTexture?: boolean;
  102730. /**
  102731. * Define the number of desired draw buffers
  102732. */
  102733. textureCount?: number;
  102734. /**
  102735. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102736. */
  102737. doNotChangeAspectRatio?: boolean;
  102738. /**
  102739. * Define the default type of the buffers we are creating
  102740. */
  102741. defaultType?: number;
  102742. }
  102743. /**
  102744. * A multi render target, like a render target provides the ability to render to a texture.
  102745. * Unlike the render target, it can render to several draw buffers in one draw.
  102746. * This is specially interesting in deferred rendering or for any effects requiring more than
  102747. * just one color from a single pass.
  102748. */
  102749. export class MultiRenderTarget extends RenderTargetTexture {
  102750. private _internalTextures;
  102751. private _textures;
  102752. private _multiRenderTargetOptions;
  102753. private _count;
  102754. /**
  102755. * Get if draw buffers are currently supported by the used hardware and browser.
  102756. */
  102757. get isSupported(): boolean;
  102758. /**
  102759. * Get the list of textures generated by the multi render target.
  102760. */
  102761. get textures(): Texture[];
  102762. /**
  102763. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102764. */
  102765. get count(): number;
  102766. /**
  102767. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102768. */
  102769. get depthTexture(): Texture;
  102770. /**
  102771. * Set the wrapping mode on U of all the textures we are rendering to.
  102772. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102773. */
  102774. set wrapU(wrap: number);
  102775. /**
  102776. * Set the wrapping mode on V of all the textures we are rendering to.
  102777. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102778. */
  102779. set wrapV(wrap: number);
  102780. /**
  102781. * Instantiate a new multi render target texture.
  102782. * A multi render target, like a render target provides the ability to render to a texture.
  102783. * Unlike the render target, it can render to several draw buffers in one draw.
  102784. * This is specially interesting in deferred rendering or for any effects requiring more than
  102785. * just one color from a single pass.
  102786. * @param name Define the name of the texture
  102787. * @param size Define the size of the buffers to render to
  102788. * @param count Define the number of target we are rendering into
  102789. * @param scene Define the scene the texture belongs to
  102790. * @param options Define the options used to create the multi render target
  102791. */
  102792. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102793. private _initTypes;
  102794. /** @hidden */
  102795. _rebuild(forceFullRebuild?: boolean): void;
  102796. private _createInternalTextures;
  102797. private _createTextures;
  102798. /**
  102799. * Replaces a texture within the MRT.
  102800. * @param texture The new texture to insert in the MRT
  102801. * @param index The index of the texture to replace
  102802. */
  102803. replaceTexture(texture: Texture, index: number): void;
  102804. /**
  102805. * Define the number of samples used if MSAA is enabled.
  102806. */
  102807. get samples(): number;
  102808. set samples(value: number);
  102809. /**
  102810. * Resize all the textures in the multi render target.
  102811. * Be careful as it will recreate all the data in the new texture.
  102812. * @param size Define the new size
  102813. */
  102814. resize(size: any): void;
  102815. /**
  102816. * Changes the number of render targets in this MRT
  102817. * Be careful as it will recreate all the data in the new texture.
  102818. * @param count new texture count
  102819. * @param options Specifies texture types and sampling modes for new textures
  102820. */
  102821. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  102822. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102823. /**
  102824. * Dispose the render targets and their associated resources
  102825. */
  102826. dispose(): void;
  102827. /**
  102828. * Release all the underlying texture used as draw buffers.
  102829. */
  102830. releaseInternalTextures(): void;
  102831. }
  102832. }
  102833. declare module BABYLON {
  102834. /** @hidden */
  102835. export var imageProcessingPixelShader: {
  102836. name: string;
  102837. shader: string;
  102838. };
  102839. }
  102840. declare module BABYLON {
  102841. /**
  102842. * ImageProcessingPostProcess
  102843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102844. */
  102845. export class ImageProcessingPostProcess extends PostProcess {
  102846. /**
  102847. * Default configuration related to image processing available in the PBR Material.
  102848. */
  102849. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102850. /**
  102851. * Gets the image processing configuration used either in this material.
  102852. */
  102853. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102854. /**
  102855. * Sets the Default image processing configuration used either in the this material.
  102856. *
  102857. * If sets to null, the scene one is in use.
  102858. */
  102859. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102860. /**
  102861. * Keep track of the image processing observer to allow dispose and replace.
  102862. */
  102863. private _imageProcessingObserver;
  102864. /**
  102865. * Attaches a new image processing configuration to the PBR Material.
  102866. * @param configuration
  102867. */
  102868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102869. /**
  102870. * If the post process is supported.
  102871. */
  102872. get isSupported(): boolean;
  102873. /**
  102874. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102875. */
  102876. get colorCurves(): Nullable<ColorCurves>;
  102877. /**
  102878. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102879. */
  102880. set colorCurves(value: Nullable<ColorCurves>);
  102881. /**
  102882. * Gets wether the color curves effect is enabled.
  102883. */
  102884. get colorCurvesEnabled(): boolean;
  102885. /**
  102886. * Sets wether the color curves effect is enabled.
  102887. */
  102888. set colorCurvesEnabled(value: boolean);
  102889. /**
  102890. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102891. */
  102892. get colorGradingTexture(): Nullable<BaseTexture>;
  102893. /**
  102894. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102895. */
  102896. set colorGradingTexture(value: Nullable<BaseTexture>);
  102897. /**
  102898. * Gets wether the color grading effect is enabled.
  102899. */
  102900. get colorGradingEnabled(): boolean;
  102901. /**
  102902. * Gets wether the color grading effect is enabled.
  102903. */
  102904. set colorGradingEnabled(value: boolean);
  102905. /**
  102906. * Gets exposure used in the effect.
  102907. */
  102908. get exposure(): number;
  102909. /**
  102910. * Sets exposure used in the effect.
  102911. */
  102912. set exposure(value: number);
  102913. /**
  102914. * Gets wether tonemapping is enabled or not.
  102915. */
  102916. get toneMappingEnabled(): boolean;
  102917. /**
  102918. * Sets wether tonemapping is enabled or not
  102919. */
  102920. set toneMappingEnabled(value: boolean);
  102921. /**
  102922. * Gets the type of tone mapping effect.
  102923. */
  102924. get toneMappingType(): number;
  102925. /**
  102926. * Sets the type of tone mapping effect.
  102927. */
  102928. set toneMappingType(value: number);
  102929. /**
  102930. * Gets contrast used in the effect.
  102931. */
  102932. get contrast(): number;
  102933. /**
  102934. * Sets contrast used in the effect.
  102935. */
  102936. set contrast(value: number);
  102937. /**
  102938. * Gets Vignette stretch size.
  102939. */
  102940. get vignetteStretch(): number;
  102941. /**
  102942. * Sets Vignette stretch size.
  102943. */
  102944. set vignetteStretch(value: number);
  102945. /**
  102946. * Gets Vignette centre X Offset.
  102947. */
  102948. get vignetteCentreX(): number;
  102949. /**
  102950. * Sets Vignette centre X Offset.
  102951. */
  102952. set vignetteCentreX(value: number);
  102953. /**
  102954. * Gets Vignette centre Y Offset.
  102955. */
  102956. get vignetteCentreY(): number;
  102957. /**
  102958. * Sets Vignette centre Y Offset.
  102959. */
  102960. set vignetteCentreY(value: number);
  102961. /**
  102962. * Gets Vignette weight or intensity of the vignette effect.
  102963. */
  102964. get vignetteWeight(): number;
  102965. /**
  102966. * Sets Vignette weight or intensity of the vignette effect.
  102967. */
  102968. set vignetteWeight(value: number);
  102969. /**
  102970. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102971. * if vignetteEnabled is set to true.
  102972. */
  102973. get vignetteColor(): Color4;
  102974. /**
  102975. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102976. * if vignetteEnabled is set to true.
  102977. */
  102978. set vignetteColor(value: Color4);
  102979. /**
  102980. * Gets Camera field of view used by the Vignette effect.
  102981. */
  102982. get vignetteCameraFov(): number;
  102983. /**
  102984. * Sets Camera field of view used by the Vignette effect.
  102985. */
  102986. set vignetteCameraFov(value: number);
  102987. /**
  102988. * Gets the vignette blend mode allowing different kind of effect.
  102989. */
  102990. get vignetteBlendMode(): number;
  102991. /**
  102992. * Sets the vignette blend mode allowing different kind of effect.
  102993. */
  102994. set vignetteBlendMode(value: number);
  102995. /**
  102996. * Gets wether the vignette effect is enabled.
  102997. */
  102998. get vignetteEnabled(): boolean;
  102999. /**
  103000. * Sets wether the vignette effect is enabled.
  103001. */
  103002. set vignetteEnabled(value: boolean);
  103003. private _fromLinearSpace;
  103004. /**
  103005. * Gets wether the input of the processing is in Gamma or Linear Space.
  103006. */
  103007. get fromLinearSpace(): boolean;
  103008. /**
  103009. * Sets wether the input of the processing is in Gamma or Linear Space.
  103010. */
  103011. set fromLinearSpace(value: boolean);
  103012. /**
  103013. * Defines cache preventing GC.
  103014. */
  103015. private _defines;
  103016. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103017. /**
  103018. * "ImageProcessingPostProcess"
  103019. * @returns "ImageProcessingPostProcess"
  103020. */
  103021. getClassName(): string;
  103022. /**
  103023. * @hidden
  103024. */
  103025. _updateParameters(): void;
  103026. dispose(camera?: Camera): void;
  103027. }
  103028. }
  103029. declare module BABYLON {
  103030. /**
  103031. * Interface for defining prepass effects in the prepass post-process pipeline
  103032. */
  103033. export interface PrePassEffectConfiguration {
  103034. /**
  103035. * Name of the effect
  103036. */
  103037. name: string;
  103038. /**
  103039. * Post process to attach for this effect
  103040. */
  103041. postProcess?: PostProcess;
  103042. /**
  103043. * Textures required in the MRT
  103044. */
  103045. texturesRequired: number[];
  103046. /**
  103047. * Is the effect enabled
  103048. */
  103049. enabled: boolean;
  103050. /**
  103051. * Disposes the effect configuration
  103052. */
  103053. dispose?: () => void;
  103054. /**
  103055. * Creates the associated post process
  103056. */
  103057. createPostProcess?: () => PostProcess;
  103058. }
  103059. }
  103060. declare module BABYLON {
  103061. /**
  103062. * Options to be used when creating a FresnelParameters.
  103063. */
  103064. export type IFresnelParametersCreationOptions = {
  103065. /**
  103066. * Define the color used on edges (grazing angle)
  103067. */
  103068. leftColor?: Color3;
  103069. /**
  103070. * Define the color used on center
  103071. */
  103072. rightColor?: Color3;
  103073. /**
  103074. * Define bias applied to computed fresnel term
  103075. */
  103076. bias?: number;
  103077. /**
  103078. * Defined the power exponent applied to fresnel term
  103079. */
  103080. power?: number;
  103081. /**
  103082. * Define if the fresnel effect is enable or not.
  103083. */
  103084. isEnabled?: boolean;
  103085. };
  103086. /**
  103087. * Serialized format for FresnelParameters.
  103088. */
  103089. export type IFresnelParametersSerialized = {
  103090. /**
  103091. * Define the color used on edges (grazing angle) [as an array]
  103092. */
  103093. leftColor: number[];
  103094. /**
  103095. * Define the color used on center [as an array]
  103096. */
  103097. rightColor: number[];
  103098. /**
  103099. * Define bias applied to computed fresnel term
  103100. */
  103101. bias: number;
  103102. /**
  103103. * Defined the power exponent applied to fresnel term
  103104. */
  103105. power?: number;
  103106. /**
  103107. * Define if the fresnel effect is enable or not.
  103108. */
  103109. isEnabled: boolean;
  103110. };
  103111. /**
  103112. * This represents all the required information to add a fresnel effect on a material:
  103113. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103114. */
  103115. export class FresnelParameters {
  103116. private _isEnabled;
  103117. /**
  103118. * Define if the fresnel effect is enable or not.
  103119. */
  103120. get isEnabled(): boolean;
  103121. set isEnabled(value: boolean);
  103122. /**
  103123. * Define the color used on edges (grazing angle)
  103124. */
  103125. leftColor: Color3;
  103126. /**
  103127. * Define the color used on center
  103128. */
  103129. rightColor: Color3;
  103130. /**
  103131. * Define bias applied to computed fresnel term
  103132. */
  103133. bias: number;
  103134. /**
  103135. * Defined the power exponent applied to fresnel term
  103136. */
  103137. power: number;
  103138. /**
  103139. * Creates a new FresnelParameters object.
  103140. *
  103141. * @param options provide your own settings to optionally to override defaults
  103142. */
  103143. constructor(options?: IFresnelParametersCreationOptions);
  103144. /**
  103145. * Clones the current fresnel and its valuues
  103146. * @returns a clone fresnel configuration
  103147. */
  103148. clone(): FresnelParameters;
  103149. /**
  103150. * Determines equality between FresnelParameters objects
  103151. * @param otherFresnelParameters defines the second operand
  103152. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103153. */
  103154. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103155. /**
  103156. * Serializes the current fresnel parameters to a JSON representation.
  103157. * @return the JSON serialization
  103158. */
  103159. serialize(): IFresnelParametersSerialized;
  103160. /**
  103161. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103162. * @param parsedFresnelParameters Define the JSON representation
  103163. * @returns the parsed parameters
  103164. */
  103165. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103166. }
  103167. }
  103168. declare module BABYLON {
  103169. /**
  103170. * This groups all the flags used to control the materials channel.
  103171. */
  103172. export class MaterialFlags {
  103173. private static _DiffuseTextureEnabled;
  103174. /**
  103175. * Are diffuse textures enabled in the application.
  103176. */
  103177. static get DiffuseTextureEnabled(): boolean;
  103178. static set DiffuseTextureEnabled(value: boolean);
  103179. private static _DetailTextureEnabled;
  103180. /**
  103181. * Are detail textures enabled in the application.
  103182. */
  103183. static get DetailTextureEnabled(): boolean;
  103184. static set DetailTextureEnabled(value: boolean);
  103185. private static _AmbientTextureEnabled;
  103186. /**
  103187. * Are ambient textures enabled in the application.
  103188. */
  103189. static get AmbientTextureEnabled(): boolean;
  103190. static set AmbientTextureEnabled(value: boolean);
  103191. private static _OpacityTextureEnabled;
  103192. /**
  103193. * Are opacity textures enabled in the application.
  103194. */
  103195. static get OpacityTextureEnabled(): boolean;
  103196. static set OpacityTextureEnabled(value: boolean);
  103197. private static _ReflectionTextureEnabled;
  103198. /**
  103199. * Are reflection textures enabled in the application.
  103200. */
  103201. static get ReflectionTextureEnabled(): boolean;
  103202. static set ReflectionTextureEnabled(value: boolean);
  103203. private static _EmissiveTextureEnabled;
  103204. /**
  103205. * Are emissive textures enabled in the application.
  103206. */
  103207. static get EmissiveTextureEnabled(): boolean;
  103208. static set EmissiveTextureEnabled(value: boolean);
  103209. private static _SpecularTextureEnabled;
  103210. /**
  103211. * Are specular textures enabled in the application.
  103212. */
  103213. static get SpecularTextureEnabled(): boolean;
  103214. static set SpecularTextureEnabled(value: boolean);
  103215. private static _BumpTextureEnabled;
  103216. /**
  103217. * Are bump textures enabled in the application.
  103218. */
  103219. static get BumpTextureEnabled(): boolean;
  103220. static set BumpTextureEnabled(value: boolean);
  103221. private static _LightmapTextureEnabled;
  103222. /**
  103223. * Are lightmap textures enabled in the application.
  103224. */
  103225. static get LightmapTextureEnabled(): boolean;
  103226. static set LightmapTextureEnabled(value: boolean);
  103227. private static _RefractionTextureEnabled;
  103228. /**
  103229. * Are refraction textures enabled in the application.
  103230. */
  103231. static get RefractionTextureEnabled(): boolean;
  103232. static set RefractionTextureEnabled(value: boolean);
  103233. private static _ColorGradingTextureEnabled;
  103234. /**
  103235. * Are color grading textures enabled in the application.
  103236. */
  103237. static get ColorGradingTextureEnabled(): boolean;
  103238. static set ColorGradingTextureEnabled(value: boolean);
  103239. private static _FresnelEnabled;
  103240. /**
  103241. * Are fresnels enabled in the application.
  103242. */
  103243. static get FresnelEnabled(): boolean;
  103244. static set FresnelEnabled(value: boolean);
  103245. private static _ClearCoatTextureEnabled;
  103246. /**
  103247. * Are clear coat textures enabled in the application.
  103248. */
  103249. static get ClearCoatTextureEnabled(): boolean;
  103250. static set ClearCoatTextureEnabled(value: boolean);
  103251. private static _ClearCoatBumpTextureEnabled;
  103252. /**
  103253. * Are clear coat bump textures enabled in the application.
  103254. */
  103255. static get ClearCoatBumpTextureEnabled(): boolean;
  103256. static set ClearCoatBumpTextureEnabled(value: boolean);
  103257. private static _ClearCoatTintTextureEnabled;
  103258. /**
  103259. * Are clear coat tint textures enabled in the application.
  103260. */
  103261. static get ClearCoatTintTextureEnabled(): boolean;
  103262. static set ClearCoatTintTextureEnabled(value: boolean);
  103263. private static _SheenTextureEnabled;
  103264. /**
  103265. * Are sheen textures enabled in the application.
  103266. */
  103267. static get SheenTextureEnabled(): boolean;
  103268. static set SheenTextureEnabled(value: boolean);
  103269. private static _AnisotropicTextureEnabled;
  103270. /**
  103271. * Are anisotropic textures enabled in the application.
  103272. */
  103273. static get AnisotropicTextureEnabled(): boolean;
  103274. static set AnisotropicTextureEnabled(value: boolean);
  103275. private static _ThicknessTextureEnabled;
  103276. /**
  103277. * Are thickness textures enabled in the application.
  103278. */
  103279. static get ThicknessTextureEnabled(): boolean;
  103280. static set ThicknessTextureEnabled(value: boolean);
  103281. }
  103282. }
  103283. declare module BABYLON {
  103284. /** @hidden */
  103285. export var defaultFragmentDeclaration: {
  103286. name: string;
  103287. shader: string;
  103288. };
  103289. }
  103290. declare module BABYLON {
  103291. /** @hidden */
  103292. export var sceneUboDeclaration: {
  103293. name: string;
  103294. shader: string;
  103295. };
  103296. }
  103297. declare module BABYLON {
  103298. /** @hidden */
  103299. export var meshUboDeclaration: {
  103300. name: string;
  103301. shader: string;
  103302. };
  103303. }
  103304. declare module BABYLON {
  103305. /** @hidden */
  103306. export var defaultUboDeclaration: {
  103307. name: string;
  103308. shader: string;
  103309. };
  103310. }
  103311. declare module BABYLON {
  103312. /** @hidden */
  103313. export var prePassDeclaration: {
  103314. name: string;
  103315. shader: string;
  103316. };
  103317. }
  103318. declare module BABYLON {
  103319. /** @hidden */
  103320. export var lightFragmentDeclaration: {
  103321. name: string;
  103322. shader: string;
  103323. };
  103324. }
  103325. declare module BABYLON {
  103326. /** @hidden */
  103327. export var lightUboDeclaration: {
  103328. name: string;
  103329. shader: string;
  103330. };
  103331. }
  103332. declare module BABYLON {
  103333. /** @hidden */
  103334. export var lightsFragmentFunctions: {
  103335. name: string;
  103336. shader: string;
  103337. };
  103338. }
  103339. declare module BABYLON {
  103340. /** @hidden */
  103341. export var shadowsFragmentFunctions: {
  103342. name: string;
  103343. shader: string;
  103344. };
  103345. }
  103346. declare module BABYLON {
  103347. /** @hidden */
  103348. export var fresnelFunction: {
  103349. name: string;
  103350. shader: string;
  103351. };
  103352. }
  103353. declare module BABYLON {
  103354. /** @hidden */
  103355. export var bumpFragmentMainFunctions: {
  103356. name: string;
  103357. shader: string;
  103358. };
  103359. }
  103360. declare module BABYLON {
  103361. /** @hidden */
  103362. export var bumpFragmentFunctions: {
  103363. name: string;
  103364. shader: string;
  103365. };
  103366. }
  103367. declare module BABYLON {
  103368. /** @hidden */
  103369. export var logDepthDeclaration: {
  103370. name: string;
  103371. shader: string;
  103372. };
  103373. }
  103374. declare module BABYLON {
  103375. /** @hidden */
  103376. export var fogFragmentDeclaration: {
  103377. name: string;
  103378. shader: string;
  103379. };
  103380. }
  103381. declare module BABYLON {
  103382. /** @hidden */
  103383. export var bumpFragment: {
  103384. name: string;
  103385. shader: string;
  103386. };
  103387. }
  103388. declare module BABYLON {
  103389. /** @hidden */
  103390. export var depthPrePass: {
  103391. name: string;
  103392. shader: string;
  103393. };
  103394. }
  103395. declare module BABYLON {
  103396. /** @hidden */
  103397. export var lightFragment: {
  103398. name: string;
  103399. shader: string;
  103400. };
  103401. }
  103402. declare module BABYLON {
  103403. /** @hidden */
  103404. export var logDepthFragment: {
  103405. name: string;
  103406. shader: string;
  103407. };
  103408. }
  103409. declare module BABYLON {
  103410. /** @hidden */
  103411. export var fogFragment: {
  103412. name: string;
  103413. shader: string;
  103414. };
  103415. }
  103416. declare module BABYLON {
  103417. /** @hidden */
  103418. export var defaultPixelShader: {
  103419. name: string;
  103420. shader: string;
  103421. };
  103422. }
  103423. declare module BABYLON {
  103424. /** @hidden */
  103425. export var defaultVertexDeclaration: {
  103426. name: string;
  103427. shader: string;
  103428. };
  103429. }
  103430. declare module BABYLON {
  103431. /** @hidden */
  103432. export var bonesDeclaration: {
  103433. name: string;
  103434. shader: string;
  103435. };
  103436. }
  103437. declare module BABYLON {
  103438. /** @hidden */
  103439. export var prePassVertexDeclaration: {
  103440. name: string;
  103441. shader: string;
  103442. };
  103443. }
  103444. declare module BABYLON {
  103445. /** @hidden */
  103446. export var bumpVertexDeclaration: {
  103447. name: string;
  103448. shader: string;
  103449. };
  103450. }
  103451. declare module BABYLON {
  103452. /** @hidden */
  103453. export var fogVertexDeclaration: {
  103454. name: string;
  103455. shader: string;
  103456. };
  103457. }
  103458. declare module BABYLON {
  103459. /** @hidden */
  103460. export var lightVxFragmentDeclaration: {
  103461. name: string;
  103462. shader: string;
  103463. };
  103464. }
  103465. declare module BABYLON {
  103466. /** @hidden */
  103467. export var lightVxUboDeclaration: {
  103468. name: string;
  103469. shader: string;
  103470. };
  103471. }
  103472. declare module BABYLON {
  103473. /** @hidden */
  103474. export var morphTargetsVertexGlobalDeclaration: {
  103475. name: string;
  103476. shader: string;
  103477. };
  103478. }
  103479. declare module BABYLON {
  103480. /** @hidden */
  103481. export var morphTargetsVertexDeclaration: {
  103482. name: string;
  103483. shader: string;
  103484. };
  103485. }
  103486. declare module BABYLON {
  103487. /** @hidden */
  103488. export var morphTargetsVertex: {
  103489. name: string;
  103490. shader: string;
  103491. };
  103492. }
  103493. declare module BABYLON {
  103494. /** @hidden */
  103495. export var instancesVertex: {
  103496. name: string;
  103497. shader: string;
  103498. };
  103499. }
  103500. declare module BABYLON {
  103501. /** @hidden */
  103502. export var bonesVertex: {
  103503. name: string;
  103504. shader: string;
  103505. };
  103506. }
  103507. declare module BABYLON {
  103508. /** @hidden */
  103509. export var prePassVertex: {
  103510. name: string;
  103511. shader: string;
  103512. };
  103513. }
  103514. declare module BABYLON {
  103515. /** @hidden */
  103516. export var bumpVertex: {
  103517. name: string;
  103518. shader: string;
  103519. };
  103520. }
  103521. declare module BABYLON {
  103522. /** @hidden */
  103523. export var fogVertex: {
  103524. name: string;
  103525. shader: string;
  103526. };
  103527. }
  103528. declare module BABYLON {
  103529. /** @hidden */
  103530. export var shadowsVertex: {
  103531. name: string;
  103532. shader: string;
  103533. };
  103534. }
  103535. declare module BABYLON {
  103536. /** @hidden */
  103537. export var pointCloudVertex: {
  103538. name: string;
  103539. shader: string;
  103540. };
  103541. }
  103542. declare module BABYLON {
  103543. /** @hidden */
  103544. export var logDepthVertex: {
  103545. name: string;
  103546. shader: string;
  103547. };
  103548. }
  103549. declare module BABYLON {
  103550. /** @hidden */
  103551. export var defaultVertexShader: {
  103552. name: string;
  103553. shader: string;
  103554. };
  103555. }
  103556. declare module BABYLON {
  103557. /**
  103558. * @hidden
  103559. */
  103560. export interface IMaterialDetailMapDefines {
  103561. DETAIL: boolean;
  103562. DETAILDIRECTUV: number;
  103563. DETAIL_NORMALBLENDMETHOD: number;
  103564. /** @hidden */
  103565. _areTexturesDirty: boolean;
  103566. }
  103567. /**
  103568. * Define the code related to the detail map parameters of a material
  103569. *
  103570. * Inspired from:
  103571. * 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
  103572. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  103573. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  103574. */
  103575. export class DetailMapConfiguration {
  103576. private _texture;
  103577. /**
  103578. * The detail texture of the material.
  103579. */
  103580. texture: Nullable<BaseTexture>;
  103581. /**
  103582. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  103583. * Bigger values mean stronger blending
  103584. */
  103585. diffuseBlendLevel: number;
  103586. /**
  103587. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  103588. * Bigger values mean stronger blending. Only used with PBR materials
  103589. */
  103590. roughnessBlendLevel: number;
  103591. /**
  103592. * Defines how strong the bump effect from the detail map is
  103593. * Bigger values mean stronger effect
  103594. */
  103595. bumpLevel: number;
  103596. private _normalBlendMethod;
  103597. /**
  103598. * The method used to blend the bump and detail normals together
  103599. */
  103600. normalBlendMethod: number;
  103601. private _isEnabled;
  103602. /**
  103603. * Enable or disable the detail map on this material
  103604. */
  103605. isEnabled: boolean;
  103606. /** @hidden */
  103607. private _internalMarkAllSubMeshesAsTexturesDirty;
  103608. /** @hidden */
  103609. _markAllSubMeshesAsTexturesDirty(): void;
  103610. /**
  103611. * Instantiate a new detail map
  103612. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103613. */
  103614. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103615. /**
  103616. * Gets whether the submesh is ready to be used or not.
  103617. * @param defines the list of "defines" to update.
  103618. * @param scene defines the scene the material belongs to.
  103619. * @returns - boolean indicating that the submesh is ready or not.
  103620. */
  103621. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  103622. /**
  103623. * Update the defines for detail map usage
  103624. * @param defines the list of "defines" to update.
  103625. * @param scene defines the scene the material belongs to.
  103626. */
  103627. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  103628. /**
  103629. * Binds the material data.
  103630. * @param uniformBuffer defines the Uniform buffer to fill in.
  103631. * @param scene defines the scene the material belongs to.
  103632. * @param isFrozen defines whether the material is frozen or not.
  103633. */
  103634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103635. /**
  103636. * Checks to see if a texture is used in the material.
  103637. * @param texture - Base texture to use.
  103638. * @returns - Boolean specifying if a texture is used in the material.
  103639. */
  103640. hasTexture(texture: BaseTexture): boolean;
  103641. /**
  103642. * Returns an array of the actively used textures.
  103643. * @param activeTextures Array of BaseTextures
  103644. */
  103645. getActiveTextures(activeTextures: BaseTexture[]): void;
  103646. /**
  103647. * Returns the animatable textures.
  103648. * @param animatables Array of animatable textures.
  103649. */
  103650. getAnimatables(animatables: IAnimatable[]): void;
  103651. /**
  103652. * Disposes the resources of the material.
  103653. * @param forceDisposeTextures - Forces the disposal of all textures.
  103654. */
  103655. dispose(forceDisposeTextures?: boolean): void;
  103656. /**
  103657. * Get the current class name useful for serialization or dynamic coding.
  103658. * @returns "DetailMap"
  103659. */
  103660. getClassName(): string;
  103661. /**
  103662. * Add the required uniforms to the current list.
  103663. * @param uniforms defines the current uniform list.
  103664. */
  103665. static AddUniforms(uniforms: string[]): void;
  103666. /**
  103667. * Add the required samplers to the current list.
  103668. * @param samplers defines the current sampler list.
  103669. */
  103670. static AddSamplers(samplers: string[]): void;
  103671. /**
  103672. * Add the required uniforms to the current buffer.
  103673. * @param uniformBuffer defines the current uniform buffer.
  103674. */
  103675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103676. /**
  103677. * Makes a duplicate of the current instance into another one.
  103678. * @param detailMap define the instance where to copy the info
  103679. */
  103680. copyTo(detailMap: DetailMapConfiguration): void;
  103681. /**
  103682. * Serializes this detail map instance
  103683. * @returns - An object with the serialized instance.
  103684. */
  103685. serialize(): any;
  103686. /**
  103687. * Parses a detail map setting from a serialized object.
  103688. * @param source - Serialized object.
  103689. * @param scene Defines the scene we are parsing for
  103690. * @param rootUrl Defines the rootUrl to load from
  103691. */
  103692. parse(source: any, scene: Scene, rootUrl: string): void;
  103693. }
  103694. }
  103695. declare module BABYLON {
  103696. /** @hidden */
  103697. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  103698. MAINUV1: boolean;
  103699. MAINUV2: boolean;
  103700. DIFFUSE: boolean;
  103701. DIFFUSEDIRECTUV: number;
  103702. DETAIL: boolean;
  103703. DETAILDIRECTUV: number;
  103704. DETAIL_NORMALBLENDMETHOD: number;
  103705. AMBIENT: boolean;
  103706. AMBIENTDIRECTUV: number;
  103707. OPACITY: boolean;
  103708. OPACITYDIRECTUV: number;
  103709. OPACITYRGB: boolean;
  103710. REFLECTION: boolean;
  103711. EMISSIVE: boolean;
  103712. EMISSIVEDIRECTUV: number;
  103713. SPECULAR: boolean;
  103714. SPECULARDIRECTUV: number;
  103715. BUMP: boolean;
  103716. BUMPDIRECTUV: number;
  103717. PARALLAX: boolean;
  103718. PARALLAXOCCLUSION: boolean;
  103719. SPECULAROVERALPHA: boolean;
  103720. CLIPPLANE: boolean;
  103721. CLIPPLANE2: boolean;
  103722. CLIPPLANE3: boolean;
  103723. CLIPPLANE4: boolean;
  103724. CLIPPLANE5: boolean;
  103725. CLIPPLANE6: boolean;
  103726. ALPHATEST: boolean;
  103727. DEPTHPREPASS: boolean;
  103728. ALPHAFROMDIFFUSE: boolean;
  103729. POINTSIZE: boolean;
  103730. FOG: boolean;
  103731. SPECULARTERM: boolean;
  103732. DIFFUSEFRESNEL: boolean;
  103733. OPACITYFRESNEL: boolean;
  103734. REFLECTIONFRESNEL: boolean;
  103735. REFRACTIONFRESNEL: boolean;
  103736. EMISSIVEFRESNEL: boolean;
  103737. FRESNEL: boolean;
  103738. NORMAL: boolean;
  103739. UV1: boolean;
  103740. UV2: boolean;
  103741. VERTEXCOLOR: boolean;
  103742. VERTEXALPHA: boolean;
  103743. NUM_BONE_INFLUENCERS: number;
  103744. BonesPerMesh: number;
  103745. BONETEXTURE: boolean;
  103746. BONES_VELOCITY_ENABLED: boolean;
  103747. INSTANCES: boolean;
  103748. THIN_INSTANCES: boolean;
  103749. GLOSSINESS: boolean;
  103750. ROUGHNESS: boolean;
  103751. EMISSIVEASILLUMINATION: boolean;
  103752. LINKEMISSIVEWITHDIFFUSE: boolean;
  103753. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103754. LIGHTMAP: boolean;
  103755. LIGHTMAPDIRECTUV: number;
  103756. OBJECTSPACE_NORMALMAP: boolean;
  103757. USELIGHTMAPASSHADOWMAP: boolean;
  103758. REFLECTIONMAP_3D: boolean;
  103759. REFLECTIONMAP_SPHERICAL: boolean;
  103760. REFLECTIONMAP_PLANAR: boolean;
  103761. REFLECTIONMAP_CUBIC: boolean;
  103762. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103763. REFLECTIONMAP_PROJECTION: boolean;
  103764. REFLECTIONMAP_SKYBOX: boolean;
  103765. REFLECTIONMAP_EXPLICIT: boolean;
  103766. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103767. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103768. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103769. INVERTCUBICMAP: boolean;
  103770. LOGARITHMICDEPTH: boolean;
  103771. REFRACTION: boolean;
  103772. REFRACTIONMAP_3D: boolean;
  103773. REFLECTIONOVERALPHA: boolean;
  103774. TWOSIDEDLIGHTING: boolean;
  103775. SHADOWFLOAT: boolean;
  103776. MORPHTARGETS: boolean;
  103777. MORPHTARGETS_NORMAL: boolean;
  103778. MORPHTARGETS_TANGENT: boolean;
  103779. MORPHTARGETS_UV: boolean;
  103780. NUM_MORPH_INFLUENCERS: number;
  103781. NONUNIFORMSCALING: boolean;
  103782. PREMULTIPLYALPHA: boolean;
  103783. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  103784. ALPHABLEND: boolean;
  103785. PREPASS: boolean;
  103786. PREPASS_IRRADIANCE: boolean;
  103787. PREPASS_IRRADIANCE_INDEX: number;
  103788. PREPASS_ALBEDO: boolean;
  103789. PREPASS_ALBEDO_INDEX: number;
  103790. PREPASS_DEPTHNORMAL: boolean;
  103791. PREPASS_DEPTHNORMAL_INDEX: number;
  103792. PREPASS_POSITION: boolean;
  103793. PREPASS_POSITION_INDEX: number;
  103794. PREPASS_VELOCITY: boolean;
  103795. PREPASS_VELOCITY_INDEX: number;
  103796. PREPASS_REFLECTIVITY: boolean;
  103797. PREPASS_REFLECTIVITY_INDEX: number;
  103798. SCENE_MRT_COUNT: number;
  103799. RGBDLIGHTMAP: boolean;
  103800. RGBDREFLECTION: boolean;
  103801. RGBDREFRACTION: boolean;
  103802. IMAGEPROCESSING: boolean;
  103803. VIGNETTE: boolean;
  103804. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103805. VIGNETTEBLENDMODEOPAQUE: boolean;
  103806. TONEMAPPING: boolean;
  103807. TONEMAPPING_ACES: boolean;
  103808. CONTRAST: boolean;
  103809. COLORCURVES: boolean;
  103810. COLORGRADING: boolean;
  103811. COLORGRADING3D: boolean;
  103812. SAMPLER3DGREENDEPTH: boolean;
  103813. SAMPLER3DBGRMAP: boolean;
  103814. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103815. MULTIVIEW: boolean;
  103816. /**
  103817. * If the reflection texture on this material is in linear color space
  103818. * @hidden
  103819. */
  103820. IS_REFLECTION_LINEAR: boolean;
  103821. /**
  103822. * If the refraction texture on this material is in linear color space
  103823. * @hidden
  103824. */
  103825. IS_REFRACTION_LINEAR: boolean;
  103826. EXPOSURE: boolean;
  103827. constructor();
  103828. setReflectionMode(modeToEnable: string): void;
  103829. }
  103830. /**
  103831. * This is the default material used in Babylon. It is the best trade off between quality
  103832. * and performances.
  103833. * @see https://doc.babylonjs.com/babylon101/materials
  103834. */
  103835. export class StandardMaterial extends PushMaterial {
  103836. private _diffuseTexture;
  103837. /**
  103838. * The basic texture of the material as viewed under a light.
  103839. */
  103840. diffuseTexture: Nullable<BaseTexture>;
  103841. private _ambientTexture;
  103842. /**
  103843. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103844. */
  103845. ambientTexture: Nullable<BaseTexture>;
  103846. private _opacityTexture;
  103847. /**
  103848. * Define the transparency of the material from a texture.
  103849. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103850. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103851. */
  103852. opacityTexture: Nullable<BaseTexture>;
  103853. private _reflectionTexture;
  103854. /**
  103855. * Define the texture used to display the reflection.
  103856. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103857. */
  103858. reflectionTexture: Nullable<BaseTexture>;
  103859. private _emissiveTexture;
  103860. /**
  103861. * Define texture of the material as if self lit.
  103862. * This will be mixed in the final result even in the absence of light.
  103863. */
  103864. emissiveTexture: Nullable<BaseTexture>;
  103865. private _specularTexture;
  103866. /**
  103867. * Define how the color and intensity of the highlight given by the light in the material.
  103868. */
  103869. specularTexture: Nullable<BaseTexture>;
  103870. private _bumpTexture;
  103871. /**
  103872. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103873. * 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.
  103874. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  103875. */
  103876. bumpTexture: Nullable<BaseTexture>;
  103877. private _lightmapTexture;
  103878. /**
  103879. * Complex lighting can be computationally expensive to compute at runtime.
  103880. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103881. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  103882. */
  103883. lightmapTexture: Nullable<BaseTexture>;
  103884. private _refractionTexture;
  103885. /**
  103886. * Define the texture used to display the refraction.
  103887. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103888. */
  103889. refractionTexture: Nullable<BaseTexture>;
  103890. /**
  103891. * The color of the material lit by the environmental background lighting.
  103892. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103893. */
  103894. ambientColor: Color3;
  103895. /**
  103896. * The basic color of the material as viewed under a light.
  103897. */
  103898. diffuseColor: Color3;
  103899. /**
  103900. * Define how the color and intensity of the highlight given by the light in the material.
  103901. */
  103902. specularColor: Color3;
  103903. /**
  103904. * Define the color of the material as if self lit.
  103905. * This will be mixed in the final result even in the absence of light.
  103906. */
  103907. emissiveColor: Color3;
  103908. /**
  103909. * Defines how sharp are the highlights in the material.
  103910. * The bigger the value the sharper giving a more glossy feeling to the result.
  103911. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103912. */
  103913. specularPower: number;
  103914. private _useAlphaFromDiffuseTexture;
  103915. /**
  103916. * Does the transparency come from the diffuse texture alpha channel.
  103917. */
  103918. useAlphaFromDiffuseTexture: boolean;
  103919. private _useEmissiveAsIllumination;
  103920. /**
  103921. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103922. */
  103923. useEmissiveAsIllumination: boolean;
  103924. private _linkEmissiveWithDiffuse;
  103925. /**
  103926. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103927. * the emissive level when the final color is close to one.
  103928. */
  103929. linkEmissiveWithDiffuse: boolean;
  103930. private _useSpecularOverAlpha;
  103931. /**
  103932. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103933. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103934. */
  103935. useSpecularOverAlpha: boolean;
  103936. private _useReflectionOverAlpha;
  103937. /**
  103938. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103939. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103940. */
  103941. useReflectionOverAlpha: boolean;
  103942. private _disableLighting;
  103943. /**
  103944. * Does lights from the scene impacts this material.
  103945. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103946. */
  103947. disableLighting: boolean;
  103948. private _useObjectSpaceNormalMap;
  103949. /**
  103950. * Allows using an object space normal map (instead of tangent space).
  103951. */
  103952. useObjectSpaceNormalMap: boolean;
  103953. private _useParallax;
  103954. /**
  103955. * Is parallax enabled or not.
  103956. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  103957. */
  103958. useParallax: boolean;
  103959. private _useParallaxOcclusion;
  103960. /**
  103961. * Is parallax occlusion enabled or not.
  103962. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103963. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  103964. */
  103965. useParallaxOcclusion: boolean;
  103966. /**
  103967. * 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.
  103968. */
  103969. parallaxScaleBias: number;
  103970. private _roughness;
  103971. /**
  103972. * Helps to define how blurry the reflections should appears in the material.
  103973. */
  103974. roughness: number;
  103975. /**
  103976. * In case of refraction, define the value of the index of refraction.
  103977. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103978. */
  103979. indexOfRefraction: number;
  103980. /**
  103981. * Invert the refraction texture alongside the y axis.
  103982. * It can be useful with procedural textures or probe for instance.
  103983. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103984. */
  103985. invertRefractionY: boolean;
  103986. /**
  103987. * Defines the alpha limits in alpha test mode.
  103988. */
  103989. alphaCutOff: number;
  103990. private _useLightmapAsShadowmap;
  103991. /**
  103992. * In case of light mapping, define whether the map contains light or shadow informations.
  103993. */
  103994. useLightmapAsShadowmap: boolean;
  103995. private _diffuseFresnelParameters;
  103996. /**
  103997. * Define the diffuse fresnel parameters of the material.
  103998. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103999. */
  104000. diffuseFresnelParameters: FresnelParameters;
  104001. private _opacityFresnelParameters;
  104002. /**
  104003. * Define the opacity fresnel parameters of the material.
  104004. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104005. */
  104006. opacityFresnelParameters: FresnelParameters;
  104007. private _reflectionFresnelParameters;
  104008. /**
  104009. * Define the reflection fresnel parameters of the material.
  104010. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104011. */
  104012. reflectionFresnelParameters: FresnelParameters;
  104013. private _refractionFresnelParameters;
  104014. /**
  104015. * Define the refraction fresnel parameters of the material.
  104016. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104017. */
  104018. refractionFresnelParameters: FresnelParameters;
  104019. private _emissiveFresnelParameters;
  104020. /**
  104021. * Define the emissive fresnel parameters of the material.
  104022. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104023. */
  104024. emissiveFresnelParameters: FresnelParameters;
  104025. private _useReflectionFresnelFromSpecular;
  104026. /**
  104027. * If true automatically deducts the fresnels values from the material specularity.
  104028. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104029. */
  104030. useReflectionFresnelFromSpecular: boolean;
  104031. private _useGlossinessFromSpecularMapAlpha;
  104032. /**
  104033. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104034. */
  104035. useGlossinessFromSpecularMapAlpha: boolean;
  104036. private _maxSimultaneousLights;
  104037. /**
  104038. * Defines the maximum number of lights that can be used in the material
  104039. */
  104040. maxSimultaneousLights: number;
  104041. private _invertNormalMapX;
  104042. /**
  104043. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104044. */
  104045. invertNormalMapX: boolean;
  104046. private _invertNormalMapY;
  104047. /**
  104048. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104049. */
  104050. invertNormalMapY: boolean;
  104051. private _twoSidedLighting;
  104052. /**
  104053. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104054. */
  104055. twoSidedLighting: boolean;
  104056. /**
  104057. * Default configuration related to image processing available in the standard Material.
  104058. */
  104059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104060. /**
  104061. * Gets the image processing configuration used either in this material.
  104062. */
  104063. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104064. /**
  104065. * Sets the Default image processing configuration used either in the this material.
  104066. *
  104067. * If sets to null, the scene one is in use.
  104068. */
  104069. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104070. /**
  104071. * Keep track of the image processing observer to allow dispose and replace.
  104072. */
  104073. private _imageProcessingObserver;
  104074. /**
  104075. * Attaches a new image processing configuration to the Standard Material.
  104076. * @param configuration
  104077. */
  104078. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104079. /**
  104080. * Defines additionnal PrePass parameters for the material.
  104081. */
  104082. readonly prePassConfiguration: PrePassConfiguration;
  104083. /**
  104084. * Gets wether the color curves effect is enabled.
  104085. */
  104086. get cameraColorCurvesEnabled(): boolean;
  104087. /**
  104088. * Sets wether the color curves effect is enabled.
  104089. */
  104090. set cameraColorCurvesEnabled(value: boolean);
  104091. /**
  104092. * Gets wether the color grading effect is enabled.
  104093. */
  104094. get cameraColorGradingEnabled(): boolean;
  104095. /**
  104096. * Gets wether the color grading effect is enabled.
  104097. */
  104098. set cameraColorGradingEnabled(value: boolean);
  104099. /**
  104100. * Gets wether tonemapping is enabled or not.
  104101. */
  104102. get cameraToneMappingEnabled(): boolean;
  104103. /**
  104104. * Sets wether tonemapping is enabled or not
  104105. */
  104106. set cameraToneMappingEnabled(value: boolean);
  104107. /**
  104108. * The camera exposure used on this material.
  104109. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104110. * This corresponds to a photographic exposure.
  104111. */
  104112. get cameraExposure(): number;
  104113. /**
  104114. * The camera exposure used on this material.
  104115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104116. * This corresponds to a photographic exposure.
  104117. */
  104118. set cameraExposure(value: number);
  104119. /**
  104120. * Gets The camera contrast used on this material.
  104121. */
  104122. get cameraContrast(): number;
  104123. /**
  104124. * Sets The camera contrast used on this material.
  104125. */
  104126. set cameraContrast(value: number);
  104127. /**
  104128. * Gets the Color Grading 2D Lookup Texture.
  104129. */
  104130. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104131. /**
  104132. * Sets the Color Grading 2D Lookup Texture.
  104133. */
  104134. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104135. /**
  104136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104138. * 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;
  104139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104140. */
  104141. get cameraColorCurves(): Nullable<ColorCurves>;
  104142. /**
  104143. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104144. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104145. * 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;
  104146. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104147. */
  104148. set cameraColorCurves(value: Nullable<ColorCurves>);
  104149. /**
  104150. * Can this material render to several textures at once
  104151. */
  104152. get canRenderToMRT(): boolean;
  104153. /**
  104154. * Defines the detail map parameters for the material.
  104155. */
  104156. readonly detailMap: DetailMapConfiguration;
  104157. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104158. protected _worldViewProjectionMatrix: Matrix;
  104159. protected _globalAmbientColor: Color3;
  104160. protected _useLogarithmicDepth: boolean;
  104161. protected _rebuildInParallel: boolean;
  104162. /**
  104163. * Instantiates a new standard material.
  104164. * This is the default material used in Babylon. It is the best trade off between quality
  104165. * and performances.
  104166. * @see https://doc.babylonjs.com/babylon101/materials
  104167. * @param name Define the name of the material in the scene
  104168. * @param scene Define the scene the material belong to
  104169. */
  104170. constructor(name: string, scene: Scene);
  104171. /**
  104172. * Gets a boolean indicating that current material needs to register RTT
  104173. */
  104174. get hasRenderTargetTextures(): boolean;
  104175. /**
  104176. * Gets the current class name of the material e.g. "StandardMaterial"
  104177. * Mainly use in serialization.
  104178. * @returns the class name
  104179. */
  104180. getClassName(): string;
  104181. /**
  104182. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104183. * You can try switching to logarithmic depth.
  104184. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104185. */
  104186. get useLogarithmicDepth(): boolean;
  104187. set useLogarithmicDepth(value: boolean);
  104188. /**
  104189. * Specifies if the material will require alpha blending
  104190. * @returns a boolean specifying if alpha blending is needed
  104191. */
  104192. needAlphaBlending(): boolean;
  104193. /**
  104194. * Specifies if this material should be rendered in alpha test mode
  104195. * @returns a boolean specifying if an alpha test is needed.
  104196. */
  104197. needAlphaTesting(): boolean;
  104198. /**
  104199. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  104200. */
  104201. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104202. /**
  104203. * Specifies whether or not there is a usable alpha channel for transparency.
  104204. */
  104205. protected _hasAlphaChannel(): boolean;
  104206. /**
  104207. * Get the texture used for alpha test purpose.
  104208. * @returns the diffuse texture in case of the standard material.
  104209. */
  104210. getAlphaTestTexture(): Nullable<BaseTexture>;
  104211. /**
  104212. * Get if the submesh is ready to be used and all its information available.
  104213. * Child classes can use it to update shaders
  104214. * @param mesh defines the mesh to check
  104215. * @param subMesh defines which submesh to check
  104216. * @param useInstances specifies that instances should be used
  104217. * @returns a boolean indicating that the submesh is ready or not
  104218. */
  104219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104220. /**
  104221. * Builds the material UBO layouts.
  104222. * Used internally during the effect preparation.
  104223. */
  104224. buildUniformLayout(): void;
  104225. /**
  104226. * Unbinds the material from the mesh
  104227. */
  104228. unbind(): void;
  104229. /**
  104230. * Binds the submesh to this material by preparing the effect and shader to draw
  104231. * @param world defines the world transformation matrix
  104232. * @param mesh defines the mesh containing the submesh
  104233. * @param subMesh defines the submesh to bind the material to
  104234. */
  104235. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104236. /**
  104237. * Get the list of animatables in the material.
  104238. * @returns the list of animatables object used in the material
  104239. */
  104240. getAnimatables(): IAnimatable[];
  104241. /**
  104242. * Gets the active textures from the material
  104243. * @returns an array of textures
  104244. */
  104245. getActiveTextures(): BaseTexture[];
  104246. /**
  104247. * Specifies if the material uses a texture
  104248. * @param texture defines the texture to check against the material
  104249. * @returns a boolean specifying if the material uses the texture
  104250. */
  104251. hasTexture(texture: BaseTexture): boolean;
  104252. /**
  104253. * Disposes the material
  104254. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104255. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104256. */
  104257. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104258. /**
  104259. * Makes a duplicate of the material, and gives it a new name
  104260. * @param name defines the new name for the duplicated material
  104261. * @returns the cloned material
  104262. */
  104263. clone(name: string): StandardMaterial;
  104264. /**
  104265. * Serializes this material in a JSON representation
  104266. * @returns the serialized material object
  104267. */
  104268. serialize(): any;
  104269. /**
  104270. * Creates a standard material from parsed material data
  104271. * @param source defines the JSON representation of the material
  104272. * @param scene defines the hosting scene
  104273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104274. * @returns a new standard material
  104275. */
  104276. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104277. /**
  104278. * Are diffuse textures enabled in the application.
  104279. */
  104280. static get DiffuseTextureEnabled(): boolean;
  104281. static set DiffuseTextureEnabled(value: boolean);
  104282. /**
  104283. * Are detail textures enabled in the application.
  104284. */
  104285. static get DetailTextureEnabled(): boolean;
  104286. static set DetailTextureEnabled(value: boolean);
  104287. /**
  104288. * Are ambient textures enabled in the application.
  104289. */
  104290. static get AmbientTextureEnabled(): boolean;
  104291. static set AmbientTextureEnabled(value: boolean);
  104292. /**
  104293. * Are opacity textures enabled in the application.
  104294. */
  104295. static get OpacityTextureEnabled(): boolean;
  104296. static set OpacityTextureEnabled(value: boolean);
  104297. /**
  104298. * Are reflection textures enabled in the application.
  104299. */
  104300. static get ReflectionTextureEnabled(): boolean;
  104301. static set ReflectionTextureEnabled(value: boolean);
  104302. /**
  104303. * Are emissive textures enabled in the application.
  104304. */
  104305. static get EmissiveTextureEnabled(): boolean;
  104306. static set EmissiveTextureEnabled(value: boolean);
  104307. /**
  104308. * Are specular textures enabled in the application.
  104309. */
  104310. static get SpecularTextureEnabled(): boolean;
  104311. static set SpecularTextureEnabled(value: boolean);
  104312. /**
  104313. * Are bump textures enabled in the application.
  104314. */
  104315. static get BumpTextureEnabled(): boolean;
  104316. static set BumpTextureEnabled(value: boolean);
  104317. /**
  104318. * Are lightmap textures enabled in the application.
  104319. */
  104320. static get LightmapTextureEnabled(): boolean;
  104321. static set LightmapTextureEnabled(value: boolean);
  104322. /**
  104323. * Are refraction textures enabled in the application.
  104324. */
  104325. static get RefractionTextureEnabled(): boolean;
  104326. static set RefractionTextureEnabled(value: boolean);
  104327. /**
  104328. * Are color grading textures enabled in the application.
  104329. */
  104330. static get ColorGradingTextureEnabled(): boolean;
  104331. static set ColorGradingTextureEnabled(value: boolean);
  104332. /**
  104333. * Are fresnels enabled in the application.
  104334. */
  104335. static get FresnelEnabled(): boolean;
  104336. static set FresnelEnabled(value: boolean);
  104337. }
  104338. }
  104339. declare module BABYLON {
  104340. /** @hidden */
  104341. export var rgbdDecodePixelShader: {
  104342. name: string;
  104343. shader: string;
  104344. };
  104345. }
  104346. declare module BABYLON {
  104347. /** @hidden */
  104348. export var passPixelShader: {
  104349. name: string;
  104350. shader: string;
  104351. };
  104352. }
  104353. declare module BABYLON {
  104354. /** @hidden */
  104355. export var passCubePixelShader: {
  104356. name: string;
  104357. shader: string;
  104358. };
  104359. }
  104360. declare module BABYLON {
  104361. /**
  104362. * PassPostProcess which produces an output the same as it's input
  104363. */
  104364. export class PassPostProcess extends PostProcess {
  104365. /**
  104366. * Gets a string identifying the name of the class
  104367. * @returns "PassPostProcess" string
  104368. */
  104369. getClassName(): string;
  104370. /**
  104371. * Creates the PassPostProcess
  104372. * @param name The name of the effect.
  104373. * @param options The required width/height ratio to downsize to before computing the render pass.
  104374. * @param camera The camera to apply the render pass to.
  104375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104376. * @param engine The engine which the post process will be applied. (default: current engine)
  104377. * @param reusable If the post process can be reused on the same frame. (default: false)
  104378. * @param textureType The type of texture to be used when performing the post processing.
  104379. * @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)
  104380. */
  104381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104382. /** @hidden */
  104383. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  104384. }
  104385. /**
  104386. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104387. */
  104388. export class PassCubePostProcess extends PostProcess {
  104389. private _face;
  104390. /**
  104391. * Gets or sets the cube face to display.
  104392. * * 0 is +X
  104393. * * 1 is -X
  104394. * * 2 is +Y
  104395. * * 3 is -Y
  104396. * * 4 is +Z
  104397. * * 5 is -Z
  104398. */
  104399. get face(): number;
  104400. set face(value: number);
  104401. /**
  104402. * Gets a string identifying the name of the class
  104403. * @returns "PassCubePostProcess" string
  104404. */
  104405. getClassName(): string;
  104406. /**
  104407. * Creates the PassCubePostProcess
  104408. * @param name The name of the effect.
  104409. * @param options The required width/height ratio to downsize to before computing the render pass.
  104410. * @param camera The camera to apply the render pass to.
  104411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104412. * @param engine The engine which the post process will be applied. (default: current engine)
  104413. * @param reusable If the post process can be reused on the same frame. (default: false)
  104414. * @param textureType The type of texture to be used when performing the post processing.
  104415. * @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)
  104416. */
  104417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104418. /** @hidden */
  104419. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  104420. }
  104421. }
  104422. declare module BABYLON {
  104423. /**
  104424. * Class used to host texture specific utilities
  104425. */
  104426. export class TextureTools {
  104427. /**
  104428. * Uses the GPU to create a copy texture rescaled at a given size
  104429. * @param texture Texture to copy from
  104430. * @param width defines the desired width
  104431. * @param height defines the desired height
  104432. * @param useBilinearMode defines if bilinear mode has to be used
  104433. * @return the generated texture
  104434. */
  104435. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  104436. /**
  104437. * Apply a post process to a texture
  104438. * @param postProcessName name of the fragment post process
  104439. * @param internalTexture the texture to encode
  104440. * @param scene the scene hosting the texture
  104441. * @param type type of the output texture. If not provided, use the one from internalTexture
  104442. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  104443. * @param format format of the output texture. If not provided, use the one from internalTexture
  104444. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  104445. */
  104446. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  104447. }
  104448. }
  104449. declare module BABYLON {
  104450. /**
  104451. * Class used to host RGBD texture specific utilities
  104452. */
  104453. export class RGBDTextureTools {
  104454. /**
  104455. * Expand the RGBD Texture from RGBD to Half Float if possible.
  104456. * @param texture the texture to expand.
  104457. */
  104458. static ExpandRGBDTexture(texture: Texture): void;
  104459. /**
  104460. * Encode the texture to RGBD if possible.
  104461. * @param internalTexture the texture to encode
  104462. * @param scene the scene hosting the texture
  104463. * @param outputTextureType type of the texture in which the encoding is performed
  104464. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  104465. */
  104466. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  104467. }
  104468. }
  104469. declare module BABYLON {
  104470. /**
  104471. * Class used to host texture specific utilities
  104472. */
  104473. export class BRDFTextureTools {
  104474. /**
  104475. * Prevents texture cache collision
  104476. */
  104477. private static _instanceNumber;
  104478. /**
  104479. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  104480. * @param scene defines the hosting scene
  104481. * @returns the environment BRDF texture
  104482. */
  104483. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  104484. private static _environmentBRDFBase64Texture;
  104485. }
  104486. }
  104487. declare module BABYLON {
  104488. /**
  104489. * @hidden
  104490. */
  104491. export interface IMaterialClearCoatDefines {
  104492. CLEARCOAT: boolean;
  104493. CLEARCOAT_DEFAULTIOR: boolean;
  104494. CLEARCOAT_TEXTURE: boolean;
  104495. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  104496. CLEARCOAT_TEXTUREDIRECTUV: number;
  104497. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  104498. CLEARCOAT_BUMP: boolean;
  104499. CLEARCOAT_BUMPDIRECTUV: number;
  104500. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  104501. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  104502. CLEARCOAT_REMAP_F0: boolean;
  104503. CLEARCOAT_TINT: boolean;
  104504. CLEARCOAT_TINT_TEXTURE: boolean;
  104505. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104506. /** @hidden */
  104507. _areTexturesDirty: boolean;
  104508. }
  104509. /**
  104510. * Define the code related to the clear coat parameters of the pbr material.
  104511. */
  104512. export class PBRClearCoatConfiguration {
  104513. /**
  104514. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104515. * The default fits with a polyurethane material.
  104516. * @hidden
  104517. */
  104518. static readonly _DefaultIndexOfRefraction: number;
  104519. private _isEnabled;
  104520. /**
  104521. * Defines if the clear coat is enabled in the material.
  104522. */
  104523. isEnabled: boolean;
  104524. /**
  104525. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  104526. */
  104527. intensity: number;
  104528. /**
  104529. * Defines the clear coat layer roughness.
  104530. */
  104531. roughness: number;
  104532. private _indexOfRefraction;
  104533. /**
  104534. * Defines the index of refraction of the clear coat.
  104535. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104536. * The default fits with a polyurethane material.
  104537. * Changing the default value is more performance intensive.
  104538. */
  104539. indexOfRefraction: number;
  104540. private _texture;
  104541. /**
  104542. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  104543. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  104544. * if textureRoughness is not empty, else no texture roughness is used
  104545. */
  104546. texture: Nullable<BaseTexture>;
  104547. private _useRoughnessFromMainTexture;
  104548. /**
  104549. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  104550. * If false, the green channel from textureRoughness is used for roughness
  104551. */
  104552. useRoughnessFromMainTexture: boolean;
  104553. private _textureRoughness;
  104554. /**
  104555. * Stores the clear coat roughness in a texture (green channel)
  104556. * Not used if useRoughnessFromMainTexture is true
  104557. */
  104558. textureRoughness: Nullable<BaseTexture>;
  104559. private _remapF0OnInterfaceChange;
  104560. /**
  104561. * Defines if the F0 value should be remapped to account for the interface change in the material.
  104562. */
  104563. remapF0OnInterfaceChange: boolean;
  104564. private _bumpTexture;
  104565. /**
  104566. * Define the clear coat specific bump texture.
  104567. */
  104568. bumpTexture: Nullable<BaseTexture>;
  104569. private _isTintEnabled;
  104570. /**
  104571. * Defines if the clear coat tint is enabled in the material.
  104572. */
  104573. isTintEnabled: boolean;
  104574. /**
  104575. * Defines the clear coat tint of the material.
  104576. * This is only use if tint is enabled
  104577. */
  104578. tintColor: Color3;
  104579. /**
  104580. * Defines the distance at which the tint color should be found in the
  104581. * clear coat media.
  104582. * This is only use if tint is enabled
  104583. */
  104584. tintColorAtDistance: number;
  104585. /**
  104586. * Defines the clear coat layer thickness.
  104587. * This is only use if tint is enabled
  104588. */
  104589. tintThickness: number;
  104590. private _tintTexture;
  104591. /**
  104592. * Stores the clear tint values in a texture.
  104593. * rgb is tint
  104594. * a is a thickness factor
  104595. */
  104596. tintTexture: Nullable<BaseTexture>;
  104597. /** @hidden */
  104598. private _internalMarkAllSubMeshesAsTexturesDirty;
  104599. /** @hidden */
  104600. _markAllSubMeshesAsTexturesDirty(): void;
  104601. /**
  104602. * Instantiate a new istance of clear coat configuration.
  104603. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104604. */
  104605. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104606. /**
  104607. * Gets wehter the submesh is ready to be used or not.
  104608. * @param defines the list of "defines" to update.
  104609. * @param scene defines the scene the material belongs to.
  104610. * @param engine defines the engine the material belongs to.
  104611. * @param disableBumpMap defines wether the material disables bump or not.
  104612. * @returns - boolean indicating that the submesh is ready or not.
  104613. */
  104614. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104615. /**
  104616. * Checks to see if a texture is used in the material.
  104617. * @param defines the list of "defines" to update.
  104618. * @param scene defines the scene to the material belongs to.
  104619. */
  104620. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104621. /**
  104622. * Binds the material data.
  104623. * @param uniformBuffer defines the Uniform buffer to fill in.
  104624. * @param scene defines the scene the material belongs to.
  104625. * @param engine defines the engine the material belongs to.
  104626. * @param disableBumpMap defines wether the material disables bump or not.
  104627. * @param isFrozen defines wether the material is frozen or not.
  104628. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104629. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104630. * @param subMesh the submesh to bind data for
  104631. */
  104632. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  104633. /**
  104634. * Checks to see if a texture is used in the material.
  104635. * @param texture - Base texture to use.
  104636. * @returns - Boolean specifying if a texture is used in the material.
  104637. */
  104638. hasTexture(texture: BaseTexture): boolean;
  104639. /**
  104640. * Returns an array of the actively used textures.
  104641. * @param activeTextures Array of BaseTextures
  104642. */
  104643. getActiveTextures(activeTextures: BaseTexture[]): void;
  104644. /**
  104645. * Returns the animatable textures.
  104646. * @param animatables Array of animatable textures.
  104647. */
  104648. getAnimatables(animatables: IAnimatable[]): void;
  104649. /**
  104650. * Disposes the resources of the material.
  104651. * @param forceDisposeTextures - Forces the disposal of all textures.
  104652. */
  104653. dispose(forceDisposeTextures?: boolean): void;
  104654. /**
  104655. * Get the current class name of the texture useful for serialization or dynamic coding.
  104656. * @returns "PBRClearCoatConfiguration"
  104657. */
  104658. getClassName(): string;
  104659. /**
  104660. * Add fallbacks to the effect fallbacks list.
  104661. * @param defines defines the Base texture to use.
  104662. * @param fallbacks defines the current fallback list.
  104663. * @param currentRank defines the current fallback rank.
  104664. * @returns the new fallback rank.
  104665. */
  104666. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104667. /**
  104668. * Add the required uniforms to the current list.
  104669. * @param uniforms defines the current uniform list.
  104670. */
  104671. static AddUniforms(uniforms: string[]): void;
  104672. /**
  104673. * Add the required samplers to the current list.
  104674. * @param samplers defines the current sampler list.
  104675. */
  104676. static AddSamplers(samplers: string[]): void;
  104677. /**
  104678. * Add the required uniforms to the current buffer.
  104679. * @param uniformBuffer defines the current uniform buffer.
  104680. */
  104681. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104682. /**
  104683. * Makes a duplicate of the current configuration into another one.
  104684. * @param clearCoatConfiguration define the config where to copy the info
  104685. */
  104686. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104687. /**
  104688. * Serializes this clear coat configuration.
  104689. * @returns - An object with the serialized config.
  104690. */
  104691. serialize(): any;
  104692. /**
  104693. * Parses a anisotropy Configuration from a serialized object.
  104694. * @param source - Serialized object.
  104695. * @param scene Defines the scene we are parsing for
  104696. * @param rootUrl Defines the rootUrl to load from
  104697. */
  104698. parse(source: any, scene: Scene, rootUrl: string): void;
  104699. }
  104700. }
  104701. declare module BABYLON {
  104702. /**
  104703. * @hidden
  104704. */
  104705. export interface IMaterialAnisotropicDefines {
  104706. ANISOTROPIC: boolean;
  104707. ANISOTROPIC_TEXTURE: boolean;
  104708. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104709. MAINUV1: boolean;
  104710. _areTexturesDirty: boolean;
  104711. _needUVs: boolean;
  104712. }
  104713. /**
  104714. * Define the code related to the anisotropic parameters of the pbr material.
  104715. */
  104716. export class PBRAnisotropicConfiguration {
  104717. private _isEnabled;
  104718. /**
  104719. * Defines if the anisotropy is enabled in the material.
  104720. */
  104721. isEnabled: boolean;
  104722. /**
  104723. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104724. */
  104725. intensity: number;
  104726. /**
  104727. * Defines if the effect is along the tangents, bitangents or in between.
  104728. * By default, the effect is "strectching" the highlights along the tangents.
  104729. */
  104730. direction: Vector2;
  104731. private _texture;
  104732. /**
  104733. * Stores the anisotropy values in a texture.
  104734. * rg is direction (like normal from -1 to 1)
  104735. * b is a intensity
  104736. */
  104737. texture: Nullable<BaseTexture>;
  104738. /** @hidden */
  104739. private _internalMarkAllSubMeshesAsTexturesDirty;
  104740. /** @hidden */
  104741. _markAllSubMeshesAsTexturesDirty(): void;
  104742. /**
  104743. * Instantiate a new istance of anisotropy configuration.
  104744. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104745. */
  104746. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104747. /**
  104748. * Specifies that the submesh is ready to be used.
  104749. * @param defines the list of "defines" to update.
  104750. * @param scene defines the scene the material belongs to.
  104751. * @returns - boolean indicating that the submesh is ready or not.
  104752. */
  104753. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104754. /**
  104755. * Checks to see if a texture is used in the material.
  104756. * @param defines the list of "defines" to update.
  104757. * @param mesh the mesh we are preparing the defines for.
  104758. * @param scene defines the scene the material belongs to.
  104759. */
  104760. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104761. /**
  104762. * Binds the material data.
  104763. * @param uniformBuffer defines the Uniform buffer to fill in.
  104764. * @param scene defines the scene the material belongs to.
  104765. * @param isFrozen defines wether the material is frozen or not.
  104766. */
  104767. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104768. /**
  104769. * Checks to see if a texture is used in the material.
  104770. * @param texture - Base texture to use.
  104771. * @returns - Boolean specifying if a texture is used in the material.
  104772. */
  104773. hasTexture(texture: BaseTexture): boolean;
  104774. /**
  104775. * Returns an array of the actively used textures.
  104776. * @param activeTextures Array of BaseTextures
  104777. */
  104778. getActiveTextures(activeTextures: BaseTexture[]): void;
  104779. /**
  104780. * Returns the animatable textures.
  104781. * @param animatables Array of animatable textures.
  104782. */
  104783. getAnimatables(animatables: IAnimatable[]): void;
  104784. /**
  104785. * Disposes the resources of the material.
  104786. * @param forceDisposeTextures - Forces the disposal of all textures.
  104787. */
  104788. dispose(forceDisposeTextures?: boolean): void;
  104789. /**
  104790. * Get the current class name of the texture useful for serialization or dynamic coding.
  104791. * @returns "PBRAnisotropicConfiguration"
  104792. */
  104793. getClassName(): string;
  104794. /**
  104795. * Add fallbacks to the effect fallbacks list.
  104796. * @param defines defines the Base texture to use.
  104797. * @param fallbacks defines the current fallback list.
  104798. * @param currentRank defines the current fallback rank.
  104799. * @returns the new fallback rank.
  104800. */
  104801. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104802. /**
  104803. * Add the required uniforms to the current list.
  104804. * @param uniforms defines the current uniform list.
  104805. */
  104806. static AddUniforms(uniforms: string[]): void;
  104807. /**
  104808. * Add the required uniforms to the current buffer.
  104809. * @param uniformBuffer defines the current uniform buffer.
  104810. */
  104811. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104812. /**
  104813. * Add the required samplers to the current list.
  104814. * @param samplers defines the current sampler list.
  104815. */
  104816. static AddSamplers(samplers: string[]): void;
  104817. /**
  104818. * Makes a duplicate of the current configuration into another one.
  104819. * @param anisotropicConfiguration define the config where to copy the info
  104820. */
  104821. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104822. /**
  104823. * Serializes this anisotropy configuration.
  104824. * @returns - An object with the serialized config.
  104825. */
  104826. serialize(): any;
  104827. /**
  104828. * Parses a anisotropy Configuration from a serialized object.
  104829. * @param source - Serialized object.
  104830. * @param scene Defines the scene we are parsing for
  104831. * @param rootUrl Defines the rootUrl to load from
  104832. */
  104833. parse(source: any, scene: Scene, rootUrl: string): void;
  104834. }
  104835. }
  104836. declare module BABYLON {
  104837. /**
  104838. * @hidden
  104839. */
  104840. export interface IMaterialBRDFDefines {
  104841. BRDF_V_HEIGHT_CORRELATED: boolean;
  104842. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104843. SPHERICAL_HARMONICS: boolean;
  104844. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  104845. /** @hidden */
  104846. _areMiscDirty: boolean;
  104847. }
  104848. /**
  104849. * Define the code related to the BRDF parameters of the pbr material.
  104850. */
  104851. export class PBRBRDFConfiguration {
  104852. /**
  104853. * Default value used for the energy conservation.
  104854. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104855. */
  104856. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104857. /**
  104858. * Default value used for the Smith Visibility Height Correlated mode.
  104859. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104860. */
  104861. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104862. /**
  104863. * Default value used for the IBL diffuse part.
  104864. * This can help switching back to the polynomials mode globally which is a tiny bit
  104865. * less GPU intensive at the drawback of a lower quality.
  104866. */
  104867. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104868. /**
  104869. * Default value used for activating energy conservation for the specular workflow.
  104870. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  104871. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  104872. */
  104873. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  104874. private _useEnergyConservation;
  104875. /**
  104876. * Defines if the material uses energy conservation.
  104877. */
  104878. useEnergyConservation: boolean;
  104879. private _useSmithVisibilityHeightCorrelated;
  104880. /**
  104881. * LEGACY Mode set to false
  104882. * Defines if the material uses height smith correlated visibility term.
  104883. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104884. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104885. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104886. * Not relying on height correlated will also disable energy conservation.
  104887. */
  104888. useSmithVisibilityHeightCorrelated: boolean;
  104889. private _useSphericalHarmonics;
  104890. /**
  104891. * LEGACY Mode set to false
  104892. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104893. * diffuse part of the IBL.
  104894. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104895. * to the ground truth.
  104896. */
  104897. useSphericalHarmonics: boolean;
  104898. private _useSpecularGlossinessInputEnergyConservation;
  104899. /**
  104900. * Defines if the material uses energy conservation, when the specular workflow is active.
  104901. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  104902. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  104903. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  104904. */
  104905. useSpecularGlossinessInputEnergyConservation: boolean;
  104906. /** @hidden */
  104907. private _internalMarkAllSubMeshesAsMiscDirty;
  104908. /** @hidden */
  104909. _markAllSubMeshesAsMiscDirty(): void;
  104910. /**
  104911. * Instantiate a new istance of clear coat configuration.
  104912. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104913. */
  104914. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104915. /**
  104916. * Checks to see if a texture is used in the material.
  104917. * @param defines the list of "defines" to update.
  104918. */
  104919. prepareDefines(defines: IMaterialBRDFDefines): void;
  104920. /**
  104921. * Get the current class name of the texture useful for serialization or dynamic coding.
  104922. * @returns "PBRClearCoatConfiguration"
  104923. */
  104924. getClassName(): string;
  104925. /**
  104926. * Makes a duplicate of the current configuration into another one.
  104927. * @param brdfConfiguration define the config where to copy the info
  104928. */
  104929. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104930. /**
  104931. * Serializes this BRDF configuration.
  104932. * @returns - An object with the serialized config.
  104933. */
  104934. serialize(): any;
  104935. /**
  104936. * Parses a anisotropy Configuration from a serialized object.
  104937. * @param source - Serialized object.
  104938. * @param scene Defines the scene we are parsing for
  104939. * @param rootUrl Defines the rootUrl to load from
  104940. */
  104941. parse(source: any, scene: Scene, rootUrl: string): void;
  104942. }
  104943. }
  104944. declare module BABYLON {
  104945. /**
  104946. * @hidden
  104947. */
  104948. export interface IMaterialSheenDefines {
  104949. SHEEN: boolean;
  104950. SHEEN_TEXTURE: boolean;
  104951. SHEEN_TEXTURE_ROUGHNESS: boolean;
  104952. SHEEN_TEXTUREDIRECTUV: number;
  104953. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  104954. SHEEN_LINKWITHALBEDO: boolean;
  104955. SHEEN_ROUGHNESS: boolean;
  104956. SHEEN_ALBEDOSCALING: boolean;
  104957. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  104958. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  104959. /** @hidden */
  104960. _areTexturesDirty: boolean;
  104961. }
  104962. /**
  104963. * Define the code related to the Sheen parameters of the pbr material.
  104964. */
  104965. export class PBRSheenConfiguration {
  104966. private _isEnabled;
  104967. /**
  104968. * Defines if the material uses sheen.
  104969. */
  104970. isEnabled: boolean;
  104971. private _linkSheenWithAlbedo;
  104972. /**
  104973. * Defines if the sheen is linked to the sheen color.
  104974. */
  104975. linkSheenWithAlbedo: boolean;
  104976. /**
  104977. * Defines the sheen intensity.
  104978. */
  104979. intensity: number;
  104980. /**
  104981. * Defines the sheen color.
  104982. */
  104983. color: Color3;
  104984. private _texture;
  104985. /**
  104986. * Stores the sheen tint values in a texture.
  104987. * rgb is tint
  104988. * 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)
  104989. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  104990. */
  104991. texture: Nullable<BaseTexture>;
  104992. private _useRoughnessFromMainTexture;
  104993. /**
  104994. * Indicates that the alpha channel of the texture property will be used for roughness.
  104995. * Has no effect if the roughness (and texture!) property is not defined
  104996. */
  104997. useRoughnessFromMainTexture: boolean;
  104998. private _roughness;
  104999. /**
  105000. * Defines the sheen roughness.
  105001. * It is not taken into account if linkSheenWithAlbedo is true.
  105002. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105003. */
  105004. roughness: Nullable<number>;
  105005. private _textureRoughness;
  105006. /**
  105007. * Stores the sheen roughness in a texture.
  105008. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105009. */
  105010. textureRoughness: Nullable<BaseTexture>;
  105011. private _albedoScaling;
  105012. /**
  105013. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105014. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105015. * making it easier to setup and tweak the effect
  105016. */
  105017. albedoScaling: boolean;
  105018. /** @hidden */
  105019. private _internalMarkAllSubMeshesAsTexturesDirty;
  105020. /** @hidden */
  105021. _markAllSubMeshesAsTexturesDirty(): void;
  105022. /**
  105023. * Instantiate a new istance of clear coat configuration.
  105024. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105025. */
  105026. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105027. /**
  105028. * Specifies that the submesh is ready to be used.
  105029. * @param defines the list of "defines" to update.
  105030. * @param scene defines the scene the material belongs to.
  105031. * @returns - boolean indicating that the submesh is ready or not.
  105032. */
  105033. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105034. /**
  105035. * Checks to see if a texture is used in the material.
  105036. * @param defines the list of "defines" to update.
  105037. * @param scene defines the scene the material belongs to.
  105038. */
  105039. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105040. /**
  105041. * Binds the material data.
  105042. * @param uniformBuffer defines the Uniform buffer to fill in.
  105043. * @param scene defines the scene the material belongs to.
  105044. * @param isFrozen defines wether the material is frozen or not.
  105045. * @param subMesh the submesh to bind data for
  105046. */
  105047. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105048. /**
  105049. * Checks to see if a texture is used in the material.
  105050. * @param texture - Base texture to use.
  105051. * @returns - Boolean specifying if a texture is used in the material.
  105052. */
  105053. hasTexture(texture: BaseTexture): boolean;
  105054. /**
  105055. * Returns an array of the actively used textures.
  105056. * @param activeTextures Array of BaseTextures
  105057. */
  105058. getActiveTextures(activeTextures: BaseTexture[]): void;
  105059. /**
  105060. * Returns the animatable textures.
  105061. * @param animatables Array of animatable textures.
  105062. */
  105063. getAnimatables(animatables: IAnimatable[]): void;
  105064. /**
  105065. * Disposes the resources of the material.
  105066. * @param forceDisposeTextures - Forces the disposal of all textures.
  105067. */
  105068. dispose(forceDisposeTextures?: boolean): void;
  105069. /**
  105070. * Get the current class name of the texture useful for serialization or dynamic coding.
  105071. * @returns "PBRSheenConfiguration"
  105072. */
  105073. getClassName(): string;
  105074. /**
  105075. * Add fallbacks to the effect fallbacks list.
  105076. * @param defines defines the Base texture to use.
  105077. * @param fallbacks defines the current fallback list.
  105078. * @param currentRank defines the current fallback rank.
  105079. * @returns the new fallback rank.
  105080. */
  105081. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105082. /**
  105083. * Add the required uniforms to the current list.
  105084. * @param uniforms defines the current uniform list.
  105085. */
  105086. static AddUniforms(uniforms: string[]): void;
  105087. /**
  105088. * Add the required uniforms to the current buffer.
  105089. * @param uniformBuffer defines the current uniform buffer.
  105090. */
  105091. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105092. /**
  105093. * Add the required samplers to the current list.
  105094. * @param samplers defines the current sampler list.
  105095. */
  105096. static AddSamplers(samplers: string[]): void;
  105097. /**
  105098. * Makes a duplicate of the current configuration into another one.
  105099. * @param sheenConfiguration define the config where to copy the info
  105100. */
  105101. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105102. /**
  105103. * Serializes this BRDF configuration.
  105104. * @returns - An object with the serialized config.
  105105. */
  105106. serialize(): any;
  105107. /**
  105108. * Parses a anisotropy Configuration from a serialized object.
  105109. * @param source - Serialized object.
  105110. * @param scene Defines the scene we are parsing for
  105111. * @param rootUrl Defines the rootUrl to load from
  105112. */
  105113. parse(source: any, scene: Scene, rootUrl: string): void;
  105114. }
  105115. }
  105116. declare module BABYLON {
  105117. /**
  105118. * @hidden
  105119. */
  105120. export interface IMaterialSubSurfaceDefines {
  105121. SUBSURFACE: boolean;
  105122. SS_REFRACTION: boolean;
  105123. SS_TRANSLUCENCY: boolean;
  105124. SS_SCATTERING: boolean;
  105125. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105126. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105127. SS_REFRACTIONMAP_3D: boolean;
  105128. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105129. SS_LODINREFRACTIONALPHA: boolean;
  105130. SS_GAMMAREFRACTION: boolean;
  105131. SS_RGBDREFRACTION: boolean;
  105132. SS_LINEARSPECULARREFRACTION: boolean;
  105133. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105134. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105135. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105136. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  105137. /** @hidden */
  105138. _areTexturesDirty: boolean;
  105139. }
  105140. /**
  105141. * Define the code related to the sub surface parameters of the pbr material.
  105142. */
  105143. export class PBRSubSurfaceConfiguration {
  105144. private _isRefractionEnabled;
  105145. /**
  105146. * Defines if the refraction is enabled in the material.
  105147. */
  105148. isRefractionEnabled: boolean;
  105149. private _isTranslucencyEnabled;
  105150. /**
  105151. * Defines if the translucency is enabled in the material.
  105152. */
  105153. isTranslucencyEnabled: boolean;
  105154. private _isScatteringEnabled;
  105155. /**
  105156. * Defines if the sub surface scattering is enabled in the material.
  105157. */
  105158. isScatteringEnabled: boolean;
  105159. private _scatteringDiffusionProfileIndex;
  105160. /**
  105161. * Diffusion profile for subsurface scattering.
  105162. * Useful for better scattering in the skins or foliages.
  105163. */
  105164. get scatteringDiffusionProfile(): Nullable<Color3>;
  105165. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105166. /**
  105167. * Defines the refraction intensity of the material.
  105168. * The refraction when enabled replaces the Diffuse part of the material.
  105169. * The intensity helps transitionning between diffuse and refraction.
  105170. */
  105171. refractionIntensity: number;
  105172. /**
  105173. * Defines the translucency intensity of the material.
  105174. * When translucency has been enabled, this defines how much of the "translucency"
  105175. * is addded to the diffuse part of the material.
  105176. */
  105177. translucencyIntensity: number;
  105178. /**
  105179. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105180. */
  105181. useAlbedoToTintRefraction: boolean;
  105182. private _thicknessTexture;
  105183. /**
  105184. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105185. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105186. * 0 would mean minimumThickness
  105187. * 1 would mean maximumThickness
  105188. * The other channels might be use as a mask to vary the different effects intensity.
  105189. */
  105190. thicknessTexture: Nullable<BaseTexture>;
  105191. private _refractionTexture;
  105192. /**
  105193. * Defines the texture to use for refraction.
  105194. */
  105195. refractionTexture: Nullable<BaseTexture>;
  105196. private _indexOfRefraction;
  105197. /**
  105198. * Index of refraction of the material base layer.
  105199. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105200. *
  105201. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105202. *
  105203. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105204. */
  105205. indexOfRefraction: number;
  105206. private _volumeIndexOfRefraction;
  105207. /**
  105208. * Index of refraction of the material's volume.
  105209. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105210. *
  105211. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105212. * the volume will use the same IOR as the surface.
  105213. */
  105214. get volumeIndexOfRefraction(): number;
  105215. set volumeIndexOfRefraction(value: number);
  105216. private _invertRefractionY;
  105217. /**
  105218. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105219. */
  105220. invertRefractionY: boolean;
  105221. private _linkRefractionWithTransparency;
  105222. /**
  105223. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105224. * Materials half opaque for instance using refraction could benefit from this control.
  105225. */
  105226. linkRefractionWithTransparency: boolean;
  105227. /**
  105228. * Defines the minimum thickness stored in the thickness map.
  105229. * If no thickness map is defined, this value will be used to simulate thickness.
  105230. */
  105231. minimumThickness: number;
  105232. /**
  105233. * Defines the maximum thickness stored in the thickness map.
  105234. */
  105235. maximumThickness: number;
  105236. /**
  105237. * Defines the volume tint of the material.
  105238. * This is used for both translucency and scattering.
  105239. */
  105240. tintColor: Color3;
  105241. /**
  105242. * Defines the distance at which the tint color should be found in the media.
  105243. * This is used for refraction only.
  105244. */
  105245. tintColorAtDistance: number;
  105246. /**
  105247. * Defines how far each channel transmit through the media.
  105248. * It is defined as a color to simplify it selection.
  105249. */
  105250. diffusionDistance: Color3;
  105251. private _useMaskFromThicknessTexture;
  105252. /**
  105253. * Stores the intensity of the different subsurface effects in the thickness texture.
  105254. * * the green channel is the translucency intensity.
  105255. * * the blue channel is the scattering intensity.
  105256. * * the alpha channel is the refraction intensity.
  105257. */
  105258. useMaskFromThicknessTexture: boolean;
  105259. private _scene;
  105260. private _useMaskFromThicknessTextureGltf;
  105261. /**
  105262. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  105263. * matches the channel-packing that is used by glTF.
  105264. * * the red channel is the transmission/translucency intensity.
  105265. * * the green channel is the thickness.
  105266. */
  105267. useMaskFromThicknessTextureGltf: boolean;
  105268. /** @hidden */
  105269. private _internalMarkAllSubMeshesAsTexturesDirty;
  105270. private _internalMarkScenePrePassDirty;
  105271. /** @hidden */
  105272. _markAllSubMeshesAsTexturesDirty(): void;
  105273. /** @hidden */
  105274. _markScenePrePassDirty(): void;
  105275. /**
  105276. * Instantiate a new istance of sub surface configuration.
  105277. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105278. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105279. * @param scene The scene
  105280. */
  105281. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105282. /**
  105283. * Gets wehter the submesh is ready to be used or not.
  105284. * @param defines the list of "defines" to update.
  105285. * @param scene defines the scene the material belongs to.
  105286. * @returns - boolean indicating that the submesh is ready or not.
  105287. */
  105288. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105289. /**
  105290. * Checks to see if a texture is used in the material.
  105291. * @param defines the list of "defines" to update.
  105292. * @param scene defines the scene to the material belongs to.
  105293. */
  105294. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105295. /**
  105296. * Binds the material data.
  105297. * @param uniformBuffer defines the Uniform buffer to fill in.
  105298. * @param scene defines the scene the material belongs to.
  105299. * @param engine defines the engine the material belongs to.
  105300. * @param isFrozen defines whether the material is frozen or not.
  105301. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105302. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105303. */
  105304. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105305. /**
  105306. * Unbinds the material from the mesh.
  105307. * @param activeEffect defines the effect that should be unbound from.
  105308. * @returns true if unbound, otherwise false
  105309. */
  105310. unbind(activeEffect: Effect): boolean;
  105311. /**
  105312. * Returns the texture used for refraction or null if none is used.
  105313. * @param scene defines the scene the material belongs to.
  105314. * @returns - Refraction texture if present. If no refraction texture and refraction
  105315. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105316. */
  105317. private _getRefractionTexture;
  105318. /**
  105319. * Returns true if alpha blending should be disabled.
  105320. */
  105321. get disableAlphaBlending(): boolean;
  105322. /**
  105323. * Fills the list of render target textures.
  105324. * @param renderTargets the list of render targets to update
  105325. */
  105326. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105327. /**
  105328. * Checks to see if a texture is used in the material.
  105329. * @param texture - Base texture to use.
  105330. * @returns - Boolean specifying if a texture is used in the material.
  105331. */
  105332. hasTexture(texture: BaseTexture): boolean;
  105333. /**
  105334. * Gets a boolean indicating that current material needs to register RTT
  105335. * @returns true if this uses a render target otherwise false.
  105336. */
  105337. hasRenderTargetTextures(): boolean;
  105338. /**
  105339. * Returns an array of the actively used textures.
  105340. * @param activeTextures Array of BaseTextures
  105341. */
  105342. getActiveTextures(activeTextures: BaseTexture[]): void;
  105343. /**
  105344. * Returns the animatable textures.
  105345. * @param animatables Array of animatable textures.
  105346. */
  105347. getAnimatables(animatables: IAnimatable[]): void;
  105348. /**
  105349. * Disposes the resources of the material.
  105350. * @param forceDisposeTextures - Forces the disposal of all textures.
  105351. */
  105352. dispose(forceDisposeTextures?: boolean): void;
  105353. /**
  105354. * Get the current class name of the texture useful for serialization or dynamic coding.
  105355. * @returns "PBRSubSurfaceConfiguration"
  105356. */
  105357. getClassName(): string;
  105358. /**
  105359. * Add fallbacks to the effect fallbacks list.
  105360. * @param defines defines the Base texture to use.
  105361. * @param fallbacks defines the current fallback list.
  105362. * @param currentRank defines the current fallback rank.
  105363. * @returns the new fallback rank.
  105364. */
  105365. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105366. /**
  105367. * Add the required uniforms to the current list.
  105368. * @param uniforms defines the current uniform list.
  105369. */
  105370. static AddUniforms(uniforms: string[]): void;
  105371. /**
  105372. * Add the required samplers to the current list.
  105373. * @param samplers defines the current sampler list.
  105374. */
  105375. static AddSamplers(samplers: string[]): void;
  105376. /**
  105377. * Add the required uniforms to the current buffer.
  105378. * @param uniformBuffer defines the current uniform buffer.
  105379. */
  105380. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105381. /**
  105382. * Makes a duplicate of the current configuration into another one.
  105383. * @param configuration define the config where to copy the info
  105384. */
  105385. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  105386. /**
  105387. * Serializes this Sub Surface configuration.
  105388. * @returns - An object with the serialized config.
  105389. */
  105390. serialize(): any;
  105391. /**
  105392. * Parses a anisotropy Configuration from a serialized object.
  105393. * @param source - Serialized object.
  105394. * @param scene Defines the scene we are parsing for
  105395. * @param rootUrl Defines the rootUrl to load from
  105396. */
  105397. parse(source: any, scene: Scene, rootUrl: string): void;
  105398. }
  105399. }
  105400. declare module BABYLON {
  105401. /**
  105402. * Class representing spherical harmonics coefficients to the 3rd degree
  105403. */
  105404. export class SphericalHarmonics {
  105405. /**
  105406. * Defines whether or not the harmonics have been prescaled for rendering.
  105407. */
  105408. preScaled: boolean;
  105409. /**
  105410. * The l0,0 coefficients of the spherical harmonics
  105411. */
  105412. l00: Vector3;
  105413. /**
  105414. * The l1,-1 coefficients of the spherical harmonics
  105415. */
  105416. l1_1: Vector3;
  105417. /**
  105418. * The l1,0 coefficients of the spherical harmonics
  105419. */
  105420. l10: Vector3;
  105421. /**
  105422. * The l1,1 coefficients of the spherical harmonics
  105423. */
  105424. l11: Vector3;
  105425. /**
  105426. * The l2,-2 coefficients of the spherical harmonics
  105427. */
  105428. l2_2: Vector3;
  105429. /**
  105430. * The l2,-1 coefficients of the spherical harmonics
  105431. */
  105432. l2_1: Vector3;
  105433. /**
  105434. * The l2,0 coefficients of the spherical harmonics
  105435. */
  105436. l20: Vector3;
  105437. /**
  105438. * The l2,1 coefficients of the spherical harmonics
  105439. */
  105440. l21: Vector3;
  105441. /**
  105442. * The l2,2 coefficients of the spherical harmonics
  105443. */
  105444. l22: Vector3;
  105445. /**
  105446. * Adds a light to the spherical harmonics
  105447. * @param direction the direction of the light
  105448. * @param color the color of the light
  105449. * @param deltaSolidAngle the delta solid angle of the light
  105450. */
  105451. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105452. /**
  105453. * Scales the spherical harmonics by the given amount
  105454. * @param scale the amount to scale
  105455. */
  105456. scaleInPlace(scale: number): void;
  105457. /**
  105458. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105459. *
  105460. * ```
  105461. * E_lm = A_l * L_lm
  105462. * ```
  105463. *
  105464. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105465. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105466. * the scaling factors are given in equation 9.
  105467. */
  105468. convertIncidentRadianceToIrradiance(): void;
  105469. /**
  105470. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105471. *
  105472. * ```
  105473. * L = (1/pi) * E * rho
  105474. * ```
  105475. *
  105476. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105477. */
  105478. convertIrradianceToLambertianRadiance(): void;
  105479. /**
  105480. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105481. * required operations at run time.
  105482. *
  105483. * This is simply done by scaling back the SH with Ylm constants parameter.
  105484. * The trigonometric part being applied by the shader at run time.
  105485. */
  105486. preScaleForRendering(): void;
  105487. /**
  105488. * Constructs a spherical harmonics from an array.
  105489. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105490. * @returns the spherical harmonics
  105491. */
  105492. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105493. /**
  105494. * Gets the spherical harmonics from polynomial
  105495. * @param polynomial the spherical polynomial
  105496. * @returns the spherical harmonics
  105497. */
  105498. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105499. }
  105500. /**
  105501. * Class representing spherical polynomial coefficients to the 3rd degree
  105502. */
  105503. export class SphericalPolynomial {
  105504. private _harmonics;
  105505. /**
  105506. * The spherical harmonics used to create the polynomials.
  105507. */
  105508. get preScaledHarmonics(): SphericalHarmonics;
  105509. /**
  105510. * The x coefficients of the spherical polynomial
  105511. */
  105512. x: Vector3;
  105513. /**
  105514. * The y coefficients of the spherical polynomial
  105515. */
  105516. y: Vector3;
  105517. /**
  105518. * The z coefficients of the spherical polynomial
  105519. */
  105520. z: Vector3;
  105521. /**
  105522. * The xx coefficients of the spherical polynomial
  105523. */
  105524. xx: Vector3;
  105525. /**
  105526. * The yy coefficients of the spherical polynomial
  105527. */
  105528. yy: Vector3;
  105529. /**
  105530. * The zz coefficients of the spherical polynomial
  105531. */
  105532. zz: Vector3;
  105533. /**
  105534. * The xy coefficients of the spherical polynomial
  105535. */
  105536. xy: Vector3;
  105537. /**
  105538. * The yz coefficients of the spherical polynomial
  105539. */
  105540. yz: Vector3;
  105541. /**
  105542. * The zx coefficients of the spherical polynomial
  105543. */
  105544. zx: Vector3;
  105545. /**
  105546. * Adds an ambient color to the spherical polynomial
  105547. * @param color the color to add
  105548. */
  105549. addAmbient(color: Color3): void;
  105550. /**
  105551. * Scales the spherical polynomial by the given amount
  105552. * @param scale the amount to scale
  105553. */
  105554. scaleInPlace(scale: number): void;
  105555. /**
  105556. * Gets the spherical polynomial from harmonics
  105557. * @param harmonics the spherical harmonics
  105558. * @returns the spherical polynomial
  105559. */
  105560. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105561. /**
  105562. * Constructs a spherical polynomial from an array.
  105563. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105564. * @returns the spherical polynomial
  105565. */
  105566. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105567. }
  105568. }
  105569. declare module BABYLON {
  105570. /**
  105571. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  105572. */
  105573. export interface CubeMapInfo {
  105574. /**
  105575. * The pixel array for the front face.
  105576. * This is stored in format, left to right, up to down format.
  105577. */
  105578. front: Nullable<ArrayBufferView>;
  105579. /**
  105580. * The pixel array for the back face.
  105581. * This is stored in format, left to right, up to down format.
  105582. */
  105583. back: Nullable<ArrayBufferView>;
  105584. /**
  105585. * The pixel array for the left face.
  105586. * This is stored in format, left to right, up to down format.
  105587. */
  105588. left: Nullable<ArrayBufferView>;
  105589. /**
  105590. * The pixel array for the right face.
  105591. * This is stored in format, left to right, up to down format.
  105592. */
  105593. right: Nullable<ArrayBufferView>;
  105594. /**
  105595. * The pixel array for the up face.
  105596. * This is stored in format, left to right, up to down format.
  105597. */
  105598. up: Nullable<ArrayBufferView>;
  105599. /**
  105600. * The pixel array for the down face.
  105601. * This is stored in format, left to right, up to down format.
  105602. */
  105603. down: Nullable<ArrayBufferView>;
  105604. /**
  105605. * The size of the cubemap stored.
  105606. *
  105607. * Each faces will be size * size pixels.
  105608. */
  105609. size: number;
  105610. /**
  105611. * The format of the texture.
  105612. *
  105613. * RGBA, RGB.
  105614. */
  105615. format: number;
  105616. /**
  105617. * The type of the texture data.
  105618. *
  105619. * UNSIGNED_INT, FLOAT.
  105620. */
  105621. type: number;
  105622. /**
  105623. * Specifies whether the texture is in gamma space.
  105624. */
  105625. gammaSpace: boolean;
  105626. }
  105627. /**
  105628. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  105629. */
  105630. export class PanoramaToCubeMapTools {
  105631. private static FACE_LEFT;
  105632. private static FACE_RIGHT;
  105633. private static FACE_FRONT;
  105634. private static FACE_BACK;
  105635. private static FACE_DOWN;
  105636. private static FACE_UP;
  105637. /**
  105638. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  105639. *
  105640. * @param float32Array The source data.
  105641. * @param inputWidth The width of the input panorama.
  105642. * @param inputHeight The height of the input panorama.
  105643. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  105644. * @return The cubemap data
  105645. */
  105646. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  105647. private static CreateCubemapTexture;
  105648. private static CalcProjectionSpherical;
  105649. }
  105650. }
  105651. declare module BABYLON {
  105652. /**
  105653. * Helper class dealing with the extraction of spherical polynomial dataArray
  105654. * from a cube map.
  105655. */
  105656. export class CubeMapToSphericalPolynomialTools {
  105657. private static FileFaces;
  105658. /**
  105659. * Converts a texture to the according Spherical Polynomial data.
  105660. * This extracts the first 3 orders only as they are the only one used in the lighting.
  105661. *
  105662. * @param texture The texture to extract the information from.
  105663. * @return The Spherical Polynomial data.
  105664. */
  105665. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  105666. /**
  105667. * Converts a cubemap to the according Spherical Polynomial data.
  105668. * This extracts the first 3 orders only as they are the only one used in the lighting.
  105669. *
  105670. * @param cubeInfo The Cube map to extract the information from.
  105671. * @return The Spherical Polynomial data.
  105672. */
  105673. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  105674. }
  105675. }
  105676. declare module BABYLON {
  105677. interface BaseTexture {
  105678. /**
  105679. * Get the polynomial representation of the texture data.
  105680. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  105681. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  105682. */
  105683. sphericalPolynomial: Nullable<SphericalPolynomial>;
  105684. }
  105685. }
  105686. declare module BABYLON {
  105687. /** @hidden */
  105688. export var pbrFragmentDeclaration: {
  105689. name: string;
  105690. shader: string;
  105691. };
  105692. }
  105693. declare module BABYLON {
  105694. /** @hidden */
  105695. export var pbrUboDeclaration: {
  105696. name: string;
  105697. shader: string;
  105698. };
  105699. }
  105700. declare module BABYLON {
  105701. /** @hidden */
  105702. export var pbrFragmentExtraDeclaration: {
  105703. name: string;
  105704. shader: string;
  105705. };
  105706. }
  105707. declare module BABYLON {
  105708. /** @hidden */
  105709. export var pbrFragmentSamplersDeclaration: {
  105710. name: string;
  105711. shader: string;
  105712. };
  105713. }
  105714. declare module BABYLON {
  105715. /** @hidden */
  105716. export var subSurfaceScatteringFunctions: {
  105717. name: string;
  105718. shader: string;
  105719. };
  105720. }
  105721. declare module BABYLON {
  105722. /** @hidden */
  105723. export var importanceSampling: {
  105724. name: string;
  105725. shader: string;
  105726. };
  105727. }
  105728. declare module BABYLON {
  105729. /** @hidden */
  105730. export var pbrHelperFunctions: {
  105731. name: string;
  105732. shader: string;
  105733. };
  105734. }
  105735. declare module BABYLON {
  105736. /** @hidden */
  105737. export var harmonicsFunctions: {
  105738. name: string;
  105739. shader: string;
  105740. };
  105741. }
  105742. declare module BABYLON {
  105743. /** @hidden */
  105744. export var pbrDirectLightingSetupFunctions: {
  105745. name: string;
  105746. shader: string;
  105747. };
  105748. }
  105749. declare module BABYLON {
  105750. /** @hidden */
  105751. export var pbrDirectLightingFalloffFunctions: {
  105752. name: string;
  105753. shader: string;
  105754. };
  105755. }
  105756. declare module BABYLON {
  105757. /** @hidden */
  105758. export var pbrBRDFFunctions: {
  105759. name: string;
  105760. shader: string;
  105761. };
  105762. }
  105763. declare module BABYLON {
  105764. /** @hidden */
  105765. export var hdrFilteringFunctions: {
  105766. name: string;
  105767. shader: string;
  105768. };
  105769. }
  105770. declare module BABYLON {
  105771. /** @hidden */
  105772. export var pbrDirectLightingFunctions: {
  105773. name: string;
  105774. shader: string;
  105775. };
  105776. }
  105777. declare module BABYLON {
  105778. /** @hidden */
  105779. export var pbrIBLFunctions: {
  105780. name: string;
  105781. shader: string;
  105782. };
  105783. }
  105784. declare module BABYLON {
  105785. /** @hidden */
  105786. export var pbrBlockAlbedoOpacity: {
  105787. name: string;
  105788. shader: string;
  105789. };
  105790. }
  105791. declare module BABYLON {
  105792. /** @hidden */
  105793. export var pbrBlockReflectivity: {
  105794. name: string;
  105795. shader: string;
  105796. };
  105797. }
  105798. declare module BABYLON {
  105799. /** @hidden */
  105800. export var pbrBlockAmbientOcclusion: {
  105801. name: string;
  105802. shader: string;
  105803. };
  105804. }
  105805. declare module BABYLON {
  105806. /** @hidden */
  105807. export var pbrBlockAlphaFresnel: {
  105808. name: string;
  105809. shader: string;
  105810. };
  105811. }
  105812. declare module BABYLON {
  105813. /** @hidden */
  105814. export var pbrBlockAnisotropic: {
  105815. name: string;
  105816. shader: string;
  105817. };
  105818. }
  105819. declare module BABYLON {
  105820. /** @hidden */
  105821. export var pbrBlockReflection: {
  105822. name: string;
  105823. shader: string;
  105824. };
  105825. }
  105826. declare module BABYLON {
  105827. /** @hidden */
  105828. export var pbrBlockSheen: {
  105829. name: string;
  105830. shader: string;
  105831. };
  105832. }
  105833. declare module BABYLON {
  105834. /** @hidden */
  105835. export var pbrBlockClearcoat: {
  105836. name: string;
  105837. shader: string;
  105838. };
  105839. }
  105840. declare module BABYLON {
  105841. /** @hidden */
  105842. export var pbrBlockSubSurface: {
  105843. name: string;
  105844. shader: string;
  105845. };
  105846. }
  105847. declare module BABYLON {
  105848. /** @hidden */
  105849. export var pbrBlockNormalGeometric: {
  105850. name: string;
  105851. shader: string;
  105852. };
  105853. }
  105854. declare module BABYLON {
  105855. /** @hidden */
  105856. export var pbrBlockNormalFinal: {
  105857. name: string;
  105858. shader: string;
  105859. };
  105860. }
  105861. declare module BABYLON {
  105862. /** @hidden */
  105863. export var pbrBlockLightmapInit: {
  105864. name: string;
  105865. shader: string;
  105866. };
  105867. }
  105868. declare module BABYLON {
  105869. /** @hidden */
  105870. export var pbrBlockGeometryInfo: {
  105871. name: string;
  105872. shader: string;
  105873. };
  105874. }
  105875. declare module BABYLON {
  105876. /** @hidden */
  105877. export var pbrBlockReflectance0: {
  105878. name: string;
  105879. shader: string;
  105880. };
  105881. }
  105882. declare module BABYLON {
  105883. /** @hidden */
  105884. export var pbrBlockReflectance: {
  105885. name: string;
  105886. shader: string;
  105887. };
  105888. }
  105889. declare module BABYLON {
  105890. /** @hidden */
  105891. export var pbrBlockDirectLighting: {
  105892. name: string;
  105893. shader: string;
  105894. };
  105895. }
  105896. declare module BABYLON {
  105897. /** @hidden */
  105898. export var pbrBlockFinalLitComponents: {
  105899. name: string;
  105900. shader: string;
  105901. };
  105902. }
  105903. declare module BABYLON {
  105904. /** @hidden */
  105905. export var pbrBlockFinalUnlitComponents: {
  105906. name: string;
  105907. shader: string;
  105908. };
  105909. }
  105910. declare module BABYLON {
  105911. /** @hidden */
  105912. export var pbrBlockFinalColorComposition: {
  105913. name: string;
  105914. shader: string;
  105915. };
  105916. }
  105917. declare module BABYLON {
  105918. /** @hidden */
  105919. export var pbrBlockImageProcessing: {
  105920. name: string;
  105921. shader: string;
  105922. };
  105923. }
  105924. declare module BABYLON {
  105925. /** @hidden */
  105926. export var pbrDebug: {
  105927. name: string;
  105928. shader: string;
  105929. };
  105930. }
  105931. declare module BABYLON {
  105932. /** @hidden */
  105933. export var pbrPixelShader: {
  105934. name: string;
  105935. shader: string;
  105936. };
  105937. }
  105938. declare module BABYLON {
  105939. /** @hidden */
  105940. export var pbrVertexDeclaration: {
  105941. name: string;
  105942. shader: string;
  105943. };
  105944. }
  105945. declare module BABYLON {
  105946. /** @hidden */
  105947. export var pbrVertexShader: {
  105948. name: string;
  105949. shader: string;
  105950. };
  105951. }
  105952. declare module BABYLON {
  105953. /**
  105954. * Manages the defines for the PBR Material.
  105955. * @hidden
  105956. */
  105957. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  105958. PBR: boolean;
  105959. NUM_SAMPLES: string;
  105960. REALTIME_FILTERING: boolean;
  105961. MAINUV1: boolean;
  105962. MAINUV2: boolean;
  105963. UV1: boolean;
  105964. UV2: boolean;
  105965. ALBEDO: boolean;
  105966. GAMMAALBEDO: boolean;
  105967. ALBEDODIRECTUV: number;
  105968. VERTEXCOLOR: boolean;
  105969. DETAIL: boolean;
  105970. DETAILDIRECTUV: number;
  105971. DETAIL_NORMALBLENDMETHOD: number;
  105972. AMBIENT: boolean;
  105973. AMBIENTDIRECTUV: number;
  105974. AMBIENTINGRAYSCALE: boolean;
  105975. OPACITY: boolean;
  105976. VERTEXALPHA: boolean;
  105977. OPACITYDIRECTUV: number;
  105978. OPACITYRGB: boolean;
  105979. ALPHATEST: boolean;
  105980. DEPTHPREPASS: boolean;
  105981. ALPHABLEND: boolean;
  105982. ALPHAFROMALBEDO: boolean;
  105983. ALPHATESTVALUE: string;
  105984. SPECULAROVERALPHA: boolean;
  105985. RADIANCEOVERALPHA: boolean;
  105986. ALPHAFRESNEL: boolean;
  105987. LINEARALPHAFRESNEL: boolean;
  105988. PREMULTIPLYALPHA: boolean;
  105989. EMISSIVE: boolean;
  105990. EMISSIVEDIRECTUV: number;
  105991. REFLECTIVITY: boolean;
  105992. REFLECTIVITYDIRECTUV: number;
  105993. SPECULARTERM: boolean;
  105994. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  105995. MICROSURFACEAUTOMATIC: boolean;
  105996. LODBASEDMICROSFURACE: boolean;
  105997. MICROSURFACEMAP: boolean;
  105998. MICROSURFACEMAPDIRECTUV: number;
  105999. METALLICWORKFLOW: boolean;
  106000. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106001. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106002. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106003. AOSTOREINMETALMAPRED: boolean;
  106004. METALLIC_REFLECTANCE: boolean;
  106005. METALLIC_REFLECTANCEDIRECTUV: number;
  106006. ENVIRONMENTBRDF: boolean;
  106007. ENVIRONMENTBRDF_RGBD: boolean;
  106008. NORMAL: boolean;
  106009. TANGENT: boolean;
  106010. BUMP: boolean;
  106011. BUMPDIRECTUV: number;
  106012. OBJECTSPACE_NORMALMAP: boolean;
  106013. PARALLAX: boolean;
  106014. PARALLAXOCCLUSION: boolean;
  106015. NORMALXYSCALE: boolean;
  106016. LIGHTMAP: boolean;
  106017. LIGHTMAPDIRECTUV: number;
  106018. USELIGHTMAPASSHADOWMAP: boolean;
  106019. GAMMALIGHTMAP: boolean;
  106020. RGBDLIGHTMAP: boolean;
  106021. REFLECTION: boolean;
  106022. REFLECTIONMAP_3D: boolean;
  106023. REFLECTIONMAP_SPHERICAL: boolean;
  106024. REFLECTIONMAP_PLANAR: boolean;
  106025. REFLECTIONMAP_CUBIC: boolean;
  106026. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106027. REFLECTIONMAP_PROJECTION: boolean;
  106028. REFLECTIONMAP_SKYBOX: boolean;
  106029. REFLECTIONMAP_EXPLICIT: boolean;
  106030. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106031. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106032. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106033. INVERTCUBICMAP: boolean;
  106034. USESPHERICALFROMREFLECTIONMAP: boolean;
  106035. USEIRRADIANCEMAP: boolean;
  106036. SPHERICAL_HARMONICS: boolean;
  106037. USESPHERICALINVERTEX: boolean;
  106038. REFLECTIONMAP_OPPOSITEZ: boolean;
  106039. LODINREFLECTIONALPHA: boolean;
  106040. GAMMAREFLECTION: boolean;
  106041. RGBDREFLECTION: boolean;
  106042. LINEARSPECULARREFLECTION: boolean;
  106043. RADIANCEOCCLUSION: boolean;
  106044. HORIZONOCCLUSION: boolean;
  106045. INSTANCES: boolean;
  106046. THIN_INSTANCES: boolean;
  106047. PREPASS: boolean;
  106048. PREPASS_IRRADIANCE: boolean;
  106049. PREPASS_IRRADIANCE_INDEX: number;
  106050. PREPASS_ALBEDO: boolean;
  106051. PREPASS_ALBEDO_INDEX: number;
  106052. PREPASS_DEPTHNORMAL: boolean;
  106053. PREPASS_DEPTHNORMAL_INDEX: number;
  106054. PREPASS_POSITION: boolean;
  106055. PREPASS_POSITION_INDEX: number;
  106056. PREPASS_VELOCITY: boolean;
  106057. PREPASS_VELOCITY_INDEX: number;
  106058. PREPASS_REFLECTIVITY: boolean;
  106059. PREPASS_REFLECTIVITY_INDEX: number;
  106060. SCENE_MRT_COUNT: number;
  106061. NUM_BONE_INFLUENCERS: number;
  106062. BonesPerMesh: number;
  106063. BONETEXTURE: boolean;
  106064. BONES_VELOCITY_ENABLED: boolean;
  106065. NONUNIFORMSCALING: boolean;
  106066. MORPHTARGETS: boolean;
  106067. MORPHTARGETS_NORMAL: boolean;
  106068. MORPHTARGETS_TANGENT: boolean;
  106069. MORPHTARGETS_UV: boolean;
  106070. NUM_MORPH_INFLUENCERS: number;
  106071. IMAGEPROCESSING: boolean;
  106072. VIGNETTE: boolean;
  106073. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106074. VIGNETTEBLENDMODEOPAQUE: boolean;
  106075. TONEMAPPING: boolean;
  106076. TONEMAPPING_ACES: boolean;
  106077. CONTRAST: boolean;
  106078. COLORCURVES: boolean;
  106079. COLORGRADING: boolean;
  106080. COLORGRADING3D: boolean;
  106081. SAMPLER3DGREENDEPTH: boolean;
  106082. SAMPLER3DBGRMAP: boolean;
  106083. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106084. EXPOSURE: boolean;
  106085. MULTIVIEW: boolean;
  106086. USEPHYSICALLIGHTFALLOFF: boolean;
  106087. USEGLTFLIGHTFALLOFF: boolean;
  106088. TWOSIDEDLIGHTING: boolean;
  106089. SHADOWFLOAT: boolean;
  106090. CLIPPLANE: boolean;
  106091. CLIPPLANE2: boolean;
  106092. CLIPPLANE3: boolean;
  106093. CLIPPLANE4: boolean;
  106094. CLIPPLANE5: boolean;
  106095. CLIPPLANE6: boolean;
  106096. POINTSIZE: boolean;
  106097. FOG: boolean;
  106098. LOGARITHMICDEPTH: boolean;
  106099. FORCENORMALFORWARD: boolean;
  106100. SPECULARAA: boolean;
  106101. CLEARCOAT: boolean;
  106102. CLEARCOAT_DEFAULTIOR: boolean;
  106103. CLEARCOAT_TEXTURE: boolean;
  106104. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106105. CLEARCOAT_TEXTUREDIRECTUV: number;
  106106. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106107. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106108. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106109. CLEARCOAT_BUMP: boolean;
  106110. CLEARCOAT_BUMPDIRECTUV: number;
  106111. CLEARCOAT_REMAP_F0: boolean;
  106112. CLEARCOAT_TINT: boolean;
  106113. CLEARCOAT_TINT_TEXTURE: boolean;
  106114. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106115. ANISOTROPIC: boolean;
  106116. ANISOTROPIC_TEXTURE: boolean;
  106117. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106118. BRDF_V_HEIGHT_CORRELATED: boolean;
  106119. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106120. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106121. SHEEN: boolean;
  106122. SHEEN_TEXTURE: boolean;
  106123. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106124. SHEEN_TEXTUREDIRECTUV: number;
  106125. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106126. SHEEN_LINKWITHALBEDO: boolean;
  106127. SHEEN_ROUGHNESS: boolean;
  106128. SHEEN_ALBEDOSCALING: boolean;
  106129. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106130. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106131. SUBSURFACE: boolean;
  106132. SS_REFRACTION: boolean;
  106133. SS_TRANSLUCENCY: boolean;
  106134. SS_SCATTERING: boolean;
  106135. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106136. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106137. SS_REFRACTIONMAP_3D: boolean;
  106138. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106139. SS_LODINREFRACTIONALPHA: boolean;
  106140. SS_GAMMAREFRACTION: boolean;
  106141. SS_RGBDREFRACTION: boolean;
  106142. SS_LINEARSPECULARREFRACTION: boolean;
  106143. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106144. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106145. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106146. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  106147. UNLIT: boolean;
  106148. DEBUGMODE: number;
  106149. /**
  106150. * Initializes the PBR Material defines.
  106151. */
  106152. constructor();
  106153. /**
  106154. * Resets the PBR Material defines.
  106155. */
  106156. reset(): void;
  106157. }
  106158. /**
  106159. * The Physically based material base class of BJS.
  106160. *
  106161. * This offers the main features of a standard PBR material.
  106162. * For more information, please refer to the documentation :
  106163. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106164. */
  106165. export abstract class PBRBaseMaterial extends PushMaterial {
  106166. /**
  106167. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106168. */
  106169. static readonly PBRMATERIAL_OPAQUE: number;
  106170. /**
  106171. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106172. */
  106173. static readonly PBRMATERIAL_ALPHATEST: number;
  106174. /**
  106175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106176. */
  106177. static readonly PBRMATERIAL_ALPHABLEND: number;
  106178. /**
  106179. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106180. * They are also discarded below the alpha cutoff threshold to improve performances.
  106181. */
  106182. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106183. /**
  106184. * Defines the default value of how much AO map is occluding the analytical lights
  106185. * (point spot...).
  106186. */
  106187. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106188. /**
  106189. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106190. */
  106191. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106192. /**
  106193. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106194. * to enhance interoperability with other engines.
  106195. */
  106196. static readonly LIGHTFALLOFF_GLTF: number;
  106197. /**
  106198. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106199. * to enhance interoperability with other materials.
  106200. */
  106201. static readonly LIGHTFALLOFF_STANDARD: number;
  106202. /**
  106203. * Intensity of the direct lights e.g. the four lights available in your scene.
  106204. * This impacts both the direct diffuse and specular highlights.
  106205. */
  106206. protected _directIntensity: number;
  106207. /**
  106208. * Intensity of the emissive part of the material.
  106209. * This helps controlling the emissive effect without modifying the emissive color.
  106210. */
  106211. protected _emissiveIntensity: number;
  106212. /**
  106213. * Intensity of the environment e.g. how much the environment will light the object
  106214. * either through harmonics for rough material or through the refelction for shiny ones.
  106215. */
  106216. protected _environmentIntensity: number;
  106217. /**
  106218. * This is a special control allowing the reduction of the specular highlights coming from the
  106219. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106220. */
  106221. protected _specularIntensity: number;
  106222. /**
  106223. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106224. */
  106225. private _lightingInfos;
  106226. /**
  106227. * Debug Control allowing disabling the bump map on this material.
  106228. */
  106229. protected _disableBumpMap: boolean;
  106230. /**
  106231. * AKA Diffuse Texture in standard nomenclature.
  106232. */
  106233. protected _albedoTexture: Nullable<BaseTexture>;
  106234. /**
  106235. * AKA Occlusion Texture in other nomenclature.
  106236. */
  106237. protected _ambientTexture: Nullable<BaseTexture>;
  106238. /**
  106239. * AKA Occlusion Texture Intensity in other nomenclature.
  106240. */
  106241. protected _ambientTextureStrength: number;
  106242. /**
  106243. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106244. * 1 means it completely occludes it
  106245. * 0 mean it has no impact
  106246. */
  106247. protected _ambientTextureImpactOnAnalyticalLights: number;
  106248. /**
  106249. * Stores the alpha values in a texture.
  106250. */
  106251. protected _opacityTexture: Nullable<BaseTexture>;
  106252. /**
  106253. * Stores the reflection values in a texture.
  106254. */
  106255. protected _reflectionTexture: Nullable<BaseTexture>;
  106256. /**
  106257. * Stores the emissive values in a texture.
  106258. */
  106259. protected _emissiveTexture: Nullable<BaseTexture>;
  106260. /**
  106261. * AKA Specular texture in other nomenclature.
  106262. */
  106263. protected _reflectivityTexture: Nullable<BaseTexture>;
  106264. /**
  106265. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106266. */
  106267. protected _metallicTexture: Nullable<BaseTexture>;
  106268. /**
  106269. * Specifies the metallic scalar of the metallic/roughness workflow.
  106270. * Can also be used to scale the metalness values of the metallic texture.
  106271. */
  106272. protected _metallic: Nullable<number>;
  106273. /**
  106274. * Specifies the roughness scalar of the metallic/roughness workflow.
  106275. * Can also be used to scale the roughness values of the metallic texture.
  106276. */
  106277. protected _roughness: Nullable<number>;
  106278. /**
  106279. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106280. * By default the indexOfrefraction is used to compute F0;
  106281. *
  106282. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106283. *
  106284. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106285. * F90 = metallicReflectanceColor;
  106286. */
  106287. protected _metallicF0Factor: number;
  106288. /**
  106289. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106290. * By default the F90 is always 1;
  106291. *
  106292. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106293. *
  106294. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106295. * F90 = metallicReflectanceColor;
  106296. */
  106297. protected _metallicReflectanceColor: Color3;
  106298. /**
  106299. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106300. * This is multiply against the scalar values defined in the material.
  106301. */
  106302. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106303. /**
  106304. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106305. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106306. */
  106307. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106308. /**
  106309. * Stores surface normal data used to displace a mesh in a texture.
  106310. */
  106311. protected _bumpTexture: Nullable<BaseTexture>;
  106312. /**
  106313. * Stores the pre-calculated light information of a mesh in a texture.
  106314. */
  106315. protected _lightmapTexture: Nullable<BaseTexture>;
  106316. /**
  106317. * The color of a material in ambient lighting.
  106318. */
  106319. protected _ambientColor: Color3;
  106320. /**
  106321. * AKA Diffuse Color in other nomenclature.
  106322. */
  106323. protected _albedoColor: Color3;
  106324. /**
  106325. * AKA Specular Color in other nomenclature.
  106326. */
  106327. protected _reflectivityColor: Color3;
  106328. /**
  106329. * The color applied when light is reflected from a material.
  106330. */
  106331. protected _reflectionColor: Color3;
  106332. /**
  106333. * The color applied when light is emitted from a material.
  106334. */
  106335. protected _emissiveColor: Color3;
  106336. /**
  106337. * AKA Glossiness in other nomenclature.
  106338. */
  106339. protected _microSurface: number;
  106340. /**
  106341. * Specifies that the material will use the light map as a show map.
  106342. */
  106343. protected _useLightmapAsShadowmap: boolean;
  106344. /**
  106345. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106346. * makes the reflect vector face the model (under horizon).
  106347. */
  106348. protected _useHorizonOcclusion: boolean;
  106349. /**
  106350. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106351. * too much the area relying on ambient texture to define their ambient occlusion.
  106352. */
  106353. protected _useRadianceOcclusion: boolean;
  106354. /**
  106355. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106356. */
  106357. protected _useAlphaFromAlbedoTexture: boolean;
  106358. /**
  106359. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106360. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106361. */
  106362. protected _useSpecularOverAlpha: boolean;
  106363. /**
  106364. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106365. */
  106366. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106367. /**
  106368. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106369. */
  106370. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  106371. /**
  106372. * Specifies if the metallic texture contains the roughness information in its green channel.
  106373. */
  106374. protected _useRoughnessFromMetallicTextureGreen: boolean;
  106375. /**
  106376. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106377. */
  106378. protected _useMetallnessFromMetallicTextureBlue: boolean;
  106379. /**
  106380. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106381. */
  106382. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  106383. /**
  106384. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106385. */
  106386. protected _useAmbientInGrayScale: boolean;
  106387. /**
  106388. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106389. * The material will try to infer what glossiness each pixel should be.
  106390. */
  106391. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  106392. /**
  106393. * Defines the falloff type used in this material.
  106394. * It by default is Physical.
  106395. */
  106396. protected _lightFalloff: number;
  106397. /**
  106398. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106399. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106400. */
  106401. protected _useRadianceOverAlpha: boolean;
  106402. /**
  106403. * Allows using an object space normal map (instead of tangent space).
  106404. */
  106405. protected _useObjectSpaceNormalMap: boolean;
  106406. /**
  106407. * Allows using the bump map in parallax mode.
  106408. */
  106409. protected _useParallax: boolean;
  106410. /**
  106411. * Allows using the bump map in parallax occlusion mode.
  106412. */
  106413. protected _useParallaxOcclusion: boolean;
  106414. /**
  106415. * Controls the scale bias of the parallax mode.
  106416. */
  106417. protected _parallaxScaleBias: number;
  106418. /**
  106419. * If sets to true, disables all the lights affecting the material.
  106420. */
  106421. protected _disableLighting: boolean;
  106422. /**
  106423. * Number of Simultaneous lights allowed on the material.
  106424. */
  106425. protected _maxSimultaneousLights: number;
  106426. /**
  106427. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106428. */
  106429. protected _invertNormalMapX: boolean;
  106430. /**
  106431. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106432. */
  106433. protected _invertNormalMapY: boolean;
  106434. /**
  106435. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106436. */
  106437. protected _twoSidedLighting: boolean;
  106438. /**
  106439. * Defines the alpha limits in alpha test mode.
  106440. */
  106441. protected _alphaCutOff: number;
  106442. /**
  106443. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106444. */
  106445. protected _forceAlphaTest: boolean;
  106446. /**
  106447. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106448. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  106449. */
  106450. protected _useAlphaFresnel: boolean;
  106451. /**
  106452. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106453. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  106454. */
  106455. protected _useLinearAlphaFresnel: boolean;
  106456. /**
  106457. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  106458. * from cos thetav and roughness:
  106459. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  106460. */
  106461. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  106462. /**
  106463. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  106464. */
  106465. protected _forceIrradianceInFragment: boolean;
  106466. private _realTimeFiltering;
  106467. /**
  106468. * Enables realtime filtering on the texture.
  106469. */
  106470. get realTimeFiltering(): boolean;
  106471. set realTimeFiltering(b: boolean);
  106472. private _realTimeFilteringQuality;
  106473. /**
  106474. * Quality switch for realtime filtering
  106475. */
  106476. get realTimeFilteringQuality(): number;
  106477. set realTimeFilteringQuality(n: number);
  106478. /**
  106479. * Can this material render to several textures at once
  106480. */
  106481. get canRenderToMRT(): boolean;
  106482. /**
  106483. * Force normal to face away from face.
  106484. */
  106485. protected _forceNormalForward: boolean;
  106486. /**
  106487. * Enables specular anti aliasing in the PBR shader.
  106488. * It will both interacts on the Geometry for analytical and IBL lighting.
  106489. * It also prefilter the roughness map based on the bump values.
  106490. */
  106491. protected _enableSpecularAntiAliasing: boolean;
  106492. /**
  106493. * Default configuration related to image processing available in the PBR Material.
  106494. */
  106495. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106496. /**
  106497. * Keep track of the image processing observer to allow dispose and replace.
  106498. */
  106499. private _imageProcessingObserver;
  106500. /**
  106501. * Attaches a new image processing configuration to the PBR Material.
  106502. * @param configuration
  106503. */
  106504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106505. /**
  106506. * Stores the available render targets.
  106507. */
  106508. private _renderTargets;
  106509. /**
  106510. * Sets the global ambient color for the material used in lighting calculations.
  106511. */
  106512. private _globalAmbientColor;
  106513. /**
  106514. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  106515. */
  106516. private _useLogarithmicDepth;
  106517. /**
  106518. * If set to true, no lighting calculations will be applied.
  106519. */
  106520. private _unlit;
  106521. private _debugMode;
  106522. /**
  106523. * @hidden
  106524. * This is reserved for the inspector.
  106525. * Defines the material debug mode.
  106526. * It helps seeing only some components of the material while troubleshooting.
  106527. */
  106528. debugMode: number;
  106529. /**
  106530. * @hidden
  106531. * This is reserved for the inspector.
  106532. * Specify from where on screen the debug mode should start.
  106533. * The value goes from -1 (full screen) to 1 (not visible)
  106534. * It helps with side by side comparison against the final render
  106535. * This defaults to -1
  106536. */
  106537. private debugLimit;
  106538. /**
  106539. * @hidden
  106540. * This is reserved for the inspector.
  106541. * As the default viewing range might not be enough (if the ambient is really small for instance)
  106542. * You can use the factor to better multiply the final value.
  106543. */
  106544. private debugFactor;
  106545. /**
  106546. * Defines the clear coat layer parameters for the material.
  106547. */
  106548. readonly clearCoat: PBRClearCoatConfiguration;
  106549. /**
  106550. * Defines the anisotropic parameters for the material.
  106551. */
  106552. readonly anisotropy: PBRAnisotropicConfiguration;
  106553. /**
  106554. * Defines the BRDF parameters for the material.
  106555. */
  106556. readonly brdf: PBRBRDFConfiguration;
  106557. /**
  106558. * Defines the Sheen parameters for the material.
  106559. */
  106560. readonly sheen: PBRSheenConfiguration;
  106561. /**
  106562. * Defines the SubSurface parameters for the material.
  106563. */
  106564. readonly subSurface: PBRSubSurfaceConfiguration;
  106565. /**
  106566. * Defines additionnal PrePass parameters for the material.
  106567. */
  106568. readonly prePassConfiguration: PrePassConfiguration;
  106569. /**
  106570. * Defines the detail map parameters for the material.
  106571. */
  106572. readonly detailMap: DetailMapConfiguration;
  106573. protected _rebuildInParallel: boolean;
  106574. /**
  106575. * Instantiates a new PBRMaterial instance.
  106576. *
  106577. * @param name The material name
  106578. * @param scene The scene the material will be use in.
  106579. */
  106580. constructor(name: string, scene: Scene);
  106581. /**
  106582. * Gets a boolean indicating that current material needs to register RTT
  106583. */
  106584. get hasRenderTargetTextures(): boolean;
  106585. /**
  106586. * Gets the name of the material class.
  106587. */
  106588. getClassName(): string;
  106589. /**
  106590. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  106591. */
  106592. get useLogarithmicDepth(): boolean;
  106593. /**
  106594. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  106595. */
  106596. set useLogarithmicDepth(value: boolean);
  106597. /**
  106598. * Returns true if alpha blending should be disabled.
  106599. */
  106600. protected get _disableAlphaBlending(): boolean;
  106601. /**
  106602. * Specifies whether or not this material should be rendered in alpha blend mode.
  106603. */
  106604. needAlphaBlending(): boolean;
  106605. /**
  106606. * Specifies whether or not this material should be rendered in alpha test mode.
  106607. */
  106608. needAlphaTesting(): boolean;
  106609. /**
  106610. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  106611. */
  106612. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  106613. /**
  106614. * Specifies whether or not there is a usable alpha channel for transparency.
  106615. */
  106616. protected _hasAlphaChannel(): boolean;
  106617. /**
  106618. * Gets the texture used for the alpha test.
  106619. */
  106620. getAlphaTestTexture(): Nullable<BaseTexture>;
  106621. /**
  106622. * Specifies that the submesh is ready to be used.
  106623. * @param mesh - BJS mesh.
  106624. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  106625. * @param useInstances - Specifies that instances should be used.
  106626. * @returns - boolean indicating that the submesh is ready or not.
  106627. */
  106628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106629. /**
  106630. * Specifies if the material uses metallic roughness workflow.
  106631. * @returns boolean specifiying if the material uses metallic roughness workflow.
  106632. */
  106633. isMetallicWorkflow(): boolean;
  106634. private _prepareEffect;
  106635. private _prepareDefines;
  106636. /**
  106637. * Force shader compilation
  106638. */
  106639. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  106640. /**
  106641. * Initializes the uniform buffer layout for the shader.
  106642. */
  106643. buildUniformLayout(): void;
  106644. /**
  106645. * Unbinds the material from the mesh
  106646. */
  106647. unbind(): void;
  106648. /**
  106649. * Binds the submesh data.
  106650. * @param world - The world matrix.
  106651. * @param mesh - The BJS mesh.
  106652. * @param subMesh - A submesh of the BJS mesh.
  106653. */
  106654. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106655. /**
  106656. * Returns the animatable textures.
  106657. * @returns - Array of animatable textures.
  106658. */
  106659. getAnimatables(): IAnimatable[];
  106660. /**
  106661. * Returns the texture used for reflections.
  106662. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  106663. */
  106664. private _getReflectionTexture;
  106665. /**
  106666. * Returns an array of the actively used textures.
  106667. * @returns - Array of BaseTextures
  106668. */
  106669. getActiveTextures(): BaseTexture[];
  106670. /**
  106671. * Checks to see if a texture is used in the material.
  106672. * @param texture - Base texture to use.
  106673. * @returns - Boolean specifying if a texture is used in the material.
  106674. */
  106675. hasTexture(texture: BaseTexture): boolean;
  106676. /**
  106677. * Sets the required values to the prepass renderer.
  106678. * @param prePassRenderer defines the prepass renderer to setup
  106679. */
  106680. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  106681. /**
  106682. * Disposes the resources of the material.
  106683. * @param forceDisposeEffect - Forces the disposal of effects.
  106684. * @param forceDisposeTextures - Forces the disposal of all textures.
  106685. */
  106686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106687. }
  106688. }
  106689. declare module BABYLON {
  106690. /**
  106691. * The Physically based material of BJS.
  106692. *
  106693. * This offers the main features of a standard PBR material.
  106694. * For more information, please refer to the documentation :
  106695. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106696. */
  106697. export class PBRMaterial extends PBRBaseMaterial {
  106698. /**
  106699. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106700. */
  106701. static readonly PBRMATERIAL_OPAQUE: number;
  106702. /**
  106703. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106704. */
  106705. static readonly PBRMATERIAL_ALPHATEST: number;
  106706. /**
  106707. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106708. */
  106709. static readonly PBRMATERIAL_ALPHABLEND: number;
  106710. /**
  106711. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106712. * They are also discarded below the alpha cutoff threshold to improve performances.
  106713. */
  106714. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106715. /**
  106716. * Defines the default value of how much AO map is occluding the analytical lights
  106717. * (point spot...).
  106718. */
  106719. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106720. /**
  106721. * Intensity of the direct lights e.g. the four lights available in your scene.
  106722. * This impacts both the direct diffuse and specular highlights.
  106723. */
  106724. directIntensity: number;
  106725. /**
  106726. * Intensity of the emissive part of the material.
  106727. * This helps controlling the emissive effect without modifying the emissive color.
  106728. */
  106729. emissiveIntensity: number;
  106730. /**
  106731. * Intensity of the environment e.g. how much the environment will light the object
  106732. * either through harmonics for rough material or through the refelction for shiny ones.
  106733. */
  106734. environmentIntensity: number;
  106735. /**
  106736. * This is a special control allowing the reduction of the specular highlights coming from the
  106737. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106738. */
  106739. specularIntensity: number;
  106740. /**
  106741. * Debug Control allowing disabling the bump map on this material.
  106742. */
  106743. disableBumpMap: boolean;
  106744. /**
  106745. * AKA Diffuse Texture in standard nomenclature.
  106746. */
  106747. albedoTexture: BaseTexture;
  106748. /**
  106749. * AKA Occlusion Texture in other nomenclature.
  106750. */
  106751. ambientTexture: BaseTexture;
  106752. /**
  106753. * AKA Occlusion Texture Intensity in other nomenclature.
  106754. */
  106755. ambientTextureStrength: number;
  106756. /**
  106757. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106758. * 1 means it completely occludes it
  106759. * 0 mean it has no impact
  106760. */
  106761. ambientTextureImpactOnAnalyticalLights: number;
  106762. /**
  106763. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  106764. */
  106765. opacityTexture: BaseTexture;
  106766. /**
  106767. * Stores the reflection values in a texture.
  106768. */
  106769. reflectionTexture: Nullable<BaseTexture>;
  106770. /**
  106771. * Stores the emissive values in a texture.
  106772. */
  106773. emissiveTexture: BaseTexture;
  106774. /**
  106775. * AKA Specular texture in other nomenclature.
  106776. */
  106777. reflectivityTexture: BaseTexture;
  106778. /**
  106779. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106780. */
  106781. metallicTexture: BaseTexture;
  106782. /**
  106783. * Specifies the metallic scalar of the metallic/roughness workflow.
  106784. * Can also be used to scale the metalness values of the metallic texture.
  106785. */
  106786. metallic: Nullable<number>;
  106787. /**
  106788. * Specifies the roughness scalar of the metallic/roughness workflow.
  106789. * Can also be used to scale the roughness values of the metallic texture.
  106790. */
  106791. roughness: Nullable<number>;
  106792. /**
  106793. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106794. * By default the indexOfrefraction is used to compute F0;
  106795. *
  106796. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106797. *
  106798. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106799. * F90 = metallicReflectanceColor;
  106800. */
  106801. metallicF0Factor: number;
  106802. /**
  106803. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106804. * By default the F90 is always 1;
  106805. *
  106806. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106807. *
  106808. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106809. * F90 = metallicReflectanceColor;
  106810. */
  106811. metallicReflectanceColor: Color3;
  106812. /**
  106813. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106814. * This is multiply against the scalar values defined in the material.
  106815. */
  106816. metallicReflectanceTexture: Nullable<BaseTexture>;
  106817. /**
  106818. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106819. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106820. */
  106821. microSurfaceTexture: BaseTexture;
  106822. /**
  106823. * Stores surface normal data used to displace a mesh in a texture.
  106824. */
  106825. bumpTexture: BaseTexture;
  106826. /**
  106827. * Stores the pre-calculated light information of a mesh in a texture.
  106828. */
  106829. lightmapTexture: BaseTexture;
  106830. /**
  106831. * Stores the refracted light information in a texture.
  106832. */
  106833. get refractionTexture(): Nullable<BaseTexture>;
  106834. set refractionTexture(value: Nullable<BaseTexture>);
  106835. /**
  106836. * The color of a material in ambient lighting.
  106837. */
  106838. ambientColor: Color3;
  106839. /**
  106840. * AKA Diffuse Color in other nomenclature.
  106841. */
  106842. albedoColor: Color3;
  106843. /**
  106844. * AKA Specular Color in other nomenclature.
  106845. */
  106846. reflectivityColor: Color3;
  106847. /**
  106848. * The color reflected from the material.
  106849. */
  106850. reflectionColor: Color3;
  106851. /**
  106852. * The color emitted from the material.
  106853. */
  106854. emissiveColor: Color3;
  106855. /**
  106856. * AKA Glossiness in other nomenclature.
  106857. */
  106858. microSurface: number;
  106859. /**
  106860. * Index of refraction of the material base layer.
  106861. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106862. *
  106863. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106864. *
  106865. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106866. */
  106867. get indexOfRefraction(): number;
  106868. set indexOfRefraction(value: number);
  106869. /**
  106870. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106871. */
  106872. get invertRefractionY(): boolean;
  106873. set invertRefractionY(value: boolean);
  106874. /**
  106875. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106876. * Materials half opaque for instance using refraction could benefit from this control.
  106877. */
  106878. get linkRefractionWithTransparency(): boolean;
  106879. set linkRefractionWithTransparency(value: boolean);
  106880. /**
  106881. * If true, the light map contains occlusion information instead of lighting info.
  106882. */
  106883. useLightmapAsShadowmap: boolean;
  106884. /**
  106885. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106886. */
  106887. useAlphaFromAlbedoTexture: boolean;
  106888. /**
  106889. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106890. */
  106891. forceAlphaTest: boolean;
  106892. /**
  106893. * Defines the alpha limits in alpha test mode.
  106894. */
  106895. alphaCutOff: number;
  106896. /**
  106897. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106898. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106899. */
  106900. useSpecularOverAlpha: boolean;
  106901. /**
  106902. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106903. */
  106904. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106905. /**
  106906. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106907. */
  106908. useRoughnessFromMetallicTextureAlpha: boolean;
  106909. /**
  106910. * Specifies if the metallic texture contains the roughness information in its green channel.
  106911. */
  106912. useRoughnessFromMetallicTextureGreen: boolean;
  106913. /**
  106914. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106915. */
  106916. useMetallnessFromMetallicTextureBlue: boolean;
  106917. /**
  106918. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106919. */
  106920. useAmbientOcclusionFromMetallicTextureRed: boolean;
  106921. /**
  106922. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106923. */
  106924. useAmbientInGrayScale: boolean;
  106925. /**
  106926. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106927. * The material will try to infer what glossiness each pixel should be.
  106928. */
  106929. useAutoMicroSurfaceFromReflectivityMap: boolean;
  106930. /**
  106931. * BJS is using an harcoded light falloff based on a manually sets up range.
  106932. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  106933. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  106934. */
  106935. get usePhysicalLightFalloff(): boolean;
  106936. /**
  106937. * BJS is using an harcoded light falloff based on a manually sets up range.
  106938. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  106939. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  106940. */
  106941. set usePhysicalLightFalloff(value: boolean);
  106942. /**
  106943. * In order to support the falloff compatibility with gltf, a special mode has been added
  106944. * to reproduce the gltf light falloff.
  106945. */
  106946. get useGLTFLightFalloff(): boolean;
  106947. /**
  106948. * In order to support the falloff compatibility with gltf, a special mode has been added
  106949. * to reproduce the gltf light falloff.
  106950. */
  106951. set useGLTFLightFalloff(value: boolean);
  106952. /**
  106953. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106954. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106955. */
  106956. useRadianceOverAlpha: boolean;
  106957. /**
  106958. * Allows using an object space normal map (instead of tangent space).
  106959. */
  106960. useObjectSpaceNormalMap: boolean;
  106961. /**
  106962. * Allows using the bump map in parallax mode.
  106963. */
  106964. useParallax: boolean;
  106965. /**
  106966. * Allows using the bump map in parallax occlusion mode.
  106967. */
  106968. useParallaxOcclusion: boolean;
  106969. /**
  106970. * Controls the scale bias of the parallax mode.
  106971. */
  106972. parallaxScaleBias: number;
  106973. /**
  106974. * If sets to true, disables all the lights affecting the material.
  106975. */
  106976. disableLighting: boolean;
  106977. /**
  106978. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  106979. */
  106980. forceIrradianceInFragment: boolean;
  106981. /**
  106982. * Number of Simultaneous lights allowed on the material.
  106983. */
  106984. maxSimultaneousLights: number;
  106985. /**
  106986. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106987. */
  106988. invertNormalMapX: boolean;
  106989. /**
  106990. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106991. */
  106992. invertNormalMapY: boolean;
  106993. /**
  106994. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106995. */
  106996. twoSidedLighting: boolean;
  106997. /**
  106998. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106999. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107000. */
  107001. useAlphaFresnel: boolean;
  107002. /**
  107003. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107004. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107005. */
  107006. useLinearAlphaFresnel: boolean;
  107007. /**
  107008. * Let user defines the brdf lookup texture used for IBL.
  107009. * A default 8bit version is embedded but you could point at :
  107010. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107011. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107012. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107013. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107014. */
  107015. environmentBRDFTexture: Nullable<BaseTexture>;
  107016. /**
  107017. * Force normal to face away from face.
  107018. */
  107019. forceNormalForward: boolean;
  107020. /**
  107021. * Enables specular anti aliasing in the PBR shader.
  107022. * It will both interacts on the Geometry for analytical and IBL lighting.
  107023. * It also prefilter the roughness map based on the bump values.
  107024. */
  107025. enableSpecularAntiAliasing: boolean;
  107026. /**
  107027. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107028. * makes the reflect vector face the model (under horizon).
  107029. */
  107030. useHorizonOcclusion: boolean;
  107031. /**
  107032. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107033. * too much the area relying on ambient texture to define their ambient occlusion.
  107034. */
  107035. useRadianceOcclusion: boolean;
  107036. /**
  107037. * If set to true, no lighting calculations will be applied.
  107038. */
  107039. unlit: boolean;
  107040. /**
  107041. * Gets the image processing configuration used either in this material.
  107042. */
  107043. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107044. /**
  107045. * Sets the Default image processing configuration used either in the this material.
  107046. *
  107047. * If sets to null, the scene one is in use.
  107048. */
  107049. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107050. /**
  107051. * Gets wether the color curves effect is enabled.
  107052. */
  107053. get cameraColorCurvesEnabled(): boolean;
  107054. /**
  107055. * Sets wether the color curves effect is enabled.
  107056. */
  107057. set cameraColorCurvesEnabled(value: boolean);
  107058. /**
  107059. * Gets wether the color grading effect is enabled.
  107060. */
  107061. get cameraColorGradingEnabled(): boolean;
  107062. /**
  107063. * Gets wether the color grading effect is enabled.
  107064. */
  107065. set cameraColorGradingEnabled(value: boolean);
  107066. /**
  107067. * Gets wether tonemapping is enabled or not.
  107068. */
  107069. get cameraToneMappingEnabled(): boolean;
  107070. /**
  107071. * Sets wether tonemapping is enabled or not
  107072. */
  107073. set cameraToneMappingEnabled(value: boolean);
  107074. /**
  107075. * The camera exposure used on this material.
  107076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107077. * This corresponds to a photographic exposure.
  107078. */
  107079. get cameraExposure(): number;
  107080. /**
  107081. * The camera exposure used on this material.
  107082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107083. * This corresponds to a photographic exposure.
  107084. */
  107085. set cameraExposure(value: number);
  107086. /**
  107087. * Gets The camera contrast used on this material.
  107088. */
  107089. get cameraContrast(): number;
  107090. /**
  107091. * Sets The camera contrast used on this material.
  107092. */
  107093. set cameraContrast(value: number);
  107094. /**
  107095. * Gets the Color Grading 2D Lookup Texture.
  107096. */
  107097. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107098. /**
  107099. * Sets the Color Grading 2D Lookup Texture.
  107100. */
  107101. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107102. /**
  107103. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107104. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107105. * 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;
  107106. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107107. */
  107108. get cameraColorCurves(): Nullable<ColorCurves>;
  107109. /**
  107110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107112. * 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;
  107113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107114. */
  107115. set cameraColorCurves(value: Nullable<ColorCurves>);
  107116. /**
  107117. * Instantiates a new PBRMaterial instance.
  107118. *
  107119. * @param name The material name
  107120. * @param scene The scene the material will be use in.
  107121. */
  107122. constructor(name: string, scene: Scene);
  107123. /**
  107124. * Returns the name of this material class.
  107125. */
  107126. getClassName(): string;
  107127. /**
  107128. * Makes a duplicate of the current material.
  107129. * @param name - name to use for the new material.
  107130. */
  107131. clone(name: string): PBRMaterial;
  107132. /**
  107133. * Serializes this PBR Material.
  107134. * @returns - An object with the serialized material.
  107135. */
  107136. serialize(): any;
  107137. /**
  107138. * Parses a PBR Material from a serialized object.
  107139. * @param source - Serialized object.
  107140. * @param scene - BJS scene instance.
  107141. * @param rootUrl - url for the scene object
  107142. * @returns - PBRMaterial
  107143. */
  107144. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107145. }
  107146. }
  107147. declare module BABYLON {
  107148. /** @hidden */
  107149. export var mrtFragmentDeclaration: {
  107150. name: string;
  107151. shader: string;
  107152. };
  107153. }
  107154. declare module BABYLON {
  107155. /** @hidden */
  107156. export var geometryPixelShader: {
  107157. name: string;
  107158. shader: string;
  107159. };
  107160. }
  107161. declare module BABYLON {
  107162. /** @hidden */
  107163. export var instancesDeclaration: {
  107164. name: string;
  107165. shader: string;
  107166. };
  107167. }
  107168. declare module BABYLON {
  107169. /** @hidden */
  107170. export var geometryVertexShader: {
  107171. name: string;
  107172. shader: string;
  107173. };
  107174. }
  107175. declare module BABYLON {
  107176. /** @hidden */
  107177. interface ISavedTransformationMatrix {
  107178. world: Matrix;
  107179. viewProjection: Matrix;
  107180. }
  107181. /**
  107182. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107183. */
  107184. export class GeometryBufferRenderer {
  107185. /**
  107186. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107187. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107188. */
  107189. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107190. /**
  107191. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107192. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107193. */
  107194. static readonly POSITION_TEXTURE_TYPE: number;
  107195. /**
  107196. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107197. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107198. */
  107199. static readonly VELOCITY_TEXTURE_TYPE: number;
  107200. /**
  107201. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107202. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107203. */
  107204. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107205. /**
  107206. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107207. * in order to compute objects velocities when enableVelocity is set to "true"
  107208. * @hidden
  107209. */
  107210. _previousTransformationMatrices: {
  107211. [index: number]: ISavedTransformationMatrix;
  107212. };
  107213. /**
  107214. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107215. * in order to compute objects velocities when enableVelocity is set to "true"
  107216. * @hidden
  107217. */
  107218. _previousBonesTransformationMatrices: {
  107219. [index: number]: Float32Array;
  107220. };
  107221. /**
  107222. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107223. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107224. */
  107225. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107226. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107227. renderTransparentMeshes: boolean;
  107228. private _scene;
  107229. private _resizeObserver;
  107230. private _multiRenderTarget;
  107231. private _ratio;
  107232. private _enablePosition;
  107233. private _enableVelocity;
  107234. private _enableReflectivity;
  107235. private _positionIndex;
  107236. private _velocityIndex;
  107237. private _reflectivityIndex;
  107238. private _depthNormalIndex;
  107239. private _linkedWithPrePass;
  107240. private _prePassRenderer;
  107241. private _attachments;
  107242. protected _effect: Effect;
  107243. protected _cachedDefines: string;
  107244. /**
  107245. * @hidden
  107246. * Sets up internal structures to share outputs with PrePassRenderer
  107247. * This method should only be called by the PrePassRenderer itself
  107248. */
  107249. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107250. /**
  107251. * @hidden
  107252. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107253. * This method should only be called by the PrePassRenderer itself
  107254. */
  107255. _unlinkPrePassRenderer(): void;
  107256. /**
  107257. * @hidden
  107258. * Resets the geometry buffer layout
  107259. */
  107260. _resetLayout(): void;
  107261. /**
  107262. * @hidden
  107263. * Replaces a texture in the geometry buffer renderer
  107264. * Useful when linking textures of the prepass renderer
  107265. */
  107266. _forceTextureType(geometryBufferType: number, index: number): void;
  107267. /**
  107268. * @hidden
  107269. * Sets texture attachments
  107270. * Useful when linking textures of the prepass renderer
  107271. */
  107272. _setAttachments(attachments: number[]): void;
  107273. /**
  107274. * @hidden
  107275. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107276. * Useful when linking textures of the prepass renderer
  107277. */
  107278. _linkInternalTexture(internalTexture: InternalTexture): void;
  107279. /**
  107280. * Gets the render list (meshes to be rendered) used in the G buffer.
  107281. */
  107282. get renderList(): Nullable<AbstractMesh[]>;
  107283. /**
  107284. * Set the render list (meshes to be rendered) used in the G buffer.
  107285. */
  107286. set renderList(meshes: Nullable<AbstractMesh[]>);
  107287. /**
  107288. * Gets wether or not G buffer are supported by the running hardware.
  107289. * This requires draw buffer supports
  107290. */
  107291. get isSupported(): boolean;
  107292. /**
  107293. * Returns the index of the given texture type in the G-Buffer textures array
  107294. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107295. * @returns the index of the given texture type in the G-Buffer textures array
  107296. */
  107297. getTextureIndex(textureType: number): number;
  107298. /**
  107299. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107300. */
  107301. get enablePosition(): boolean;
  107302. /**
  107303. * Sets whether or not objects positions are enabled for the G buffer.
  107304. */
  107305. set enablePosition(enable: boolean);
  107306. /**
  107307. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107308. */
  107309. get enableVelocity(): boolean;
  107310. /**
  107311. * Sets wether or not objects velocities are enabled for the G buffer.
  107312. */
  107313. set enableVelocity(enable: boolean);
  107314. /**
  107315. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107316. */
  107317. get enableReflectivity(): boolean;
  107318. /**
  107319. * Sets wether or not objects roughness are enabled for the G buffer.
  107320. */
  107321. set enableReflectivity(enable: boolean);
  107322. /**
  107323. * Gets the scene associated with the buffer.
  107324. */
  107325. get scene(): Scene;
  107326. /**
  107327. * Gets the ratio used by the buffer during its creation.
  107328. * How big is the buffer related to the main canvas.
  107329. */
  107330. get ratio(): number;
  107331. /** @hidden */
  107332. static _SceneComponentInitialization: (scene: Scene) => void;
  107333. /**
  107334. * Creates a new G Buffer for the scene
  107335. * @param scene The scene the buffer belongs to
  107336. * @param ratio How big is the buffer related to the main canvas.
  107337. */
  107338. constructor(scene: Scene, ratio?: number);
  107339. /**
  107340. * Checks wether everything is ready to render a submesh to the G buffer.
  107341. * @param subMesh the submesh to check readiness for
  107342. * @param useInstances is the mesh drawn using instance or not
  107343. * @returns true if ready otherwise false
  107344. */
  107345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107346. /**
  107347. * Gets the current underlying G Buffer.
  107348. * @returns the buffer
  107349. */
  107350. getGBuffer(): MultiRenderTarget;
  107351. /**
  107352. * Gets the number of samples used to render the buffer (anti aliasing).
  107353. */
  107354. get samples(): number;
  107355. /**
  107356. * Sets the number of samples used to render the buffer (anti aliasing).
  107357. */
  107358. set samples(value: number);
  107359. /**
  107360. * Disposes the renderer and frees up associated resources.
  107361. */
  107362. dispose(): void;
  107363. private _assignRenderTargetIndices;
  107364. protected _createRenderTargets(): void;
  107365. private _copyBonesTransformationMatrices;
  107366. }
  107367. }
  107368. declare module BABYLON {
  107369. /**
  107370. * Renders a pre pass of the scene
  107371. * This means every mesh in the scene will be rendered to a render target texture
  107372. * And then this texture will be composited to the rendering canvas with post processes
  107373. * It is necessary for effects like subsurface scattering or deferred shading
  107374. */
  107375. export class PrePassRenderer {
  107376. /** @hidden */
  107377. static _SceneComponentInitialization: (scene: Scene) => void;
  107378. private _textureFormats;
  107379. /**
  107380. * To save performance, we can excluded skinned meshes from the prepass
  107381. */
  107382. excludedSkinnedMesh: AbstractMesh[];
  107383. /**
  107384. * Force material to be excluded from the prepass
  107385. * Can be useful when `useGeometryBufferFallback` is set to `true`
  107386. * and you don't want a material to show in the effect.
  107387. */
  107388. excludedMaterials: Material[];
  107389. private _textureIndices;
  107390. private _scene;
  107391. private _engine;
  107392. private _isDirty;
  107393. /**
  107394. * Number of textures in the multi render target texture where the scene is directly rendered
  107395. */
  107396. mrtCount: number;
  107397. /**
  107398. * The render target where the scene is directly rendered
  107399. */
  107400. prePassRT: MultiRenderTarget;
  107401. private _multiRenderAttachments;
  107402. private _defaultAttachments;
  107403. private _clearAttachments;
  107404. private _postProcesses;
  107405. private readonly _clearColor;
  107406. /**
  107407. * Image processing post process for composition
  107408. */
  107409. imageProcessingPostProcess: ImageProcessingPostProcess;
  107410. /**
  107411. * Configuration for prepass effects
  107412. */
  107413. private _effectConfigurations;
  107414. private _mrtFormats;
  107415. private _mrtLayout;
  107416. private _enabled;
  107417. /**
  107418. * Indicates if the prepass is enabled
  107419. */
  107420. get enabled(): boolean;
  107421. /**
  107422. * How many samples are used for MSAA of the scene render target
  107423. */
  107424. get samples(): number;
  107425. set samples(n: number);
  107426. private _geometryBuffer;
  107427. private _useGeometryBufferFallback;
  107428. /**
  107429. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  107430. */
  107431. get useGeometryBufferFallback(): boolean;
  107432. set useGeometryBufferFallback(value: boolean);
  107433. /**
  107434. * Set to true to disable gamma transform in PrePass.
  107435. * Can be useful in case you already proceed to gamma transform on a material level
  107436. * and your post processes don't need to be in linear color space.
  107437. */
  107438. disableGammaTransform: boolean;
  107439. /**
  107440. * Instanciates a prepass renderer
  107441. * @param scene The scene
  107442. */
  107443. constructor(scene: Scene);
  107444. private _initializeAttachments;
  107445. private _createCompositionEffect;
  107446. /**
  107447. * Indicates if rendering a prepass is supported
  107448. */
  107449. get isSupported(): boolean;
  107450. /**
  107451. * Sets the proper output textures to draw in the engine.
  107452. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  107453. * @param subMesh Submesh on which the effect is applied
  107454. */
  107455. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  107456. /**
  107457. * Restores attachments for single texture draw.
  107458. */
  107459. restoreAttachments(): void;
  107460. /**
  107461. * @hidden
  107462. */
  107463. _beforeCameraDraw(): void;
  107464. /**
  107465. * @hidden
  107466. */
  107467. _afterCameraDraw(): void;
  107468. private _checkRTSize;
  107469. private _bindFrameBuffer;
  107470. /**
  107471. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  107472. */
  107473. clear(): void;
  107474. private _setState;
  107475. private _updateGeometryBufferLayout;
  107476. /**
  107477. * Adds an effect configuration to the prepass.
  107478. * If an effect has already been added, it won't add it twice and will return the configuration
  107479. * already present.
  107480. * @param cfg the effect configuration
  107481. * @return the effect configuration now used by the prepass
  107482. */
  107483. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  107484. /**
  107485. * Returns the index of a texture in the multi render target texture array.
  107486. * @param type Texture type
  107487. * @return The index
  107488. */
  107489. getIndex(type: number): number;
  107490. private _enable;
  107491. private _disable;
  107492. private _resetLayout;
  107493. private _resetPostProcessChain;
  107494. private _bindPostProcessChain;
  107495. /**
  107496. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  107497. */
  107498. markAsDirty(): void;
  107499. /**
  107500. * Enables a texture on the MultiRenderTarget for prepass
  107501. */
  107502. private _enableTextures;
  107503. private _update;
  107504. private _markAllMaterialsAsPrePassDirty;
  107505. /**
  107506. * Disposes the prepass renderer.
  107507. */
  107508. dispose(): void;
  107509. }
  107510. }
  107511. declare module BABYLON {
  107512. /**
  107513. * Size options for a post process
  107514. */
  107515. export type PostProcessOptions = {
  107516. width: number;
  107517. height: number;
  107518. };
  107519. /**
  107520. * PostProcess can be used to apply a shader to a texture after it has been rendered
  107521. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107522. */
  107523. export class PostProcess {
  107524. /**
  107525. * Gets or sets the unique id of the post process
  107526. */
  107527. uniqueId: number;
  107528. /** Name of the PostProcess. */
  107529. name: string;
  107530. /**
  107531. * Width of the texture to apply the post process on
  107532. */
  107533. width: number;
  107534. /**
  107535. * Height of the texture to apply the post process on
  107536. */
  107537. height: number;
  107538. /**
  107539. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  107540. */
  107541. nodeMaterialSource: Nullable<NodeMaterial>;
  107542. /**
  107543. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  107544. * @hidden
  107545. */
  107546. _outputTexture: Nullable<InternalTexture>;
  107547. /**
  107548. * Sampling mode used by the shader
  107549. * See https://doc.babylonjs.com/classes/3.1/texture
  107550. */
  107551. renderTargetSamplingMode: number;
  107552. /**
  107553. * Clear color to use when screen clearing
  107554. */
  107555. clearColor: Color4;
  107556. /**
  107557. * If the buffer needs to be cleared before applying the post process. (default: true)
  107558. * Should be set to false if shader will overwrite all previous pixels.
  107559. */
  107560. autoClear: boolean;
  107561. /**
  107562. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  107563. */
  107564. alphaMode: number;
  107565. /**
  107566. * Sets the setAlphaBlendConstants of the babylon engine
  107567. */
  107568. alphaConstants: Color4;
  107569. /**
  107570. * Animations to be used for the post processing
  107571. */
  107572. animations: Animation[];
  107573. /**
  107574. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  107575. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  107576. */
  107577. enablePixelPerfectMode: boolean;
  107578. /**
  107579. * Force the postprocess to be applied without taking in account viewport
  107580. */
  107581. forceFullscreenViewport: boolean;
  107582. /**
  107583. * List of inspectable custom properties (used by the Inspector)
  107584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  107585. */
  107586. inspectableCustomProperties: IInspectable[];
  107587. /**
  107588. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  107589. *
  107590. * | Value | Type | Description |
  107591. * | ----- | ----------------------------------- | ----------- |
  107592. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  107593. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  107594. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  107595. *
  107596. */
  107597. scaleMode: number;
  107598. /**
  107599. * Force textures to be a power of two (default: false)
  107600. */
  107601. alwaysForcePOT: boolean;
  107602. private _samples;
  107603. /**
  107604. * Number of sample textures (default: 1)
  107605. */
  107606. get samples(): number;
  107607. set samples(n: number);
  107608. /**
  107609. * Modify the scale of the post process to be the same as the viewport (default: false)
  107610. */
  107611. adaptScaleToCurrentViewport: boolean;
  107612. private _camera;
  107613. protected _scene: Scene;
  107614. private _engine;
  107615. private _options;
  107616. private _reusable;
  107617. private _textureType;
  107618. private _textureFormat;
  107619. /**
  107620. * Smart array of input and output textures for the post process.
  107621. * @hidden
  107622. */
  107623. _textures: SmartArray<InternalTexture>;
  107624. /**
  107625. * The index in _textures that corresponds to the output texture.
  107626. * @hidden
  107627. */
  107628. _currentRenderTextureInd: number;
  107629. private _effect;
  107630. private _samplers;
  107631. private _fragmentUrl;
  107632. private _vertexUrl;
  107633. private _parameters;
  107634. private _scaleRatio;
  107635. protected _indexParameters: any;
  107636. private _shareOutputWithPostProcess;
  107637. private _texelSize;
  107638. private _forcedOutputTexture;
  107639. /**
  107640. * Prepass configuration in case this post process needs a texture from prepass
  107641. * @hidden
  107642. */
  107643. _prePassEffectConfiguration: PrePassEffectConfiguration;
  107644. /**
  107645. * Returns the fragment url or shader name used in the post process.
  107646. * @returns the fragment url or name in the shader store.
  107647. */
  107648. getEffectName(): string;
  107649. /**
  107650. * An event triggered when the postprocess is activated.
  107651. */
  107652. onActivateObservable: Observable<Camera>;
  107653. private _onActivateObserver;
  107654. /**
  107655. * A function that is added to the onActivateObservable
  107656. */
  107657. set onActivate(callback: Nullable<(camera: Camera) => void>);
  107658. /**
  107659. * An event triggered when the postprocess changes its size.
  107660. */
  107661. onSizeChangedObservable: Observable<PostProcess>;
  107662. private _onSizeChangedObserver;
  107663. /**
  107664. * A function that is added to the onSizeChangedObservable
  107665. */
  107666. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  107667. /**
  107668. * An event triggered when the postprocess applies its effect.
  107669. */
  107670. onApplyObservable: Observable<Effect>;
  107671. private _onApplyObserver;
  107672. /**
  107673. * A function that is added to the onApplyObservable
  107674. */
  107675. set onApply(callback: (effect: Effect) => void);
  107676. /**
  107677. * An event triggered before rendering the postprocess
  107678. */
  107679. onBeforeRenderObservable: Observable<Effect>;
  107680. private _onBeforeRenderObserver;
  107681. /**
  107682. * A function that is added to the onBeforeRenderObservable
  107683. */
  107684. set onBeforeRender(callback: (effect: Effect) => void);
  107685. /**
  107686. * An event triggered after rendering the postprocess
  107687. */
  107688. onAfterRenderObservable: Observable<Effect>;
  107689. private _onAfterRenderObserver;
  107690. /**
  107691. * A function that is added to the onAfterRenderObservable
  107692. */
  107693. set onAfterRender(callback: (efect: Effect) => void);
  107694. /**
  107695. * 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
  107696. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  107697. */
  107698. get inputTexture(): InternalTexture;
  107699. set inputTexture(value: InternalTexture);
  107700. /**
  107701. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  107702. * the only way to unset it is to use this function to restore its internal state
  107703. */
  107704. restoreDefaultInputTexture(): void;
  107705. /**
  107706. * Gets the camera which post process is applied to.
  107707. * @returns The camera the post process is applied to.
  107708. */
  107709. getCamera(): Camera;
  107710. /**
  107711. * Gets the texel size of the postprocess.
  107712. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  107713. */
  107714. get texelSize(): Vector2;
  107715. /**
  107716. * Creates a new instance PostProcess
  107717. * @param name The name of the PostProcess.
  107718. * @param fragmentUrl The url of the fragment shader to be used.
  107719. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  107720. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  107721. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  107722. * @param camera The camera to apply the render pass to.
  107723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107724. * @param engine The engine which the post process will be applied. (default: current engine)
  107725. * @param reusable If the post process can be reused on the same frame. (default: false)
  107726. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  107727. * @param textureType Type of textures used when performing the post process. (default: 0)
  107728. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  107729. * @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
  107730. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  107731. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  107732. */
  107733. 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);
  107734. /**
  107735. * Gets a string identifying the name of the class
  107736. * @returns "PostProcess" string
  107737. */
  107738. getClassName(): string;
  107739. /**
  107740. * Gets the engine which this post process belongs to.
  107741. * @returns The engine the post process was enabled with.
  107742. */
  107743. getEngine(): Engine;
  107744. /**
  107745. * The effect that is created when initializing the post process.
  107746. * @returns The created effect corresponding the the postprocess.
  107747. */
  107748. getEffect(): Effect;
  107749. /**
  107750. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  107751. * @param postProcess The post process to share the output with.
  107752. * @returns This post process.
  107753. */
  107754. shareOutputWith(postProcess: PostProcess): PostProcess;
  107755. /**
  107756. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  107757. * This should be called if the post process that shares output with this post process is disabled/disposed.
  107758. */
  107759. useOwnOutput(): void;
  107760. /**
  107761. * Updates the effect with the current post process compile time values and recompiles the shader.
  107762. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107763. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107764. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107765. * @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
  107766. * @param onCompiled Called when the shader has been compiled.
  107767. * @param onError Called if there is an error when compiling a shader.
  107768. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  107769. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  107770. */
  107771. 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;
  107772. /**
  107773. * The post process is reusable if it can be used multiple times within one frame.
  107774. * @returns If the post process is reusable
  107775. */
  107776. isReusable(): boolean;
  107777. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  107778. markTextureDirty(): void;
  107779. /**
  107780. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  107781. * 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.
  107782. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  107783. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  107784. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  107785. * @returns The target texture that was bound to be written to.
  107786. */
  107787. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  107788. /**
  107789. * If the post process is supported.
  107790. */
  107791. get isSupported(): boolean;
  107792. /**
  107793. * The aspect ratio of the output texture.
  107794. */
  107795. get aspectRatio(): number;
  107796. /**
  107797. * Get a value indicating if the post-process is ready to be used
  107798. * @returns true if the post-process is ready (shader is compiled)
  107799. */
  107800. isReady(): boolean;
  107801. /**
  107802. * Binds all textures and uniforms to the shader, this will be run on every pass.
  107803. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  107804. */
  107805. apply(): Nullable<Effect>;
  107806. private _disposeTextures;
  107807. /**
  107808. * Sets the required values to the prepass renderer.
  107809. * @param prePassRenderer defines the prepass renderer to setup.
  107810. * @returns true if the pre pass is needed.
  107811. */
  107812. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107813. /**
  107814. * Disposes the post process.
  107815. * @param camera The camera to dispose the post process on.
  107816. */
  107817. dispose(camera?: Camera): void;
  107818. /**
  107819. * Serializes the particle system to a JSON object
  107820. * @returns the JSON object
  107821. */
  107822. serialize(): any;
  107823. /**
  107824. * Creates a material from parsed material data
  107825. * @param parsedPostProcess defines parsed post process data
  107826. * @param scene defines the hosting scene
  107827. * @param rootUrl defines the root URL to use to load textures
  107828. * @returns a new post process
  107829. */
  107830. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  107831. }
  107832. }
  107833. declare module BABYLON {
  107834. /** @hidden */
  107835. export var kernelBlurVaryingDeclaration: {
  107836. name: string;
  107837. shader: string;
  107838. };
  107839. }
  107840. declare module BABYLON {
  107841. /** @hidden */
  107842. export var packingFunctions: {
  107843. name: string;
  107844. shader: string;
  107845. };
  107846. }
  107847. declare module BABYLON {
  107848. /** @hidden */
  107849. export var kernelBlurFragment: {
  107850. name: string;
  107851. shader: string;
  107852. };
  107853. }
  107854. declare module BABYLON {
  107855. /** @hidden */
  107856. export var kernelBlurFragment2: {
  107857. name: string;
  107858. shader: string;
  107859. };
  107860. }
  107861. declare module BABYLON {
  107862. /** @hidden */
  107863. export var kernelBlurPixelShader: {
  107864. name: string;
  107865. shader: string;
  107866. };
  107867. }
  107868. declare module BABYLON {
  107869. /** @hidden */
  107870. export var kernelBlurVertex: {
  107871. name: string;
  107872. shader: string;
  107873. };
  107874. }
  107875. declare module BABYLON {
  107876. /** @hidden */
  107877. export var kernelBlurVertexShader: {
  107878. name: string;
  107879. shader: string;
  107880. };
  107881. }
  107882. declare module BABYLON {
  107883. /**
  107884. * The Blur Post Process which blurs an image based on a kernel and direction.
  107885. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  107886. */
  107887. export class BlurPostProcess extends PostProcess {
  107888. private blockCompilation;
  107889. protected _kernel: number;
  107890. protected _idealKernel: number;
  107891. protected _packedFloat: boolean;
  107892. private _staticDefines;
  107893. /** The direction in which to blur the image. */
  107894. direction: Vector2;
  107895. /**
  107896. * Sets the length in pixels of the blur sample region
  107897. */
  107898. set kernel(v: number);
  107899. /**
  107900. * Gets the length in pixels of the blur sample region
  107901. */
  107902. get kernel(): number;
  107903. /**
  107904. * Sets wether or not the blur needs to unpack/repack floats
  107905. */
  107906. set packedFloat(v: boolean);
  107907. /**
  107908. * Gets wether or not the blur is unpacking/repacking floats
  107909. */
  107910. get packedFloat(): boolean;
  107911. /**
  107912. * Gets a string identifying the name of the class
  107913. * @returns "BlurPostProcess" string
  107914. */
  107915. getClassName(): string;
  107916. /**
  107917. * Creates a new instance BlurPostProcess
  107918. * @param name The name of the effect.
  107919. * @param direction The direction in which to blur the image.
  107920. * @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.
  107921. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  107922. * @param camera The camera to apply the render pass to.
  107923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107924. * @param engine The engine which the post process will be applied. (default: current engine)
  107925. * @param reusable If the post process can be reused on the same frame. (default: false)
  107926. * @param textureType Type of textures used when performing the post process. (default: 0)
  107927. * @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)
  107928. */
  107929. 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);
  107930. /**
  107931. * Updates the effect with the current post process compile time values and recompiles the shader.
  107932. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107933. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107934. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107935. * @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
  107936. * @param onCompiled Called when the shader has been compiled.
  107937. * @param onError Called if there is an error when compiling a shader.
  107938. */
  107939. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107940. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107941. /**
  107942. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  107943. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  107944. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  107945. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  107946. * The gaps between physical kernels are compensated for in the weighting of the samples
  107947. * @param idealKernel Ideal blur kernel.
  107948. * @return Nearest best kernel.
  107949. */
  107950. protected _nearestBestKernel(idealKernel: number): number;
  107951. /**
  107952. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  107953. * @param x The point on the Gaussian distribution to sample.
  107954. * @return the value of the Gaussian function at x.
  107955. */
  107956. protected _gaussianWeight(x: number): number;
  107957. /**
  107958. * Generates a string that can be used as a floating point number in GLSL.
  107959. * @param x Value to print.
  107960. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  107961. * @return GLSL float string.
  107962. */
  107963. protected _glslFloat(x: number, decimalFigures?: number): string;
  107964. /** @hidden */
  107965. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  107966. }
  107967. }
  107968. declare module BABYLON {
  107969. /**
  107970. * Mirror texture can be used to simulate the view from a mirror in a scene.
  107971. * It will dynamically be rendered every frame to adapt to the camera point of view.
  107972. * You can then easily use it as a reflectionTexture on a flat surface.
  107973. * In case the surface is not a plane, please consider relying on reflection probes.
  107974. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  107975. */
  107976. export class MirrorTexture extends RenderTargetTexture {
  107977. private scene;
  107978. /**
  107979. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  107980. * 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.
  107981. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  107982. */
  107983. mirrorPlane: Plane;
  107984. /**
  107985. * Define the blur ratio used to blur the reflection if needed.
  107986. */
  107987. set blurRatio(value: number);
  107988. get blurRatio(): number;
  107989. /**
  107990. * Define the adaptive blur kernel used to blur the reflection if needed.
  107991. * This will autocompute the closest best match for the `blurKernel`
  107992. */
  107993. set adaptiveBlurKernel(value: number);
  107994. /**
  107995. * Define the blur kernel used to blur the reflection if needed.
  107996. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  107997. */
  107998. set blurKernel(value: number);
  107999. /**
  108000. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108001. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108002. */
  108003. set blurKernelX(value: number);
  108004. get blurKernelX(): number;
  108005. /**
  108006. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108007. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108008. */
  108009. set blurKernelY(value: number);
  108010. get blurKernelY(): number;
  108011. private _autoComputeBlurKernel;
  108012. protected _onRatioRescale(): void;
  108013. private _updateGammaSpace;
  108014. private _imageProcessingConfigChangeObserver;
  108015. private _transformMatrix;
  108016. private _mirrorMatrix;
  108017. private _savedViewMatrix;
  108018. private _blurX;
  108019. private _blurY;
  108020. private _adaptiveBlurKernel;
  108021. private _blurKernelX;
  108022. private _blurKernelY;
  108023. private _blurRatio;
  108024. /**
  108025. * Instantiates a Mirror Texture.
  108026. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108027. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108028. * You can then easily use it as a reflectionTexture on a flat surface.
  108029. * In case the surface is not a plane, please consider relying on reflection probes.
  108030. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108031. * @param name
  108032. * @param size
  108033. * @param scene
  108034. * @param generateMipMaps
  108035. * @param type
  108036. * @param samplingMode
  108037. * @param generateDepthBuffer
  108038. */
  108039. constructor(name: string, size: number | {
  108040. width: number;
  108041. height: number;
  108042. } | {
  108043. ratio: number;
  108044. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108045. private _preparePostProcesses;
  108046. /**
  108047. * Clone the mirror texture.
  108048. * @returns the cloned texture
  108049. */
  108050. clone(): MirrorTexture;
  108051. /**
  108052. * Serialize the texture to a JSON representation you could use in Parse later on
  108053. * @returns the serialized JSON representation
  108054. */
  108055. serialize(): any;
  108056. /**
  108057. * Dispose the texture and release its associated resources.
  108058. */
  108059. dispose(): void;
  108060. }
  108061. }
  108062. declare module BABYLON {
  108063. /**
  108064. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108065. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108066. */
  108067. export class Texture extends BaseTexture {
  108068. /**
  108069. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108070. */
  108071. static SerializeBuffers: boolean;
  108072. /**
  108073. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  108074. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  108075. */
  108076. static ForceSerializeBuffers: boolean;
  108077. /** @hidden */
  108078. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108079. /** @hidden */
  108080. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108081. /** @hidden */
  108082. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108083. /** nearest is mag = nearest and min = nearest and mip = linear */
  108084. static readonly NEAREST_SAMPLINGMODE: number;
  108085. /** nearest is mag = nearest and min = nearest and mip = linear */
  108086. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108087. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108088. static readonly BILINEAR_SAMPLINGMODE: number;
  108089. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108090. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108091. /** Trilinear is mag = linear and min = linear and mip = linear */
  108092. static readonly TRILINEAR_SAMPLINGMODE: number;
  108093. /** Trilinear is mag = linear and min = linear and mip = linear */
  108094. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108095. /** mag = nearest and min = nearest and mip = nearest */
  108096. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108097. /** mag = nearest and min = linear and mip = nearest */
  108098. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108099. /** mag = nearest and min = linear and mip = linear */
  108100. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108101. /** mag = nearest and min = linear and mip = none */
  108102. static readonly NEAREST_LINEAR: number;
  108103. /** mag = nearest and min = nearest and mip = none */
  108104. static readonly NEAREST_NEAREST: number;
  108105. /** mag = linear and min = nearest and mip = nearest */
  108106. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108107. /** mag = linear and min = nearest and mip = linear */
  108108. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108109. /** mag = linear and min = linear and mip = none */
  108110. static readonly LINEAR_LINEAR: number;
  108111. /** mag = linear and min = nearest and mip = none */
  108112. static readonly LINEAR_NEAREST: number;
  108113. /** Explicit coordinates mode */
  108114. static readonly EXPLICIT_MODE: number;
  108115. /** Spherical coordinates mode */
  108116. static readonly SPHERICAL_MODE: number;
  108117. /** Planar coordinates mode */
  108118. static readonly PLANAR_MODE: number;
  108119. /** Cubic coordinates mode */
  108120. static readonly CUBIC_MODE: number;
  108121. /** Projection coordinates mode */
  108122. static readonly PROJECTION_MODE: number;
  108123. /** Inverse Cubic coordinates mode */
  108124. static readonly SKYBOX_MODE: number;
  108125. /** Inverse Cubic coordinates mode */
  108126. static readonly INVCUBIC_MODE: number;
  108127. /** Equirectangular coordinates mode */
  108128. static readonly EQUIRECTANGULAR_MODE: number;
  108129. /** Equirectangular Fixed coordinates mode */
  108130. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108131. /** Equirectangular Fixed Mirrored coordinates mode */
  108132. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108133. /** Texture is not repeating outside of 0..1 UVs */
  108134. static readonly CLAMP_ADDRESSMODE: number;
  108135. /** Texture is repeating outside of 0..1 UVs */
  108136. static readonly WRAP_ADDRESSMODE: number;
  108137. /** Texture is repeating and mirrored */
  108138. static readonly MIRROR_ADDRESSMODE: number;
  108139. /**
  108140. * 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
  108141. */
  108142. static UseSerializedUrlIfAny: boolean;
  108143. /**
  108144. * Define the url of the texture.
  108145. */
  108146. url: Nullable<string>;
  108147. /**
  108148. * Define an offset on the texture to offset the u coordinates of the UVs
  108149. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108150. */
  108151. uOffset: number;
  108152. /**
  108153. * Define an offset on the texture to offset the v coordinates of the UVs
  108154. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108155. */
  108156. vOffset: number;
  108157. /**
  108158. * Define an offset on the texture to scale the u coordinates of the UVs
  108159. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108160. */
  108161. uScale: number;
  108162. /**
  108163. * Define an offset on the texture to scale the v coordinates of the UVs
  108164. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108165. */
  108166. vScale: number;
  108167. /**
  108168. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108169. * @see https://doc.babylonjs.com/how_to/more_materials
  108170. */
  108171. uAng: number;
  108172. /**
  108173. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108174. * @see https://doc.babylonjs.com/how_to/more_materials
  108175. */
  108176. vAng: number;
  108177. /**
  108178. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108179. * @see https://doc.babylonjs.com/how_to/more_materials
  108180. */
  108181. wAng: number;
  108182. /**
  108183. * Defines the center of rotation (U)
  108184. */
  108185. uRotationCenter: number;
  108186. /**
  108187. * Defines the center of rotation (V)
  108188. */
  108189. vRotationCenter: number;
  108190. /**
  108191. * Defines the center of rotation (W)
  108192. */
  108193. wRotationCenter: number;
  108194. /**
  108195. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108196. */
  108197. homogeneousRotationInUVTransform: boolean;
  108198. /**
  108199. * Are mip maps generated for this texture or not.
  108200. */
  108201. get noMipmap(): boolean;
  108202. /**
  108203. * List of inspectable custom properties (used by the Inspector)
  108204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108205. */
  108206. inspectableCustomProperties: Nullable<IInspectable[]>;
  108207. private _noMipmap;
  108208. /** @hidden */
  108209. _invertY: boolean;
  108210. private _rowGenerationMatrix;
  108211. private _cachedTextureMatrix;
  108212. private _projectionModeMatrix;
  108213. private _t0;
  108214. private _t1;
  108215. private _t2;
  108216. private _cachedUOffset;
  108217. private _cachedVOffset;
  108218. private _cachedUScale;
  108219. private _cachedVScale;
  108220. private _cachedUAng;
  108221. private _cachedVAng;
  108222. private _cachedWAng;
  108223. private _cachedProjectionMatrixId;
  108224. private _cachedURotationCenter;
  108225. private _cachedVRotationCenter;
  108226. private _cachedWRotationCenter;
  108227. private _cachedHomogeneousRotationInUVTransform;
  108228. private _cachedCoordinatesMode;
  108229. /** @hidden */
  108230. protected _initialSamplingMode: number;
  108231. /** @hidden */
  108232. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108233. private _deleteBuffer;
  108234. protected _format: Nullable<number>;
  108235. private _delayedOnLoad;
  108236. private _delayedOnError;
  108237. private _mimeType?;
  108238. private _loaderOptions?;
  108239. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108240. get mimeType(): string | undefined;
  108241. /**
  108242. * Observable triggered once the texture has been loaded.
  108243. */
  108244. onLoadObservable: Observable<Texture>;
  108245. protected _isBlocking: boolean;
  108246. /**
  108247. * Is the texture preventing material to render while loading.
  108248. * If false, a default texture will be used instead of the loading one during the preparation step.
  108249. */
  108250. set isBlocking(value: boolean);
  108251. get isBlocking(): boolean;
  108252. /**
  108253. * Get the current sampling mode associated with the texture.
  108254. */
  108255. get samplingMode(): number;
  108256. /**
  108257. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108258. */
  108259. get invertY(): boolean;
  108260. /**
  108261. * Instantiates a new texture.
  108262. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108263. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108264. * @param url defines the url of the picture to load as a texture
  108265. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108266. * @param noMipmap defines if the texture will require mip maps or not
  108267. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108268. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108269. * @param onLoad defines a callback triggered when the texture has been loaded
  108270. * @param onError defines a callback triggered when an error occurred during the loading session
  108271. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108272. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108273. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108274. * @param mimeType defines an optional mime type information
  108275. * @param loaderOptions options to be passed to the loader
  108276. */
  108277. 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);
  108278. /**
  108279. * Update the url (and optional buffer) of this texture if url was null during construction.
  108280. * @param url the url of the texture
  108281. * @param buffer the buffer of the texture (defaults to null)
  108282. * @param onLoad callback called when the texture is loaded (defaults to null)
  108283. */
  108284. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108285. /**
  108286. * Finish the loading sequence of a texture flagged as delayed load.
  108287. * @hidden
  108288. */
  108289. delayLoad(): void;
  108290. private _prepareRowForTextureGeneration;
  108291. /**
  108292. * Checks if the texture has the same transform matrix than another texture
  108293. * @param texture texture to check against
  108294. * @returns true if the transforms are the same, else false
  108295. */
  108296. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  108297. /**
  108298. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108299. * @returns the transform matrix of the texture.
  108300. */
  108301. getTextureMatrix(uBase?: number): Matrix;
  108302. /**
  108303. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108304. * @returns The reflection texture transform
  108305. */
  108306. getReflectionTextureMatrix(): Matrix;
  108307. /**
  108308. * Clones the texture.
  108309. * @returns the cloned texture
  108310. */
  108311. clone(): Texture;
  108312. /**
  108313. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108314. * @returns The JSON representation of the texture
  108315. */
  108316. serialize(): any;
  108317. /**
  108318. * Get the current class name of the texture useful for serialization or dynamic coding.
  108319. * @returns "Texture"
  108320. */
  108321. getClassName(): string;
  108322. /**
  108323. * Dispose the texture and release its associated resources.
  108324. */
  108325. dispose(): void;
  108326. /**
  108327. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108328. * @param parsedTexture Define the JSON representation of the texture
  108329. * @param scene Define the scene the parsed texture should be instantiated in
  108330. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108331. * @returns The parsed texture if successful
  108332. */
  108333. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108334. /**
  108335. * Creates a texture from its base 64 representation.
  108336. * @param data Define the base64 payload without the data: prefix
  108337. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108338. * @param scene Define the scene the texture should belong to
  108339. * @param noMipmap Forces the texture to not create mip map information if true
  108340. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108341. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108342. * @param onLoad define a callback triggered when the texture has been loaded
  108343. * @param onError define a callback triggered when an error occurred during the loading session
  108344. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108345. * @returns the created texture
  108346. */
  108347. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108348. /**
  108349. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108350. * @param data Define the base64 payload without the data: prefix
  108351. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108352. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108353. * @param scene Define the scene the texture should belong to
  108354. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108355. * @param noMipmap Forces the texture to not create mip map information if true
  108356. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108357. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108358. * @param onLoad define a callback triggered when the texture has been loaded
  108359. * @param onError define a callback triggered when an error occurred during the loading session
  108360. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108361. * @returns the created texture
  108362. */
  108363. 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;
  108364. }
  108365. }
  108366. declare module BABYLON {
  108367. /**
  108368. * ThinSprite Class used to represent a thin sprite
  108369. * This is the base class for sprites but can also directly be used with ThinEngine
  108370. * @see https://doc.babylonjs.com/babylon101/sprites
  108371. */
  108372. export class ThinSprite {
  108373. /** Gets or sets the cell index in the sprite sheet */
  108374. cellIndex: number;
  108375. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  108376. cellRef: string;
  108377. /** Gets or sets the current world position */
  108378. position: IVector3Like;
  108379. /** Gets or sets the main color */
  108380. color: IColor4Like;
  108381. /** Gets or sets the width */
  108382. width: number;
  108383. /** Gets or sets the height */
  108384. height: number;
  108385. /** Gets or sets rotation angle */
  108386. angle: number;
  108387. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  108388. invertU: boolean;
  108389. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  108390. invertV: boolean;
  108391. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  108392. isVisible: boolean;
  108393. /**
  108394. * Returns a boolean indicating if the animation is started
  108395. */
  108396. get animationStarted(): boolean;
  108397. /** Gets the initial key for the animation (setting it will restart the animation) */
  108398. get fromIndex(): number;
  108399. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  108400. get toIndex(): number;
  108401. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  108402. get loopAnimation(): boolean;
  108403. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  108404. get delay(): number;
  108405. /** @hidden */
  108406. _xOffset: number;
  108407. /** @hidden */
  108408. _yOffset: number;
  108409. /** @hidden */
  108410. _xSize: number;
  108411. /** @hidden */
  108412. _ySize: number;
  108413. private _animationStarted;
  108414. protected _loopAnimation: boolean;
  108415. protected _fromIndex: number;
  108416. protected _toIndex: number;
  108417. protected _delay: number;
  108418. private _direction;
  108419. private _time;
  108420. private _onBaseAnimationEnd;
  108421. /**
  108422. * Creates a new Thin Sprite
  108423. */
  108424. constructor();
  108425. /**
  108426. * Starts an animation
  108427. * @param from defines the initial key
  108428. * @param to defines the end key
  108429. * @param loop defines if the animation must loop
  108430. * @param delay defines the start delay (in ms)
  108431. * @param onAnimationEnd defines a callback for when the animation ends
  108432. */
  108433. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  108434. /** Stops current animation (if any) */
  108435. stopAnimation(): void;
  108436. /** @hidden */
  108437. _animate(deltaTime: number): void;
  108438. }
  108439. }
  108440. declare module BABYLON {
  108441. /** @hidden */
  108442. export var imageProcessingCompatibility: {
  108443. name: string;
  108444. shader: string;
  108445. };
  108446. }
  108447. declare module BABYLON {
  108448. /** @hidden */
  108449. export var spritesPixelShader: {
  108450. name: string;
  108451. shader: string;
  108452. };
  108453. }
  108454. declare module BABYLON {
  108455. /** @hidden */
  108456. export var spritesVertexShader: {
  108457. name: string;
  108458. shader: string;
  108459. };
  108460. }
  108461. declare module BABYLON {
  108462. /**
  108463. * Class used to render sprites.
  108464. *
  108465. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  108466. */
  108467. export class SpriteRenderer {
  108468. /**
  108469. * Defines the texture of the spritesheet
  108470. */
  108471. texture: Nullable<ThinTexture>;
  108472. /**
  108473. * Defines the default width of a cell in the spritesheet
  108474. */
  108475. cellWidth: number;
  108476. /**
  108477. * Defines the default height of a cell in the spritesheet
  108478. */
  108479. cellHeight: number;
  108480. /**
  108481. * Blend mode use to render the particle, it can be any of
  108482. * the static Constants.ALPHA_x properties provided in this class.
  108483. * Default value is Constants.ALPHA_COMBINE
  108484. */
  108485. blendMode: number;
  108486. /**
  108487. * Gets or sets a boolean indicating if alpha mode is automatically
  108488. * reset.
  108489. */
  108490. autoResetAlpha: boolean;
  108491. /**
  108492. * Disables writing to the depth buffer when rendering the sprites.
  108493. * It can be handy to disable depth writing when using textures without alpha channel
  108494. * and setting some specific blend modes.
  108495. */
  108496. disableDepthWrite: boolean;
  108497. /**
  108498. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  108499. */
  108500. fogEnabled: boolean;
  108501. /**
  108502. * Gets the capacity of the manager
  108503. */
  108504. get capacity(): number;
  108505. private readonly _engine;
  108506. private readonly _useVAO;
  108507. private readonly _useInstancing;
  108508. private readonly _scene;
  108509. private readonly _capacity;
  108510. private readonly _epsilon;
  108511. private _vertexBufferSize;
  108512. private _vertexData;
  108513. private _buffer;
  108514. private _vertexBuffers;
  108515. private _spriteBuffer;
  108516. private _indexBuffer;
  108517. private _effectBase;
  108518. private _effectFog;
  108519. private _vertexArrayObject;
  108520. /**
  108521. * Creates a new sprite Renderer
  108522. * @param engine defines the engine the renderer works with
  108523. * @param capacity defines the maximum allowed number of sprites
  108524. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  108525. * @param scene defines the hosting scene
  108526. */
  108527. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  108528. /**
  108529. * Render all child sprites
  108530. * @param sprites defines the list of sprites to render
  108531. * @param deltaTime defines the time since last frame
  108532. * @param viewMatrix defines the viewMatrix to use to render the sprites
  108533. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  108534. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  108535. */
  108536. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  108537. private _appendSpriteVertex;
  108538. /**
  108539. * Release associated resources
  108540. */
  108541. dispose(): void;
  108542. }
  108543. }
  108544. declare module BABYLON {
  108545. /**
  108546. * Defines the minimum interface to fullfil in order to be a sprite manager.
  108547. */
  108548. export interface ISpriteManager extends IDisposable {
  108549. /**
  108550. * Gets manager's name
  108551. */
  108552. name: string;
  108553. /**
  108554. * Restricts the camera to viewing objects with the same layerMask.
  108555. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  108556. */
  108557. layerMask: number;
  108558. /**
  108559. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108560. */
  108561. isPickable: boolean;
  108562. /**
  108563. * Gets the hosting scene
  108564. */
  108565. scene: Scene;
  108566. /**
  108567. * Specifies the rendering group id for this mesh (0 by default)
  108568. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108569. */
  108570. renderingGroupId: number;
  108571. /**
  108572. * Defines the list of sprites managed by the manager.
  108573. */
  108574. sprites: Array<Sprite>;
  108575. /**
  108576. * Gets or sets the spritesheet texture
  108577. */
  108578. texture: Texture;
  108579. /** Defines the default width of a cell in the spritesheet */
  108580. cellWidth: number;
  108581. /** Defines the default height of a cell in the spritesheet */
  108582. cellHeight: number;
  108583. /**
  108584. * Tests the intersection of a sprite with a specific ray.
  108585. * @param ray The ray we are sending to test the collision
  108586. * @param camera The camera space we are sending rays in
  108587. * @param predicate A predicate allowing excluding sprites from the list of object to test
  108588. * @param fastCheck defines if the first intersection will be used (and not the closest)
  108589. * @returns picking info or null.
  108590. */
  108591. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  108592. /**
  108593. * Intersects the sprites with a ray
  108594. * @param ray defines the ray to intersect with
  108595. * @param camera defines the current active camera
  108596. * @param predicate defines a predicate used to select candidate sprites
  108597. * @returns null if no hit or a PickingInfo array
  108598. */
  108599. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  108600. /**
  108601. * Renders the list of sprites on screen.
  108602. */
  108603. render(): void;
  108604. }
  108605. /**
  108606. * Class used to manage multiple sprites on the same spritesheet
  108607. * @see https://doc.babylonjs.com/babylon101/sprites
  108608. */
  108609. export class SpriteManager implements ISpriteManager {
  108610. /** defines the manager's name */
  108611. name: string;
  108612. /** Define the Url to load snippets */
  108613. static SnippetUrl: string;
  108614. /** Snippet ID if the manager was created from the snippet server */
  108615. snippetId: string;
  108616. /** Gets the list of sprites */
  108617. sprites: Sprite[];
  108618. /** Gets or sets the rendering group id (0 by default) */
  108619. renderingGroupId: number;
  108620. /** Gets or sets camera layer mask */
  108621. layerMask: number;
  108622. /** Gets or sets a boolean indicating if the sprites are pickable */
  108623. isPickable: boolean;
  108624. /**
  108625. * An event triggered when the manager is disposed.
  108626. */
  108627. onDisposeObservable: Observable<SpriteManager>;
  108628. /**
  108629. * Callback called when the manager is disposed
  108630. */
  108631. set onDispose(callback: () => void);
  108632. /**
  108633. * Gets or sets the unique id of the sprite
  108634. */
  108635. uniqueId: number;
  108636. /**
  108637. * Gets the array of sprites
  108638. */
  108639. get children(): Sprite[];
  108640. /**
  108641. * Gets the hosting scene
  108642. */
  108643. get scene(): Scene;
  108644. /**
  108645. * Gets the capacity of the manager
  108646. */
  108647. get capacity(): number;
  108648. /**
  108649. * Gets or sets the spritesheet texture
  108650. */
  108651. get texture(): Texture;
  108652. set texture(value: Texture);
  108653. /** Defines the default width of a cell in the spritesheet */
  108654. get cellWidth(): number;
  108655. set cellWidth(value: number);
  108656. /** Defines the default height of a cell in the spritesheet */
  108657. get cellHeight(): number;
  108658. set cellHeight(value: number);
  108659. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  108660. get fogEnabled(): boolean;
  108661. set fogEnabled(value: boolean);
  108662. /**
  108663. * Blend mode use to render the particle, it can be any of
  108664. * the static Constants.ALPHA_x properties provided in this class.
  108665. * Default value is Constants.ALPHA_COMBINE
  108666. */
  108667. get blendMode(): number;
  108668. set blendMode(blendMode: number);
  108669. /** Disables writing to the depth buffer when rendering the sprites.
  108670. * It can be handy to disable depth writing when using textures without alpha channel
  108671. * and setting some specific blend modes.
  108672. */
  108673. disableDepthWrite: boolean;
  108674. private _spriteRenderer;
  108675. /** Associative array from JSON sprite data file */
  108676. private _cellData;
  108677. /** Array of sprite names from JSON sprite data file */
  108678. private _spriteMap;
  108679. /** True when packed cell data from JSON file is ready*/
  108680. private _packedAndReady;
  108681. private _textureContent;
  108682. private _onDisposeObserver;
  108683. private _fromPacked;
  108684. private _scene;
  108685. /**
  108686. * Creates a new sprite manager
  108687. * @param name defines the manager's name
  108688. * @param imgUrl defines the sprite sheet url
  108689. * @param capacity defines the maximum allowed number of sprites
  108690. * @param cellSize defines the size of a sprite cell
  108691. * @param scene defines the hosting scene
  108692. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  108693. * @param samplingMode defines the smapling mode to use with spritesheet
  108694. * @param fromPacked set to false; do not alter
  108695. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  108696. */
  108697. constructor(
  108698. /** defines the manager's name */
  108699. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  108700. /**
  108701. * Returns the string "SpriteManager"
  108702. * @returns "SpriteManager"
  108703. */
  108704. getClassName(): string;
  108705. private _makePacked;
  108706. private _checkTextureAlpha;
  108707. /**
  108708. * Intersects the sprites with a ray
  108709. * @param ray defines the ray to intersect with
  108710. * @param camera defines the current active camera
  108711. * @param predicate defines a predicate used to select candidate sprites
  108712. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  108713. * @returns null if no hit or a PickingInfo
  108714. */
  108715. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  108716. /**
  108717. * Intersects the sprites with a ray
  108718. * @param ray defines the ray to intersect with
  108719. * @param camera defines the current active camera
  108720. * @param predicate defines a predicate used to select candidate sprites
  108721. * @returns null if no hit or a PickingInfo array
  108722. */
  108723. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  108724. /**
  108725. * Render all child sprites
  108726. */
  108727. render(): void;
  108728. private _customUpdate;
  108729. /**
  108730. * Release associated resources
  108731. */
  108732. dispose(): void;
  108733. /**
  108734. * Serializes the sprite manager to a JSON object
  108735. * @param serializeTexture defines if the texture must be serialized as well
  108736. * @returns the JSON object
  108737. */
  108738. serialize(serializeTexture?: boolean): any;
  108739. /**
  108740. * Parses a JSON object to create a new sprite manager.
  108741. * @param parsedManager The JSON object to parse
  108742. * @param scene The scene to create the sprite managerin
  108743. * @param rootUrl The root url to use to load external dependencies like texture
  108744. * @returns the new sprite manager
  108745. */
  108746. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  108747. /**
  108748. * Creates a sprite manager from a snippet saved in a remote file
  108749. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  108750. * @param url defines the url to load from
  108751. * @param scene defines the hosting scene
  108752. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108753. * @returns a promise that will resolve to the new sprite manager
  108754. */
  108755. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  108756. /**
  108757. * Creates a sprite manager from a snippet saved by the sprite editor
  108758. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  108759. * @param scene defines the hosting scene
  108760. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108761. * @returns a promise that will resolve to the new sprite manager
  108762. */
  108763. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  108764. }
  108765. }
  108766. declare module BABYLON {
  108767. /**
  108768. * Class used to represent a sprite
  108769. * @see https://doc.babylonjs.com/babylon101/sprites
  108770. */
  108771. export class Sprite extends ThinSprite implements IAnimatable {
  108772. /** defines the name */
  108773. name: string;
  108774. /** Gets or sets the current world position */
  108775. position: Vector3;
  108776. /** Gets or sets the main color */
  108777. color: Color4;
  108778. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  108779. disposeWhenFinishedAnimating: boolean;
  108780. /** Gets the list of attached animations */
  108781. animations: Nullable<Array<Animation>>;
  108782. /** Gets or sets a boolean indicating if the sprite can be picked */
  108783. isPickable: boolean;
  108784. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  108785. useAlphaForPicking: boolean;
  108786. /**
  108787. * Gets or sets the associated action manager
  108788. */
  108789. actionManager: Nullable<ActionManager>;
  108790. /**
  108791. * An event triggered when the control has been disposed
  108792. */
  108793. onDisposeObservable: Observable<Sprite>;
  108794. private _manager;
  108795. private _onAnimationEnd;
  108796. /**
  108797. * Gets or sets the sprite size
  108798. */
  108799. get size(): number;
  108800. set size(value: number);
  108801. /**
  108802. * Gets or sets the unique id of the sprite
  108803. */
  108804. uniqueId: number;
  108805. /**
  108806. * Gets the manager of this sprite
  108807. */
  108808. get manager(): ISpriteManager;
  108809. /**
  108810. * Creates a new Sprite
  108811. * @param name defines the name
  108812. * @param manager defines the manager
  108813. */
  108814. constructor(
  108815. /** defines the name */
  108816. name: string, manager: ISpriteManager);
  108817. /**
  108818. * Returns the string "Sprite"
  108819. * @returns "Sprite"
  108820. */
  108821. getClassName(): string;
  108822. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  108823. get fromIndex(): number;
  108824. set fromIndex(value: number);
  108825. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  108826. get toIndex(): number;
  108827. set toIndex(value: number);
  108828. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  108829. get loopAnimation(): boolean;
  108830. set loopAnimation(value: boolean);
  108831. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  108832. get delay(): number;
  108833. set delay(value: number);
  108834. /**
  108835. * Starts an animation
  108836. * @param from defines the initial key
  108837. * @param to defines the end key
  108838. * @param loop defines if the animation must loop
  108839. * @param delay defines the start delay (in ms)
  108840. * @param onAnimationEnd defines a callback to call when animation ends
  108841. */
  108842. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  108843. private _endAnimation;
  108844. /** Release associated resources */
  108845. dispose(): void;
  108846. /**
  108847. * Serializes the sprite to a JSON object
  108848. * @returns the JSON object
  108849. */
  108850. serialize(): any;
  108851. /**
  108852. * Parses a JSON object to create a new sprite
  108853. * @param parsedSprite The JSON object to parse
  108854. * @param manager defines the hosting manager
  108855. * @returns the new sprite
  108856. */
  108857. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  108858. }
  108859. }
  108860. declare module BABYLON {
  108861. /**
  108862. * Information about the result of picking within a scene
  108863. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  108864. */
  108865. export class PickingInfo {
  108866. /** @hidden */
  108867. _pickingUnavailable: boolean;
  108868. /**
  108869. * If the pick collided with an object
  108870. */
  108871. hit: boolean;
  108872. /**
  108873. * Distance away where the pick collided
  108874. */
  108875. distance: number;
  108876. /**
  108877. * The location of pick collision
  108878. */
  108879. pickedPoint: Nullable<Vector3>;
  108880. /**
  108881. * The mesh corresponding the the pick collision
  108882. */
  108883. pickedMesh: Nullable<AbstractMesh>;
  108884. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  108885. bu: number;
  108886. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  108887. bv: number;
  108888. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  108889. faceId: number;
  108890. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  108891. subMeshFaceId: number;
  108892. /** Id of the the submesh that was picked */
  108893. subMeshId: number;
  108894. /** If a sprite was picked, this will be the sprite the pick collided with */
  108895. pickedSprite: Nullable<Sprite>;
  108896. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  108897. thinInstanceIndex: number;
  108898. /**
  108899. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  108900. */
  108901. originMesh: Nullable<AbstractMesh>;
  108902. /**
  108903. * The ray that was used to perform the picking.
  108904. */
  108905. ray: Nullable<Ray>;
  108906. /**
  108907. * Gets the normal correspodning to the face the pick collided with
  108908. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  108909. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  108910. * @returns The normal correspodning to the face the pick collided with
  108911. */
  108912. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  108913. /**
  108914. * Gets the texture coordinates of where the pick occured
  108915. * @returns the vector containing the coordnates of the texture
  108916. */
  108917. getTextureCoordinates(): Nullable<Vector2>;
  108918. }
  108919. }
  108920. declare module BABYLON {
  108921. /**
  108922. * Gather the list of pointer event types as constants.
  108923. */
  108924. export class PointerEventTypes {
  108925. /**
  108926. * 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.
  108927. */
  108928. static readonly POINTERDOWN: number;
  108929. /**
  108930. * The pointerup event is fired when a pointer is no longer active.
  108931. */
  108932. static readonly POINTERUP: number;
  108933. /**
  108934. * The pointermove event is fired when a pointer changes coordinates.
  108935. */
  108936. static readonly POINTERMOVE: number;
  108937. /**
  108938. * The pointerwheel event is fired when a mouse wheel has been rotated.
  108939. */
  108940. static readonly POINTERWHEEL: number;
  108941. /**
  108942. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  108943. */
  108944. static readonly POINTERPICK: number;
  108945. /**
  108946. * The pointertap event is fired when a the object has been touched and released without drag.
  108947. */
  108948. static readonly POINTERTAP: number;
  108949. /**
  108950. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  108951. */
  108952. static readonly POINTERDOUBLETAP: number;
  108953. }
  108954. /**
  108955. * Base class of pointer info types.
  108956. */
  108957. export class PointerInfoBase {
  108958. /**
  108959. * Defines the type of event (PointerEventTypes)
  108960. */
  108961. type: number;
  108962. /**
  108963. * Defines the related dom event
  108964. */
  108965. event: PointerEvent | MouseWheelEvent;
  108966. /**
  108967. * Instantiates the base class of pointers info.
  108968. * @param type Defines the type of event (PointerEventTypes)
  108969. * @param event Defines the related dom event
  108970. */
  108971. constructor(
  108972. /**
  108973. * Defines the type of event (PointerEventTypes)
  108974. */
  108975. type: number,
  108976. /**
  108977. * Defines the related dom event
  108978. */
  108979. event: PointerEvent | MouseWheelEvent);
  108980. }
  108981. /**
  108982. * This class is used to store pointer related info for the onPrePointerObservable event.
  108983. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  108984. */
  108985. export class PointerInfoPre extends PointerInfoBase {
  108986. /**
  108987. * Ray from a pointer if availible (eg. 6dof controller)
  108988. */
  108989. ray: Nullable<Ray>;
  108990. /**
  108991. * Defines the local position of the pointer on the canvas.
  108992. */
  108993. localPosition: Vector2;
  108994. /**
  108995. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  108996. */
  108997. skipOnPointerObservable: boolean;
  108998. /**
  108999. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  109000. * @param type Defines the type of event (PointerEventTypes)
  109001. * @param event Defines the related dom event
  109002. * @param localX Defines the local x coordinates of the pointer when the event occured
  109003. * @param localY Defines the local y coordinates of the pointer when the event occured
  109004. */
  109005. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  109006. }
  109007. /**
  109008. * This type contains all the data related to a pointer event in Babylon.js.
  109009. * 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.
  109010. */
  109011. export class PointerInfo extends PointerInfoBase {
  109012. /**
  109013. * Defines the picking info associated to the info (if any)\
  109014. */
  109015. pickInfo: Nullable<PickingInfo>;
  109016. /**
  109017. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  109018. * @param type Defines the type of event (PointerEventTypes)
  109019. * @param event Defines the related dom event
  109020. * @param pickInfo Defines the picking info associated to the info (if any)\
  109021. */
  109022. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  109023. /**
  109024. * Defines the picking info associated to the info (if any)\
  109025. */
  109026. pickInfo: Nullable<PickingInfo>);
  109027. }
  109028. /**
  109029. * Data relating to a touch event on the screen.
  109030. */
  109031. export interface PointerTouch {
  109032. /**
  109033. * X coordinate of touch.
  109034. */
  109035. x: number;
  109036. /**
  109037. * Y coordinate of touch.
  109038. */
  109039. y: number;
  109040. /**
  109041. * Id of touch. Unique for each finger.
  109042. */
  109043. pointerId: number;
  109044. /**
  109045. * Event type passed from DOM.
  109046. */
  109047. type: any;
  109048. }
  109049. }
  109050. declare module BABYLON {
  109051. /**
  109052. * Manage the mouse inputs to control the movement of a free camera.
  109053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109054. */
  109055. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  109056. /**
  109057. * Define if touch is enabled in the mouse input
  109058. */
  109059. touchEnabled: boolean;
  109060. /**
  109061. * Defines the camera the input is attached to.
  109062. */
  109063. camera: FreeCamera;
  109064. /**
  109065. * Defines the buttons associated with the input to handle camera move.
  109066. */
  109067. buttons: number[];
  109068. /**
  109069. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  109070. */
  109071. angularSensibility: number;
  109072. private _pointerInput;
  109073. private _onMouseMove;
  109074. private _observer;
  109075. private previousPosition;
  109076. /**
  109077. * Observable for when a pointer move event occurs containing the move offset
  109078. */
  109079. onPointerMovedObservable: Observable<{
  109080. offsetX: number;
  109081. offsetY: number;
  109082. }>;
  109083. /**
  109084. * @hidden
  109085. * If the camera should be rotated automatically based on pointer movement
  109086. */
  109087. _allowCameraRotation: boolean;
  109088. /**
  109089. * Manage the mouse inputs to control the movement of a free camera.
  109090. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109091. * @param touchEnabled Defines if touch is enabled or not
  109092. */
  109093. constructor(
  109094. /**
  109095. * Define if touch is enabled in the mouse input
  109096. */
  109097. touchEnabled?: boolean);
  109098. /**
  109099. * Attach the input controls to a specific dom element to get the input from.
  109100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109101. */
  109102. attachControl(noPreventDefault?: boolean): void;
  109103. /**
  109104. * Called on JS contextmenu event.
  109105. * Override this method to provide functionality.
  109106. */
  109107. protected onContextMenu(evt: PointerEvent): void;
  109108. /**
  109109. * Detach the current controls from the specified dom element.
  109110. */
  109111. detachControl(): void;
  109112. /**
  109113. * Gets the class name of the current intput.
  109114. * @returns the class name
  109115. */
  109116. getClassName(): string;
  109117. /**
  109118. * Get the friendly name associated with the input class.
  109119. * @returns the input friendly name
  109120. */
  109121. getSimpleName(): string;
  109122. }
  109123. }
  109124. declare module BABYLON {
  109125. /**
  109126. * Base class for mouse wheel input..
  109127. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  109128. * for example usage.
  109129. */
  109130. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  109131. /**
  109132. * Defines the camera the input is attached to.
  109133. */
  109134. abstract camera: Camera;
  109135. /**
  109136. * How fast is the camera moves in relation to X axis mouseWheel events.
  109137. * Use negative value to reverse direction.
  109138. */
  109139. wheelPrecisionX: number;
  109140. /**
  109141. * How fast is the camera moves in relation to Y axis mouseWheel events.
  109142. * Use negative value to reverse direction.
  109143. */
  109144. wheelPrecisionY: number;
  109145. /**
  109146. * How fast is the camera moves in relation to Z axis mouseWheel events.
  109147. * Use negative value to reverse direction.
  109148. */
  109149. wheelPrecisionZ: number;
  109150. /**
  109151. * Observable for when a mouse wheel move event occurs.
  109152. */
  109153. onChangedObservable: Observable<{
  109154. wheelDeltaX: number;
  109155. wheelDeltaY: number;
  109156. wheelDeltaZ: number;
  109157. }>;
  109158. private _wheel;
  109159. private _observer;
  109160. /**
  109161. * Attach the input controls to a specific dom element to get the input from.
  109162. * @param noPreventDefault Defines whether event caught by the controls
  109163. * should call preventdefault().
  109164. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109165. */
  109166. attachControl(noPreventDefault?: boolean): void;
  109167. /**
  109168. * Detach the current controls from the specified dom element.
  109169. */
  109170. detachControl(): void;
  109171. /**
  109172. * Called for each rendered frame.
  109173. */
  109174. checkInputs(): void;
  109175. /**
  109176. * Gets the class name of the current intput.
  109177. * @returns the class name
  109178. */
  109179. getClassName(): string;
  109180. /**
  109181. * Get the friendly name associated with the input class.
  109182. * @returns the input friendly name
  109183. */
  109184. getSimpleName(): string;
  109185. /**
  109186. * Incremental value of multiple mouse wheel movements of the X axis.
  109187. * Should be zero-ed when read.
  109188. */
  109189. protected _wheelDeltaX: number;
  109190. /**
  109191. * Incremental value of multiple mouse wheel movements of the Y axis.
  109192. * Should be zero-ed when read.
  109193. */
  109194. protected _wheelDeltaY: number;
  109195. /**
  109196. * Incremental value of multiple mouse wheel movements of the Z axis.
  109197. * Should be zero-ed when read.
  109198. */
  109199. protected _wheelDeltaZ: number;
  109200. /**
  109201. * Firefox uses a different scheme to report scroll distances to other
  109202. * browsers. Rather than use complicated methods to calculate the exact
  109203. * multiple we need to apply, let's just cheat and use a constant.
  109204. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  109205. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  109206. */
  109207. private readonly _ffMultiplier;
  109208. /**
  109209. * Different event attributes for wheel data fall into a few set ranges.
  109210. * Some relevant but dated date here:
  109211. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  109212. */
  109213. private readonly _normalize;
  109214. }
  109215. }
  109216. declare module BABYLON {
  109217. /**
  109218. * Manage the mouse wheel inputs to control a free camera.
  109219. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109220. */
  109221. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  109222. /**
  109223. * Defines the camera the input is attached to.
  109224. */
  109225. camera: FreeCamera;
  109226. /**
  109227. * Gets the class name of the current input.
  109228. * @returns the class name
  109229. */
  109230. getClassName(): string;
  109231. /**
  109232. * Set which movement axis (relative to camera's orientation) the mouse
  109233. * wheel's X axis controls.
  109234. * @param axis The axis to be moved. Set null to clear.
  109235. */
  109236. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  109237. /**
  109238. * Get the configured movement axis (relative to camera's orientation) the
  109239. * mouse wheel's X axis controls.
  109240. * @returns The configured axis or null if none.
  109241. */
  109242. get wheelXMoveRelative(): Nullable<Coordinate>;
  109243. /**
  109244. * Set which movement axis (relative to camera's orientation) the mouse
  109245. * wheel's Y axis controls.
  109246. * @param axis The axis to be moved. Set null to clear.
  109247. */
  109248. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  109249. /**
  109250. * Get the configured movement axis (relative to camera's orientation) the
  109251. * mouse wheel's Y axis controls.
  109252. * @returns The configured axis or null if none.
  109253. */
  109254. get wheelYMoveRelative(): Nullable<Coordinate>;
  109255. /**
  109256. * Set which movement axis (relative to camera's orientation) the mouse
  109257. * wheel's Z axis controls.
  109258. * @param axis The axis to be moved. Set null to clear.
  109259. */
  109260. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  109261. /**
  109262. * Get the configured movement axis (relative to camera's orientation) the
  109263. * mouse wheel's Z axis controls.
  109264. * @returns The configured axis or null if none.
  109265. */
  109266. get wheelZMoveRelative(): Nullable<Coordinate>;
  109267. /**
  109268. * Set which rotation axis (relative to camera's orientation) the mouse
  109269. * wheel's X axis controls.
  109270. * @param axis The axis to be moved. Set null to clear.
  109271. */
  109272. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  109273. /**
  109274. * Get the configured rotation axis (relative to camera's orientation) the
  109275. * mouse wheel's X axis controls.
  109276. * @returns The configured axis or null if none.
  109277. */
  109278. get wheelXRotateRelative(): Nullable<Coordinate>;
  109279. /**
  109280. * Set which rotation axis (relative to camera's orientation) the mouse
  109281. * wheel's Y axis controls.
  109282. * @param axis The axis to be moved. Set null to clear.
  109283. */
  109284. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  109285. /**
  109286. * Get the configured rotation axis (relative to camera's orientation) the
  109287. * mouse wheel's Y axis controls.
  109288. * @returns The configured axis or null if none.
  109289. */
  109290. get wheelYRotateRelative(): Nullable<Coordinate>;
  109291. /**
  109292. * Set which rotation axis (relative to camera's orientation) the mouse
  109293. * wheel's Z axis controls.
  109294. * @param axis The axis to be moved. Set null to clear.
  109295. */
  109296. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  109297. /**
  109298. * Get the configured rotation axis (relative to camera's orientation) the
  109299. * mouse wheel's Z axis controls.
  109300. * @returns The configured axis or null if none.
  109301. */
  109302. get wheelZRotateRelative(): Nullable<Coordinate>;
  109303. /**
  109304. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  109305. * controls.
  109306. * @param axis The axis to be moved. Set null to clear.
  109307. */
  109308. set wheelXMoveScene(axis: Nullable<Coordinate>);
  109309. /**
  109310. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109311. * X axis controls.
  109312. * @returns The configured axis or null if none.
  109313. */
  109314. get wheelXMoveScene(): Nullable<Coordinate>;
  109315. /**
  109316. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  109317. * controls.
  109318. * @param axis The axis to be moved. Set null to clear.
  109319. */
  109320. set wheelYMoveScene(axis: Nullable<Coordinate>);
  109321. /**
  109322. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109323. * Y axis controls.
  109324. * @returns The configured axis or null if none.
  109325. */
  109326. get wheelYMoveScene(): Nullable<Coordinate>;
  109327. /**
  109328. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  109329. * controls.
  109330. * @param axis The axis to be moved. Set null to clear.
  109331. */
  109332. set wheelZMoveScene(axis: Nullable<Coordinate>);
  109333. /**
  109334. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109335. * Z axis controls.
  109336. * @returns The configured axis or null if none.
  109337. */
  109338. get wheelZMoveScene(): Nullable<Coordinate>;
  109339. /**
  109340. * Called for each rendered frame.
  109341. */
  109342. checkInputs(): void;
  109343. private _moveRelative;
  109344. private _rotateRelative;
  109345. private _moveScene;
  109346. /**
  109347. * These are set to the desired default behaviour.
  109348. */
  109349. private _wheelXAction;
  109350. private _wheelXActionCoordinate;
  109351. private _wheelYAction;
  109352. private _wheelYActionCoordinate;
  109353. private _wheelZAction;
  109354. private _wheelZActionCoordinate;
  109355. /**
  109356. * Update the camera according to any configured properties for the 3
  109357. * mouse-wheel axis.
  109358. */
  109359. private _updateCamera;
  109360. }
  109361. }
  109362. declare module BABYLON {
  109363. /**
  109364. * Manage the touch inputs to control the movement of a free camera.
  109365. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109366. */
  109367. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  109368. /**
  109369. * Define if mouse events can be treated as touch events
  109370. */
  109371. allowMouse: boolean;
  109372. /**
  109373. * Defines the camera the input is attached to.
  109374. */
  109375. camera: FreeCamera;
  109376. /**
  109377. * Defines the touch sensibility for rotation.
  109378. * The higher the faster.
  109379. */
  109380. touchAngularSensibility: number;
  109381. /**
  109382. * Defines the touch sensibility for move.
  109383. * The higher the faster.
  109384. */
  109385. touchMoveSensibility: number;
  109386. private _offsetX;
  109387. private _offsetY;
  109388. private _pointerPressed;
  109389. private _pointerInput?;
  109390. private _observer;
  109391. private _onLostFocus;
  109392. /**
  109393. * Manage the touch inputs to control the movement of a free camera.
  109394. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109395. * @param allowMouse Defines if mouse events can be treated as touch events
  109396. */
  109397. constructor(
  109398. /**
  109399. * Define if mouse events can be treated as touch events
  109400. */
  109401. allowMouse?: boolean);
  109402. /**
  109403. * Attach the input controls to a specific dom element to get the input from.
  109404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109405. */
  109406. attachControl(noPreventDefault?: boolean): void;
  109407. /**
  109408. * Detach the current controls from the specified dom element.
  109409. */
  109410. detachControl(): void;
  109411. /**
  109412. * Update the current camera state depending on the inputs that have been used this frame.
  109413. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109414. */
  109415. checkInputs(): void;
  109416. /**
  109417. * Gets the class name of the current intput.
  109418. * @returns the class name
  109419. */
  109420. getClassName(): string;
  109421. /**
  109422. * Get the friendly name associated with the input class.
  109423. * @returns the input friendly name
  109424. */
  109425. getSimpleName(): string;
  109426. }
  109427. }
  109428. declare module BABYLON {
  109429. /**
  109430. * Default Inputs manager for the FreeCamera.
  109431. * It groups all the default supported inputs for ease of use.
  109432. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109433. */
  109434. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  109435. /**
  109436. * @hidden
  109437. */
  109438. _mouseInput: Nullable<FreeCameraMouseInput>;
  109439. /**
  109440. * @hidden
  109441. */
  109442. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  109443. /**
  109444. * Instantiates a new FreeCameraInputsManager.
  109445. * @param camera Defines the camera the inputs belong to
  109446. */
  109447. constructor(camera: FreeCamera);
  109448. /**
  109449. * Add keyboard input support to the input manager.
  109450. * @returns the current input manager
  109451. */
  109452. addKeyboard(): FreeCameraInputsManager;
  109453. /**
  109454. * Add mouse input support to the input manager.
  109455. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  109456. * @returns the current input manager
  109457. */
  109458. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  109459. /**
  109460. * Removes the mouse input support from the manager
  109461. * @returns the current input manager
  109462. */
  109463. removeMouse(): FreeCameraInputsManager;
  109464. /**
  109465. * Add mouse wheel input support to the input manager.
  109466. * @returns the current input manager
  109467. */
  109468. addMouseWheel(): FreeCameraInputsManager;
  109469. /**
  109470. * Removes the mouse wheel input support from the manager
  109471. * @returns the current input manager
  109472. */
  109473. removeMouseWheel(): FreeCameraInputsManager;
  109474. /**
  109475. * Add touch input support to the input manager.
  109476. * @returns the current input manager
  109477. */
  109478. addTouch(): FreeCameraInputsManager;
  109479. /**
  109480. * Remove all attached input methods from a camera
  109481. */
  109482. clear(): void;
  109483. }
  109484. }
  109485. declare module BABYLON {
  109486. /**
  109487. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109488. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  109489. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  109490. */
  109491. export class FreeCamera extends TargetCamera {
  109492. /**
  109493. * Define the collision ellipsoid of the camera.
  109494. * This is helpful to simulate a camera body like the player body around the camera
  109495. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109496. */
  109497. ellipsoid: Vector3;
  109498. /**
  109499. * Define an offset for the position of the ellipsoid around the camera.
  109500. * This can be helpful to determine the center of the body near the gravity center of the body
  109501. * instead of its head.
  109502. */
  109503. ellipsoidOffset: Vector3;
  109504. /**
  109505. * Enable or disable collisions of the camera with the rest of the scene objects.
  109506. */
  109507. checkCollisions: boolean;
  109508. /**
  109509. * Enable or disable gravity on the camera.
  109510. */
  109511. applyGravity: boolean;
  109512. /**
  109513. * Define the input manager associated to the camera.
  109514. */
  109515. inputs: FreeCameraInputsManager;
  109516. /**
  109517. * Gets the input sensibility for a mouse input. (default is 2000.0)
  109518. * Higher values reduce sensitivity.
  109519. */
  109520. get angularSensibility(): number;
  109521. /**
  109522. * Sets the input sensibility for a mouse input. (default is 2000.0)
  109523. * Higher values reduce sensitivity.
  109524. */
  109525. set angularSensibility(value: number);
  109526. /**
  109527. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  109528. */
  109529. get keysUp(): number[];
  109530. set keysUp(value: number[]);
  109531. /**
  109532. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  109533. */
  109534. get keysUpward(): number[];
  109535. set keysUpward(value: number[]);
  109536. /**
  109537. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  109538. */
  109539. get keysDown(): number[];
  109540. set keysDown(value: number[]);
  109541. /**
  109542. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  109543. */
  109544. get keysDownward(): number[];
  109545. set keysDownward(value: number[]);
  109546. /**
  109547. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  109548. */
  109549. get keysLeft(): number[];
  109550. set keysLeft(value: number[]);
  109551. /**
  109552. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  109553. */
  109554. get keysRight(): number[];
  109555. set keysRight(value: number[]);
  109556. /**
  109557. * Event raised when the camera collide with a mesh in the scene.
  109558. */
  109559. onCollide: (collidedMesh: AbstractMesh) => void;
  109560. private _collider;
  109561. private _needMoveForGravity;
  109562. private _oldPosition;
  109563. private _diffPosition;
  109564. private _newPosition;
  109565. /** @hidden */
  109566. _localDirection: Vector3;
  109567. /** @hidden */
  109568. _transformedDirection: Vector3;
  109569. /**
  109570. * Instantiates a Free Camera.
  109571. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109572. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  109573. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  109574. * @param name Define the name of the camera in the scene
  109575. * @param position Define the start position of the camera in the scene
  109576. * @param scene Define the scene the camera belongs to
  109577. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109578. */
  109579. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109580. /**
  109581. * Attach the input controls to a specific dom element to get the input from.
  109582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109583. */
  109584. attachControl(noPreventDefault?: boolean): void;
  109585. /**
  109586. * Attach the input controls to a specific dom element to get the input from.
  109587. * @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
  109588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109589. * BACK COMPAT SIGNATURE ONLY.
  109590. */
  109591. attachControl(ignored: any, noPreventDefault?: boolean): void;
  109592. /**
  109593. * Detach the current controls from the specified dom element.
  109594. */
  109595. detachControl(): void;
  109596. /**
  109597. * Detach the current controls from the specified dom element.
  109598. * @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
  109599. */
  109600. detachControl(ignored: any): void;
  109601. private _collisionMask;
  109602. /**
  109603. * Define a collision mask to limit the list of object the camera can collide with
  109604. */
  109605. get collisionMask(): number;
  109606. set collisionMask(mask: number);
  109607. /** @hidden */
  109608. _collideWithWorld(displacement: Vector3): void;
  109609. private _onCollisionPositionChange;
  109610. /** @hidden */
  109611. _checkInputs(): void;
  109612. /** @hidden */
  109613. _decideIfNeedsToMove(): boolean;
  109614. /** @hidden */
  109615. _updatePosition(): void;
  109616. /**
  109617. * Destroy the camera and release the current resources hold by it.
  109618. */
  109619. dispose(): void;
  109620. /**
  109621. * Gets the current object class name.
  109622. * @return the class name
  109623. */
  109624. getClassName(): string;
  109625. }
  109626. }
  109627. declare module BABYLON {
  109628. /**
  109629. * Represents a gamepad control stick position
  109630. */
  109631. export class StickValues {
  109632. /**
  109633. * The x component of the control stick
  109634. */
  109635. x: number;
  109636. /**
  109637. * The y component of the control stick
  109638. */
  109639. y: number;
  109640. /**
  109641. * Initializes the gamepad x and y control stick values
  109642. * @param x The x component of the gamepad control stick value
  109643. * @param y The y component of the gamepad control stick value
  109644. */
  109645. constructor(
  109646. /**
  109647. * The x component of the control stick
  109648. */
  109649. x: number,
  109650. /**
  109651. * The y component of the control stick
  109652. */
  109653. y: number);
  109654. }
  109655. /**
  109656. * An interface which manages callbacks for gamepad button changes
  109657. */
  109658. export interface GamepadButtonChanges {
  109659. /**
  109660. * Called when a gamepad has been changed
  109661. */
  109662. changed: boolean;
  109663. /**
  109664. * Called when a gamepad press event has been triggered
  109665. */
  109666. pressChanged: boolean;
  109667. /**
  109668. * Called when a touch event has been triggered
  109669. */
  109670. touchChanged: boolean;
  109671. /**
  109672. * Called when a value has changed
  109673. */
  109674. valueChanged: boolean;
  109675. }
  109676. /**
  109677. * Represents a gamepad
  109678. */
  109679. export class Gamepad {
  109680. /**
  109681. * The id of the gamepad
  109682. */
  109683. id: string;
  109684. /**
  109685. * The index of the gamepad
  109686. */
  109687. index: number;
  109688. /**
  109689. * The browser gamepad
  109690. */
  109691. browserGamepad: any;
  109692. /**
  109693. * Specifies what type of gamepad this represents
  109694. */
  109695. type: number;
  109696. private _leftStick;
  109697. private _rightStick;
  109698. /** @hidden */
  109699. _isConnected: boolean;
  109700. private _leftStickAxisX;
  109701. private _leftStickAxisY;
  109702. private _rightStickAxisX;
  109703. private _rightStickAxisY;
  109704. /**
  109705. * Triggered when the left control stick has been changed
  109706. */
  109707. private _onleftstickchanged;
  109708. /**
  109709. * Triggered when the right control stick has been changed
  109710. */
  109711. private _onrightstickchanged;
  109712. /**
  109713. * Represents a gamepad controller
  109714. */
  109715. static GAMEPAD: number;
  109716. /**
  109717. * Represents a generic controller
  109718. */
  109719. static GENERIC: number;
  109720. /**
  109721. * Represents an XBox controller
  109722. */
  109723. static XBOX: number;
  109724. /**
  109725. * Represents a pose-enabled controller
  109726. */
  109727. static POSE_ENABLED: number;
  109728. /**
  109729. * Represents an Dual Shock controller
  109730. */
  109731. static DUALSHOCK: number;
  109732. /**
  109733. * Specifies whether the left control stick should be Y-inverted
  109734. */
  109735. protected _invertLeftStickY: boolean;
  109736. /**
  109737. * Specifies if the gamepad has been connected
  109738. */
  109739. get isConnected(): boolean;
  109740. /**
  109741. * Initializes the gamepad
  109742. * @param id The id of the gamepad
  109743. * @param index The index of the gamepad
  109744. * @param browserGamepad The browser gamepad
  109745. * @param leftStickX The x component of the left joystick
  109746. * @param leftStickY The y component of the left joystick
  109747. * @param rightStickX The x component of the right joystick
  109748. * @param rightStickY The y component of the right joystick
  109749. */
  109750. constructor(
  109751. /**
  109752. * The id of the gamepad
  109753. */
  109754. id: string,
  109755. /**
  109756. * The index of the gamepad
  109757. */
  109758. index: number,
  109759. /**
  109760. * The browser gamepad
  109761. */
  109762. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  109763. /**
  109764. * Callback triggered when the left joystick has changed
  109765. * @param callback
  109766. */
  109767. onleftstickchanged(callback: (values: StickValues) => void): void;
  109768. /**
  109769. * Callback triggered when the right joystick has changed
  109770. * @param callback
  109771. */
  109772. onrightstickchanged(callback: (values: StickValues) => void): void;
  109773. /**
  109774. * Gets the left joystick
  109775. */
  109776. get leftStick(): StickValues;
  109777. /**
  109778. * Sets the left joystick values
  109779. */
  109780. set leftStick(newValues: StickValues);
  109781. /**
  109782. * Gets the right joystick
  109783. */
  109784. get rightStick(): StickValues;
  109785. /**
  109786. * Sets the right joystick value
  109787. */
  109788. set rightStick(newValues: StickValues);
  109789. /**
  109790. * Updates the gamepad joystick positions
  109791. */
  109792. update(): void;
  109793. /**
  109794. * Disposes the gamepad
  109795. */
  109796. dispose(): void;
  109797. }
  109798. /**
  109799. * Represents a generic gamepad
  109800. */
  109801. export class GenericPad extends Gamepad {
  109802. private _buttons;
  109803. private _onbuttondown;
  109804. private _onbuttonup;
  109805. /**
  109806. * Observable triggered when a button has been pressed
  109807. */
  109808. onButtonDownObservable: Observable<number>;
  109809. /**
  109810. * Observable triggered when a button has been released
  109811. */
  109812. onButtonUpObservable: Observable<number>;
  109813. /**
  109814. * Callback triggered when a button has been pressed
  109815. * @param callback Called when a button has been pressed
  109816. */
  109817. onbuttondown(callback: (buttonPressed: number) => void): void;
  109818. /**
  109819. * Callback triggered when a button has been released
  109820. * @param callback Called when a button has been released
  109821. */
  109822. onbuttonup(callback: (buttonReleased: number) => void): void;
  109823. /**
  109824. * Initializes the generic gamepad
  109825. * @param id The id of the generic gamepad
  109826. * @param index The index of the generic gamepad
  109827. * @param browserGamepad The browser gamepad
  109828. */
  109829. constructor(id: string, index: number, browserGamepad: any);
  109830. private _setButtonValue;
  109831. /**
  109832. * Updates the generic gamepad
  109833. */
  109834. update(): void;
  109835. /**
  109836. * Disposes the generic gamepad
  109837. */
  109838. dispose(): void;
  109839. }
  109840. }
  109841. declare module BABYLON {
  109842. /**
  109843. * Defines a runtime animation
  109844. */
  109845. export class RuntimeAnimation {
  109846. private _events;
  109847. /**
  109848. * The current frame of the runtime animation
  109849. */
  109850. private _currentFrame;
  109851. /**
  109852. * The animation used by the runtime animation
  109853. */
  109854. private _animation;
  109855. /**
  109856. * The target of the runtime animation
  109857. */
  109858. private _target;
  109859. /**
  109860. * The initiating animatable
  109861. */
  109862. private _host;
  109863. /**
  109864. * The original value of the runtime animation
  109865. */
  109866. private _originalValue;
  109867. /**
  109868. * The original blend value of the runtime animation
  109869. */
  109870. private _originalBlendValue;
  109871. /**
  109872. * The offsets cache of the runtime animation
  109873. */
  109874. private _offsetsCache;
  109875. /**
  109876. * The high limits cache of the runtime animation
  109877. */
  109878. private _highLimitsCache;
  109879. /**
  109880. * Specifies if the runtime animation has been stopped
  109881. */
  109882. private _stopped;
  109883. /**
  109884. * The blending factor of the runtime animation
  109885. */
  109886. private _blendingFactor;
  109887. /**
  109888. * The BabylonJS scene
  109889. */
  109890. private _scene;
  109891. /**
  109892. * The current value of the runtime animation
  109893. */
  109894. private _currentValue;
  109895. /** @hidden */
  109896. _animationState: _IAnimationState;
  109897. /**
  109898. * The active target of the runtime animation
  109899. */
  109900. private _activeTargets;
  109901. private _currentActiveTarget;
  109902. private _directTarget;
  109903. /**
  109904. * The target path of the runtime animation
  109905. */
  109906. private _targetPath;
  109907. /**
  109908. * The weight of the runtime animation
  109909. */
  109910. private _weight;
  109911. /**
  109912. * The ratio offset of the runtime animation
  109913. */
  109914. private _ratioOffset;
  109915. /**
  109916. * The previous delay of the runtime animation
  109917. */
  109918. private _previousDelay;
  109919. /**
  109920. * The previous ratio of the runtime animation
  109921. */
  109922. private _previousRatio;
  109923. private _enableBlending;
  109924. private _keys;
  109925. private _minFrame;
  109926. private _maxFrame;
  109927. private _minValue;
  109928. private _maxValue;
  109929. private _targetIsArray;
  109930. /**
  109931. * Gets the current frame of the runtime animation
  109932. */
  109933. get currentFrame(): number;
  109934. /**
  109935. * Gets the weight of the runtime animation
  109936. */
  109937. get weight(): number;
  109938. /**
  109939. * Gets the current value of the runtime animation
  109940. */
  109941. get currentValue(): any;
  109942. /**
  109943. * Gets the target path of the runtime animation
  109944. */
  109945. get targetPath(): string;
  109946. /**
  109947. * Gets the actual target of the runtime animation
  109948. */
  109949. get target(): any;
  109950. /**
  109951. * Gets the additive state of the runtime animation
  109952. */
  109953. get isAdditive(): boolean;
  109954. /** @hidden */
  109955. _onLoop: () => void;
  109956. /**
  109957. * Create a new RuntimeAnimation object
  109958. * @param target defines the target of the animation
  109959. * @param animation defines the source animation object
  109960. * @param scene defines the hosting scene
  109961. * @param host defines the initiating Animatable
  109962. */
  109963. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  109964. private _preparePath;
  109965. /**
  109966. * Gets the animation from the runtime animation
  109967. */
  109968. get animation(): Animation;
  109969. /**
  109970. * Resets the runtime animation to the beginning
  109971. * @param restoreOriginal defines whether to restore the target property to the original value
  109972. */
  109973. reset(restoreOriginal?: boolean): void;
  109974. /**
  109975. * Specifies if the runtime animation is stopped
  109976. * @returns Boolean specifying if the runtime animation is stopped
  109977. */
  109978. isStopped(): boolean;
  109979. /**
  109980. * Disposes of the runtime animation
  109981. */
  109982. dispose(): void;
  109983. /**
  109984. * Apply the interpolated value to the target
  109985. * @param currentValue defines the value computed by the animation
  109986. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  109987. */
  109988. setValue(currentValue: any, weight: number): void;
  109989. private _getOriginalValues;
  109990. private _setValue;
  109991. /**
  109992. * Gets the loop pmode of the runtime animation
  109993. * @returns Loop Mode
  109994. */
  109995. private _getCorrectLoopMode;
  109996. /**
  109997. * Move the current animation to a given frame
  109998. * @param frame defines the frame to move to
  109999. */
  110000. goToFrame(frame: number): void;
  110001. /**
  110002. * @hidden Internal use only
  110003. */
  110004. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  110005. /**
  110006. * Execute the current animation
  110007. * @param delay defines the delay to add to the current frame
  110008. * @param from defines the lower bound of the animation range
  110009. * @param to defines the upper bound of the animation range
  110010. * @param loop defines if the current animation must loop
  110011. * @param speedRatio defines the current speed ratio
  110012. * @param weight defines the weight of the animation (default is -1 so no weight)
  110013. * @param onLoop optional callback called when animation loops
  110014. * @returns a boolean indicating if the animation is running
  110015. */
  110016. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  110017. }
  110018. }
  110019. declare module BABYLON {
  110020. /**
  110021. * Class used to store an actual running animation
  110022. */
  110023. export class Animatable {
  110024. /** defines the target object */
  110025. target: any;
  110026. /** defines the starting frame number (default is 0) */
  110027. fromFrame: number;
  110028. /** defines the ending frame number (default is 100) */
  110029. toFrame: number;
  110030. /** defines if the animation must loop (default is false) */
  110031. loopAnimation: boolean;
  110032. /** defines a callback to call when animation ends if it is not looping */
  110033. onAnimationEnd?: (() => void) | null | undefined;
  110034. /** defines a callback to call when animation loops */
  110035. onAnimationLoop?: (() => void) | null | undefined;
  110036. /** defines whether the animation should be evaluated additively */
  110037. isAdditive: boolean;
  110038. private _localDelayOffset;
  110039. private _pausedDelay;
  110040. private _runtimeAnimations;
  110041. private _paused;
  110042. private _scene;
  110043. private _speedRatio;
  110044. private _weight;
  110045. private _syncRoot;
  110046. /**
  110047. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  110048. * This will only apply for non looping animation (default is true)
  110049. */
  110050. disposeOnEnd: boolean;
  110051. /**
  110052. * Gets a boolean indicating if the animation has started
  110053. */
  110054. animationStarted: boolean;
  110055. /**
  110056. * Observer raised when the animation ends
  110057. */
  110058. onAnimationEndObservable: Observable<Animatable>;
  110059. /**
  110060. * Observer raised when the animation loops
  110061. */
  110062. onAnimationLoopObservable: Observable<Animatable>;
  110063. /**
  110064. * Gets the root Animatable used to synchronize and normalize animations
  110065. */
  110066. get syncRoot(): Nullable<Animatable>;
  110067. /**
  110068. * Gets the current frame of the first RuntimeAnimation
  110069. * Used to synchronize Animatables
  110070. */
  110071. get masterFrame(): number;
  110072. /**
  110073. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  110074. */
  110075. get weight(): number;
  110076. set weight(value: number);
  110077. /**
  110078. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  110079. */
  110080. get speedRatio(): number;
  110081. set speedRatio(value: number);
  110082. /**
  110083. * Creates a new Animatable
  110084. * @param scene defines the hosting scene
  110085. * @param target defines the target object
  110086. * @param fromFrame defines the starting frame number (default is 0)
  110087. * @param toFrame defines the ending frame number (default is 100)
  110088. * @param loopAnimation defines if the animation must loop (default is false)
  110089. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  110090. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  110091. * @param animations defines a group of animation to add to the new Animatable
  110092. * @param onAnimationLoop defines a callback to call when animation loops
  110093. * @param isAdditive defines whether the animation should be evaluated additively
  110094. */
  110095. constructor(scene: Scene,
  110096. /** defines the target object */
  110097. target: any,
  110098. /** defines the starting frame number (default is 0) */
  110099. fromFrame?: number,
  110100. /** defines the ending frame number (default is 100) */
  110101. toFrame?: number,
  110102. /** defines if the animation must loop (default is false) */
  110103. loopAnimation?: boolean, speedRatio?: number,
  110104. /** defines a callback to call when animation ends if it is not looping */
  110105. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  110106. /** defines a callback to call when animation loops */
  110107. onAnimationLoop?: (() => void) | null | undefined,
  110108. /** defines whether the animation should be evaluated additively */
  110109. isAdditive?: boolean);
  110110. /**
  110111. * Synchronize and normalize current Animatable with a source Animatable
  110112. * This is useful when using animation weights and when animations are not of the same length
  110113. * @param root defines the root Animatable to synchronize with
  110114. * @returns the current Animatable
  110115. */
  110116. syncWith(root: Animatable): Animatable;
  110117. /**
  110118. * Gets the list of runtime animations
  110119. * @returns an array of RuntimeAnimation
  110120. */
  110121. getAnimations(): RuntimeAnimation[];
  110122. /**
  110123. * Adds more animations to the current animatable
  110124. * @param target defines the target of the animations
  110125. * @param animations defines the new animations to add
  110126. */
  110127. appendAnimations(target: any, animations: Animation[]): void;
  110128. /**
  110129. * Gets the source animation for a specific property
  110130. * @param property defines the propertyu to look for
  110131. * @returns null or the source animation for the given property
  110132. */
  110133. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  110134. /**
  110135. * Gets the runtime animation for a specific property
  110136. * @param property defines the propertyu to look for
  110137. * @returns null or the runtime animation for the given property
  110138. */
  110139. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  110140. /**
  110141. * Resets the animatable to its original state
  110142. */
  110143. reset(): void;
  110144. /**
  110145. * Allows the animatable to blend with current running animations
  110146. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110147. * @param blendingSpeed defines the blending speed to use
  110148. */
  110149. enableBlending(blendingSpeed: number): void;
  110150. /**
  110151. * Disable animation blending
  110152. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110153. */
  110154. disableBlending(): void;
  110155. /**
  110156. * Jump directly to a given frame
  110157. * @param frame defines the frame to jump to
  110158. */
  110159. goToFrame(frame: number): void;
  110160. /**
  110161. * Pause the animation
  110162. */
  110163. pause(): void;
  110164. /**
  110165. * Restart the animation
  110166. */
  110167. restart(): void;
  110168. private _raiseOnAnimationEnd;
  110169. /**
  110170. * Stop and delete the current animation
  110171. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  110172. * @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)
  110173. */
  110174. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  110175. /**
  110176. * Wait asynchronously for the animation to end
  110177. * @returns a promise which will be fullfilled when the animation ends
  110178. */
  110179. waitAsync(): Promise<Animatable>;
  110180. /** @hidden */
  110181. _animate(delay: number): boolean;
  110182. }
  110183. interface Scene {
  110184. /** @hidden */
  110185. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  110186. /** @hidden */
  110187. _processLateAnimationBindingsForMatrices(holder: {
  110188. totalWeight: number;
  110189. totalAdditiveWeight: number;
  110190. animations: RuntimeAnimation[];
  110191. additiveAnimations: RuntimeAnimation[];
  110192. originalValue: Matrix;
  110193. }): any;
  110194. /** @hidden */
  110195. _processLateAnimationBindingsForQuaternions(holder: {
  110196. totalWeight: number;
  110197. totalAdditiveWeight: number;
  110198. animations: RuntimeAnimation[];
  110199. additiveAnimations: RuntimeAnimation[];
  110200. originalValue: Quaternion;
  110201. }, refQuaternion: Quaternion): Quaternion;
  110202. /** @hidden */
  110203. _processLateAnimationBindings(): void;
  110204. /**
  110205. * Will start the animation sequence of a given target
  110206. * @param target defines the target
  110207. * @param from defines from which frame should animation start
  110208. * @param to defines until which frame should animation run.
  110209. * @param weight defines the weight to apply to the animation (1.0 by default)
  110210. * @param loop defines if the animation loops
  110211. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110212. * @param onAnimationEnd defines the function to be executed when the animation ends
  110213. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110214. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110215. * @param onAnimationLoop defines the callback to call when an animation loops
  110216. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110217. * @returns the animatable object created for this animation
  110218. */
  110219. 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;
  110220. /**
  110221. * Will start the animation sequence of a given target
  110222. * @param target defines the target
  110223. * @param from defines from which frame should animation start
  110224. * @param to defines until which frame should animation run.
  110225. * @param loop defines if the animation loops
  110226. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110227. * @param onAnimationEnd defines the function to be executed when the animation ends
  110228. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110229. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110230. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  110231. * @param onAnimationLoop defines the callback to call when an animation loops
  110232. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110233. * @returns the animatable object created for this animation
  110234. */
  110235. 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;
  110236. /**
  110237. * Will start the animation sequence of a given target and its hierarchy
  110238. * @param target defines the target
  110239. * @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.
  110240. * @param from defines from which frame should animation start
  110241. * @param to defines until which frame should animation run.
  110242. * @param loop defines if the animation loops
  110243. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110244. * @param onAnimationEnd defines the function to be executed when the animation ends
  110245. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110246. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110247. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110248. * @param onAnimationLoop defines the callback to call when an animation loops
  110249. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110250. * @returns the list of created animatables
  110251. */
  110252. 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[];
  110253. /**
  110254. * Begin a new animation on a given node
  110255. * @param target defines the target where the animation will take place
  110256. * @param animations defines the list of animations to start
  110257. * @param from defines the initial value
  110258. * @param to defines the final value
  110259. * @param loop defines if you want animation to loop (off by default)
  110260. * @param speedRatio defines the speed ratio to apply to all animations
  110261. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110262. * @param onAnimationLoop defines the callback to call when an animation loops
  110263. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110264. * @returns the list of created animatables
  110265. */
  110266. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  110267. /**
  110268. * Begin a new animation on a given node and its hierarchy
  110269. * @param target defines the root node where the animation will take place
  110270. * @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.
  110271. * @param animations defines the list of animations to start
  110272. * @param from defines the initial value
  110273. * @param to defines the final value
  110274. * @param loop defines if you want animation to loop (off by default)
  110275. * @param speedRatio defines the speed ratio to apply to all animations
  110276. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110277. * @param onAnimationLoop defines the callback to call when an animation loops
  110278. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110279. * @returns the list of animatables created for all nodes
  110280. */
  110281. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  110282. /**
  110283. * Gets the animatable associated with a specific target
  110284. * @param target defines the target of the animatable
  110285. * @returns the required animatable if found
  110286. */
  110287. getAnimatableByTarget(target: any): Nullable<Animatable>;
  110288. /**
  110289. * Gets all animatables associated with a given target
  110290. * @param target defines the target to look animatables for
  110291. * @returns an array of Animatables
  110292. */
  110293. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  110294. /**
  110295. * Stops and removes all animations that have been applied to the scene
  110296. */
  110297. stopAllAnimations(): void;
  110298. /**
  110299. * Gets the current delta time used by animation engine
  110300. */
  110301. deltaTime: number;
  110302. }
  110303. interface Bone {
  110304. /**
  110305. * Copy an animation range from another bone
  110306. * @param source defines the source bone
  110307. * @param rangeName defines the range name to copy
  110308. * @param frameOffset defines the frame offset
  110309. * @param rescaleAsRequired defines if rescaling must be applied if required
  110310. * @param skelDimensionsRatio defines the scaling ratio
  110311. * @returns true if operation was successful
  110312. */
  110313. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  110314. }
  110315. }
  110316. declare module BABYLON {
  110317. /**
  110318. * Class used to override all child animations of a given target
  110319. */
  110320. export class AnimationPropertiesOverride {
  110321. /**
  110322. * Gets or sets a value indicating if animation blending must be used
  110323. */
  110324. enableBlending: boolean;
  110325. /**
  110326. * Gets or sets the blending speed to use when enableBlending is true
  110327. */
  110328. blendingSpeed: number;
  110329. /**
  110330. * Gets or sets the default loop mode to use
  110331. */
  110332. loopMode: number;
  110333. }
  110334. }
  110335. declare module BABYLON {
  110336. /**
  110337. * Class used to handle skinning animations
  110338. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110339. */
  110340. export class Skeleton implements IAnimatable {
  110341. /** defines the skeleton name */
  110342. name: string;
  110343. /** defines the skeleton Id */
  110344. id: string;
  110345. /**
  110346. * Defines the list of child bones
  110347. */
  110348. bones: Bone[];
  110349. /**
  110350. * Defines an estimate of the dimension of the skeleton at rest
  110351. */
  110352. dimensionsAtRest: Vector3;
  110353. /**
  110354. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  110355. */
  110356. needInitialSkinMatrix: boolean;
  110357. /**
  110358. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  110359. */
  110360. overrideMesh: Nullable<AbstractMesh>;
  110361. /**
  110362. * Gets the list of animations attached to this skeleton
  110363. */
  110364. animations: Array<Animation>;
  110365. private _scene;
  110366. private _isDirty;
  110367. private _transformMatrices;
  110368. private _transformMatrixTexture;
  110369. private _meshesWithPoseMatrix;
  110370. private _animatables;
  110371. private _identity;
  110372. private _synchronizedWithMesh;
  110373. private _ranges;
  110374. private _lastAbsoluteTransformsUpdateId;
  110375. private _canUseTextureForBones;
  110376. private _uniqueId;
  110377. /** @hidden */
  110378. _numBonesWithLinkedTransformNode: number;
  110379. /** @hidden */
  110380. _hasWaitingData: Nullable<boolean>;
  110381. /** @hidden */
  110382. _waitingOverrideMeshId: Nullable<string>;
  110383. /**
  110384. * Specifies if the skeleton should be serialized
  110385. */
  110386. doNotSerialize: boolean;
  110387. private _useTextureToStoreBoneMatrices;
  110388. /**
  110389. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  110390. * Please note that this option is not available if the hardware does not support it
  110391. */
  110392. get useTextureToStoreBoneMatrices(): boolean;
  110393. set useTextureToStoreBoneMatrices(value: boolean);
  110394. private _animationPropertiesOverride;
  110395. /**
  110396. * Gets or sets the animation properties override
  110397. */
  110398. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110399. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110400. /**
  110401. * List of inspectable custom properties (used by the Inspector)
  110402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110403. */
  110404. inspectableCustomProperties: IInspectable[];
  110405. /**
  110406. * An observable triggered before computing the skeleton's matrices
  110407. */
  110408. onBeforeComputeObservable: Observable<Skeleton>;
  110409. /**
  110410. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  110411. */
  110412. get isUsingTextureForMatrices(): boolean;
  110413. /**
  110414. * Gets the unique ID of this skeleton
  110415. */
  110416. get uniqueId(): number;
  110417. /**
  110418. * Creates a new skeleton
  110419. * @param name defines the skeleton name
  110420. * @param id defines the skeleton Id
  110421. * @param scene defines the hosting scene
  110422. */
  110423. constructor(
  110424. /** defines the skeleton name */
  110425. name: string,
  110426. /** defines the skeleton Id */
  110427. id: string, scene: Scene);
  110428. /**
  110429. * Gets the current object class name.
  110430. * @return the class name
  110431. */
  110432. getClassName(): string;
  110433. /**
  110434. * Returns an array containing the root bones
  110435. * @returns an array containing the root bones
  110436. */
  110437. getChildren(): Array<Bone>;
  110438. /**
  110439. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  110440. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  110441. * @returns a Float32Array containing matrices data
  110442. */
  110443. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  110444. /**
  110445. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  110446. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  110447. * @returns a raw texture containing the data
  110448. */
  110449. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  110450. /**
  110451. * Gets the current hosting scene
  110452. * @returns a scene object
  110453. */
  110454. getScene(): Scene;
  110455. /**
  110456. * Gets a string representing the current skeleton data
  110457. * @param fullDetails defines a boolean indicating if we want a verbose version
  110458. * @returns a string representing the current skeleton data
  110459. */
  110460. toString(fullDetails?: boolean): string;
  110461. /**
  110462. * Get bone's index searching by name
  110463. * @param name defines bone's name to search for
  110464. * @return the indice of the bone. Returns -1 if not found
  110465. */
  110466. getBoneIndexByName(name: string): number;
  110467. /**
  110468. * Creater a new animation range
  110469. * @param name defines the name of the range
  110470. * @param from defines the start key
  110471. * @param to defines the end key
  110472. */
  110473. createAnimationRange(name: string, from: number, to: number): void;
  110474. /**
  110475. * Delete a specific animation range
  110476. * @param name defines the name of the range
  110477. * @param deleteFrames defines if frames must be removed as well
  110478. */
  110479. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110480. /**
  110481. * Gets a specific animation range
  110482. * @param name defines the name of the range to look for
  110483. * @returns the requested animation range or null if not found
  110484. */
  110485. getAnimationRange(name: string): Nullable<AnimationRange>;
  110486. /**
  110487. * Gets the list of all animation ranges defined on this skeleton
  110488. * @returns an array
  110489. */
  110490. getAnimationRanges(): Nullable<AnimationRange>[];
  110491. /**
  110492. * Copy animation range from a source skeleton.
  110493. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  110494. * @param source defines the source skeleton
  110495. * @param name defines the name of the range to copy
  110496. * @param rescaleAsRequired defines if rescaling must be applied if required
  110497. * @returns true if operation was successful
  110498. */
  110499. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  110500. /**
  110501. * Forces the skeleton to go to rest pose
  110502. */
  110503. returnToRest(): void;
  110504. private _getHighestAnimationFrame;
  110505. /**
  110506. * Begin a specific animation range
  110507. * @param name defines the name of the range to start
  110508. * @param loop defines if looping must be turned on (false by default)
  110509. * @param speedRatio defines the speed ratio to apply (1 by default)
  110510. * @param onAnimationEnd defines a callback which will be called when animation will end
  110511. * @returns a new animatable
  110512. */
  110513. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110514. /**
  110515. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  110516. * @param skeleton defines the Skeleton containing the animation range to convert
  110517. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110518. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  110519. * @returns the original skeleton
  110520. */
  110521. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  110522. /** @hidden */
  110523. _markAsDirty(): void;
  110524. /** @hidden */
  110525. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  110526. /** @hidden */
  110527. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  110528. private _computeTransformMatrices;
  110529. /**
  110530. * Build all resources required to render a skeleton
  110531. */
  110532. prepare(): void;
  110533. /**
  110534. * Gets the list of animatables currently running for this skeleton
  110535. * @returns an array of animatables
  110536. */
  110537. getAnimatables(): IAnimatable[];
  110538. /**
  110539. * Clone the current skeleton
  110540. * @param name defines the name of the new skeleton
  110541. * @param id defines the id of the new skeleton
  110542. * @returns the new skeleton
  110543. */
  110544. clone(name: string, id?: string): Skeleton;
  110545. /**
  110546. * Enable animation blending for this skeleton
  110547. * @param blendingSpeed defines the blending speed to apply
  110548. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110549. */
  110550. enableBlending(blendingSpeed?: number): void;
  110551. /**
  110552. * Releases all resources associated with the current skeleton
  110553. */
  110554. dispose(): void;
  110555. /**
  110556. * Serialize the skeleton in a JSON object
  110557. * @returns a JSON object
  110558. */
  110559. serialize(): any;
  110560. /**
  110561. * Creates a new skeleton from serialized data
  110562. * @param parsedSkeleton defines the serialized data
  110563. * @param scene defines the hosting scene
  110564. * @returns a new skeleton
  110565. */
  110566. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  110567. /**
  110568. * Compute all node absolute transforms
  110569. * @param forceUpdate defines if computation must be done even if cache is up to date
  110570. */
  110571. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  110572. /**
  110573. * Gets the root pose matrix
  110574. * @returns a matrix
  110575. */
  110576. getPoseMatrix(): Nullable<Matrix>;
  110577. /**
  110578. * Sorts bones per internal index
  110579. */
  110580. sortBones(): void;
  110581. private _sortBones;
  110582. /**
  110583. * Set the current local matrix as the restPose for all bones in the skeleton.
  110584. */
  110585. setCurrentPoseAsRest(): void;
  110586. }
  110587. }
  110588. declare module BABYLON {
  110589. /**
  110590. * Class used to store bone information
  110591. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110592. */
  110593. export class Bone extends Node {
  110594. /**
  110595. * defines the bone name
  110596. */
  110597. name: string;
  110598. private static _tmpVecs;
  110599. private static _tmpQuat;
  110600. private static _tmpMats;
  110601. /**
  110602. * Gets the list of child bones
  110603. */
  110604. children: Bone[];
  110605. /** Gets the animations associated with this bone */
  110606. animations: Animation[];
  110607. /**
  110608. * Gets or sets bone length
  110609. */
  110610. length: number;
  110611. /**
  110612. * @hidden Internal only
  110613. * Set this value to map this bone to a different index in the transform matrices
  110614. * Set this value to -1 to exclude the bone from the transform matrices
  110615. */
  110616. _index: Nullable<number>;
  110617. private _skeleton;
  110618. private _localMatrix;
  110619. private _restPose;
  110620. private _bindPose;
  110621. private _baseMatrix;
  110622. private _absoluteTransform;
  110623. private _invertedAbsoluteTransform;
  110624. private _parent;
  110625. private _scalingDeterminant;
  110626. private _worldTransform;
  110627. private _localScaling;
  110628. private _localRotation;
  110629. private _localPosition;
  110630. private _needToDecompose;
  110631. private _needToCompose;
  110632. /** @hidden */
  110633. _linkedTransformNode: Nullable<TransformNode>;
  110634. /** @hidden */
  110635. _waitingTransformNodeId: Nullable<string>;
  110636. /** @hidden */
  110637. get _matrix(): Matrix;
  110638. /** @hidden */
  110639. set _matrix(value: Matrix);
  110640. /**
  110641. * Create a new bone
  110642. * @param name defines the bone name
  110643. * @param skeleton defines the parent skeleton
  110644. * @param parentBone defines the parent (can be null if the bone is the root)
  110645. * @param localMatrix defines the local matrix
  110646. * @param restPose defines the rest pose matrix
  110647. * @param baseMatrix defines the base matrix
  110648. * @param index defines index of the bone in the hiearchy
  110649. */
  110650. constructor(
  110651. /**
  110652. * defines the bone name
  110653. */
  110654. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  110655. /**
  110656. * Gets the current object class name.
  110657. * @return the class name
  110658. */
  110659. getClassName(): string;
  110660. /**
  110661. * Gets the parent skeleton
  110662. * @returns a skeleton
  110663. */
  110664. getSkeleton(): Skeleton;
  110665. /**
  110666. * Gets parent bone
  110667. * @returns a bone or null if the bone is the root of the bone hierarchy
  110668. */
  110669. getParent(): Nullable<Bone>;
  110670. /**
  110671. * Returns an array containing the root bones
  110672. * @returns an array containing the root bones
  110673. */
  110674. getChildren(): Array<Bone>;
  110675. /**
  110676. * Gets the node index in matrix array generated for rendering
  110677. * @returns the node index
  110678. */
  110679. getIndex(): number;
  110680. /**
  110681. * Sets the parent bone
  110682. * @param parent defines the parent (can be null if the bone is the root)
  110683. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  110684. */
  110685. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  110686. /**
  110687. * Gets the local matrix
  110688. * @returns a matrix
  110689. */
  110690. getLocalMatrix(): Matrix;
  110691. /**
  110692. * Gets the base matrix (initial matrix which remains unchanged)
  110693. * @returns a matrix
  110694. */
  110695. getBaseMatrix(): Matrix;
  110696. /**
  110697. * Gets the rest pose matrix
  110698. * @returns a matrix
  110699. */
  110700. getRestPose(): Matrix;
  110701. /**
  110702. * Sets the rest pose matrix
  110703. * @param matrix the local-space rest pose to set for this bone
  110704. */
  110705. setRestPose(matrix: Matrix): void;
  110706. /**
  110707. * Gets the bind pose matrix
  110708. * @returns the bind pose matrix
  110709. */
  110710. getBindPose(): Matrix;
  110711. /**
  110712. * Sets the bind pose matrix
  110713. * @param matrix the local-space bind pose to set for this bone
  110714. */
  110715. setBindPose(matrix: Matrix): void;
  110716. /**
  110717. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  110718. */
  110719. getWorldMatrix(): Matrix;
  110720. /**
  110721. * Sets the local matrix to rest pose matrix
  110722. */
  110723. returnToRest(): void;
  110724. /**
  110725. * Gets the inverse of the absolute transform matrix.
  110726. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  110727. * @returns a matrix
  110728. */
  110729. getInvertedAbsoluteTransform(): Matrix;
  110730. /**
  110731. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  110732. * @returns a matrix
  110733. */
  110734. getAbsoluteTransform(): Matrix;
  110735. /**
  110736. * Links with the given transform node.
  110737. * The local matrix of this bone is copied from the transform node every frame.
  110738. * @param transformNode defines the transform node to link to
  110739. */
  110740. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  110741. /**
  110742. * Gets the node used to drive the bone's transformation
  110743. * @returns a transform node or null
  110744. */
  110745. getTransformNode(): Nullable<TransformNode>;
  110746. /** Gets or sets current position (in local space) */
  110747. get position(): Vector3;
  110748. set position(newPosition: Vector3);
  110749. /** Gets or sets current rotation (in local space) */
  110750. get rotation(): Vector3;
  110751. set rotation(newRotation: Vector3);
  110752. /** Gets or sets current rotation quaternion (in local space) */
  110753. get rotationQuaternion(): Quaternion;
  110754. set rotationQuaternion(newRotation: Quaternion);
  110755. /** Gets or sets current scaling (in local space) */
  110756. get scaling(): Vector3;
  110757. set scaling(newScaling: Vector3);
  110758. /**
  110759. * Gets the animation properties override
  110760. */
  110761. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110762. private _decompose;
  110763. private _compose;
  110764. /**
  110765. * Update the base and local matrices
  110766. * @param matrix defines the new base or local matrix
  110767. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  110768. * @param updateLocalMatrix defines if the local matrix should be updated
  110769. */
  110770. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  110771. /** @hidden */
  110772. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  110773. /**
  110774. * Flag the bone as dirty (Forcing it to update everything)
  110775. */
  110776. markAsDirty(): void;
  110777. /** @hidden */
  110778. _markAsDirtyAndCompose(): void;
  110779. private _markAsDirtyAndDecompose;
  110780. /**
  110781. * Translate the bone in local or world space
  110782. * @param vec The amount to translate the bone
  110783. * @param space The space that the translation is in
  110784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110785. */
  110786. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  110787. /**
  110788. * Set the postion of the bone in local or world space
  110789. * @param position The position to set the bone
  110790. * @param space The space that the position is in
  110791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110792. */
  110793. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  110794. /**
  110795. * Set the absolute position of the bone (world space)
  110796. * @param position The position to set the bone
  110797. * @param mesh The mesh that this bone is attached to
  110798. */
  110799. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  110800. /**
  110801. * Scale the bone on the x, y and z axes (in local space)
  110802. * @param x The amount to scale the bone on the x axis
  110803. * @param y The amount to scale the bone on the y axis
  110804. * @param z The amount to scale the bone on the z axis
  110805. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  110806. */
  110807. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  110808. /**
  110809. * Set the bone scaling in local space
  110810. * @param scale defines the scaling vector
  110811. */
  110812. setScale(scale: Vector3): void;
  110813. /**
  110814. * Gets the current scaling in local space
  110815. * @returns the current scaling vector
  110816. */
  110817. getScale(): Vector3;
  110818. /**
  110819. * Gets the current scaling in local space and stores it in a target vector
  110820. * @param result defines the target vector
  110821. */
  110822. getScaleToRef(result: Vector3): void;
  110823. /**
  110824. * Set the yaw, pitch, and roll of the bone in local or world space
  110825. * @param yaw The rotation of the bone on the y axis
  110826. * @param pitch The rotation of the bone on the x axis
  110827. * @param roll The rotation of the bone on the z axis
  110828. * @param space The space that the axes of rotation are in
  110829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110830. */
  110831. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  110832. /**
  110833. * Add a rotation to the bone on an axis in local or world space
  110834. * @param axis The axis to rotate the bone on
  110835. * @param amount The amount to rotate the bone
  110836. * @param space The space that the axis is in
  110837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110838. */
  110839. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  110840. /**
  110841. * Set the rotation of the bone to a particular axis angle in local or world space
  110842. * @param axis The axis to rotate the bone on
  110843. * @param angle The angle that the bone should be rotated to
  110844. * @param space The space that the axis is in
  110845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110846. */
  110847. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  110848. /**
  110849. * Set the euler rotation of the bone in local or world space
  110850. * @param rotation The euler rotation that the bone should be set to
  110851. * @param space The space that the rotation is in
  110852. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110853. */
  110854. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  110855. /**
  110856. * Set the quaternion rotation of the bone in local or world space
  110857. * @param quat The quaternion rotation that the bone should be set to
  110858. * @param space The space that the rotation is in
  110859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110860. */
  110861. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  110862. /**
  110863. * Set the rotation matrix of the bone in local or world space
  110864. * @param rotMat The rotation matrix that the bone should be set to
  110865. * @param space The space that the rotation is in
  110866. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110867. */
  110868. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  110869. private _rotateWithMatrix;
  110870. private _getNegativeRotationToRef;
  110871. /**
  110872. * Get the position of the bone in local or world space
  110873. * @param space The space that the returned position is in
  110874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110875. * @returns The position of the bone
  110876. */
  110877. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  110878. /**
  110879. * Copy the position of the bone to a vector3 in local or world space
  110880. * @param space The space that the returned position is in
  110881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110882. * @param result The vector3 to copy the position to
  110883. */
  110884. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  110885. /**
  110886. * Get the absolute position of the bone (world space)
  110887. * @param mesh The mesh that this bone is attached to
  110888. * @returns The absolute position of the bone
  110889. */
  110890. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  110891. /**
  110892. * Copy the absolute position of the bone (world space) to the result param
  110893. * @param mesh The mesh that this bone is attached to
  110894. * @param result The vector3 to copy the absolute position to
  110895. */
  110896. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  110897. /**
  110898. * Compute the absolute transforms of this bone and its children
  110899. */
  110900. computeAbsoluteTransforms(): void;
  110901. /**
  110902. * Get the world direction from an axis that is in the local space of the bone
  110903. * @param localAxis The local direction that is used to compute the world direction
  110904. * @param mesh The mesh that this bone is attached to
  110905. * @returns The world direction
  110906. */
  110907. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  110908. /**
  110909. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  110910. * @param localAxis The local direction that is used to compute the world direction
  110911. * @param mesh The mesh that this bone is attached to
  110912. * @param result The vector3 that the world direction will be copied to
  110913. */
  110914. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110915. /**
  110916. * Get the euler rotation of the bone in local or world space
  110917. * @param space The space that the rotation should be in
  110918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110919. * @returns The euler rotation
  110920. */
  110921. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  110922. /**
  110923. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  110924. * @param space The space that the rotation should be in
  110925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110926. * @param result The vector3 that the rotation should be copied to
  110927. */
  110928. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110929. /**
  110930. * Get the quaternion rotation of the bone in either local or world space
  110931. * @param space The space that the rotation should be in
  110932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110933. * @returns The quaternion rotation
  110934. */
  110935. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  110936. /**
  110937. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  110938. * @param space The space that the rotation should be in
  110939. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110940. * @param result The quaternion that the rotation should be copied to
  110941. */
  110942. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  110943. /**
  110944. * Get the rotation matrix of the bone in local or world space
  110945. * @param space The space that the rotation should be in
  110946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110947. * @returns The rotation matrix
  110948. */
  110949. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  110950. /**
  110951. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  110952. * @param space The space that the rotation should be in
  110953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110954. * @param result The quaternion that the rotation should be copied to
  110955. */
  110956. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  110957. /**
  110958. * Get the world position of a point that is in the local space of the bone
  110959. * @param position The local position
  110960. * @param mesh The mesh that this bone is attached to
  110961. * @returns The world position
  110962. */
  110963. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  110964. /**
  110965. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  110966. * @param position The local position
  110967. * @param mesh The mesh that this bone is attached to
  110968. * @param result The vector3 that the world position should be copied to
  110969. */
  110970. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110971. /**
  110972. * Get the local position of a point that is in world space
  110973. * @param position The world position
  110974. * @param mesh The mesh that this bone is attached to
  110975. * @returns The local position
  110976. */
  110977. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  110978. /**
  110979. * Get the local position of a point that is in world space and copy it to the result param
  110980. * @param position The world position
  110981. * @param mesh The mesh that this bone is attached to
  110982. * @param result The vector3 that the local position should be copied to
  110983. */
  110984. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110985. /**
  110986. * Set the current local matrix as the restPose for this bone.
  110987. */
  110988. setCurrentPoseAsRest(): void;
  110989. }
  110990. }
  110991. declare module BABYLON {
  110992. /**
  110993. * 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.
  110994. * @see https://doc.babylonjs.com/how_to/transformnode
  110995. */
  110996. export class TransformNode extends Node {
  110997. /**
  110998. * Object will not rotate to face the camera
  110999. */
  111000. static BILLBOARDMODE_NONE: number;
  111001. /**
  111002. * Object will rotate to face the camera but only on the x axis
  111003. */
  111004. static BILLBOARDMODE_X: number;
  111005. /**
  111006. * Object will rotate to face the camera but only on the y axis
  111007. */
  111008. static BILLBOARDMODE_Y: number;
  111009. /**
  111010. * Object will rotate to face the camera but only on the z axis
  111011. */
  111012. static BILLBOARDMODE_Z: number;
  111013. /**
  111014. * Object will rotate to face the camera
  111015. */
  111016. static BILLBOARDMODE_ALL: number;
  111017. /**
  111018. * Object will rotate to face the camera's position instead of orientation
  111019. */
  111020. static BILLBOARDMODE_USE_POSITION: number;
  111021. private static _TmpRotation;
  111022. private static _TmpScaling;
  111023. private static _TmpTranslation;
  111024. private _forward;
  111025. private _forwardInverted;
  111026. private _up;
  111027. private _right;
  111028. private _rightInverted;
  111029. private _position;
  111030. private _rotation;
  111031. private _rotationQuaternion;
  111032. protected _scaling: Vector3;
  111033. protected _isDirty: boolean;
  111034. private _transformToBoneReferal;
  111035. private _isAbsoluteSynced;
  111036. private _billboardMode;
  111037. /**
  111038. * Gets or sets the billboard mode. Default is 0.
  111039. *
  111040. * | Value | Type | Description |
  111041. * | --- | --- | --- |
  111042. * | 0 | BILLBOARDMODE_NONE | |
  111043. * | 1 | BILLBOARDMODE_X | |
  111044. * | 2 | BILLBOARDMODE_Y | |
  111045. * | 4 | BILLBOARDMODE_Z | |
  111046. * | 7 | BILLBOARDMODE_ALL | |
  111047. *
  111048. */
  111049. get billboardMode(): number;
  111050. set billboardMode(value: number);
  111051. private _preserveParentRotationForBillboard;
  111052. /**
  111053. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  111054. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  111055. */
  111056. get preserveParentRotationForBillboard(): boolean;
  111057. set preserveParentRotationForBillboard(value: boolean);
  111058. /**
  111059. * 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
  111060. */
  111061. scalingDeterminant: number;
  111062. private _infiniteDistance;
  111063. /**
  111064. * Gets or sets the distance of the object to max, often used by skybox
  111065. */
  111066. get infiniteDistance(): boolean;
  111067. set infiniteDistance(value: boolean);
  111068. /**
  111069. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  111070. * By default the system will update normals to compensate
  111071. */
  111072. ignoreNonUniformScaling: boolean;
  111073. /**
  111074. * 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
  111075. */
  111076. reIntegrateRotationIntoRotationQuaternion: boolean;
  111077. /** @hidden */
  111078. _poseMatrix: Nullable<Matrix>;
  111079. /** @hidden */
  111080. _localMatrix: Matrix;
  111081. private _usePivotMatrix;
  111082. private _absolutePosition;
  111083. private _absoluteScaling;
  111084. private _absoluteRotationQuaternion;
  111085. private _pivotMatrix;
  111086. private _pivotMatrixInverse;
  111087. /** @hidden */
  111088. _postMultiplyPivotMatrix: boolean;
  111089. protected _isWorldMatrixFrozen: boolean;
  111090. /** @hidden */
  111091. _indexInSceneTransformNodesArray: number;
  111092. /**
  111093. * An event triggered after the world matrix is updated
  111094. */
  111095. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  111096. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  111097. /**
  111098. * Gets a string identifying the name of the class
  111099. * @returns "TransformNode" string
  111100. */
  111101. getClassName(): string;
  111102. /**
  111103. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  111104. */
  111105. get position(): Vector3;
  111106. set position(newPosition: Vector3);
  111107. /**
  111108. * 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)).
  111109. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  111110. */
  111111. get rotation(): Vector3;
  111112. set rotation(newRotation: Vector3);
  111113. /**
  111114. * 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)).
  111115. */
  111116. get scaling(): Vector3;
  111117. set scaling(newScaling: Vector3);
  111118. /**
  111119. * 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).
  111120. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  111121. */
  111122. get rotationQuaternion(): Nullable<Quaternion>;
  111123. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  111124. /**
  111125. * The forward direction of that transform in world space.
  111126. */
  111127. get forward(): Vector3;
  111128. /**
  111129. * The up direction of that transform in world space.
  111130. */
  111131. get up(): Vector3;
  111132. /**
  111133. * The right direction of that transform in world space.
  111134. */
  111135. get right(): Vector3;
  111136. /**
  111137. * Copies the parameter passed Matrix into the mesh Pose matrix.
  111138. * @param matrix the matrix to copy the pose from
  111139. * @returns this TransformNode.
  111140. */
  111141. updatePoseMatrix(matrix: Matrix): TransformNode;
  111142. /**
  111143. * Returns the mesh Pose matrix.
  111144. * @returns the pose matrix
  111145. */
  111146. getPoseMatrix(): Matrix;
  111147. /** @hidden */
  111148. _isSynchronized(): boolean;
  111149. /** @hidden */
  111150. _initCache(): void;
  111151. /**
  111152. * Flag the transform node as dirty (Forcing it to update everything)
  111153. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  111154. * @returns this transform node
  111155. */
  111156. markAsDirty(property: string): TransformNode;
  111157. /**
  111158. * Returns the current mesh absolute position.
  111159. * Returns a Vector3.
  111160. */
  111161. get absolutePosition(): Vector3;
  111162. /**
  111163. * Returns the current mesh absolute scaling.
  111164. * Returns a Vector3.
  111165. */
  111166. get absoluteScaling(): Vector3;
  111167. /**
  111168. * Returns the current mesh absolute rotation.
  111169. * Returns a Quaternion.
  111170. */
  111171. get absoluteRotationQuaternion(): Quaternion;
  111172. /**
  111173. * Sets a new matrix to apply before all other transformation
  111174. * @param matrix defines the transform matrix
  111175. * @returns the current TransformNode
  111176. */
  111177. setPreTransformMatrix(matrix: Matrix): TransformNode;
  111178. /**
  111179. * Sets a new pivot matrix to the current node
  111180. * @param matrix defines the new pivot matrix to use
  111181. * @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
  111182. * @returns the current TransformNode
  111183. */
  111184. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  111185. /**
  111186. * Returns the mesh pivot matrix.
  111187. * Default : Identity.
  111188. * @returns the matrix
  111189. */
  111190. getPivotMatrix(): Matrix;
  111191. /**
  111192. * Instantiate (when possible) or clone that node with its hierarchy
  111193. * @param newParent defines the new parent to use for the instance (or clone)
  111194. * @param options defines options to configure how copy is done
  111195. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  111196. * @returns an instance (or a clone) of the current node with its hiearchy
  111197. */
  111198. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  111199. doNotInstantiate: boolean;
  111200. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  111201. /**
  111202. * Prevents the World matrix to be computed any longer
  111203. * @param newWorldMatrix defines an optional matrix to use as world matrix
  111204. * @returns the TransformNode.
  111205. */
  111206. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  111207. /**
  111208. * Allows back the World matrix computation.
  111209. * @returns the TransformNode.
  111210. */
  111211. unfreezeWorldMatrix(): this;
  111212. /**
  111213. * True if the World matrix has been frozen.
  111214. */
  111215. get isWorldMatrixFrozen(): boolean;
  111216. /**
  111217. * Retuns the mesh absolute position in the World.
  111218. * @returns a Vector3.
  111219. */
  111220. getAbsolutePosition(): Vector3;
  111221. /**
  111222. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  111223. * @param absolutePosition the absolute position to set
  111224. * @returns the TransformNode.
  111225. */
  111226. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  111227. /**
  111228. * Sets the mesh position in its local space.
  111229. * @param vector3 the position to set in localspace
  111230. * @returns the TransformNode.
  111231. */
  111232. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  111233. /**
  111234. * Returns the mesh position in the local space from the current World matrix values.
  111235. * @returns a new Vector3.
  111236. */
  111237. getPositionExpressedInLocalSpace(): Vector3;
  111238. /**
  111239. * Translates the mesh along the passed Vector3 in its local space.
  111240. * @param vector3 the distance to translate in localspace
  111241. * @returns the TransformNode.
  111242. */
  111243. locallyTranslate(vector3: Vector3): TransformNode;
  111244. private static _lookAtVectorCache;
  111245. /**
  111246. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  111247. * @param targetPoint the position (must be in same space as current mesh) to look at
  111248. * @param yawCor optional yaw (y-axis) correction in radians
  111249. * @param pitchCor optional pitch (x-axis) correction in radians
  111250. * @param rollCor optional roll (z-axis) correction in radians
  111251. * @param space the choosen space of the target
  111252. * @returns the TransformNode.
  111253. */
  111254. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  111255. /**
  111256. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111257. * This Vector3 is expressed in the World space.
  111258. * @param localAxis axis to rotate
  111259. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111260. */
  111261. getDirection(localAxis: Vector3): Vector3;
  111262. /**
  111263. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  111264. * localAxis is expressed in the mesh local space.
  111265. * result is computed in the Wordl space from the mesh World matrix.
  111266. * @param localAxis axis to rotate
  111267. * @param result the resulting transformnode
  111268. * @returns this TransformNode.
  111269. */
  111270. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  111271. /**
  111272. * Sets this transform node rotation to the given local axis.
  111273. * @param localAxis the axis in local space
  111274. * @param yawCor optional yaw (y-axis) correction in radians
  111275. * @param pitchCor optional pitch (x-axis) correction in radians
  111276. * @param rollCor optional roll (z-axis) correction in radians
  111277. * @returns this TransformNode
  111278. */
  111279. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  111280. /**
  111281. * Sets a new pivot point to the current node
  111282. * @param point defines the new pivot point to use
  111283. * @param space defines if the point is in world or local space (local by default)
  111284. * @returns the current TransformNode
  111285. */
  111286. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  111287. /**
  111288. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  111289. * @returns the pivot point
  111290. */
  111291. getPivotPoint(): Vector3;
  111292. /**
  111293. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  111294. * @param result the vector3 to store the result
  111295. * @returns this TransformNode.
  111296. */
  111297. getPivotPointToRef(result: Vector3): TransformNode;
  111298. /**
  111299. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  111300. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  111301. */
  111302. getAbsolutePivotPoint(): Vector3;
  111303. /**
  111304. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  111305. * @param result vector3 to store the result
  111306. * @returns this TransformNode.
  111307. */
  111308. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  111309. /**
  111310. * Defines the passed node as the parent of the current node.
  111311. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  111312. * @see https://doc.babylonjs.com/how_to/parenting
  111313. * @param node the node ot set as the parent
  111314. * @returns this TransformNode.
  111315. */
  111316. setParent(node: Nullable<Node>): TransformNode;
  111317. private _nonUniformScaling;
  111318. /**
  111319. * True if the scaling property of this object is non uniform eg. (1,2,1)
  111320. */
  111321. get nonUniformScaling(): boolean;
  111322. /** @hidden */
  111323. _updateNonUniformScalingState(value: boolean): boolean;
  111324. /**
  111325. * Attach the current TransformNode to another TransformNode associated with a bone
  111326. * @param bone Bone affecting the TransformNode
  111327. * @param affectedTransformNode TransformNode associated with the bone
  111328. * @returns this object
  111329. */
  111330. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  111331. /**
  111332. * Detach the transform node if its associated with a bone
  111333. * @returns this object
  111334. */
  111335. detachFromBone(): TransformNode;
  111336. private static _rotationAxisCache;
  111337. /**
  111338. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  111339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111340. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111341. * The passed axis is also normalized.
  111342. * @param axis the axis to rotate around
  111343. * @param amount the amount to rotate in radians
  111344. * @param space Space to rotate in (Default: local)
  111345. * @returns the TransformNode.
  111346. */
  111347. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  111348. /**
  111349. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  111350. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111351. * The passed axis is also normalized. .
  111352. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  111353. * @param point the point to rotate around
  111354. * @param axis the axis to rotate around
  111355. * @param amount the amount to rotate in radians
  111356. * @returns the TransformNode
  111357. */
  111358. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  111359. /**
  111360. * Translates the mesh along the axis vector for the passed distance in the given space.
  111361. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111362. * @param axis the axis to translate in
  111363. * @param distance the distance to translate
  111364. * @param space Space to rotate in (Default: local)
  111365. * @returns the TransformNode.
  111366. */
  111367. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  111368. /**
  111369. * Adds a rotation step to the mesh current rotation.
  111370. * x, y, z are Euler angles expressed in radians.
  111371. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  111372. * This means this rotation is made in the mesh local space only.
  111373. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  111374. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  111375. * ```javascript
  111376. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  111377. * ```
  111378. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  111379. * 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.
  111380. * @param x Rotation to add
  111381. * @param y Rotation to add
  111382. * @param z Rotation to add
  111383. * @returns the TransformNode.
  111384. */
  111385. addRotation(x: number, y: number, z: number): TransformNode;
  111386. /**
  111387. * @hidden
  111388. */
  111389. protected _getEffectiveParent(): Nullable<Node>;
  111390. /**
  111391. * Computes the world matrix of the node
  111392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111393. * @returns the world matrix
  111394. */
  111395. computeWorldMatrix(force?: boolean): Matrix;
  111396. /**
  111397. * Resets this nodeTransform's local matrix to Matrix.Identity().
  111398. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  111399. */
  111400. resetLocalMatrix(independentOfChildren?: boolean): void;
  111401. protected _afterComputeWorldMatrix(): void;
  111402. /**
  111403. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  111404. * @param func callback function to add
  111405. *
  111406. * @returns the TransformNode.
  111407. */
  111408. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  111409. /**
  111410. * Removes a registered callback function.
  111411. * @param func callback function to remove
  111412. * @returns the TransformNode.
  111413. */
  111414. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  111415. /**
  111416. * Gets the position of the current mesh in camera space
  111417. * @param camera defines the camera to use
  111418. * @returns a position
  111419. */
  111420. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  111421. /**
  111422. * Returns the distance from the mesh to the active camera
  111423. * @param camera defines the camera to use
  111424. * @returns the distance
  111425. */
  111426. getDistanceToCamera(camera?: Nullable<Camera>): number;
  111427. /**
  111428. * Clone the current transform node
  111429. * @param name Name of the new clone
  111430. * @param newParent New parent for the clone
  111431. * @param doNotCloneChildren Do not clone children hierarchy
  111432. * @returns the new transform node
  111433. */
  111434. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  111435. /**
  111436. * Serializes the objects information.
  111437. * @param currentSerializationObject defines the object to serialize in
  111438. * @returns the serialized object
  111439. */
  111440. serialize(currentSerializationObject?: any): any;
  111441. /**
  111442. * Returns a new TransformNode object parsed from the source provided.
  111443. * @param parsedTransformNode is the source.
  111444. * @param scene the scne the object belongs to
  111445. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  111446. * @returns a new TransformNode object parsed from the source provided.
  111447. */
  111448. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  111449. /**
  111450. * Get all child-transformNodes of this node
  111451. * @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
  111452. * @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
  111453. * @returns an array of TransformNode
  111454. */
  111455. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  111456. /**
  111457. * Releases resources associated with this transform node.
  111458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111460. */
  111461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111462. /**
  111463. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111464. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111465. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111466. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111467. * @returns the current mesh
  111468. */
  111469. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  111470. private _syncAbsoluteScalingAndRotation;
  111471. }
  111472. }
  111473. declare module BABYLON {
  111474. /**
  111475. * Defines the types of pose enabled controllers that are supported
  111476. */
  111477. export enum PoseEnabledControllerType {
  111478. /**
  111479. * HTC Vive
  111480. */
  111481. VIVE = 0,
  111482. /**
  111483. * Oculus Rift
  111484. */
  111485. OCULUS = 1,
  111486. /**
  111487. * Windows mixed reality
  111488. */
  111489. WINDOWS = 2,
  111490. /**
  111491. * Samsung gear VR
  111492. */
  111493. GEAR_VR = 3,
  111494. /**
  111495. * Google Daydream
  111496. */
  111497. DAYDREAM = 4,
  111498. /**
  111499. * Generic
  111500. */
  111501. GENERIC = 5
  111502. }
  111503. /**
  111504. * Defines the MutableGamepadButton interface for the state of a gamepad button
  111505. */
  111506. export interface MutableGamepadButton {
  111507. /**
  111508. * Value of the button/trigger
  111509. */
  111510. value: number;
  111511. /**
  111512. * If the button/trigger is currently touched
  111513. */
  111514. touched: boolean;
  111515. /**
  111516. * If the button/trigger is currently pressed
  111517. */
  111518. pressed: boolean;
  111519. }
  111520. /**
  111521. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  111522. * @hidden
  111523. */
  111524. export interface ExtendedGamepadButton extends GamepadButton {
  111525. /**
  111526. * If the button/trigger is currently pressed
  111527. */
  111528. readonly pressed: boolean;
  111529. /**
  111530. * If the button/trigger is currently touched
  111531. */
  111532. readonly touched: boolean;
  111533. /**
  111534. * Value of the button/trigger
  111535. */
  111536. readonly value: number;
  111537. }
  111538. /** @hidden */
  111539. export interface _GamePadFactory {
  111540. /**
  111541. * Returns whether or not the current gamepad can be created for this type of controller.
  111542. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  111543. * @returns true if it can be created, otherwise false
  111544. */
  111545. canCreate(gamepadInfo: any): boolean;
  111546. /**
  111547. * Creates a new instance of the Gamepad.
  111548. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  111549. * @returns the new gamepad instance
  111550. */
  111551. create(gamepadInfo: any): Gamepad;
  111552. }
  111553. /**
  111554. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  111555. */
  111556. export class PoseEnabledControllerHelper {
  111557. /** @hidden */
  111558. static _ControllerFactories: _GamePadFactory[];
  111559. /** @hidden */
  111560. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  111561. /**
  111562. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  111563. * @param vrGamepad the gamepad to initialized
  111564. * @returns a vr controller of the type the gamepad identified as
  111565. */
  111566. static InitiateController(vrGamepad: any): Gamepad;
  111567. }
  111568. /**
  111569. * Defines the PoseEnabledController object that contains state of a vr capable controller
  111570. */
  111571. export class PoseEnabledController extends Gamepad implements PoseControlled {
  111572. /**
  111573. * If the controller is used in a webXR session
  111574. */
  111575. isXR: boolean;
  111576. private _deviceRoomPosition;
  111577. private _deviceRoomRotationQuaternion;
  111578. /**
  111579. * The device position in babylon space
  111580. */
  111581. devicePosition: Vector3;
  111582. /**
  111583. * The device rotation in babylon space
  111584. */
  111585. deviceRotationQuaternion: Quaternion;
  111586. /**
  111587. * The scale factor of the device in babylon space
  111588. */
  111589. deviceScaleFactor: number;
  111590. /**
  111591. * (Likely devicePosition should be used instead) The device position in its room space
  111592. */
  111593. position: Vector3;
  111594. /**
  111595. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  111596. */
  111597. rotationQuaternion: Quaternion;
  111598. /**
  111599. * The type of controller (Eg. Windows mixed reality)
  111600. */
  111601. controllerType: PoseEnabledControllerType;
  111602. protected _calculatedPosition: Vector3;
  111603. private _calculatedRotation;
  111604. /**
  111605. * The raw pose from the device
  111606. */
  111607. rawPose: DevicePose;
  111608. private _trackPosition;
  111609. private _maxRotationDistFromHeadset;
  111610. private _draggedRoomRotation;
  111611. /**
  111612. * @hidden
  111613. */
  111614. _disableTrackPosition(fixedPosition: Vector3): void;
  111615. /**
  111616. * Internal, the mesh attached to the controller
  111617. * @hidden
  111618. */
  111619. _mesh: Nullable<AbstractMesh>;
  111620. private _poseControlledCamera;
  111621. private _leftHandSystemQuaternion;
  111622. /**
  111623. * Internal, matrix used to convert room space to babylon space
  111624. * @hidden
  111625. */
  111626. _deviceToWorld: Matrix;
  111627. /**
  111628. * Node to be used when casting a ray from the controller
  111629. * @hidden
  111630. */
  111631. _pointingPoseNode: Nullable<TransformNode>;
  111632. /**
  111633. * Name of the child mesh that can be used to cast a ray from the controller
  111634. */
  111635. static readonly POINTING_POSE: string;
  111636. /**
  111637. * Creates a new PoseEnabledController from a gamepad
  111638. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  111639. */
  111640. constructor(browserGamepad: any);
  111641. private _workingMatrix;
  111642. /**
  111643. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  111644. */
  111645. update(): void;
  111646. /**
  111647. * Updates only the pose device and mesh without doing any button event checking
  111648. */
  111649. protected _updatePoseAndMesh(): void;
  111650. /**
  111651. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  111652. * @param poseData raw pose fromthe device
  111653. */
  111654. updateFromDevice(poseData: DevicePose): void;
  111655. /**
  111656. * @hidden
  111657. */
  111658. _meshAttachedObservable: Observable<AbstractMesh>;
  111659. /**
  111660. * Attaches a mesh to the controller
  111661. * @param mesh the mesh to be attached
  111662. */
  111663. attachToMesh(mesh: AbstractMesh): void;
  111664. /**
  111665. * Attaches the controllers mesh to a camera
  111666. * @param camera the camera the mesh should be attached to
  111667. */
  111668. attachToPoseControlledCamera(camera: TargetCamera): void;
  111669. /**
  111670. * Disposes of the controller
  111671. */
  111672. dispose(): void;
  111673. /**
  111674. * The mesh that is attached to the controller
  111675. */
  111676. get mesh(): Nullable<AbstractMesh>;
  111677. /**
  111678. * Gets the ray of the controller in the direction the controller is pointing
  111679. * @param length the length the resulting ray should be
  111680. * @returns a ray in the direction the controller is pointing
  111681. */
  111682. getForwardRay(length?: number): Ray;
  111683. }
  111684. }
  111685. declare module BABYLON {
  111686. /**
  111687. * Defines the WebVRController object that represents controllers tracked in 3D space
  111688. */
  111689. export abstract class WebVRController extends PoseEnabledController {
  111690. /**
  111691. * Internal, the default controller model for the controller
  111692. */
  111693. protected _defaultModel: Nullable<AbstractMesh>;
  111694. /**
  111695. * Fired when the trigger state has changed
  111696. */
  111697. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111698. /**
  111699. * Fired when the main button state has changed
  111700. */
  111701. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111702. /**
  111703. * Fired when the secondary button state has changed
  111704. */
  111705. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111706. /**
  111707. * Fired when the pad state has changed
  111708. */
  111709. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  111710. /**
  111711. * Fired when controllers stick values have changed
  111712. */
  111713. onPadValuesChangedObservable: Observable<StickValues>;
  111714. /**
  111715. * Array of button availible on the controller
  111716. */
  111717. protected _buttons: Array<MutableGamepadButton>;
  111718. private _onButtonStateChange;
  111719. /**
  111720. * Fired when a controller button's state has changed
  111721. * @param callback the callback containing the button that was modified
  111722. */
  111723. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  111724. /**
  111725. * X and Y axis corresponding to the controllers joystick
  111726. */
  111727. pad: StickValues;
  111728. /**
  111729. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  111730. */
  111731. hand: string;
  111732. /**
  111733. * The default controller model for the controller
  111734. */
  111735. get defaultModel(): Nullable<AbstractMesh>;
  111736. /**
  111737. * Creates a new WebVRController from a gamepad
  111738. * @param vrGamepad the gamepad that the WebVRController should be created from
  111739. */
  111740. constructor(vrGamepad: any);
  111741. /**
  111742. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  111743. */
  111744. update(): void;
  111745. /**
  111746. * Function to be called when a button is modified
  111747. */
  111748. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111749. /**
  111750. * Loads a mesh and attaches it to the controller
  111751. * @param scene the scene the mesh should be added to
  111752. * @param meshLoaded callback for when the mesh has been loaded
  111753. */
  111754. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111755. private _setButtonValue;
  111756. private _changes;
  111757. private _checkChanges;
  111758. /**
  111759. * Disposes of th webVRCOntroller
  111760. */
  111761. dispose(): void;
  111762. }
  111763. }
  111764. declare module BABYLON {
  111765. /**
  111766. * The HemisphericLight simulates the ambient environment light,
  111767. * so the passed direction is the light reflection direction, not the incoming direction.
  111768. */
  111769. export class HemisphericLight extends Light {
  111770. /**
  111771. * The groundColor is the light in the opposite direction to the one specified during creation.
  111772. * 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.
  111773. */
  111774. groundColor: Color3;
  111775. /**
  111776. * The light reflection direction, not the incoming direction.
  111777. */
  111778. direction: Vector3;
  111779. /**
  111780. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  111781. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  111782. * The HemisphericLight can't cast shadows.
  111783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111784. * @param name The friendly name of the light
  111785. * @param direction The direction of the light reflection
  111786. * @param scene The scene the light belongs to
  111787. */
  111788. constructor(name: string, direction: Vector3, scene: Scene);
  111789. protected _buildUniformLayout(): void;
  111790. /**
  111791. * Returns the string "HemisphericLight".
  111792. * @return The class name
  111793. */
  111794. getClassName(): string;
  111795. /**
  111796. * Sets the HemisphericLight direction towards the passed target (Vector3).
  111797. * Returns the updated direction.
  111798. * @param target The target the direction should point to
  111799. * @return The computed direction
  111800. */
  111801. setDirectionToTarget(target: Vector3): Vector3;
  111802. /**
  111803. * Returns the shadow generator associated to the light.
  111804. * @returns Always null for hemispheric lights because it does not support shadows.
  111805. */
  111806. getShadowGenerator(): Nullable<IShadowGenerator>;
  111807. /**
  111808. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  111809. * @param effect The effect to update
  111810. * @param lightIndex The index of the light in the effect to update
  111811. * @returns The hemispheric light
  111812. */
  111813. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  111814. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111815. /**
  111816. * Computes the world matrix of the node
  111817. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111818. * @param useWasUpdatedFlag defines a reserved property
  111819. * @returns the world matrix
  111820. */
  111821. computeWorldMatrix(): Matrix;
  111822. /**
  111823. * Returns the integer 3.
  111824. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111825. */
  111826. getTypeID(): number;
  111827. /**
  111828. * Prepares the list of defines specific to the light type.
  111829. * @param defines the list of defines
  111830. * @param lightIndex defines the index of the light for the effect
  111831. */
  111832. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111833. }
  111834. }
  111835. declare module BABYLON {
  111836. /** @hidden */
  111837. export var vrMultiviewToSingleviewPixelShader: {
  111838. name: string;
  111839. shader: string;
  111840. };
  111841. }
  111842. declare module BABYLON {
  111843. /**
  111844. * Renders to multiple views with a single draw call
  111845. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  111846. */
  111847. export class MultiviewRenderTarget extends RenderTargetTexture {
  111848. /**
  111849. * Creates a multiview render target
  111850. * @param scene scene used with the render target
  111851. * @param size the size of the render target (used for each view)
  111852. */
  111853. constructor(scene: Scene, size?: number | {
  111854. width: number;
  111855. height: number;
  111856. } | {
  111857. ratio: number;
  111858. });
  111859. /**
  111860. * @hidden
  111861. * @param faceIndex the face index, if its a cube texture
  111862. */
  111863. _bindFrameBuffer(faceIndex?: number): void;
  111864. /**
  111865. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  111866. * @returns the view count
  111867. */
  111868. getViewCount(): number;
  111869. }
  111870. }
  111871. declare module BABYLON {
  111872. interface Engine {
  111873. /**
  111874. * Creates a new multiview render target
  111875. * @param width defines the width of the texture
  111876. * @param height defines the height of the texture
  111877. * @returns the created multiview texture
  111878. */
  111879. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  111880. /**
  111881. * Binds a multiview framebuffer to be drawn to
  111882. * @param multiviewTexture texture to bind
  111883. */
  111884. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  111885. }
  111886. interface Camera {
  111887. /**
  111888. * @hidden
  111889. * 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)
  111890. */
  111891. _useMultiviewToSingleView: boolean;
  111892. /**
  111893. * @hidden
  111894. * 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)
  111895. */
  111896. _multiviewTexture: Nullable<RenderTargetTexture>;
  111897. /**
  111898. * @hidden
  111899. * ensures the multiview texture of the camera exists and has the specified width/height
  111900. * @param width height to set on the multiview texture
  111901. * @param height width to set on the multiview texture
  111902. */
  111903. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  111904. }
  111905. interface Scene {
  111906. /** @hidden */
  111907. _transformMatrixR: Matrix;
  111908. /** @hidden */
  111909. _multiviewSceneUbo: Nullable<UniformBuffer>;
  111910. /** @hidden */
  111911. _createMultiviewUbo(): void;
  111912. /** @hidden */
  111913. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  111914. /** @hidden */
  111915. _renderMultiviewToSingleView(camera: Camera): void;
  111916. }
  111917. }
  111918. declare module BABYLON {
  111919. /**
  111920. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  111921. * This will not be used for webXR as it supports displaying texture arrays directly
  111922. */
  111923. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  111924. /**
  111925. * Gets a string identifying the name of the class
  111926. * @returns "VRMultiviewToSingleviewPostProcess" string
  111927. */
  111928. getClassName(): string;
  111929. /**
  111930. * Initializes a VRMultiviewToSingleview
  111931. * @param name name of the post process
  111932. * @param camera camera to be applied to
  111933. * @param scaleFactor scaling factor to the size of the output texture
  111934. */
  111935. constructor(name: string, camera: Camera, scaleFactor: number);
  111936. }
  111937. }
  111938. declare module BABYLON {
  111939. /**
  111940. * Interface used to define additional presentation attributes
  111941. */
  111942. export interface IVRPresentationAttributes {
  111943. /**
  111944. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  111945. */
  111946. highRefreshRate: boolean;
  111947. /**
  111948. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  111949. */
  111950. foveationLevel: number;
  111951. }
  111952. interface Engine {
  111953. /** @hidden */
  111954. _vrDisplay: any;
  111955. /** @hidden */
  111956. _vrSupported: boolean;
  111957. /** @hidden */
  111958. _oldSize: Size;
  111959. /** @hidden */
  111960. _oldHardwareScaleFactor: number;
  111961. /** @hidden */
  111962. _vrExclusivePointerMode: boolean;
  111963. /** @hidden */
  111964. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  111965. /** @hidden */
  111966. _onVRDisplayPointerRestricted: () => void;
  111967. /** @hidden */
  111968. _onVRDisplayPointerUnrestricted: () => void;
  111969. /** @hidden */
  111970. _onVrDisplayConnect: Nullable<(display: any) => void>;
  111971. /** @hidden */
  111972. _onVrDisplayDisconnect: Nullable<() => void>;
  111973. /** @hidden */
  111974. _onVrDisplayPresentChange: Nullable<() => void>;
  111975. /**
  111976. * Observable signaled when VR display mode changes
  111977. */
  111978. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  111979. /**
  111980. * Observable signaled when VR request present is complete
  111981. */
  111982. onVRRequestPresentComplete: Observable<boolean>;
  111983. /**
  111984. * Observable signaled when VR request present starts
  111985. */
  111986. onVRRequestPresentStart: Observable<Engine>;
  111987. /**
  111988. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  111989. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  111990. */
  111991. isInVRExclusivePointerMode: boolean;
  111992. /**
  111993. * Gets a boolean indicating if a webVR device was detected
  111994. * @returns true if a webVR device was detected
  111995. */
  111996. isVRDevicePresent(): boolean;
  111997. /**
  111998. * Gets the current webVR device
  111999. * @returns the current webVR device (or null)
  112000. */
  112001. getVRDevice(): any;
  112002. /**
  112003. * Initializes a webVR display and starts listening to display change events
  112004. * The onVRDisplayChangedObservable will be notified upon these changes
  112005. * @returns A promise containing a VRDisplay and if vr is supported
  112006. */
  112007. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  112008. /** @hidden */
  112009. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  112010. /**
  112011. * Gets or sets the presentation attributes used to configure VR rendering
  112012. */
  112013. vrPresentationAttributes?: IVRPresentationAttributes;
  112014. /**
  112015. * Call this function to switch to webVR mode
  112016. * Will do nothing if webVR is not supported or if there is no webVR device
  112017. * @param options the webvr options provided to the camera. mainly used for multiview
  112018. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112019. */
  112020. enableVR(options: WebVROptions): void;
  112021. /** @hidden */
  112022. _onVRFullScreenTriggered(): void;
  112023. }
  112024. }
  112025. declare module BABYLON {
  112026. /**
  112027. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  112028. * IMPORTANT!! The data is right-hand data.
  112029. * @export
  112030. * @interface DevicePose
  112031. */
  112032. export interface DevicePose {
  112033. /**
  112034. * The position of the device, values in array are [x,y,z].
  112035. */
  112036. readonly position: Nullable<Float32Array>;
  112037. /**
  112038. * The linearVelocity of the device, values in array are [x,y,z].
  112039. */
  112040. readonly linearVelocity: Nullable<Float32Array>;
  112041. /**
  112042. * The linearAcceleration of the device, values in array are [x,y,z].
  112043. */
  112044. readonly linearAcceleration: Nullable<Float32Array>;
  112045. /**
  112046. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  112047. */
  112048. readonly orientation: Nullable<Float32Array>;
  112049. /**
  112050. * The angularVelocity of the device, values in array are [x,y,z].
  112051. */
  112052. readonly angularVelocity: Nullable<Float32Array>;
  112053. /**
  112054. * The angularAcceleration of the device, values in array are [x,y,z].
  112055. */
  112056. readonly angularAcceleration: Nullable<Float32Array>;
  112057. }
  112058. /**
  112059. * Interface representing a pose controlled object in Babylon.
  112060. * A pose controlled object has both regular pose values as well as pose values
  112061. * from an external device such as a VR head mounted display
  112062. */
  112063. export interface PoseControlled {
  112064. /**
  112065. * The position of the object in babylon space.
  112066. */
  112067. position: Vector3;
  112068. /**
  112069. * The rotation quaternion of the object in babylon space.
  112070. */
  112071. rotationQuaternion: Quaternion;
  112072. /**
  112073. * The position of the device in babylon space.
  112074. */
  112075. devicePosition?: Vector3;
  112076. /**
  112077. * The rotation quaternion of the device in babylon space.
  112078. */
  112079. deviceRotationQuaternion: Quaternion;
  112080. /**
  112081. * The raw pose coming from the device.
  112082. */
  112083. rawPose: Nullable<DevicePose>;
  112084. /**
  112085. * The scale of the device to be used when translating from device space to babylon space.
  112086. */
  112087. deviceScaleFactor: number;
  112088. /**
  112089. * Updates the poseControlled values based on the input device pose.
  112090. * @param poseData the pose data to update the object with
  112091. */
  112092. updateFromDevice(poseData: DevicePose): void;
  112093. }
  112094. /**
  112095. * Set of options to customize the webVRCamera
  112096. */
  112097. export interface WebVROptions {
  112098. /**
  112099. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  112100. */
  112101. trackPosition?: boolean;
  112102. /**
  112103. * Sets the scale of the vrDevice in babylon space. (default: 1)
  112104. */
  112105. positionScale?: number;
  112106. /**
  112107. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  112108. */
  112109. displayName?: string;
  112110. /**
  112111. * Should the native controller meshes be initialized. (default: true)
  112112. */
  112113. controllerMeshes?: boolean;
  112114. /**
  112115. * Creating a default HemiLight only on controllers. (default: true)
  112116. */
  112117. defaultLightingOnControllers?: boolean;
  112118. /**
  112119. * If you don't want to use the default VR button of the helper. (default: false)
  112120. */
  112121. useCustomVRButton?: boolean;
  112122. /**
  112123. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  112124. */
  112125. customVRButton?: HTMLButtonElement;
  112126. /**
  112127. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  112128. */
  112129. rayLength?: number;
  112130. /**
  112131. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  112132. */
  112133. defaultHeight?: number;
  112134. /**
  112135. * If multiview should be used if availible (default: false)
  112136. */
  112137. useMultiview?: boolean;
  112138. }
  112139. /**
  112140. * This represents a WebVR camera.
  112141. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  112142. * @example https://doc.babylonjs.com/how_to/webvr_camera
  112143. */
  112144. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  112145. private webVROptions;
  112146. /**
  112147. * @hidden
  112148. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  112149. */
  112150. _vrDevice: any;
  112151. /**
  112152. * The rawPose of the vrDevice.
  112153. */
  112154. rawPose: Nullable<DevicePose>;
  112155. private _onVREnabled;
  112156. private _specsVersion;
  112157. private _attached;
  112158. private _frameData;
  112159. protected _descendants: Array<Node>;
  112160. private _deviceRoomPosition;
  112161. /** @hidden */
  112162. _deviceRoomRotationQuaternion: Quaternion;
  112163. private _standingMatrix;
  112164. /**
  112165. * Represents device position in babylon space.
  112166. */
  112167. devicePosition: Vector3;
  112168. /**
  112169. * Represents device rotation in babylon space.
  112170. */
  112171. deviceRotationQuaternion: Quaternion;
  112172. /**
  112173. * The scale of the device to be used when translating from device space to babylon space.
  112174. */
  112175. deviceScaleFactor: number;
  112176. private _deviceToWorld;
  112177. private _worldToDevice;
  112178. /**
  112179. * References to the webVR controllers for the vrDevice.
  112180. */
  112181. controllers: Array<WebVRController>;
  112182. /**
  112183. * Emits an event when a controller is attached.
  112184. */
  112185. onControllersAttachedObservable: Observable<WebVRController[]>;
  112186. /**
  112187. * Emits an event when a controller's mesh has been loaded;
  112188. */
  112189. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112190. /**
  112191. * Emits an event when the HMD's pose has been updated.
  112192. */
  112193. onPoseUpdatedFromDeviceObservable: Observable<any>;
  112194. private _poseSet;
  112195. /**
  112196. * If the rig cameras be used as parent instead of this camera.
  112197. */
  112198. rigParenting: boolean;
  112199. private _lightOnControllers;
  112200. private _defaultHeight?;
  112201. /**
  112202. * Instantiates a WebVRFreeCamera.
  112203. * @param name The name of the WebVRFreeCamera
  112204. * @param position The starting anchor position for the camera
  112205. * @param scene The scene the camera belongs to
  112206. * @param webVROptions a set of customizable options for the webVRCamera
  112207. */
  112208. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  112209. /**
  112210. * Gets the device distance from the ground in meters.
  112211. * @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.
  112212. */
  112213. deviceDistanceToRoomGround(): number;
  112214. /**
  112215. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112216. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  112217. */
  112218. useStandingMatrix(callback?: (bool: boolean) => void): void;
  112219. /**
  112220. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112221. * @returns A promise with a boolean set to if the standing matrix is supported.
  112222. */
  112223. useStandingMatrixAsync(): Promise<boolean>;
  112224. /**
  112225. * Disposes the camera
  112226. */
  112227. dispose(): void;
  112228. /**
  112229. * Gets a vrController by name.
  112230. * @param name The name of the controller to retreive
  112231. * @returns the controller matching the name specified or null if not found
  112232. */
  112233. getControllerByName(name: string): Nullable<WebVRController>;
  112234. private _leftController;
  112235. /**
  112236. * The controller corresponding to the users left hand.
  112237. */
  112238. get leftController(): Nullable<WebVRController>;
  112239. private _rightController;
  112240. /**
  112241. * The controller corresponding to the users right hand.
  112242. */
  112243. get rightController(): Nullable<WebVRController>;
  112244. /**
  112245. * Casts a ray forward from the vrCamera's gaze.
  112246. * @param length Length of the ray (default: 100)
  112247. * @returns the ray corresponding to the gaze
  112248. */
  112249. getForwardRay(length?: number): Ray;
  112250. /**
  112251. * @hidden
  112252. * Updates the camera based on device's frame data
  112253. */
  112254. _checkInputs(): void;
  112255. /**
  112256. * Updates the poseControlled values based on the input device pose.
  112257. * @param poseData Pose coming from the device
  112258. */
  112259. updateFromDevice(poseData: DevicePose): void;
  112260. private _detachIfAttached;
  112261. /**
  112262. * WebVR's attach control will start broadcasting frames to the device.
  112263. * Note that in certain browsers (chrome for example) this function must be called
  112264. * within a user-interaction callback. Example:
  112265. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  112266. *
  112267. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  112268. */
  112269. attachControl(noPreventDefault?: boolean): void;
  112270. /**
  112271. * Detach the current controls from the specified dom element.
  112272. */
  112273. detachControl(): void;
  112274. /**
  112275. * @returns the name of this class
  112276. */
  112277. getClassName(): string;
  112278. /**
  112279. * Calls resetPose on the vrDisplay
  112280. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  112281. */
  112282. resetToCurrentRotation(): void;
  112283. /**
  112284. * @hidden
  112285. * Updates the rig cameras (left and right eye)
  112286. */
  112287. _updateRigCameras(): void;
  112288. private _workingVector;
  112289. private _oneVector;
  112290. private _workingMatrix;
  112291. private updateCacheCalled;
  112292. private _correctPositionIfNotTrackPosition;
  112293. /**
  112294. * @hidden
  112295. * Updates the cached values of the camera
  112296. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  112297. */
  112298. _updateCache(ignoreParentClass?: boolean): void;
  112299. /**
  112300. * @hidden
  112301. * Get current device position in babylon world
  112302. */
  112303. _computeDevicePosition(): void;
  112304. /**
  112305. * Updates the current device position and rotation in the babylon world
  112306. */
  112307. update(): void;
  112308. /**
  112309. * @hidden
  112310. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  112311. * @returns an identity matrix
  112312. */
  112313. _getViewMatrix(): Matrix;
  112314. private _tmpMatrix;
  112315. /**
  112316. * This function is called by the two RIG cameras.
  112317. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  112318. * @hidden
  112319. */
  112320. _getWebVRViewMatrix(): Matrix;
  112321. /** @hidden */
  112322. _getWebVRProjectionMatrix(): Matrix;
  112323. private _onGamepadConnectedObserver;
  112324. private _onGamepadDisconnectedObserver;
  112325. private _updateCacheWhenTrackingDisabledObserver;
  112326. /**
  112327. * Initializes the controllers and their meshes
  112328. */
  112329. initControllers(): void;
  112330. }
  112331. }
  112332. declare module BABYLON {
  112333. /**
  112334. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  112335. *
  112336. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  112337. *
  112338. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  112339. */
  112340. export class MaterialHelper {
  112341. /**
  112342. * Bind the current view position to an effect.
  112343. * @param effect The effect to be bound
  112344. * @param scene The scene the eyes position is used from
  112345. * @param variableName name of the shader variable that will hold the eye position
  112346. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  112347. * @return the computed eye position
  112348. */
  112349. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  112350. /**
  112351. * Helps preparing the defines values about the UVs in used in the effect.
  112352. * UVs are shared as much as we can accross channels in the shaders.
  112353. * @param texture The texture we are preparing the UVs for
  112354. * @param defines The defines to update
  112355. * @param key The channel key "diffuse", "specular"... used in the shader
  112356. */
  112357. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  112358. /**
  112359. * Binds a texture matrix value to its corrsponding uniform
  112360. * @param texture The texture to bind the matrix for
  112361. * @param uniformBuffer The uniform buffer receivin the data
  112362. * @param key The channel key "diffuse", "specular"... used in the shader
  112363. */
  112364. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  112365. /**
  112366. * Gets the current status of the fog (should it be enabled?)
  112367. * @param mesh defines the mesh to evaluate for fog support
  112368. * @param scene defines the hosting scene
  112369. * @returns true if fog must be enabled
  112370. */
  112371. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  112372. /**
  112373. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  112374. * @param mesh defines the current mesh
  112375. * @param scene defines the current scene
  112376. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  112377. * @param pointsCloud defines if point cloud rendering has to be turned on
  112378. * @param fogEnabled defines if fog has to be turned on
  112379. * @param alphaTest defines if alpha testing has to be turned on
  112380. * @param defines defines the current list of defines
  112381. */
  112382. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  112383. /**
  112384. * Helper used to prepare the list of defines associated with frame values for shader compilation
  112385. * @param scene defines the current scene
  112386. * @param engine defines the current engine
  112387. * @param defines specifies the list of active defines
  112388. * @param useInstances defines if instances have to be turned on
  112389. * @param useClipPlane defines if clip plane have to be turned on
  112390. * @param useInstances defines if instances have to be turned on
  112391. * @param useThinInstances defines if thin instances have to be turned on
  112392. */
  112393. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  112394. /**
  112395. * Prepares the defines for bones
  112396. * @param mesh The mesh containing the geometry data we will draw
  112397. * @param defines The defines to update
  112398. */
  112399. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  112400. /**
  112401. * Prepares the defines for morph targets
  112402. * @param mesh The mesh containing the geometry data we will draw
  112403. * @param defines The defines to update
  112404. */
  112405. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  112406. /**
  112407. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  112408. * @param mesh The mesh containing the geometry data we will draw
  112409. * @param defines The defines to update
  112410. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  112411. * @param useBones Precise whether bones should be used or not (override mesh info)
  112412. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  112413. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  112414. * @returns false if defines are considered not dirty and have not been checked
  112415. */
  112416. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  112417. /**
  112418. * Prepares the defines related to multiview
  112419. * @param scene The scene we are intending to draw
  112420. * @param defines The defines to update
  112421. */
  112422. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  112423. /**
  112424. * Prepares the defines related to the prepass
  112425. * @param scene The scene we are intending to draw
  112426. * @param defines The defines to update
  112427. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  112428. */
  112429. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  112430. /**
  112431. * Prepares the defines related to the light information passed in parameter
  112432. * @param scene The scene we are intending to draw
  112433. * @param mesh The mesh the effect is compiling for
  112434. * @param light The light the effect is compiling for
  112435. * @param lightIndex The index of the light
  112436. * @param defines The defines to update
  112437. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  112438. * @param state Defines the current state regarding what is needed (normals, etc...)
  112439. */
  112440. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  112441. needNormals: boolean;
  112442. needRebuild: boolean;
  112443. shadowEnabled: boolean;
  112444. specularEnabled: boolean;
  112445. lightmapMode: boolean;
  112446. }): void;
  112447. /**
  112448. * Prepares the defines related to the light information passed in parameter
  112449. * @param scene The scene we are intending to draw
  112450. * @param mesh The mesh the effect is compiling for
  112451. * @param defines The defines to update
  112452. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  112453. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  112454. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  112455. * @returns true if normals will be required for the rest of the effect
  112456. */
  112457. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  112458. /**
  112459. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  112460. * @param lightIndex defines the light index
  112461. * @param uniformsList The uniform list
  112462. * @param samplersList The sampler list
  112463. * @param projectedLightTexture defines if projected texture must be used
  112464. * @param uniformBuffersList defines an optional list of uniform buffers
  112465. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  112466. */
  112467. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  112468. /**
  112469. * Prepares the uniforms and samplers list to be used in the effect
  112470. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  112471. * @param samplersList The sampler list
  112472. * @param defines The defines helping in the list generation
  112473. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  112474. */
  112475. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  112476. /**
  112477. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  112478. * @param defines The defines to update while falling back
  112479. * @param fallbacks The authorized effect fallbacks
  112480. * @param maxSimultaneousLights The maximum number of lights allowed
  112481. * @param rank the current rank of the Effect
  112482. * @returns The newly affected rank
  112483. */
  112484. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  112485. private static _TmpMorphInfluencers;
  112486. /**
  112487. * Prepares the list of attributes required for morph targets according to the effect defines.
  112488. * @param attribs The current list of supported attribs
  112489. * @param mesh The mesh to prepare the morph targets attributes for
  112490. * @param influencers The number of influencers
  112491. */
  112492. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  112493. /**
  112494. * Prepares the list of attributes required for morph targets according to the effect defines.
  112495. * @param attribs The current list of supported attribs
  112496. * @param mesh The mesh to prepare the morph targets attributes for
  112497. * @param defines The current Defines of the effect
  112498. */
  112499. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  112500. /**
  112501. * Prepares the list of attributes required for bones according to the effect defines.
  112502. * @param attribs The current list of supported attribs
  112503. * @param mesh The mesh to prepare the bones attributes for
  112504. * @param defines The current Defines of the effect
  112505. * @param fallbacks The current efffect fallback strategy
  112506. */
  112507. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  112508. /**
  112509. * Check and prepare the list of attributes required for instances according to the effect defines.
  112510. * @param attribs The current list of supported attribs
  112511. * @param defines The current MaterialDefines of the effect
  112512. */
  112513. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  112514. /**
  112515. * Add the list of attributes required for instances to the attribs array.
  112516. * @param attribs The current list of supported attribs
  112517. */
  112518. static PushAttributesForInstances(attribs: string[]): void;
  112519. /**
  112520. * Binds the light information to the effect.
  112521. * @param light The light containing the generator
  112522. * @param effect The effect we are binding the data to
  112523. * @param lightIndex The light index in the effect used to render
  112524. */
  112525. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  112526. /**
  112527. * Binds the lights information from the scene to the effect for the given mesh.
  112528. * @param light Light to bind
  112529. * @param lightIndex Light index
  112530. * @param scene The scene where the light belongs to
  112531. * @param effect The effect we are binding the data to
  112532. * @param useSpecular Defines if specular is supported
  112533. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  112534. */
  112535. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  112536. /**
  112537. * Binds the lights information from the scene to the effect for the given mesh.
  112538. * @param scene The scene the lights belongs to
  112539. * @param mesh The mesh we are binding the information to render
  112540. * @param effect The effect we are binding the data to
  112541. * @param defines The generated defines for the effect
  112542. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  112543. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  112544. */
  112545. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  112546. private static _tempFogColor;
  112547. /**
  112548. * Binds the fog information from the scene to the effect for the given mesh.
  112549. * @param scene The scene the lights belongs to
  112550. * @param mesh The mesh we are binding the information to render
  112551. * @param effect The effect we are binding the data to
  112552. * @param linearSpace Defines if the fog effect is applied in linear space
  112553. */
  112554. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  112555. /**
  112556. * Binds the bones information from the mesh to the effect.
  112557. * @param mesh The mesh we are binding the information to render
  112558. * @param effect The effect we are binding the data to
  112559. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  112560. */
  112561. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  112562. private static _CopyBonesTransformationMatrices;
  112563. /**
  112564. * Binds the morph targets information from the mesh to the effect.
  112565. * @param abstractMesh The mesh we are binding the information to render
  112566. * @param effect The effect we are binding the data to
  112567. */
  112568. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  112569. /**
  112570. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  112571. * @param defines The generated defines used in the effect
  112572. * @param effect The effect we are binding the data to
  112573. * @param scene The scene we are willing to render with logarithmic scale for
  112574. */
  112575. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  112576. /**
  112577. * Binds the clip plane information from the scene to the effect.
  112578. * @param scene The scene the clip plane information are extracted from
  112579. * @param effect The effect we are binding the data to
  112580. */
  112581. static BindClipPlane(effect: Effect, scene: Scene): void;
  112582. }
  112583. }
  112584. declare module BABYLON {
  112585. /** @hidden */
  112586. export var bayerDitherFunctions: {
  112587. name: string;
  112588. shader: string;
  112589. };
  112590. }
  112591. declare module BABYLON {
  112592. /** @hidden */
  112593. export var shadowMapFragmentDeclaration: {
  112594. name: string;
  112595. shader: string;
  112596. };
  112597. }
  112598. declare module BABYLON {
  112599. /** @hidden */
  112600. export var shadowMapFragment: {
  112601. name: string;
  112602. shader: string;
  112603. };
  112604. }
  112605. declare module BABYLON {
  112606. /** @hidden */
  112607. export var shadowMapPixelShader: {
  112608. name: string;
  112609. shader: string;
  112610. };
  112611. }
  112612. declare module BABYLON {
  112613. /** @hidden */
  112614. export var shadowMapVertexDeclaration: {
  112615. name: string;
  112616. shader: string;
  112617. };
  112618. }
  112619. declare module BABYLON {
  112620. /** @hidden */
  112621. export var shadowMapVertexNormalBias: {
  112622. name: string;
  112623. shader: string;
  112624. };
  112625. }
  112626. declare module BABYLON {
  112627. /** @hidden */
  112628. export var shadowMapVertexMetric: {
  112629. name: string;
  112630. shader: string;
  112631. };
  112632. }
  112633. declare module BABYLON {
  112634. /** @hidden */
  112635. export var shadowMapVertexShader: {
  112636. name: string;
  112637. shader: string;
  112638. };
  112639. }
  112640. declare module BABYLON {
  112641. /** @hidden */
  112642. export var depthBoxBlurPixelShader: {
  112643. name: string;
  112644. shader: string;
  112645. };
  112646. }
  112647. declare module BABYLON {
  112648. /** @hidden */
  112649. export var shadowMapFragmentSoftTransparentShadow: {
  112650. name: string;
  112651. shader: string;
  112652. };
  112653. }
  112654. declare module BABYLON {
  112655. /**
  112656. * Creates an instance based on a source mesh.
  112657. */
  112658. export class InstancedMesh extends AbstractMesh {
  112659. private _sourceMesh;
  112660. private _currentLOD;
  112661. /** @hidden */
  112662. _indexInSourceMeshInstanceArray: number;
  112663. constructor(name: string, source: Mesh);
  112664. /**
  112665. * Returns the string "InstancedMesh".
  112666. */
  112667. getClassName(): string;
  112668. /** Gets the list of lights affecting that mesh */
  112669. get lightSources(): Light[];
  112670. _resyncLightSources(): void;
  112671. _resyncLightSource(light: Light): void;
  112672. _removeLightSource(light: Light, dispose: boolean): void;
  112673. /**
  112674. * If the source mesh receives shadows
  112675. */
  112676. get receiveShadows(): boolean;
  112677. /**
  112678. * The material of the source mesh
  112679. */
  112680. get material(): Nullable<Material>;
  112681. /**
  112682. * Visibility of the source mesh
  112683. */
  112684. get visibility(): number;
  112685. /**
  112686. * Skeleton of the source mesh
  112687. */
  112688. get skeleton(): Nullable<Skeleton>;
  112689. /**
  112690. * Rendering ground id of the source mesh
  112691. */
  112692. get renderingGroupId(): number;
  112693. set renderingGroupId(value: number);
  112694. /**
  112695. * Returns the total number of vertices (integer).
  112696. */
  112697. getTotalVertices(): number;
  112698. /**
  112699. * Returns a positive integer : the total number of indices in this mesh geometry.
  112700. * @returns the numner of indices or zero if the mesh has no geometry.
  112701. */
  112702. getTotalIndices(): number;
  112703. /**
  112704. * The source mesh of the instance
  112705. */
  112706. get sourceMesh(): Mesh;
  112707. /**
  112708. * Creates a new InstancedMesh object from the mesh model.
  112709. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  112710. * @param name defines the name of the new instance
  112711. * @returns a new InstancedMesh
  112712. */
  112713. createInstance(name: string): InstancedMesh;
  112714. /**
  112715. * Is this node ready to be used/rendered
  112716. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112717. * @return {boolean} is it ready
  112718. */
  112719. isReady(completeCheck?: boolean): boolean;
  112720. /**
  112721. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  112722. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  112723. * @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.
  112724. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  112725. */
  112726. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  112727. /**
  112728. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112729. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112730. * The `data` are either a numeric array either a Float32Array.
  112731. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  112732. * 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).
  112733. * Note that a new underlying VertexBuffer object is created each call.
  112734. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112735. *
  112736. * Possible `kind` values :
  112737. * - VertexBuffer.PositionKind
  112738. * - VertexBuffer.UVKind
  112739. * - VertexBuffer.UV2Kind
  112740. * - VertexBuffer.UV3Kind
  112741. * - VertexBuffer.UV4Kind
  112742. * - VertexBuffer.UV5Kind
  112743. * - VertexBuffer.UV6Kind
  112744. * - VertexBuffer.ColorKind
  112745. * - VertexBuffer.MatricesIndicesKind
  112746. * - VertexBuffer.MatricesIndicesExtraKind
  112747. * - VertexBuffer.MatricesWeightsKind
  112748. * - VertexBuffer.MatricesWeightsExtraKind
  112749. *
  112750. * Returns the Mesh.
  112751. */
  112752. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112753. /**
  112754. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112755. * If the mesh has no geometry, it is simply returned as it is.
  112756. * The `data` are either a numeric array either a Float32Array.
  112757. * No new underlying VertexBuffer object is created.
  112758. * 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.
  112759. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  112760. *
  112761. * Possible `kind` values :
  112762. * - VertexBuffer.PositionKind
  112763. * - VertexBuffer.UVKind
  112764. * - VertexBuffer.UV2Kind
  112765. * - VertexBuffer.UV3Kind
  112766. * - VertexBuffer.UV4Kind
  112767. * - VertexBuffer.UV5Kind
  112768. * - VertexBuffer.UV6Kind
  112769. * - VertexBuffer.ColorKind
  112770. * - VertexBuffer.MatricesIndicesKind
  112771. * - VertexBuffer.MatricesIndicesExtraKind
  112772. * - VertexBuffer.MatricesWeightsKind
  112773. * - VertexBuffer.MatricesWeightsExtraKind
  112774. *
  112775. * Returns the Mesh.
  112776. */
  112777. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  112778. /**
  112779. * Sets the mesh indices.
  112780. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  112781. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112782. * This method creates a new index buffer each call.
  112783. * Returns the Mesh.
  112784. */
  112785. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  112786. /**
  112787. * Boolean : True if the mesh owns the requested kind of data.
  112788. */
  112789. isVerticesDataPresent(kind: string): boolean;
  112790. /**
  112791. * Returns an array of indices (IndicesArray).
  112792. */
  112793. getIndices(): Nullable<IndicesArray>;
  112794. get _positions(): Nullable<Vector3[]>;
  112795. /**
  112796. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112797. * This means the mesh underlying bounding box and sphere are recomputed.
  112798. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112799. * @returns the current mesh
  112800. */
  112801. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  112802. /** @hidden */
  112803. _preActivate(): InstancedMesh;
  112804. /** @hidden */
  112805. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112806. /** @hidden */
  112807. _postActivate(): void;
  112808. getWorldMatrix(): Matrix;
  112809. get isAnInstance(): boolean;
  112810. /**
  112811. * Returns the current associated LOD AbstractMesh.
  112812. */
  112813. getLOD(camera: Camera): AbstractMesh;
  112814. /** @hidden */
  112815. _preActivateForIntermediateRendering(renderId: number): Mesh;
  112816. /** @hidden */
  112817. _syncSubMeshes(): InstancedMesh;
  112818. /** @hidden */
  112819. _generatePointsArray(): boolean;
  112820. /** @hidden */
  112821. _updateBoundingInfo(): AbstractMesh;
  112822. /**
  112823. * Creates a new InstancedMesh from the current mesh.
  112824. * - name (string) : the cloned mesh name
  112825. * - newParent (optional Node) : the optional Node to parent the clone to.
  112826. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  112827. *
  112828. * Returns the clone.
  112829. */
  112830. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  112831. /**
  112832. * Disposes the InstancedMesh.
  112833. * Returns nothing.
  112834. */
  112835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112836. }
  112837. interface Mesh {
  112838. /**
  112839. * Register a custom buffer that will be instanced
  112840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  112841. * @param kind defines the buffer kind
  112842. * @param stride defines the stride in floats
  112843. */
  112844. registerInstancedBuffer(kind: string, stride: number): void;
  112845. /**
  112846. * true to use the edge renderer for all instances of this mesh
  112847. */
  112848. edgesShareWithInstances: boolean;
  112849. /** @hidden */
  112850. _userInstancedBuffersStorage: {
  112851. data: {
  112852. [key: string]: Float32Array;
  112853. };
  112854. sizes: {
  112855. [key: string]: number;
  112856. };
  112857. vertexBuffers: {
  112858. [key: string]: Nullable<VertexBuffer>;
  112859. };
  112860. strides: {
  112861. [key: string]: number;
  112862. };
  112863. };
  112864. }
  112865. interface AbstractMesh {
  112866. /**
  112867. * Object used to store instanced buffers defined by user
  112868. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  112869. */
  112870. instancedBuffers: {
  112871. [key: string]: any;
  112872. };
  112873. }
  112874. }
  112875. declare module BABYLON {
  112876. /**
  112877. * Defines the options associated with the creation of a shader material.
  112878. */
  112879. export interface IShaderMaterialOptions {
  112880. /**
  112881. * Does the material work in alpha blend mode
  112882. */
  112883. needAlphaBlending: boolean;
  112884. /**
  112885. * Does the material work in alpha test mode
  112886. */
  112887. needAlphaTesting: boolean;
  112888. /**
  112889. * The list of attribute names used in the shader
  112890. */
  112891. attributes: string[];
  112892. /**
  112893. * The list of unifrom names used in the shader
  112894. */
  112895. uniforms: string[];
  112896. /**
  112897. * The list of UBO names used in the shader
  112898. */
  112899. uniformBuffers: string[];
  112900. /**
  112901. * The list of sampler names used in the shader
  112902. */
  112903. samplers: string[];
  112904. /**
  112905. * The list of defines used in the shader
  112906. */
  112907. defines: string[];
  112908. }
  112909. /**
  112910. * 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.
  112911. *
  112912. * This returned material effects how the mesh will look based on the code in the shaders.
  112913. *
  112914. * @see https://doc.babylonjs.com/how_to/shader_material
  112915. */
  112916. export class ShaderMaterial extends Material {
  112917. private _shaderPath;
  112918. private _options;
  112919. private _textures;
  112920. private _textureArrays;
  112921. private _floats;
  112922. private _ints;
  112923. private _floatsArrays;
  112924. private _colors3;
  112925. private _colors3Arrays;
  112926. private _colors4;
  112927. private _colors4Arrays;
  112928. private _vectors2;
  112929. private _vectors3;
  112930. private _vectors4;
  112931. private _matrices;
  112932. private _matrixArrays;
  112933. private _matrices3x3;
  112934. private _matrices2x2;
  112935. private _vectors2Arrays;
  112936. private _vectors3Arrays;
  112937. private _vectors4Arrays;
  112938. private _cachedWorldViewMatrix;
  112939. private _cachedWorldViewProjectionMatrix;
  112940. private _renderId;
  112941. private _multiview;
  112942. private _cachedDefines;
  112943. /** Define the Url to load snippets */
  112944. static SnippetUrl: string;
  112945. /** Snippet ID if the material was created from the snippet server */
  112946. snippetId: string;
  112947. /**
  112948. * Instantiate a new shader material.
  112949. * 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.
  112950. * This returned material effects how the mesh will look based on the code in the shaders.
  112951. * @see https://doc.babylonjs.com/how_to/shader_material
  112952. * @param name Define the name of the material in the scene
  112953. * @param scene Define the scene the material belongs to
  112954. * @param shaderPath Defines the route to the shader code in one of three ways:
  112955. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  112956. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  112957. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  112958. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  112959. * @param options Define the options used to create the shader
  112960. */
  112961. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  112962. /**
  112963. * Gets the shader path used to define the shader code
  112964. * It can be modified to trigger a new compilation
  112965. */
  112966. get shaderPath(): any;
  112967. /**
  112968. * Sets the shader path used to define the shader code
  112969. * It can be modified to trigger a new compilation
  112970. */
  112971. set shaderPath(shaderPath: any);
  112972. /**
  112973. * Gets the options used to compile the shader.
  112974. * They can be modified to trigger a new compilation
  112975. */
  112976. get options(): IShaderMaterialOptions;
  112977. /**
  112978. * Gets the current class name of the material e.g. "ShaderMaterial"
  112979. * Mainly use in serialization.
  112980. * @returns the class name
  112981. */
  112982. getClassName(): string;
  112983. /**
  112984. * Specifies if the material will require alpha blending
  112985. * @returns a boolean specifying if alpha blending is needed
  112986. */
  112987. needAlphaBlending(): boolean;
  112988. /**
  112989. * Specifies if this material should be rendered in alpha test mode
  112990. * @returns a boolean specifying if an alpha test is needed.
  112991. */
  112992. needAlphaTesting(): boolean;
  112993. private _checkUniform;
  112994. /**
  112995. * Set a texture in the shader.
  112996. * @param name Define the name of the uniform samplers as defined in the shader
  112997. * @param texture Define the texture to bind to this sampler
  112998. * @return the material itself allowing "fluent" like uniform updates
  112999. */
  113000. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  113001. /**
  113002. * Set a texture array in the shader.
  113003. * @param name Define the name of the uniform sampler array as defined in the shader
  113004. * @param textures Define the list of textures to bind to this sampler
  113005. * @return the material itself allowing "fluent" like uniform updates
  113006. */
  113007. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  113008. /**
  113009. * Set a float in the shader.
  113010. * @param name Define the name of the uniform as defined in the shader
  113011. * @param value Define the value to give to the uniform
  113012. * @return the material itself allowing "fluent" like uniform updates
  113013. */
  113014. setFloat(name: string, value: number): ShaderMaterial;
  113015. /**
  113016. * Set a int in the shader.
  113017. * @param name Define the name of the uniform as defined in the shader
  113018. * @param value Define the value to give to the uniform
  113019. * @return the material itself allowing "fluent" like uniform updates
  113020. */
  113021. setInt(name: string, value: number): ShaderMaterial;
  113022. /**
  113023. * Set an array of floats in the shader.
  113024. * @param name Define the name of the uniform as defined in the shader
  113025. * @param value Define the value to give to the uniform
  113026. * @return the material itself allowing "fluent" like uniform updates
  113027. */
  113028. setFloats(name: string, value: number[]): ShaderMaterial;
  113029. /**
  113030. * Set a vec3 in the shader from a Color3.
  113031. * @param name Define the name of the uniform as defined in the shader
  113032. * @param value Define the value to give to the uniform
  113033. * @return the material itself allowing "fluent" like uniform updates
  113034. */
  113035. setColor3(name: string, value: Color3): ShaderMaterial;
  113036. /**
  113037. * Set a vec3 array in the shader from a Color3 array.
  113038. * @param name Define the name of the uniform as defined in the shader
  113039. * @param value Define the value to give to the uniform
  113040. * @return the material itself allowing "fluent" like uniform updates
  113041. */
  113042. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  113043. /**
  113044. * Set a vec4 in the shader from a Color4.
  113045. * @param name Define the name of the uniform as defined in the shader
  113046. * @param value Define the value to give to the uniform
  113047. * @return the material itself allowing "fluent" like uniform updates
  113048. */
  113049. setColor4(name: string, value: Color4): ShaderMaterial;
  113050. /**
  113051. * Set a vec4 array in the shader from a Color4 array.
  113052. * @param name Define the name of the uniform as defined in the shader
  113053. * @param value Define the value to give to the uniform
  113054. * @return the material itself allowing "fluent" like uniform updates
  113055. */
  113056. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  113057. /**
  113058. * Set a vec2 in the shader from a Vector2.
  113059. * @param name Define the name of the uniform as defined in the shader
  113060. * @param value Define the value to give to the uniform
  113061. * @return the material itself allowing "fluent" like uniform updates
  113062. */
  113063. setVector2(name: string, value: Vector2): ShaderMaterial;
  113064. /**
  113065. * Set a vec3 in the shader from a Vector3.
  113066. * @param name Define the name of the uniform as defined in the shader
  113067. * @param value Define the value to give to the uniform
  113068. * @return the material itself allowing "fluent" like uniform updates
  113069. */
  113070. setVector3(name: string, value: Vector3): ShaderMaterial;
  113071. /**
  113072. * Set a vec4 in the shader from a Vector4.
  113073. * @param name Define the name of the uniform as defined in the shader
  113074. * @param value Define the value to give to the uniform
  113075. * @return the material itself allowing "fluent" like uniform updates
  113076. */
  113077. setVector4(name: string, value: Vector4): ShaderMaterial;
  113078. /**
  113079. * Set a mat4 in the shader from a Matrix.
  113080. * @param name Define the name of the uniform as defined in the shader
  113081. * @param value Define the value to give to the uniform
  113082. * @return the material itself allowing "fluent" like uniform updates
  113083. */
  113084. setMatrix(name: string, value: Matrix): ShaderMaterial;
  113085. /**
  113086. * Set a float32Array in the shader from a matrix array.
  113087. * @param name Define the name of the uniform as defined in the shader
  113088. * @param value Define the value to give to the uniform
  113089. * @return the material itself allowing "fluent" like uniform updates
  113090. */
  113091. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  113092. /**
  113093. * Set a mat3 in the shader from a Float32Array.
  113094. * @param name Define the name of the uniform as defined in the shader
  113095. * @param value Define the value to give to the uniform
  113096. * @return the material itself allowing "fluent" like uniform updates
  113097. */
  113098. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113099. /**
  113100. * Set a mat2 in the shader from a Float32Array.
  113101. * @param name Define the name of the uniform as defined in the shader
  113102. * @param value Define the value to give to the uniform
  113103. * @return the material itself allowing "fluent" like uniform updates
  113104. */
  113105. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113106. /**
  113107. * Set a vec2 array in the shader from a number array.
  113108. * @param name Define the name of the uniform as defined in the shader
  113109. * @param value Define the value to give to the uniform
  113110. * @return the material itself allowing "fluent" like uniform updates
  113111. */
  113112. setArray2(name: string, value: number[]): ShaderMaterial;
  113113. /**
  113114. * Set a vec3 array in the shader from a number array.
  113115. * @param name Define the name of the uniform as defined in the shader
  113116. * @param value Define the value to give to the uniform
  113117. * @return the material itself allowing "fluent" like uniform updates
  113118. */
  113119. setArray3(name: string, value: number[]): ShaderMaterial;
  113120. /**
  113121. * Set a vec4 array in the shader from a number array.
  113122. * @param name Define the name of the uniform as defined in the shader
  113123. * @param value Define the value to give to the uniform
  113124. * @return the material itself allowing "fluent" like uniform updates
  113125. */
  113126. setArray4(name: string, value: number[]): ShaderMaterial;
  113127. private _checkCache;
  113128. /**
  113129. * Specifies that the submesh is ready to be used
  113130. * @param mesh defines the mesh to check
  113131. * @param subMesh defines which submesh to check
  113132. * @param useInstances specifies that instances should be used
  113133. * @returns a boolean indicating that the submesh is ready or not
  113134. */
  113135. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113136. /**
  113137. * Checks if the material is ready to render the requested mesh
  113138. * @param mesh Define the mesh to render
  113139. * @param useInstances Define whether or not the material is used with instances
  113140. * @returns true if ready, otherwise false
  113141. */
  113142. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  113143. /**
  113144. * Binds the world matrix to the material
  113145. * @param world defines the world transformation matrix
  113146. * @param effectOverride - If provided, use this effect instead of internal effect
  113147. */
  113148. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  113149. /**
  113150. * Binds the submesh to this material by preparing the effect and shader to draw
  113151. * @param world defines the world transformation matrix
  113152. * @param mesh defines the mesh containing the submesh
  113153. * @param subMesh defines the submesh to bind the material to
  113154. */
  113155. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113156. /**
  113157. * Binds the material to the mesh
  113158. * @param world defines the world transformation matrix
  113159. * @param mesh defines the mesh to bind the material to
  113160. * @param effectOverride - If provided, use this effect instead of internal effect
  113161. */
  113162. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  113163. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  113164. /**
  113165. * Gets the active textures from the material
  113166. * @returns an array of textures
  113167. */
  113168. getActiveTextures(): BaseTexture[];
  113169. /**
  113170. * Specifies if the material uses a texture
  113171. * @param texture defines the texture to check against the material
  113172. * @returns a boolean specifying if the material uses the texture
  113173. */
  113174. hasTexture(texture: BaseTexture): boolean;
  113175. /**
  113176. * Makes a duplicate of the material, and gives it a new name
  113177. * @param name defines the new name for the duplicated material
  113178. * @returns the cloned material
  113179. */
  113180. clone(name: string): ShaderMaterial;
  113181. /**
  113182. * Disposes the material
  113183. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113184. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113185. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113186. */
  113187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113188. /**
  113189. * Serializes this material in a JSON representation
  113190. * @returns the serialized material object
  113191. */
  113192. serialize(): any;
  113193. /**
  113194. * Creates a shader material from parsed shader material data
  113195. * @param source defines the JSON represnetation of the material
  113196. * @param scene defines the hosting scene
  113197. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113198. * @returns a new material
  113199. */
  113200. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  113201. /**
  113202. * Creates a new ShaderMaterial from a snippet saved in a remote file
  113203. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  113204. * @param url defines the url to load from
  113205. * @param scene defines the hosting scene
  113206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113207. * @returns a promise that will resolve to the new ShaderMaterial
  113208. */
  113209. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113210. /**
  113211. * Creates a ShaderMaterial from a snippet saved by the Inspector
  113212. * @param snippetId defines the snippet to load
  113213. * @param scene defines the hosting scene
  113214. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113215. * @returns a promise that will resolve to the new ShaderMaterial
  113216. */
  113217. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113218. }
  113219. }
  113220. declare module BABYLON {
  113221. /** @hidden */
  113222. export var colorPixelShader: {
  113223. name: string;
  113224. shader: string;
  113225. };
  113226. }
  113227. declare module BABYLON {
  113228. /** @hidden */
  113229. export var colorVertexShader: {
  113230. name: string;
  113231. shader: string;
  113232. };
  113233. }
  113234. declare module BABYLON {
  113235. /**
  113236. * Line mesh
  113237. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  113238. */
  113239. export class LinesMesh extends Mesh {
  113240. /**
  113241. * If vertex color should be applied to the mesh
  113242. */
  113243. readonly useVertexColor?: boolean | undefined;
  113244. /**
  113245. * If vertex alpha should be applied to the mesh
  113246. */
  113247. readonly useVertexAlpha?: boolean | undefined;
  113248. /**
  113249. * Color of the line (Default: White)
  113250. */
  113251. color: Color3;
  113252. /**
  113253. * Alpha of the line (Default: 1)
  113254. */
  113255. alpha: number;
  113256. /**
  113257. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113258. * This margin is expressed in world space coordinates, so its value may vary.
  113259. * Default value is 0.1
  113260. */
  113261. intersectionThreshold: number;
  113262. private _colorShader;
  113263. private color4;
  113264. /**
  113265. * Creates a new LinesMesh
  113266. * @param name defines the name
  113267. * @param scene defines the hosting scene
  113268. * @param parent defines the parent mesh if any
  113269. * @param source defines the optional source LinesMesh used to clone data from
  113270. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113271. * When false, achieved by calling a clone(), also passing False.
  113272. * This will make creation of children, recursive.
  113273. * @param useVertexColor defines if this LinesMesh supports vertex color
  113274. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  113275. */
  113276. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  113277. /**
  113278. * If vertex color should be applied to the mesh
  113279. */
  113280. useVertexColor?: boolean | undefined,
  113281. /**
  113282. * If vertex alpha should be applied to the mesh
  113283. */
  113284. useVertexAlpha?: boolean | undefined);
  113285. private _addClipPlaneDefine;
  113286. private _removeClipPlaneDefine;
  113287. isReady(): boolean;
  113288. /**
  113289. * Returns the string "LineMesh"
  113290. */
  113291. getClassName(): string;
  113292. /**
  113293. * @hidden
  113294. */
  113295. get material(): Material;
  113296. /**
  113297. * @hidden
  113298. */
  113299. set material(value: Material);
  113300. /**
  113301. * @hidden
  113302. */
  113303. get checkCollisions(): boolean;
  113304. set checkCollisions(value: boolean);
  113305. /** @hidden */
  113306. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113307. /** @hidden */
  113308. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113309. /**
  113310. * Disposes of the line mesh
  113311. * @param doNotRecurse If children should be disposed
  113312. */
  113313. dispose(doNotRecurse?: boolean): void;
  113314. /**
  113315. * Returns a new LineMesh object cloned from the current one.
  113316. */
  113317. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  113318. /**
  113319. * Creates a new InstancedLinesMesh object from the mesh model.
  113320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113321. * @param name defines the name of the new instance
  113322. * @returns a new InstancedLinesMesh
  113323. */
  113324. createInstance(name: string): InstancedLinesMesh;
  113325. }
  113326. /**
  113327. * Creates an instance based on a source LinesMesh
  113328. */
  113329. export class InstancedLinesMesh extends InstancedMesh {
  113330. /**
  113331. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113332. * This margin is expressed in world space coordinates, so its value may vary.
  113333. * Initilized with the intersectionThreshold value of the source LinesMesh
  113334. */
  113335. intersectionThreshold: number;
  113336. constructor(name: string, source: LinesMesh);
  113337. /**
  113338. * Returns the string "InstancedLinesMesh".
  113339. */
  113340. getClassName(): string;
  113341. }
  113342. }
  113343. declare module BABYLON {
  113344. /** @hidden */
  113345. export var linePixelShader: {
  113346. name: string;
  113347. shader: string;
  113348. };
  113349. }
  113350. declare module BABYLON {
  113351. /** @hidden */
  113352. export var lineVertexShader: {
  113353. name: string;
  113354. shader: string;
  113355. };
  113356. }
  113357. declare module BABYLON {
  113358. interface Scene {
  113359. /** @hidden */
  113360. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  113361. }
  113362. interface AbstractMesh {
  113363. /**
  113364. * Gets the edgesRenderer associated with the mesh
  113365. */
  113366. edgesRenderer: Nullable<EdgesRenderer>;
  113367. }
  113368. interface LinesMesh {
  113369. /**
  113370. * Enables the edge rendering mode on the mesh.
  113371. * This mode makes the mesh edges visible
  113372. * @param epsilon defines the maximal distance between two angles to detect a face
  113373. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113374. * @returns the currentAbstractMesh
  113375. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113376. */
  113377. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113378. }
  113379. interface InstancedLinesMesh {
  113380. /**
  113381. * Enables the edge rendering mode on the mesh.
  113382. * This mode makes the mesh edges visible
  113383. * @param epsilon defines the maximal distance between two angles to detect a face
  113384. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113385. * @returns the current InstancedLinesMesh
  113386. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113387. */
  113388. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  113389. }
  113390. /**
  113391. * Defines the minimum contract an Edges renderer should follow.
  113392. */
  113393. export interface IEdgesRenderer extends IDisposable {
  113394. /**
  113395. * Gets or sets a boolean indicating if the edgesRenderer is active
  113396. */
  113397. isEnabled: boolean;
  113398. /**
  113399. * Renders the edges of the attached mesh,
  113400. */
  113401. render(): void;
  113402. /**
  113403. * Checks wether or not the edges renderer is ready to render.
  113404. * @return true if ready, otherwise false.
  113405. */
  113406. isReady(): boolean;
  113407. /**
  113408. * List of instances to render in case the source mesh has instances
  113409. */
  113410. customInstances: SmartArray<Matrix>;
  113411. }
  113412. /**
  113413. * Defines the additional options of the edges renderer
  113414. */
  113415. export interface IEdgesRendererOptions {
  113416. /**
  113417. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  113418. * If not defined, the default value is true
  113419. */
  113420. useAlternateEdgeFinder?: boolean;
  113421. /**
  113422. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  113423. * If not defined, the default value is true.
  113424. * 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)
  113425. * This option is used only if useAlternateEdgeFinder = true
  113426. */
  113427. useFastVertexMerger?: boolean;
  113428. /**
  113429. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  113430. * The default value is 1e-6
  113431. * This option is used only if useAlternateEdgeFinder = true
  113432. */
  113433. epsilonVertexMerge?: number;
  113434. /**
  113435. * 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
  113436. * 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.
  113437. * This option is used only if useAlternateEdgeFinder = true
  113438. */
  113439. applyTessellation?: boolean;
  113440. /**
  113441. * 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
  113442. * The default value is 1e-6
  113443. * This option is used only if useAlternateEdgeFinder = true
  113444. */
  113445. epsilonVertexAligned?: number;
  113446. }
  113447. /**
  113448. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  113449. */
  113450. export class EdgesRenderer implements IEdgesRenderer {
  113451. /**
  113452. * Define the size of the edges with an orthographic camera
  113453. */
  113454. edgesWidthScalerForOrthographic: number;
  113455. /**
  113456. * Define the size of the edges with a perspective camera
  113457. */
  113458. edgesWidthScalerForPerspective: number;
  113459. protected _source: AbstractMesh;
  113460. protected _linesPositions: number[];
  113461. protected _linesNormals: number[];
  113462. protected _linesIndices: number[];
  113463. protected _epsilon: number;
  113464. protected _indicesCount: number;
  113465. protected _lineShader: ShaderMaterial;
  113466. protected _ib: DataBuffer;
  113467. protected _buffers: {
  113468. [key: string]: Nullable<VertexBuffer>;
  113469. };
  113470. protected _buffersForInstances: {
  113471. [key: string]: Nullable<VertexBuffer>;
  113472. };
  113473. protected _checkVerticesInsteadOfIndices: boolean;
  113474. protected _options: Nullable<IEdgesRendererOptions>;
  113475. private _meshRebuildObserver;
  113476. private _meshDisposeObserver;
  113477. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  113478. isEnabled: boolean;
  113479. /** Gets the vertices generated by the edge renderer */
  113480. get linesPositions(): Immutable<Array<number>>;
  113481. /** Gets the normals generated by the edge renderer */
  113482. get linesNormals(): Immutable<Array<number>>;
  113483. /** Gets the indices generated by the edge renderer */
  113484. get linesIndices(): Immutable<Array<number>>;
  113485. /**
  113486. * List of instances to render in case the source mesh has instances
  113487. */
  113488. customInstances: SmartArray<Matrix>;
  113489. private static GetShader;
  113490. /**
  113491. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  113492. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  113493. * @param source Mesh used to create edges
  113494. * @param epsilon sum of angles in adjacency to check for edge
  113495. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  113496. * @param generateEdgesLines - should generate Lines or only prepare resources.
  113497. * @param options The options to apply when generating the edges
  113498. */
  113499. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  113500. protected _prepareRessources(): void;
  113501. /** @hidden */
  113502. _rebuild(): void;
  113503. /**
  113504. * Releases the required resources for the edges renderer
  113505. */
  113506. dispose(): void;
  113507. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  113508. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  113509. /**
  113510. * Checks if the pair of p0 and p1 is en edge
  113511. * @param faceIndex
  113512. * @param edge
  113513. * @param faceNormals
  113514. * @param p0
  113515. * @param p1
  113516. * @private
  113517. */
  113518. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  113519. /**
  113520. * push line into the position, normal and index buffer
  113521. * @protected
  113522. */
  113523. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  113524. /**
  113525. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  113526. */
  113527. private _tessellateTriangle;
  113528. private _generateEdgesLinesAlternate;
  113529. /**
  113530. * Generates lines edges from adjacencjes
  113531. * @private
  113532. */
  113533. _generateEdgesLines(): void;
  113534. /**
  113535. * Checks wether or not the edges renderer is ready to render.
  113536. * @return true if ready, otherwise false.
  113537. */
  113538. isReady(): boolean;
  113539. /**
  113540. * Renders the edges of the attached mesh,
  113541. */
  113542. render(): void;
  113543. }
  113544. /**
  113545. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  113546. */
  113547. export class LineEdgesRenderer extends EdgesRenderer {
  113548. /**
  113549. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  113550. * @param source LineMesh used to generate edges
  113551. * @param epsilon not important (specified angle for edge detection)
  113552. * @param checkVerticesInsteadOfIndices not important for LineMesh
  113553. */
  113554. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  113555. /**
  113556. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  113557. */
  113558. _generateEdgesLines(): void;
  113559. }
  113560. }
  113561. declare module BABYLON {
  113562. /**
  113563. * This represents the object necessary to create a rendering group.
  113564. * This is exclusively used and created by the rendering manager.
  113565. * To modify the behavior, you use the available helpers in your scene or meshes.
  113566. * @hidden
  113567. */
  113568. export class RenderingGroup {
  113569. index: number;
  113570. private static _zeroVector;
  113571. private _scene;
  113572. private _opaqueSubMeshes;
  113573. private _transparentSubMeshes;
  113574. private _alphaTestSubMeshes;
  113575. private _depthOnlySubMeshes;
  113576. private _particleSystems;
  113577. private _spriteManagers;
  113578. private _opaqueSortCompareFn;
  113579. private _alphaTestSortCompareFn;
  113580. private _transparentSortCompareFn;
  113581. private _renderOpaque;
  113582. private _renderAlphaTest;
  113583. private _renderTransparent;
  113584. /** @hidden */
  113585. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  113586. onBeforeTransparentRendering: () => void;
  113587. /**
  113588. * Set the opaque sort comparison function.
  113589. * If null the sub meshes will be render in the order they were created
  113590. */
  113591. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  113592. /**
  113593. * Set the alpha test sort comparison function.
  113594. * If null the sub meshes will be render in the order they were created
  113595. */
  113596. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  113597. /**
  113598. * Set the transparent sort comparison function.
  113599. * If null the sub meshes will be render in the order they were created
  113600. */
  113601. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  113602. /**
  113603. * Creates a new rendering group.
  113604. * @param index The rendering group index
  113605. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  113606. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  113607. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  113608. */
  113609. 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>);
  113610. /**
  113611. * Render all the sub meshes contained in the group.
  113612. * @param customRenderFunction Used to override the default render behaviour of the group.
  113613. * @returns true if rendered some submeshes.
  113614. */
  113615. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  113616. /**
  113617. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  113618. * @param subMeshes The submeshes to render
  113619. */
  113620. private renderOpaqueSorted;
  113621. /**
  113622. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  113623. * @param subMeshes The submeshes to render
  113624. */
  113625. private renderAlphaTestSorted;
  113626. /**
  113627. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  113628. * @param subMeshes The submeshes to render
  113629. */
  113630. private renderTransparentSorted;
  113631. /**
  113632. * Renders the submeshes in a specified order.
  113633. * @param subMeshes The submeshes to sort before render
  113634. * @param sortCompareFn The comparison function use to sort
  113635. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  113636. * @param transparent Specifies to activate blending if true
  113637. */
  113638. private static renderSorted;
  113639. /**
  113640. * Renders the submeshes in the order they were dispatched (no sort applied).
  113641. * @param subMeshes The submeshes to render
  113642. */
  113643. private static renderUnsorted;
  113644. /**
  113645. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  113646. * are rendered back to front if in the same alpha index.
  113647. *
  113648. * @param a The first submesh
  113649. * @param b The second submesh
  113650. * @returns The result of the comparison
  113651. */
  113652. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  113653. /**
  113654. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  113655. * are rendered back to front.
  113656. *
  113657. * @param a The first submesh
  113658. * @param b The second submesh
  113659. * @returns The result of the comparison
  113660. */
  113661. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  113662. /**
  113663. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  113664. * are rendered front to back (prevent overdraw).
  113665. *
  113666. * @param a The first submesh
  113667. * @param b The second submesh
  113668. * @returns The result of the comparison
  113669. */
  113670. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  113671. /**
  113672. * Resets the different lists of submeshes to prepare a new frame.
  113673. */
  113674. prepare(): void;
  113675. dispose(): void;
  113676. /**
  113677. * Inserts the submesh in its correct queue depending on its material.
  113678. * @param subMesh The submesh to dispatch
  113679. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  113680. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  113681. */
  113682. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  113683. dispatchSprites(spriteManager: ISpriteManager): void;
  113684. dispatchParticles(particleSystem: IParticleSystem): void;
  113685. private _renderParticles;
  113686. private _renderSprites;
  113687. }
  113688. }
  113689. declare module BABYLON {
  113690. /**
  113691. * Interface describing the different options available in the rendering manager
  113692. * regarding Auto Clear between groups.
  113693. */
  113694. export interface IRenderingManagerAutoClearSetup {
  113695. /**
  113696. * Defines whether or not autoclear is enable.
  113697. */
  113698. autoClear: boolean;
  113699. /**
  113700. * Defines whether or not to autoclear the depth buffer.
  113701. */
  113702. depth: boolean;
  113703. /**
  113704. * Defines whether or not to autoclear the stencil buffer.
  113705. */
  113706. stencil: boolean;
  113707. }
  113708. /**
  113709. * This class is used by the onRenderingGroupObservable
  113710. */
  113711. export class RenderingGroupInfo {
  113712. /**
  113713. * The Scene that being rendered
  113714. */
  113715. scene: Scene;
  113716. /**
  113717. * The camera currently used for the rendering pass
  113718. */
  113719. camera: Nullable<Camera>;
  113720. /**
  113721. * The ID of the renderingGroup being processed
  113722. */
  113723. renderingGroupId: number;
  113724. }
  113725. /**
  113726. * This is the manager responsible of all the rendering for meshes sprites and particles.
  113727. * It is enable to manage the different groups as well as the different necessary sort functions.
  113728. * This should not be used directly aside of the few static configurations
  113729. */
  113730. export class RenderingManager {
  113731. /**
  113732. * The max id used for rendering groups (not included)
  113733. */
  113734. static MAX_RENDERINGGROUPS: number;
  113735. /**
  113736. * The min id used for rendering groups (included)
  113737. */
  113738. static MIN_RENDERINGGROUPS: number;
  113739. /**
  113740. * Used to globally prevent autoclearing scenes.
  113741. */
  113742. static AUTOCLEAR: boolean;
  113743. /**
  113744. * @hidden
  113745. */
  113746. _useSceneAutoClearSetup: boolean;
  113747. private _scene;
  113748. private _renderingGroups;
  113749. private _depthStencilBufferAlreadyCleaned;
  113750. private _autoClearDepthStencil;
  113751. private _customOpaqueSortCompareFn;
  113752. private _customAlphaTestSortCompareFn;
  113753. private _customTransparentSortCompareFn;
  113754. private _renderingGroupInfo;
  113755. /**
  113756. * Instantiates a new rendering group for a particular scene
  113757. * @param scene Defines the scene the groups belongs to
  113758. */
  113759. constructor(scene: Scene);
  113760. private _clearDepthStencilBuffer;
  113761. /**
  113762. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  113763. * @hidden
  113764. */
  113765. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  113766. /**
  113767. * Resets the different information of the group to prepare a new frame
  113768. * @hidden
  113769. */
  113770. reset(): void;
  113771. /**
  113772. * Dispose and release the group and its associated resources.
  113773. * @hidden
  113774. */
  113775. dispose(): void;
  113776. /**
  113777. * Clear the info related to rendering groups preventing retention points during dispose.
  113778. */
  113779. freeRenderingGroups(): void;
  113780. private _prepareRenderingGroup;
  113781. /**
  113782. * Add a sprite manager to the rendering manager in order to render it this frame.
  113783. * @param spriteManager Define the sprite manager to render
  113784. */
  113785. dispatchSprites(spriteManager: ISpriteManager): void;
  113786. /**
  113787. * Add a particle system to the rendering manager in order to render it this frame.
  113788. * @param particleSystem Define the particle system to render
  113789. */
  113790. dispatchParticles(particleSystem: IParticleSystem): void;
  113791. /**
  113792. * Add a submesh to the manager in order to render it this frame
  113793. * @param subMesh The submesh to dispatch
  113794. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  113795. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  113796. */
  113797. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  113798. /**
  113799. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113800. * This allowed control for front to back rendering or reversly depending of the special needs.
  113801. *
  113802. * @param renderingGroupId The rendering group id corresponding to its index
  113803. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113804. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113805. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113806. */
  113807. 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;
  113808. /**
  113809. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113810. *
  113811. * @param renderingGroupId The rendering group id corresponding to its index
  113812. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113813. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113814. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113815. */
  113816. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113817. /**
  113818. * Gets the current auto clear configuration for one rendering group of the rendering
  113819. * manager.
  113820. * @param index the rendering group index to get the information for
  113821. * @returns The auto clear setup for the requested rendering group
  113822. */
  113823. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113824. }
  113825. }
  113826. declare module BABYLON {
  113827. /**
  113828. * Defines the options associated with the creation of a custom shader for a shadow generator.
  113829. */
  113830. export interface ICustomShaderOptions {
  113831. /**
  113832. * Gets or sets the custom shader name to use
  113833. */
  113834. shaderName: string;
  113835. /**
  113836. * The list of attribute names used in the shader
  113837. */
  113838. attributes?: string[];
  113839. /**
  113840. * The list of unifrom names used in the shader
  113841. */
  113842. uniforms?: string[];
  113843. /**
  113844. * The list of sampler names used in the shader
  113845. */
  113846. samplers?: string[];
  113847. /**
  113848. * The list of defines used in the shader
  113849. */
  113850. defines?: string[];
  113851. }
  113852. /**
  113853. * Interface to implement to create a shadow generator compatible with BJS.
  113854. */
  113855. export interface IShadowGenerator {
  113856. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  113857. id: string;
  113858. /**
  113859. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  113860. * @returns The render target texture if present otherwise, null
  113861. */
  113862. getShadowMap(): Nullable<RenderTargetTexture>;
  113863. /**
  113864. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  113865. * @param subMesh The submesh we want to render in the shadow map
  113866. * @param useInstances Defines wether will draw in the map using instances
  113867. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  113868. * @returns true if ready otherwise, false
  113869. */
  113870. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  113871. /**
  113872. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  113873. * @param defines Defines of the material we want to update
  113874. * @param lightIndex Index of the light in the enabled light list of the material
  113875. */
  113876. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  113877. /**
  113878. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  113879. * defined in the generator but impacting the effect).
  113880. * It implies the unifroms available on the materials are the standard BJS ones.
  113881. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  113882. * @param effect The effect we are binfing the information for
  113883. */
  113884. bindShadowLight(lightIndex: string, effect: Effect): void;
  113885. /**
  113886. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  113887. * (eq to shadow prjection matrix * light transform matrix)
  113888. * @returns The transform matrix used to create the shadow map
  113889. */
  113890. getTransformMatrix(): Matrix;
  113891. /**
  113892. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  113893. * Cube and 2D textures for instance.
  113894. */
  113895. recreateShadowMap(): void;
  113896. /**
  113897. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  113898. * @param onCompiled Callback triggered at the and of the effects compilation
  113899. * @param options Sets of optional options forcing the compilation with different modes
  113900. */
  113901. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  113902. useInstances: boolean;
  113903. }>): void;
  113904. /**
  113905. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  113906. * @param options Sets of optional options forcing the compilation with different modes
  113907. * @returns A promise that resolves when the compilation completes
  113908. */
  113909. forceCompilationAsync(options?: Partial<{
  113910. useInstances: boolean;
  113911. }>): Promise<void>;
  113912. /**
  113913. * Serializes the shadow generator setup to a json object.
  113914. * @returns The serialized JSON object
  113915. */
  113916. serialize(): any;
  113917. /**
  113918. * Disposes the Shadow map and related Textures and effects.
  113919. */
  113920. dispose(): void;
  113921. }
  113922. /**
  113923. * Default implementation IShadowGenerator.
  113924. * This is the main object responsible of generating shadows in the framework.
  113925. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  113926. */
  113927. export class ShadowGenerator implements IShadowGenerator {
  113928. private static _Counter;
  113929. /**
  113930. * Name of the shadow generator class
  113931. */
  113932. static CLASSNAME: string;
  113933. /**
  113934. * Shadow generator mode None: no filtering applied.
  113935. */
  113936. static readonly FILTER_NONE: number;
  113937. /**
  113938. * Shadow generator mode ESM: Exponential Shadow Mapping.
  113939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113940. */
  113941. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  113942. /**
  113943. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  113944. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  113945. */
  113946. static readonly FILTER_POISSONSAMPLING: number;
  113947. /**
  113948. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  113949. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113950. */
  113951. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  113952. /**
  113953. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  113954. * edge artifacts on steep falloff.
  113955. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113956. */
  113957. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  113958. /**
  113959. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  113960. * edge artifacts on steep falloff.
  113961. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113962. */
  113963. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  113964. /**
  113965. * Shadow generator mode PCF: Percentage Closer Filtering
  113966. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  113967. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  113968. */
  113969. static readonly FILTER_PCF: number;
  113970. /**
  113971. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  113972. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  113973. * Contact Hardening
  113974. */
  113975. static readonly FILTER_PCSS: number;
  113976. /**
  113977. * Reserved for PCF and PCSS
  113978. * Highest Quality.
  113979. *
  113980. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  113981. *
  113982. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  113983. */
  113984. static readonly QUALITY_HIGH: number;
  113985. /**
  113986. * Reserved for PCF and PCSS
  113987. * Good tradeoff for quality/perf cross devices
  113988. *
  113989. * Execute PCF on a 3*3 kernel.
  113990. *
  113991. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  113992. */
  113993. static readonly QUALITY_MEDIUM: number;
  113994. /**
  113995. * Reserved for PCF and PCSS
  113996. * The lowest quality but the fastest.
  113997. *
  113998. * Execute PCF on a 1*1 kernel.
  113999. *
  114000. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  114001. */
  114002. static readonly QUALITY_LOW: number;
  114003. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  114004. id: string;
  114005. /** Gets or sets the custom shader name to use */
  114006. customShaderOptions: ICustomShaderOptions;
  114007. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  114008. customAllowRendering: (subMesh: SubMesh) => boolean;
  114009. /**
  114010. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  114011. */
  114012. onBeforeShadowMapRenderObservable: Observable<Effect>;
  114013. /**
  114014. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  114015. */
  114016. onAfterShadowMapRenderObservable: Observable<Effect>;
  114017. /**
  114018. * Observable triggered before a mesh is rendered in the shadow map.
  114019. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  114020. */
  114021. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  114022. /**
  114023. * Observable triggered after a mesh is rendered in the shadow map.
  114024. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  114025. */
  114026. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  114027. protected _bias: number;
  114028. /**
  114029. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  114030. */
  114031. get bias(): number;
  114032. /**
  114033. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  114034. */
  114035. set bias(bias: number);
  114036. protected _normalBias: number;
  114037. /**
  114038. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114039. */
  114040. get normalBias(): number;
  114041. /**
  114042. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114043. */
  114044. set normalBias(normalBias: number);
  114045. protected _blurBoxOffset: number;
  114046. /**
  114047. * Gets the blur box offset: offset applied during the blur pass.
  114048. * Only useful if useKernelBlur = false
  114049. */
  114050. get blurBoxOffset(): number;
  114051. /**
  114052. * Sets the blur box offset: offset applied during the blur pass.
  114053. * Only useful if useKernelBlur = false
  114054. */
  114055. set blurBoxOffset(value: number);
  114056. protected _blurScale: number;
  114057. /**
  114058. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  114059. * 2 means half of the size.
  114060. */
  114061. get blurScale(): number;
  114062. /**
  114063. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  114064. * 2 means half of the size.
  114065. */
  114066. set blurScale(value: number);
  114067. protected _blurKernel: number;
  114068. /**
  114069. * Gets the blur kernel: kernel size of the blur pass.
  114070. * Only useful if useKernelBlur = true
  114071. */
  114072. get blurKernel(): number;
  114073. /**
  114074. * Sets the blur kernel: kernel size of the blur pass.
  114075. * Only useful if useKernelBlur = true
  114076. */
  114077. set blurKernel(value: number);
  114078. protected _useKernelBlur: boolean;
  114079. /**
  114080. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  114081. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114082. */
  114083. get useKernelBlur(): boolean;
  114084. /**
  114085. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  114086. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114087. */
  114088. set useKernelBlur(value: boolean);
  114089. protected _depthScale: number;
  114090. /**
  114091. * Gets the depth scale used in ESM mode.
  114092. */
  114093. get depthScale(): number;
  114094. /**
  114095. * Sets the depth scale used in ESM mode.
  114096. * This can override the scale stored on the light.
  114097. */
  114098. set depthScale(value: number);
  114099. protected _validateFilter(filter: number): number;
  114100. protected _filter: number;
  114101. /**
  114102. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  114103. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114104. */
  114105. get filter(): number;
  114106. /**
  114107. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  114108. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114109. */
  114110. set filter(value: number);
  114111. /**
  114112. * Gets if the current filter is set to Poisson Sampling.
  114113. */
  114114. get usePoissonSampling(): boolean;
  114115. /**
  114116. * Sets the current filter to Poisson Sampling.
  114117. */
  114118. set usePoissonSampling(value: boolean);
  114119. /**
  114120. * Gets if the current filter is set to ESM.
  114121. */
  114122. get useExponentialShadowMap(): boolean;
  114123. /**
  114124. * Sets the current filter is to ESM.
  114125. */
  114126. set useExponentialShadowMap(value: boolean);
  114127. /**
  114128. * Gets if the current filter is set to filtered ESM.
  114129. */
  114130. get useBlurExponentialShadowMap(): boolean;
  114131. /**
  114132. * Gets if the current filter is set to filtered ESM.
  114133. */
  114134. set useBlurExponentialShadowMap(value: boolean);
  114135. /**
  114136. * Gets if the current filter is set to "close ESM" (using the inverse of the
  114137. * exponential to prevent steep falloff artifacts).
  114138. */
  114139. get useCloseExponentialShadowMap(): boolean;
  114140. /**
  114141. * Sets the current filter to "close ESM" (using the inverse of the
  114142. * exponential to prevent steep falloff artifacts).
  114143. */
  114144. set useCloseExponentialShadowMap(value: boolean);
  114145. /**
  114146. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  114147. * exponential to prevent steep falloff artifacts).
  114148. */
  114149. get useBlurCloseExponentialShadowMap(): boolean;
  114150. /**
  114151. * Sets the current filter to filtered "close ESM" (using the inverse of the
  114152. * exponential to prevent steep falloff artifacts).
  114153. */
  114154. set useBlurCloseExponentialShadowMap(value: boolean);
  114155. /**
  114156. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  114157. */
  114158. get usePercentageCloserFiltering(): boolean;
  114159. /**
  114160. * Sets the current filter to "PCF" (percentage closer filtering).
  114161. */
  114162. set usePercentageCloserFiltering(value: boolean);
  114163. protected _filteringQuality: number;
  114164. /**
  114165. * Gets the PCF or PCSS Quality.
  114166. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114167. */
  114168. get filteringQuality(): number;
  114169. /**
  114170. * Sets the PCF or PCSS Quality.
  114171. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114172. */
  114173. set filteringQuality(filteringQuality: number);
  114174. /**
  114175. * Gets if the current filter is set to "PCSS" (contact hardening).
  114176. */
  114177. get useContactHardeningShadow(): boolean;
  114178. /**
  114179. * Sets the current filter to "PCSS" (contact hardening).
  114180. */
  114181. set useContactHardeningShadow(value: boolean);
  114182. protected _contactHardeningLightSizeUVRatio: number;
  114183. /**
  114184. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114185. * Using a ratio helps keeping shape stability independently of the map size.
  114186. *
  114187. * It does not account for the light projection as it was having too much
  114188. * instability during the light setup or during light position changes.
  114189. *
  114190. * Only valid if useContactHardeningShadow is true.
  114191. */
  114192. get contactHardeningLightSizeUVRatio(): number;
  114193. /**
  114194. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114195. * Using a ratio helps keeping shape stability independently of the map size.
  114196. *
  114197. * It does not account for the light projection as it was having too much
  114198. * instability during the light setup or during light position changes.
  114199. *
  114200. * Only valid if useContactHardeningShadow is true.
  114201. */
  114202. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  114203. protected _darkness: number;
  114204. /** Gets or sets the actual darkness of a shadow */
  114205. get darkness(): number;
  114206. set darkness(value: number);
  114207. /**
  114208. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  114209. * 0 means strongest and 1 would means no shadow.
  114210. * @returns the darkness.
  114211. */
  114212. getDarkness(): number;
  114213. /**
  114214. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  114215. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  114216. * @returns the shadow generator allowing fluent coding.
  114217. */
  114218. setDarkness(darkness: number): ShadowGenerator;
  114219. protected _transparencyShadow: boolean;
  114220. /** Gets or sets the ability to have transparent shadow */
  114221. get transparencyShadow(): boolean;
  114222. set transparencyShadow(value: boolean);
  114223. /**
  114224. * Sets the ability to have transparent shadow (boolean).
  114225. * @param transparent True if transparent else False
  114226. * @returns the shadow generator allowing fluent coding
  114227. */
  114228. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  114229. /**
  114230. * Enables or disables shadows with varying strength based on the transparency
  114231. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  114232. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  114233. * mesh.visibility * alphaTexture.a
  114234. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  114235. */
  114236. enableSoftTransparentShadow: boolean;
  114237. protected _shadowMap: Nullable<RenderTargetTexture>;
  114238. protected _shadowMap2: Nullable<RenderTargetTexture>;
  114239. /**
  114240. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  114241. * @returns The render target texture if present otherwise, null
  114242. */
  114243. getShadowMap(): Nullable<RenderTargetTexture>;
  114244. /**
  114245. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  114246. * @returns The render target texture if the shadow map is present otherwise, null
  114247. */
  114248. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  114249. /**
  114250. * Gets the class name of that object
  114251. * @returns "ShadowGenerator"
  114252. */
  114253. getClassName(): string;
  114254. /**
  114255. * Helper function to add a mesh and its descendants to the list of shadow casters.
  114256. * @param mesh Mesh to add
  114257. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  114258. * @returns the Shadow Generator itself
  114259. */
  114260. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114261. /**
  114262. * Helper function to remove a mesh and its descendants from the list of shadow casters
  114263. * @param mesh Mesh to remove
  114264. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  114265. * @returns the Shadow Generator itself
  114266. */
  114267. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114268. /**
  114269. * Controls the extent to which the shadows fade out at the edge of the frustum
  114270. */
  114271. frustumEdgeFalloff: number;
  114272. protected _light: IShadowLight;
  114273. /**
  114274. * Returns the associated light object.
  114275. * @returns the light generating the shadow
  114276. */
  114277. getLight(): IShadowLight;
  114278. /**
  114279. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  114280. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  114281. * It might on the other hand introduce peter panning.
  114282. */
  114283. forceBackFacesOnly: boolean;
  114284. protected _scene: Scene;
  114285. protected _lightDirection: Vector3;
  114286. protected _viewMatrix: Matrix;
  114287. protected _projectionMatrix: Matrix;
  114288. protected _transformMatrix: Matrix;
  114289. protected _cachedPosition: Vector3;
  114290. protected _cachedDirection: Vector3;
  114291. protected _cachedDefines: string;
  114292. protected _currentRenderID: number;
  114293. protected _boxBlurPostprocess: Nullable<PostProcess>;
  114294. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  114295. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  114296. protected _blurPostProcesses: PostProcess[];
  114297. protected _mapSize: number;
  114298. protected _currentFaceIndex: number;
  114299. protected _currentFaceIndexCache: number;
  114300. protected _textureType: number;
  114301. protected _defaultTextureMatrix: Matrix;
  114302. protected _storedUniqueId: Nullable<number>;
  114303. protected _nameForCustomEffect: string;
  114304. /** @hidden */
  114305. static _SceneComponentInitialization: (scene: Scene) => void;
  114306. /**
  114307. * Gets or sets the size of the texture what stores the shadows
  114308. */
  114309. get mapSize(): number;
  114310. set mapSize(size: number);
  114311. /**
  114312. * Creates a ShadowGenerator object.
  114313. * A ShadowGenerator is the required tool to use the shadows.
  114314. * Each light casting shadows needs to use its own ShadowGenerator.
  114315. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  114316. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  114317. * @param light The light object generating the shadows.
  114318. * @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.
  114319. */
  114320. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  114321. protected _initializeGenerator(): void;
  114322. protected _createTargetRenderTexture(): void;
  114323. protected _initializeShadowMap(): void;
  114324. protected _initializeBlurRTTAndPostProcesses(): void;
  114325. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  114326. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  114327. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  114328. protected _applyFilterValues(): void;
  114329. /**
  114330. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114331. * @param onCompiled Callback triggered at the and of the effects compilation
  114332. * @param options Sets of optional options forcing the compilation with different modes
  114333. */
  114334. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  114335. useInstances: boolean;
  114336. }>): void;
  114337. /**
  114338. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114339. * @param options Sets of optional options forcing the compilation with different modes
  114340. * @returns A promise that resolves when the compilation completes
  114341. */
  114342. forceCompilationAsync(options?: Partial<{
  114343. useInstances: boolean;
  114344. }>): Promise<void>;
  114345. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  114346. private _prepareShadowDefines;
  114347. /**
  114348. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  114349. * @param subMesh The submesh we want to render in the shadow map
  114350. * @param useInstances Defines wether will draw in the map using instances
  114351. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  114352. * @returns true if ready otherwise, false
  114353. */
  114354. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  114355. /**
  114356. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  114357. * @param defines Defines of the material we want to update
  114358. * @param lightIndex Index of the light in the enabled light list of the material
  114359. */
  114360. prepareDefines(defines: any, lightIndex: number): void;
  114361. /**
  114362. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  114363. * defined in the generator but impacting the effect).
  114364. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  114365. * @param effect The effect we are binfing the information for
  114366. */
  114367. bindShadowLight(lightIndex: string, effect: Effect): void;
  114368. /**
  114369. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  114370. * (eq to shadow prjection matrix * light transform matrix)
  114371. * @returns The transform matrix used to create the shadow map
  114372. */
  114373. getTransformMatrix(): Matrix;
  114374. /**
  114375. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  114376. * Cube and 2D textures for instance.
  114377. */
  114378. recreateShadowMap(): void;
  114379. protected _disposeBlurPostProcesses(): void;
  114380. protected _disposeRTTandPostProcesses(): void;
  114381. /**
  114382. * Disposes the ShadowGenerator.
  114383. * Returns nothing.
  114384. */
  114385. dispose(): void;
  114386. /**
  114387. * Serializes the shadow generator setup to a json object.
  114388. * @returns The serialized JSON object
  114389. */
  114390. serialize(): any;
  114391. /**
  114392. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  114393. * @param parsedShadowGenerator The JSON object to parse
  114394. * @param scene The scene to create the shadow map for
  114395. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  114396. * @returns The parsed shadow generator
  114397. */
  114398. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  114399. }
  114400. }
  114401. declare module BABYLON {
  114402. /**
  114403. * Options to be used when creating a shadow depth material
  114404. */
  114405. export interface IIOptionShadowDepthMaterial {
  114406. /** Variables in the vertex shader code that need to have their names remapped.
  114407. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  114408. * "var_name" should be either: worldPos or vNormalW
  114409. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  114410. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  114411. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  114412. */
  114413. remappedVariables?: string[];
  114414. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  114415. standalone?: boolean;
  114416. }
  114417. /**
  114418. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  114419. */
  114420. export class ShadowDepthWrapper {
  114421. private _scene;
  114422. private _options?;
  114423. private _baseMaterial;
  114424. private _onEffectCreatedObserver;
  114425. private _subMeshToEffect;
  114426. private _subMeshToDepthEffect;
  114427. private _meshes;
  114428. /** @hidden */
  114429. _matriceNames: any;
  114430. /** Gets the standalone status of the wrapper */
  114431. get standalone(): boolean;
  114432. /** Gets the base material the wrapper is built upon */
  114433. get baseMaterial(): Material;
  114434. /**
  114435. * Instantiate a new shadow depth wrapper.
  114436. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  114437. * generate the shadow depth map. For more information, please refer to the documentation:
  114438. * https://doc.babylonjs.com/babylon101/shadows
  114439. * @param baseMaterial Material to wrap
  114440. * @param scene Define the scene the material belongs to
  114441. * @param options Options used to create the wrapper
  114442. */
  114443. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  114444. /**
  114445. * Gets the effect to use to generate the depth map
  114446. * @param subMesh subMesh to get the effect for
  114447. * @param shadowGenerator shadow generator to get the effect for
  114448. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  114449. */
  114450. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  114451. /**
  114452. * Specifies that the submesh is ready to be used for depth rendering
  114453. * @param subMesh submesh to check
  114454. * @param defines the list of defines to take into account when checking the effect
  114455. * @param shadowGenerator combined with subMesh, it defines the effect to check
  114456. * @param useInstances specifies that instances should be used
  114457. * @returns a boolean indicating that the submesh is ready or not
  114458. */
  114459. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  114460. /**
  114461. * Disposes the resources
  114462. */
  114463. dispose(): void;
  114464. private _makeEffect;
  114465. }
  114466. }
  114467. declare module BABYLON {
  114468. /**
  114469. * Options for compiling materials.
  114470. */
  114471. export interface IMaterialCompilationOptions {
  114472. /**
  114473. * Defines whether clip planes are enabled.
  114474. */
  114475. clipPlane: boolean;
  114476. /**
  114477. * Defines whether instances are enabled.
  114478. */
  114479. useInstances: boolean;
  114480. }
  114481. /**
  114482. * Options passed when calling customShaderNameResolve
  114483. */
  114484. export interface ICustomShaderNameResolveOptions {
  114485. /**
  114486. * 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
  114487. */
  114488. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114489. }
  114490. /**
  114491. * Base class for the main features of a material in Babylon.js
  114492. */
  114493. export class Material implements IAnimatable {
  114494. /**
  114495. * Returns the triangle fill mode
  114496. */
  114497. static readonly TriangleFillMode: number;
  114498. /**
  114499. * Returns the wireframe mode
  114500. */
  114501. static readonly WireFrameFillMode: number;
  114502. /**
  114503. * Returns the point fill mode
  114504. */
  114505. static readonly PointFillMode: number;
  114506. /**
  114507. * Returns the point list draw mode
  114508. */
  114509. static readonly PointListDrawMode: number;
  114510. /**
  114511. * Returns the line list draw mode
  114512. */
  114513. static readonly LineListDrawMode: number;
  114514. /**
  114515. * Returns the line loop draw mode
  114516. */
  114517. static readonly LineLoopDrawMode: number;
  114518. /**
  114519. * Returns the line strip draw mode
  114520. */
  114521. static readonly LineStripDrawMode: number;
  114522. /**
  114523. * Returns the triangle strip draw mode
  114524. */
  114525. static readonly TriangleStripDrawMode: number;
  114526. /**
  114527. * Returns the triangle fan draw mode
  114528. */
  114529. static readonly TriangleFanDrawMode: number;
  114530. /**
  114531. * Stores the clock-wise side orientation
  114532. */
  114533. static readonly ClockWiseSideOrientation: number;
  114534. /**
  114535. * Stores the counter clock-wise side orientation
  114536. */
  114537. static readonly CounterClockWiseSideOrientation: number;
  114538. /**
  114539. * The dirty texture flag value
  114540. */
  114541. static readonly TextureDirtyFlag: number;
  114542. /**
  114543. * The dirty light flag value
  114544. */
  114545. static readonly LightDirtyFlag: number;
  114546. /**
  114547. * The dirty fresnel flag value
  114548. */
  114549. static readonly FresnelDirtyFlag: number;
  114550. /**
  114551. * The dirty attribute flag value
  114552. */
  114553. static readonly AttributesDirtyFlag: number;
  114554. /**
  114555. * The dirty misc flag value
  114556. */
  114557. static readonly MiscDirtyFlag: number;
  114558. /**
  114559. * The dirty prepass flag value
  114560. */
  114561. static readonly PrePassDirtyFlag: number;
  114562. /**
  114563. * The all dirty flag value
  114564. */
  114565. static readonly AllDirtyFlag: number;
  114566. /**
  114567. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114568. */
  114569. static readonly MATERIAL_OPAQUE: number;
  114570. /**
  114571. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114572. */
  114573. static readonly MATERIAL_ALPHATEST: number;
  114574. /**
  114575. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114576. */
  114577. static readonly MATERIAL_ALPHABLEND: number;
  114578. /**
  114579. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114580. * They are also discarded below the alpha cutoff threshold to improve performances.
  114581. */
  114582. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  114583. /**
  114584. * The Whiteout method is used to blend normals.
  114585. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  114586. */
  114587. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  114588. /**
  114589. * The Reoriented Normal Mapping method is used to blend normals.
  114590. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  114591. */
  114592. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  114593. /**
  114594. * Custom callback helping to override the default shader used in the material.
  114595. */
  114596. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  114597. /**
  114598. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  114599. */
  114600. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  114601. /**
  114602. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  114603. * This means that the material can keep using a previous shader while a new one is being compiled.
  114604. * This is mostly used when shader parallel compilation is supported (true by default)
  114605. */
  114606. allowShaderHotSwapping: boolean;
  114607. /**
  114608. * The ID of the material
  114609. */
  114610. id: string;
  114611. /**
  114612. * Gets or sets the unique id of the material
  114613. */
  114614. uniqueId: number;
  114615. /**
  114616. * The name of the material
  114617. */
  114618. name: string;
  114619. /**
  114620. * Gets or sets user defined metadata
  114621. */
  114622. metadata: any;
  114623. /**
  114624. * For internal use only. Please do not use.
  114625. */
  114626. reservedDataStore: any;
  114627. /**
  114628. * Specifies if the ready state should be checked on each call
  114629. */
  114630. checkReadyOnEveryCall: boolean;
  114631. /**
  114632. * Specifies if the ready state should be checked once
  114633. */
  114634. checkReadyOnlyOnce: boolean;
  114635. /**
  114636. * The state of the material
  114637. */
  114638. state: string;
  114639. /**
  114640. * If the material can be rendered to several textures with MRT extension
  114641. */
  114642. get canRenderToMRT(): boolean;
  114643. /**
  114644. * The alpha value of the material
  114645. */
  114646. protected _alpha: number;
  114647. /**
  114648. * List of inspectable custom properties (used by the Inspector)
  114649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  114650. */
  114651. inspectableCustomProperties: IInspectable[];
  114652. /**
  114653. * Sets the alpha value of the material
  114654. */
  114655. set alpha(value: number);
  114656. /**
  114657. * Gets the alpha value of the material
  114658. */
  114659. get alpha(): number;
  114660. /**
  114661. * Specifies if back face culling is enabled
  114662. */
  114663. protected _backFaceCulling: boolean;
  114664. /**
  114665. * Sets the back-face culling state
  114666. */
  114667. set backFaceCulling(value: boolean);
  114668. /**
  114669. * Gets the back-face culling state
  114670. */
  114671. get backFaceCulling(): boolean;
  114672. /**
  114673. * Stores the value for side orientation
  114674. */
  114675. sideOrientation: number;
  114676. /**
  114677. * Callback triggered when the material is compiled
  114678. */
  114679. onCompiled: Nullable<(effect: Effect) => void>;
  114680. /**
  114681. * Callback triggered when an error occurs
  114682. */
  114683. onError: Nullable<(effect: Effect, errors: string) => void>;
  114684. /**
  114685. * Callback triggered to get the render target textures
  114686. */
  114687. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  114688. /**
  114689. * Gets a boolean indicating that current material needs to register RTT
  114690. */
  114691. get hasRenderTargetTextures(): boolean;
  114692. /**
  114693. * Specifies if the material should be serialized
  114694. */
  114695. doNotSerialize: boolean;
  114696. /**
  114697. * @hidden
  114698. */
  114699. _storeEffectOnSubMeshes: boolean;
  114700. /**
  114701. * Stores the animations for the material
  114702. */
  114703. animations: Nullable<Array<Animation>>;
  114704. /**
  114705. * An event triggered when the material is disposed
  114706. */
  114707. onDisposeObservable: Observable<Material>;
  114708. /**
  114709. * An observer which watches for dispose events
  114710. */
  114711. private _onDisposeObserver;
  114712. private _onUnBindObservable;
  114713. /**
  114714. * Called during a dispose event
  114715. */
  114716. set onDispose(callback: () => void);
  114717. private _onBindObservable;
  114718. /**
  114719. * An event triggered when the material is bound
  114720. */
  114721. get onBindObservable(): Observable<AbstractMesh>;
  114722. /**
  114723. * An observer which watches for bind events
  114724. */
  114725. private _onBindObserver;
  114726. /**
  114727. * Called during a bind event
  114728. */
  114729. set onBind(callback: (Mesh: AbstractMesh) => void);
  114730. /**
  114731. * An event triggered when the material is unbound
  114732. */
  114733. get onUnBindObservable(): Observable<Material>;
  114734. protected _onEffectCreatedObservable: Nullable<Observable<{
  114735. effect: Effect;
  114736. subMesh: Nullable<SubMesh>;
  114737. }>>;
  114738. /**
  114739. * An event triggered when the effect is (re)created
  114740. */
  114741. get onEffectCreatedObservable(): Observable<{
  114742. effect: Effect;
  114743. subMesh: Nullable<SubMesh>;
  114744. }>;
  114745. /**
  114746. * Stores the value of the alpha mode
  114747. */
  114748. private _alphaMode;
  114749. /**
  114750. * Sets the value of the alpha mode.
  114751. *
  114752. * | Value | Type | Description |
  114753. * | --- | --- | --- |
  114754. * | 0 | ALPHA_DISABLE | |
  114755. * | 1 | ALPHA_ADD | |
  114756. * | 2 | ALPHA_COMBINE | |
  114757. * | 3 | ALPHA_SUBTRACT | |
  114758. * | 4 | ALPHA_MULTIPLY | |
  114759. * | 5 | ALPHA_MAXIMIZED | |
  114760. * | 6 | ALPHA_ONEONE | |
  114761. * | 7 | ALPHA_PREMULTIPLIED | |
  114762. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  114763. * | 9 | ALPHA_INTERPOLATE | |
  114764. * | 10 | ALPHA_SCREENMODE | |
  114765. *
  114766. */
  114767. set alphaMode(value: number);
  114768. /**
  114769. * Gets the value of the alpha mode
  114770. */
  114771. get alphaMode(): number;
  114772. /**
  114773. * Stores the state of the need depth pre-pass value
  114774. */
  114775. private _needDepthPrePass;
  114776. /**
  114777. * Sets the need depth pre-pass value
  114778. */
  114779. set needDepthPrePass(value: boolean);
  114780. /**
  114781. * Gets the depth pre-pass value
  114782. */
  114783. get needDepthPrePass(): boolean;
  114784. /**
  114785. * Specifies if depth writing should be disabled
  114786. */
  114787. disableDepthWrite: boolean;
  114788. /**
  114789. * Specifies if color writing should be disabled
  114790. */
  114791. disableColorWrite: boolean;
  114792. /**
  114793. * Specifies if depth writing should be forced
  114794. */
  114795. forceDepthWrite: boolean;
  114796. /**
  114797. * Specifies the depth function that should be used. 0 means the default engine function
  114798. */
  114799. depthFunction: number;
  114800. /**
  114801. * Specifies if there should be a separate pass for culling
  114802. */
  114803. separateCullingPass: boolean;
  114804. /**
  114805. * Stores the state specifing if fog should be enabled
  114806. */
  114807. private _fogEnabled;
  114808. /**
  114809. * Sets the state for enabling fog
  114810. */
  114811. set fogEnabled(value: boolean);
  114812. /**
  114813. * Gets the value of the fog enabled state
  114814. */
  114815. get fogEnabled(): boolean;
  114816. /**
  114817. * Stores the size of points
  114818. */
  114819. pointSize: number;
  114820. /**
  114821. * Stores the z offset value
  114822. */
  114823. zOffset: number;
  114824. get wireframe(): boolean;
  114825. /**
  114826. * Sets the state of wireframe mode
  114827. */
  114828. set wireframe(value: boolean);
  114829. /**
  114830. * Gets the value specifying if point clouds are enabled
  114831. */
  114832. get pointsCloud(): boolean;
  114833. /**
  114834. * Sets the state of point cloud mode
  114835. */
  114836. set pointsCloud(value: boolean);
  114837. /**
  114838. * Gets the material fill mode
  114839. */
  114840. get fillMode(): number;
  114841. /**
  114842. * Sets the material fill mode
  114843. */
  114844. set fillMode(value: number);
  114845. /**
  114846. * @hidden
  114847. * Stores the effects for the material
  114848. */
  114849. _effect: Nullable<Effect>;
  114850. /**
  114851. * Specifies if uniform buffers should be used
  114852. */
  114853. private _useUBO;
  114854. /**
  114855. * Stores a reference to the scene
  114856. */
  114857. private _scene;
  114858. private _needToBindSceneUbo;
  114859. /**
  114860. * Stores the fill mode state
  114861. */
  114862. private _fillMode;
  114863. /**
  114864. * Specifies if the depth write state should be cached
  114865. */
  114866. private _cachedDepthWriteState;
  114867. /**
  114868. * Specifies if the color write state should be cached
  114869. */
  114870. private _cachedColorWriteState;
  114871. /**
  114872. * Specifies if the depth function state should be cached
  114873. */
  114874. private _cachedDepthFunctionState;
  114875. /**
  114876. * Stores the uniform buffer
  114877. */
  114878. protected _uniformBuffer: UniformBuffer;
  114879. /** @hidden */
  114880. _indexInSceneMaterialArray: number;
  114881. /** @hidden */
  114882. meshMap: Nullable<{
  114883. [id: string]: AbstractMesh | undefined;
  114884. }>;
  114885. /**
  114886. * Creates a material instance
  114887. * @param name defines the name of the material
  114888. * @param scene defines the scene to reference
  114889. * @param doNotAdd specifies if the material should be added to the scene
  114890. */
  114891. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  114892. /**
  114893. * Returns a string representation of the current material
  114894. * @param fullDetails defines a boolean indicating which levels of logging is desired
  114895. * @returns a string with material information
  114896. */
  114897. toString(fullDetails?: boolean): string;
  114898. /**
  114899. * Gets the class name of the material
  114900. * @returns a string with the class name of the material
  114901. */
  114902. getClassName(): string;
  114903. /**
  114904. * Specifies if updates for the material been locked
  114905. */
  114906. get isFrozen(): boolean;
  114907. /**
  114908. * Locks updates for the material
  114909. */
  114910. freeze(): void;
  114911. /**
  114912. * Unlocks updates for the material
  114913. */
  114914. unfreeze(): void;
  114915. /**
  114916. * Specifies if the material is ready to be used
  114917. * @param mesh defines the mesh to check
  114918. * @param useInstances specifies if instances should be used
  114919. * @returns a boolean indicating if the material is ready to be used
  114920. */
  114921. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  114922. /**
  114923. * Specifies that the submesh is ready to be used
  114924. * @param mesh defines the mesh to check
  114925. * @param subMesh defines which submesh to check
  114926. * @param useInstances specifies that instances should be used
  114927. * @returns a boolean indicating that the submesh is ready or not
  114928. */
  114929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114930. /**
  114931. * Returns the material effect
  114932. * @returns the effect associated with the material
  114933. */
  114934. getEffect(): Nullable<Effect>;
  114935. /**
  114936. * Returns the current scene
  114937. * @returns a Scene
  114938. */
  114939. getScene(): Scene;
  114940. /**
  114941. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114942. */
  114943. protected _forceAlphaTest: boolean;
  114944. /**
  114945. * The transparency mode of the material.
  114946. */
  114947. protected _transparencyMode: Nullable<number>;
  114948. /**
  114949. * Gets the current transparency mode.
  114950. */
  114951. get transparencyMode(): Nullable<number>;
  114952. /**
  114953. * Sets the transparency mode of the material.
  114954. *
  114955. * | Value | Type | Description |
  114956. * | ----- | ----------------------------------- | ----------- |
  114957. * | 0 | OPAQUE | |
  114958. * | 1 | ALPHATEST | |
  114959. * | 2 | ALPHABLEND | |
  114960. * | 3 | ALPHATESTANDBLEND | |
  114961. *
  114962. */
  114963. set transparencyMode(value: Nullable<number>);
  114964. /**
  114965. * Returns true if alpha blending should be disabled.
  114966. */
  114967. protected get _disableAlphaBlending(): boolean;
  114968. /**
  114969. * Specifies whether or not this material should be rendered in alpha blend mode.
  114970. * @returns a boolean specifying if alpha blending is needed
  114971. */
  114972. needAlphaBlending(): boolean;
  114973. /**
  114974. * Specifies if the mesh will require alpha blending
  114975. * @param mesh defines the mesh to check
  114976. * @returns a boolean specifying if alpha blending is needed for the mesh
  114977. */
  114978. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114979. /**
  114980. * Specifies whether or not this material should be rendered in alpha test mode.
  114981. * @returns a boolean specifying if an alpha test is needed.
  114982. */
  114983. needAlphaTesting(): boolean;
  114984. /**
  114985. * Specifies if material alpha testing should be turned on for the mesh
  114986. * @param mesh defines the mesh to check
  114987. */
  114988. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  114989. /**
  114990. * Gets the texture used for the alpha test
  114991. * @returns the texture to use for alpha testing
  114992. */
  114993. getAlphaTestTexture(): Nullable<BaseTexture>;
  114994. /**
  114995. * Marks the material to indicate that it needs to be re-calculated
  114996. */
  114997. markDirty(): void;
  114998. /** @hidden */
  114999. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  115000. /**
  115001. * Binds the material to the mesh
  115002. * @param world defines the world transformation matrix
  115003. * @param mesh defines the mesh to bind the material to
  115004. */
  115005. bind(world: Matrix, mesh?: Mesh): void;
  115006. /**
  115007. * Binds the submesh to the material
  115008. * @param world defines the world transformation matrix
  115009. * @param mesh defines the mesh containing the submesh
  115010. * @param subMesh defines the submesh to bind the material to
  115011. */
  115012. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115013. /**
  115014. * Binds the world matrix to the material
  115015. * @param world defines the world transformation matrix
  115016. */
  115017. bindOnlyWorldMatrix(world: Matrix): void;
  115018. /**
  115019. * Update the scene ubo before it can be used in rendering processing
  115020. * @param scene the scene to retrieve the ubo from
  115021. * @returns the scene UniformBuffer
  115022. */
  115023. finalizeSceneUbo(scene: Scene): UniformBuffer;
  115024. /**
  115025. * Binds the scene's uniform buffer to the effect.
  115026. * @param effect defines the effect to bind to the scene uniform buffer
  115027. * @param sceneUbo defines the uniform buffer storing scene data
  115028. */
  115029. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  115030. /**
  115031. * Binds the view matrix to the effect
  115032. * @param effect defines the effect to bind the view matrix to
  115033. */
  115034. bindView(effect: Effect): void;
  115035. /**
  115036. * Binds the view projection and projection matrices to the effect
  115037. * @param effect defines the effect to bind the view projection and projection matrices to
  115038. */
  115039. bindViewProjection(effect: Effect): void;
  115040. /**
  115041. * Binds the view matrix to the effect
  115042. * @param effect defines the effect to bind the view matrix to
  115043. * @param variableName name of the shader variable that will hold the eye position
  115044. */
  115045. bindEyePosition(effect: Effect, variableName?: string): void;
  115046. /**
  115047. * Processes to execute after binding the material to a mesh
  115048. * @param mesh defines the rendered mesh
  115049. */
  115050. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  115051. /**
  115052. * Unbinds the material from the mesh
  115053. */
  115054. unbind(): void;
  115055. /**
  115056. * Gets the active textures from the material
  115057. * @returns an array of textures
  115058. */
  115059. getActiveTextures(): BaseTexture[];
  115060. /**
  115061. * Specifies if the material uses a texture
  115062. * @param texture defines the texture to check against the material
  115063. * @returns a boolean specifying if the material uses the texture
  115064. */
  115065. hasTexture(texture: BaseTexture): boolean;
  115066. /**
  115067. * Makes a duplicate of the material, and gives it a new name
  115068. * @param name defines the new name for the duplicated material
  115069. * @returns the cloned material
  115070. */
  115071. clone(name: string): Nullable<Material>;
  115072. /**
  115073. * Gets the meshes bound to the material
  115074. * @returns an array of meshes bound to the material
  115075. */
  115076. getBindedMeshes(): AbstractMesh[];
  115077. /**
  115078. * Force shader compilation
  115079. * @param mesh defines the mesh associated with this material
  115080. * @param onCompiled defines a function to execute once the material is compiled
  115081. * @param options defines the options to configure the compilation
  115082. * @param onError defines a function to execute if the material fails compiling
  115083. */
  115084. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  115085. /**
  115086. * Force shader compilation
  115087. * @param mesh defines the mesh that will use this material
  115088. * @param options defines additional options for compiling the shaders
  115089. * @returns a promise that resolves when the compilation completes
  115090. */
  115091. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  115092. private static readonly _AllDirtyCallBack;
  115093. private static readonly _ImageProcessingDirtyCallBack;
  115094. private static readonly _TextureDirtyCallBack;
  115095. private static readonly _FresnelDirtyCallBack;
  115096. private static readonly _MiscDirtyCallBack;
  115097. private static readonly _PrePassDirtyCallBack;
  115098. private static readonly _LightsDirtyCallBack;
  115099. private static readonly _AttributeDirtyCallBack;
  115100. private static _FresnelAndMiscDirtyCallBack;
  115101. private static _TextureAndMiscDirtyCallBack;
  115102. private static readonly _DirtyCallbackArray;
  115103. private static readonly _RunDirtyCallBacks;
  115104. /**
  115105. * Marks a define in the material to indicate that it needs to be re-computed
  115106. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  115107. */
  115108. markAsDirty(flag: number): void;
  115109. /**
  115110. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  115111. * @param func defines a function which checks material defines against the submeshes
  115112. */
  115113. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  115114. /**
  115115. * Indicates that the scene should check if the rendering now needs a prepass
  115116. */
  115117. protected _markScenePrePassDirty(): void;
  115118. /**
  115119. * Indicates that we need to re-calculated for all submeshes
  115120. */
  115121. protected _markAllSubMeshesAsAllDirty(): void;
  115122. /**
  115123. * Indicates that image processing needs to be re-calculated for all submeshes
  115124. */
  115125. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  115126. /**
  115127. * Indicates that textures need to be re-calculated for all submeshes
  115128. */
  115129. protected _markAllSubMeshesAsTexturesDirty(): void;
  115130. /**
  115131. * Indicates that fresnel needs to be re-calculated for all submeshes
  115132. */
  115133. protected _markAllSubMeshesAsFresnelDirty(): void;
  115134. /**
  115135. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  115136. */
  115137. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  115138. /**
  115139. * Indicates that lights need to be re-calculated for all submeshes
  115140. */
  115141. protected _markAllSubMeshesAsLightsDirty(): void;
  115142. /**
  115143. * Indicates that attributes need to be re-calculated for all submeshes
  115144. */
  115145. protected _markAllSubMeshesAsAttributesDirty(): void;
  115146. /**
  115147. * Indicates that misc needs to be re-calculated for all submeshes
  115148. */
  115149. protected _markAllSubMeshesAsMiscDirty(): void;
  115150. /**
  115151. * Indicates that prepass needs to be re-calculated for all submeshes
  115152. */
  115153. protected _markAllSubMeshesAsPrePassDirty(): void;
  115154. /**
  115155. * Indicates that textures and misc need to be re-calculated for all submeshes
  115156. */
  115157. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  115158. /**
  115159. * Sets the required values to the prepass renderer.
  115160. * @param prePassRenderer defines the prepass renderer to setup.
  115161. * @returns true if the pre pass is needed.
  115162. */
  115163. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  115164. /**
  115165. * Disposes the material
  115166. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115167. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115168. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115169. */
  115170. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115171. /** @hidden */
  115172. private releaseVertexArrayObject;
  115173. /**
  115174. * Serializes this material
  115175. * @returns the serialized material object
  115176. */
  115177. serialize(): any;
  115178. /**
  115179. * Creates a material from parsed material data
  115180. * @param parsedMaterial defines parsed material data
  115181. * @param scene defines the hosting scene
  115182. * @param rootUrl defines the root URL to use to load textures
  115183. * @returns a new material
  115184. */
  115185. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  115186. }
  115187. }
  115188. declare module BABYLON {
  115189. /**
  115190. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115191. * separate meshes. This can be use to improve performances.
  115192. * @see https://doc.babylonjs.com/how_to/multi_materials
  115193. */
  115194. export class MultiMaterial extends Material {
  115195. private _subMaterials;
  115196. /**
  115197. * Gets or Sets the list of Materials used within the multi material.
  115198. * They need to be ordered according to the submeshes order in the associated mesh
  115199. */
  115200. get subMaterials(): Nullable<Material>[];
  115201. set subMaterials(value: Nullable<Material>[]);
  115202. /**
  115203. * Function used to align with Node.getChildren()
  115204. * @returns the list of Materials used within the multi material
  115205. */
  115206. getChildren(): Nullable<Material>[];
  115207. /**
  115208. * Instantiates a new Multi Material
  115209. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115210. * separate meshes. This can be use to improve performances.
  115211. * @see https://doc.babylonjs.com/how_to/multi_materials
  115212. * @param name Define the name in the scene
  115213. * @param scene Define the scene the material belongs to
  115214. */
  115215. constructor(name: string, scene: Scene);
  115216. private _hookArray;
  115217. /**
  115218. * Get one of the submaterial by its index in the submaterials array
  115219. * @param index The index to look the sub material at
  115220. * @returns The Material if the index has been defined
  115221. */
  115222. getSubMaterial(index: number): Nullable<Material>;
  115223. /**
  115224. * Get the list of active textures for the whole sub materials list.
  115225. * @returns All the textures that will be used during the rendering
  115226. */
  115227. getActiveTextures(): BaseTexture[];
  115228. /**
  115229. * Specifies if any sub-materials of this multi-material use a given texture.
  115230. * @param texture Defines the texture to check against this multi-material's sub-materials.
  115231. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  115232. */
  115233. hasTexture(texture: BaseTexture): boolean;
  115234. /**
  115235. * Gets the current class name of the material e.g. "MultiMaterial"
  115236. * Mainly use in serialization.
  115237. * @returns the class name
  115238. */
  115239. getClassName(): string;
  115240. /**
  115241. * Checks if the material is ready to render the requested sub mesh
  115242. * @param mesh Define the mesh the submesh belongs to
  115243. * @param subMesh Define the sub mesh to look readyness for
  115244. * @param useInstances Define whether or not the material is used with instances
  115245. * @returns true if ready, otherwise false
  115246. */
  115247. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115248. /**
  115249. * Clones the current material and its related sub materials
  115250. * @param name Define the name of the newly cloned material
  115251. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  115252. * @returns the cloned material
  115253. */
  115254. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  115255. /**
  115256. * Serializes the materials into a JSON representation.
  115257. * @returns the JSON representation
  115258. */
  115259. serialize(): any;
  115260. /**
  115261. * Dispose the material and release its associated resources
  115262. * @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)
  115263. * @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)
  115264. * @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)
  115265. */
  115266. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  115267. /**
  115268. * Creates a MultiMaterial from parsed MultiMaterial data.
  115269. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  115270. * @param scene defines the hosting scene
  115271. * @returns a new MultiMaterial
  115272. */
  115273. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  115274. }
  115275. }
  115276. declare module BABYLON {
  115277. /** @hidden */
  115278. export interface ICustomEffect {
  115279. effect: Effect;
  115280. defines: string;
  115281. }
  115282. /**
  115283. * Defines a subdivision inside a mesh
  115284. */
  115285. export class SubMesh implements ICullable {
  115286. /** the material index to use */
  115287. materialIndex: number;
  115288. /** vertex index start */
  115289. verticesStart: number;
  115290. /** vertices count */
  115291. verticesCount: number;
  115292. /** index start */
  115293. indexStart: number;
  115294. /** indices count */
  115295. indexCount: number;
  115296. /** @hidden */
  115297. _materialDefines: Nullable<MaterialDefines>;
  115298. /** @hidden */
  115299. _materialEffect: Nullable<Effect>;
  115300. /** @hidden */
  115301. _effectOverride: Nullable<Effect>;
  115302. private _customEffects;
  115303. /**
  115304. * Gets material defines used by the effect associated to the sub mesh
  115305. */
  115306. get materialDefines(): Nullable<MaterialDefines>;
  115307. /**
  115308. * Sets material defines used by the effect associated to the sub mesh
  115309. */
  115310. set materialDefines(defines: Nullable<MaterialDefines>);
  115311. /** @hidden */
  115312. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  115313. /** @hidden */
  115314. _removeCustomEffect(name: string): void;
  115315. /**
  115316. * Gets associated effect
  115317. */
  115318. get effect(): Nullable<Effect>;
  115319. /**
  115320. * Sets associated effect (effect used to render this submesh)
  115321. * @param effect defines the effect to associate with
  115322. * @param defines defines the set of defines used to compile this effect
  115323. */
  115324. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  115325. /** @hidden */
  115326. _linesIndexCount: number;
  115327. private _mesh;
  115328. private _renderingMesh;
  115329. private _boundingInfo;
  115330. private _linesIndexBuffer;
  115331. /** @hidden */
  115332. _lastColliderWorldVertices: Nullable<Vector3[]>;
  115333. /** @hidden */
  115334. _trianglePlanes: Plane[];
  115335. /** @hidden */
  115336. _lastColliderTransformMatrix: Nullable<Matrix>;
  115337. /** @hidden */
  115338. _renderId: number;
  115339. /** @hidden */
  115340. _alphaIndex: number;
  115341. /** @hidden */
  115342. _distanceToCamera: number;
  115343. /** @hidden */
  115344. _id: number;
  115345. private _currentMaterial;
  115346. /**
  115347. * Add a new submesh to a mesh
  115348. * @param materialIndex defines the material index to use
  115349. * @param verticesStart defines vertex index start
  115350. * @param verticesCount defines vertices count
  115351. * @param indexStart defines index start
  115352. * @param indexCount defines indices count
  115353. * @param mesh defines the parent mesh
  115354. * @param renderingMesh defines an optional rendering mesh
  115355. * @param createBoundingBox defines if bounding box should be created for this submesh
  115356. * @returns the new submesh
  115357. */
  115358. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  115359. /**
  115360. * Creates a new submesh
  115361. * @param materialIndex defines the material index to use
  115362. * @param verticesStart defines vertex index start
  115363. * @param verticesCount defines vertices count
  115364. * @param indexStart defines index start
  115365. * @param indexCount defines indices count
  115366. * @param mesh defines the parent mesh
  115367. * @param renderingMesh defines an optional rendering mesh
  115368. * @param createBoundingBox defines if bounding box should be created for this submesh
  115369. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  115370. */
  115371. constructor(
  115372. /** the material index to use */
  115373. materialIndex: number,
  115374. /** vertex index start */
  115375. verticesStart: number,
  115376. /** vertices count */
  115377. verticesCount: number,
  115378. /** index start */
  115379. indexStart: number,
  115380. /** indices count */
  115381. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  115382. /**
  115383. * Returns true if this submesh covers the entire parent mesh
  115384. * @ignorenaming
  115385. */
  115386. get IsGlobal(): boolean;
  115387. /**
  115388. * Returns the submesh BoudingInfo object
  115389. * @returns current bounding info (or mesh's one if the submesh is global)
  115390. */
  115391. getBoundingInfo(): BoundingInfo;
  115392. /**
  115393. * Sets the submesh BoundingInfo
  115394. * @param boundingInfo defines the new bounding info to use
  115395. * @returns the SubMesh
  115396. */
  115397. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  115398. /**
  115399. * Returns the mesh of the current submesh
  115400. * @return the parent mesh
  115401. */
  115402. getMesh(): AbstractMesh;
  115403. /**
  115404. * Returns the rendering mesh of the submesh
  115405. * @returns the rendering mesh (could be different from parent mesh)
  115406. */
  115407. getRenderingMesh(): Mesh;
  115408. /**
  115409. * Returns the replacement mesh of the submesh
  115410. * @returns the replacement mesh (could be different from parent mesh)
  115411. */
  115412. getReplacementMesh(): Nullable<AbstractMesh>;
  115413. /**
  115414. * Returns the effective mesh of the submesh
  115415. * @returns the effective mesh (could be different from parent mesh)
  115416. */
  115417. getEffectiveMesh(): AbstractMesh;
  115418. /**
  115419. * Returns the submesh material
  115420. * @returns null or the current material
  115421. */
  115422. getMaterial(): Nullable<Material>;
  115423. private _IsMultiMaterial;
  115424. /**
  115425. * Sets a new updated BoundingInfo object to the submesh
  115426. * @param data defines an optional position array to use to determine the bounding info
  115427. * @returns the SubMesh
  115428. */
  115429. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  115430. /** @hidden */
  115431. _checkCollision(collider: Collider): boolean;
  115432. /**
  115433. * Updates the submesh BoundingInfo
  115434. * @param world defines the world matrix to use to update the bounding info
  115435. * @returns the submesh
  115436. */
  115437. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  115438. /**
  115439. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  115440. * @param frustumPlanes defines the frustum planes
  115441. * @returns true if the submesh is intersecting with the frustum
  115442. */
  115443. isInFrustum(frustumPlanes: Plane[]): boolean;
  115444. /**
  115445. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  115446. * @param frustumPlanes defines the frustum planes
  115447. * @returns true if the submesh is inside the frustum
  115448. */
  115449. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  115450. /**
  115451. * Renders the submesh
  115452. * @param enableAlphaMode defines if alpha needs to be used
  115453. * @returns the submesh
  115454. */
  115455. render(enableAlphaMode: boolean): SubMesh;
  115456. /**
  115457. * @hidden
  115458. */
  115459. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  115460. /**
  115461. * Checks if the submesh intersects with a ray
  115462. * @param ray defines the ray to test
  115463. * @returns true is the passed ray intersects the submesh bounding box
  115464. */
  115465. canIntersects(ray: Ray): boolean;
  115466. /**
  115467. * Intersects current submesh with a ray
  115468. * @param ray defines the ray to test
  115469. * @param positions defines mesh's positions array
  115470. * @param indices defines mesh's indices array
  115471. * @param fastCheck defines if the first intersection will be used (and not the closest)
  115472. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  115473. * @returns intersection info or null if no intersection
  115474. */
  115475. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  115476. /** @hidden */
  115477. private _intersectLines;
  115478. /** @hidden */
  115479. private _intersectUnIndexedLines;
  115480. /** @hidden */
  115481. private _intersectTriangles;
  115482. /** @hidden */
  115483. private _intersectUnIndexedTriangles;
  115484. /** @hidden */
  115485. _rebuild(): void;
  115486. /**
  115487. * Creates a new submesh from the passed mesh
  115488. * @param newMesh defines the new hosting mesh
  115489. * @param newRenderingMesh defines an optional rendering mesh
  115490. * @returns the new submesh
  115491. */
  115492. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  115493. /**
  115494. * Release associated resources
  115495. */
  115496. dispose(): void;
  115497. /**
  115498. * Gets the class name
  115499. * @returns the string "SubMesh".
  115500. */
  115501. getClassName(): string;
  115502. /**
  115503. * Creates a new submesh from indices data
  115504. * @param materialIndex the index of the main mesh material
  115505. * @param startIndex the index where to start the copy in the mesh indices array
  115506. * @param indexCount the number of indices to copy then from the startIndex
  115507. * @param mesh the main mesh to create the submesh from
  115508. * @param renderingMesh the optional rendering mesh
  115509. * @returns a new submesh
  115510. */
  115511. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  115512. }
  115513. }
  115514. declare module BABYLON {
  115515. /**
  115516. * Class used to represent data loading progression
  115517. */
  115518. export class SceneLoaderFlags {
  115519. private static _ForceFullSceneLoadingForIncremental;
  115520. private static _ShowLoadingScreen;
  115521. private static _CleanBoneMatrixWeights;
  115522. private static _loggingLevel;
  115523. /**
  115524. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115525. */
  115526. static get ForceFullSceneLoadingForIncremental(): boolean;
  115527. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115528. /**
  115529. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115530. */
  115531. static get ShowLoadingScreen(): boolean;
  115532. static set ShowLoadingScreen(value: boolean);
  115533. /**
  115534. * Defines the current logging level (while loading the scene)
  115535. * @ignorenaming
  115536. */
  115537. static get loggingLevel(): number;
  115538. static set loggingLevel(value: number);
  115539. /**
  115540. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115541. */
  115542. static get CleanBoneMatrixWeights(): boolean;
  115543. static set CleanBoneMatrixWeights(value: boolean);
  115544. }
  115545. }
  115546. declare module BABYLON {
  115547. /**
  115548. * Class used to store geometry data (vertex buffers + index buffer)
  115549. */
  115550. export class Geometry implements IGetSetVerticesData {
  115551. /**
  115552. * Gets or sets the ID of the geometry
  115553. */
  115554. id: string;
  115555. /**
  115556. * Gets or sets the unique ID of the geometry
  115557. */
  115558. uniqueId: number;
  115559. /**
  115560. * Gets the delay loading state of the geometry (none by default which means not delayed)
  115561. */
  115562. delayLoadState: number;
  115563. /**
  115564. * Gets the file containing the data to load when running in delay load state
  115565. */
  115566. delayLoadingFile: Nullable<string>;
  115567. /**
  115568. * Callback called when the geometry is updated
  115569. */
  115570. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  115571. private _scene;
  115572. private _engine;
  115573. private _meshes;
  115574. private _totalVertices;
  115575. /** @hidden */
  115576. _indices: IndicesArray;
  115577. /** @hidden */
  115578. _vertexBuffers: {
  115579. [key: string]: VertexBuffer;
  115580. };
  115581. private _isDisposed;
  115582. private _extend;
  115583. private _boundingBias;
  115584. /** @hidden */
  115585. _delayInfo: Array<string>;
  115586. private _indexBuffer;
  115587. private _indexBufferIsUpdatable;
  115588. /** @hidden */
  115589. _boundingInfo: Nullable<BoundingInfo>;
  115590. /** @hidden */
  115591. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  115592. /** @hidden */
  115593. _softwareSkinningFrameId: number;
  115594. private _vertexArrayObjects;
  115595. private _updatable;
  115596. /** @hidden */
  115597. _positions: Nullable<Vector3[]>;
  115598. private _positionsCache;
  115599. /**
  115600. * 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
  115601. */
  115602. get boundingBias(): Vector2;
  115603. /**
  115604. * 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
  115605. */
  115606. set boundingBias(value: Vector2);
  115607. /**
  115608. * Static function used to attach a new empty geometry to a mesh
  115609. * @param mesh defines the mesh to attach the geometry to
  115610. * @returns the new Geometry
  115611. */
  115612. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  115613. /** Get the list of meshes using this geometry */
  115614. get meshes(): Mesh[];
  115615. /**
  115616. * 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
  115617. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  115618. */
  115619. useBoundingInfoFromGeometry: boolean;
  115620. /**
  115621. * Creates a new geometry
  115622. * @param id defines the unique ID
  115623. * @param scene defines the hosting scene
  115624. * @param vertexData defines the VertexData used to get geometry data
  115625. * @param updatable defines if geometry must be updatable (false by default)
  115626. * @param mesh defines the mesh that will be associated with the geometry
  115627. */
  115628. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  115629. /**
  115630. * Gets the current extend of the geometry
  115631. */
  115632. get extend(): {
  115633. minimum: Vector3;
  115634. maximum: Vector3;
  115635. };
  115636. /**
  115637. * Gets the hosting scene
  115638. * @returns the hosting Scene
  115639. */
  115640. getScene(): Scene;
  115641. /**
  115642. * Gets the hosting engine
  115643. * @returns the hosting Engine
  115644. */
  115645. getEngine(): Engine;
  115646. /**
  115647. * Defines if the geometry is ready to use
  115648. * @returns true if the geometry is ready to be used
  115649. */
  115650. isReady(): boolean;
  115651. /**
  115652. * Gets a value indicating that the geometry should not be serialized
  115653. */
  115654. get doNotSerialize(): boolean;
  115655. /** @hidden */
  115656. _rebuild(): void;
  115657. /**
  115658. * Affects all geometry data in one call
  115659. * @param vertexData defines the geometry data
  115660. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  115661. */
  115662. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  115663. /**
  115664. * Set specific vertex data
  115665. * @param kind defines the data kind (Position, normal, etc...)
  115666. * @param data defines the vertex data to use
  115667. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  115668. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  115669. */
  115670. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  115671. /**
  115672. * Removes a specific vertex data
  115673. * @param kind defines the data kind (Position, normal, etc...)
  115674. */
  115675. removeVerticesData(kind: string): void;
  115676. /**
  115677. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  115678. * @param buffer defines the vertex buffer to use
  115679. * @param totalVertices defines the total number of vertices for position kind (could be null)
  115680. */
  115681. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  115682. /**
  115683. * Update a specific vertex buffer
  115684. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  115685. * It will do nothing if the buffer is not updatable
  115686. * @param kind defines the data kind (Position, normal, etc...)
  115687. * @param data defines the data to use
  115688. * @param offset defines the offset in the target buffer where to store the data
  115689. * @param useBytes set to true if the offset is in bytes
  115690. */
  115691. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  115692. /**
  115693. * Update a specific vertex buffer
  115694. * This function will create a new buffer if the current one is not updatable
  115695. * @param kind defines the data kind (Position, normal, etc...)
  115696. * @param data defines the data to use
  115697. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  115698. */
  115699. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  115700. private _updateBoundingInfo;
  115701. /** @hidden */
  115702. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  115703. /**
  115704. * Gets total number of vertices
  115705. * @returns the total number of vertices
  115706. */
  115707. getTotalVertices(): number;
  115708. /**
  115709. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  115710. * @param kind defines the data kind (Position, normal, etc...)
  115711. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115713. * @returns a float array containing vertex data
  115714. */
  115715. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  115716. /**
  115717. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  115718. * @param kind defines the data kind (Position, normal, etc...)
  115719. * @returns true if the vertex buffer with the specified kind is updatable
  115720. */
  115721. isVertexBufferUpdatable(kind: string): boolean;
  115722. /**
  115723. * Gets a specific vertex buffer
  115724. * @param kind defines the data kind (Position, normal, etc...)
  115725. * @returns a VertexBuffer
  115726. */
  115727. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  115728. /**
  115729. * Returns all vertex buffers
  115730. * @return an object holding all vertex buffers indexed by kind
  115731. */
  115732. getVertexBuffers(): Nullable<{
  115733. [key: string]: VertexBuffer;
  115734. }>;
  115735. /**
  115736. * Gets a boolean indicating if specific vertex buffer is present
  115737. * @param kind defines the data kind (Position, normal, etc...)
  115738. * @returns true if data is present
  115739. */
  115740. isVerticesDataPresent(kind: string): boolean;
  115741. /**
  115742. * Gets a list of all attached data kinds (Position, normal, etc...)
  115743. * @returns a list of string containing all kinds
  115744. */
  115745. getVerticesDataKinds(): string[];
  115746. /**
  115747. * Update index buffer
  115748. * @param indices defines the indices to store in the index buffer
  115749. * @param offset defines the offset in the target buffer where to store the data
  115750. * @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)
  115751. */
  115752. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  115753. /**
  115754. * Creates a new index buffer
  115755. * @param indices defines the indices to store in the index buffer
  115756. * @param totalVertices defines the total number of vertices (could be null)
  115757. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  115758. */
  115759. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  115760. /**
  115761. * Return the total number of indices
  115762. * @returns the total number of indices
  115763. */
  115764. getTotalIndices(): number;
  115765. /**
  115766. * Gets the index buffer array
  115767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115769. * @returns the index buffer array
  115770. */
  115771. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  115772. /**
  115773. * Gets the index buffer
  115774. * @return the index buffer
  115775. */
  115776. getIndexBuffer(): Nullable<DataBuffer>;
  115777. /** @hidden */
  115778. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  115779. /**
  115780. * Release the associated resources for a specific mesh
  115781. * @param mesh defines the source mesh
  115782. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  115783. */
  115784. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  115785. /**
  115786. * Apply current geometry to a given mesh
  115787. * @param mesh defines the mesh to apply geometry to
  115788. */
  115789. applyToMesh(mesh: Mesh): void;
  115790. private _updateExtend;
  115791. private _applyToMesh;
  115792. private notifyUpdate;
  115793. /**
  115794. * Load the geometry if it was flagged as delay loaded
  115795. * @param scene defines the hosting scene
  115796. * @param onLoaded defines a callback called when the geometry is loaded
  115797. */
  115798. load(scene: Scene, onLoaded?: () => void): void;
  115799. private _queueLoad;
  115800. /**
  115801. * Invert the geometry to move from a right handed system to a left handed one.
  115802. */
  115803. toLeftHanded(): void;
  115804. /** @hidden */
  115805. _resetPointsArrayCache(): void;
  115806. /** @hidden */
  115807. _generatePointsArray(): boolean;
  115808. /**
  115809. * Gets a value indicating if the geometry is disposed
  115810. * @returns true if the geometry was disposed
  115811. */
  115812. isDisposed(): boolean;
  115813. private _disposeVertexArrayObjects;
  115814. /**
  115815. * Free all associated resources
  115816. */
  115817. dispose(): void;
  115818. /**
  115819. * Clone the current geometry into a new geometry
  115820. * @param id defines the unique ID of the new geometry
  115821. * @returns a new geometry object
  115822. */
  115823. copy(id: string): Geometry;
  115824. /**
  115825. * Serialize the current geometry info (and not the vertices data) into a JSON object
  115826. * @return a JSON representation of the current geometry data (without the vertices data)
  115827. */
  115828. serialize(): any;
  115829. private toNumberArray;
  115830. /**
  115831. * Serialize all vertices data into a JSON oject
  115832. * @returns a JSON representation of the current geometry data
  115833. */
  115834. serializeVerticeData(): any;
  115835. /**
  115836. * Extracts a clone of a mesh geometry
  115837. * @param mesh defines the source mesh
  115838. * @param id defines the unique ID of the new geometry object
  115839. * @returns the new geometry object
  115840. */
  115841. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  115842. /**
  115843. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  115844. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115845. * Be aware Math.random() could cause collisions, but:
  115846. * "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"
  115847. * @returns a string containing a new GUID
  115848. */
  115849. static RandomId(): string;
  115850. /** @hidden */
  115851. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  115852. private static _CleanMatricesWeights;
  115853. /**
  115854. * Create a new geometry from persisted data (Using .babylon file format)
  115855. * @param parsedVertexData defines the persisted data
  115856. * @param scene defines the hosting scene
  115857. * @param rootUrl defines the root url to use to load assets (like delayed data)
  115858. * @returns the new geometry object
  115859. */
  115860. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  115861. }
  115862. }
  115863. declare module BABYLON {
  115864. /**
  115865. * Defines a target to use with MorphTargetManager
  115866. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  115867. */
  115868. export class MorphTarget implements IAnimatable {
  115869. /** defines the name of the target */
  115870. name: string;
  115871. /**
  115872. * Gets or sets the list of animations
  115873. */
  115874. animations: Animation[];
  115875. private _scene;
  115876. private _positions;
  115877. private _normals;
  115878. private _tangents;
  115879. private _uvs;
  115880. private _influence;
  115881. private _uniqueId;
  115882. /**
  115883. * Observable raised when the influence changes
  115884. */
  115885. onInfluenceChanged: Observable<boolean>;
  115886. /** @hidden */
  115887. _onDataLayoutChanged: Observable<void>;
  115888. /**
  115889. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  115890. */
  115891. get influence(): number;
  115892. set influence(influence: number);
  115893. /**
  115894. * Gets or sets the id of the morph Target
  115895. */
  115896. id: string;
  115897. private _animationPropertiesOverride;
  115898. /**
  115899. * Gets or sets the animation properties override
  115900. */
  115901. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115902. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115903. /**
  115904. * Creates a new MorphTarget
  115905. * @param name defines the name of the target
  115906. * @param influence defines the influence to use
  115907. * @param scene defines the scene the morphtarget belongs to
  115908. */
  115909. constructor(
  115910. /** defines the name of the target */
  115911. name: string, influence?: number, scene?: Nullable<Scene>);
  115912. /**
  115913. * Gets the unique ID of this manager
  115914. */
  115915. get uniqueId(): number;
  115916. /**
  115917. * Gets a boolean defining if the target contains position data
  115918. */
  115919. get hasPositions(): boolean;
  115920. /**
  115921. * Gets a boolean defining if the target contains normal data
  115922. */
  115923. get hasNormals(): boolean;
  115924. /**
  115925. * Gets a boolean defining if the target contains tangent data
  115926. */
  115927. get hasTangents(): boolean;
  115928. /**
  115929. * Gets a boolean defining if the target contains texture coordinates data
  115930. */
  115931. get hasUVs(): boolean;
  115932. /**
  115933. * Affects position data to this target
  115934. * @param data defines the position data to use
  115935. */
  115936. setPositions(data: Nullable<FloatArray>): void;
  115937. /**
  115938. * Gets the position data stored in this target
  115939. * @returns a FloatArray containing the position data (or null if not present)
  115940. */
  115941. getPositions(): Nullable<FloatArray>;
  115942. /**
  115943. * Affects normal data to this target
  115944. * @param data defines the normal data to use
  115945. */
  115946. setNormals(data: Nullable<FloatArray>): void;
  115947. /**
  115948. * Gets the normal data stored in this target
  115949. * @returns a FloatArray containing the normal data (or null if not present)
  115950. */
  115951. getNormals(): Nullable<FloatArray>;
  115952. /**
  115953. * Affects tangent data to this target
  115954. * @param data defines the tangent data to use
  115955. */
  115956. setTangents(data: Nullable<FloatArray>): void;
  115957. /**
  115958. * Gets the tangent data stored in this target
  115959. * @returns a FloatArray containing the tangent data (or null if not present)
  115960. */
  115961. getTangents(): Nullable<FloatArray>;
  115962. /**
  115963. * Affects texture coordinates data to this target
  115964. * @param data defines the texture coordinates data to use
  115965. */
  115966. setUVs(data: Nullable<FloatArray>): void;
  115967. /**
  115968. * Gets the texture coordinates data stored in this target
  115969. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  115970. */
  115971. getUVs(): Nullable<FloatArray>;
  115972. /**
  115973. * Clone the current target
  115974. * @returns a new MorphTarget
  115975. */
  115976. clone(): MorphTarget;
  115977. /**
  115978. * Serializes the current target into a Serialization object
  115979. * @returns the serialized object
  115980. */
  115981. serialize(): any;
  115982. /**
  115983. * Returns the string "MorphTarget"
  115984. * @returns "MorphTarget"
  115985. */
  115986. getClassName(): string;
  115987. /**
  115988. * Creates a new target from serialized data
  115989. * @param serializationObject defines the serialized data to use
  115990. * @returns a new MorphTarget
  115991. */
  115992. static Parse(serializationObject: any): MorphTarget;
  115993. /**
  115994. * Creates a MorphTarget from mesh data
  115995. * @param mesh defines the source mesh
  115996. * @param name defines the name to use for the new target
  115997. * @param influence defines the influence to attach to the target
  115998. * @returns a new MorphTarget
  115999. */
  116000. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  116001. }
  116002. }
  116003. declare module BABYLON {
  116004. /**
  116005. * This class is used to deform meshes using morphing between different targets
  116006. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  116007. */
  116008. export class MorphTargetManager {
  116009. private _targets;
  116010. private _targetInfluenceChangedObservers;
  116011. private _targetDataLayoutChangedObservers;
  116012. private _activeTargets;
  116013. private _scene;
  116014. private _influences;
  116015. private _supportsNormals;
  116016. private _supportsTangents;
  116017. private _supportsUVs;
  116018. private _vertexCount;
  116019. private _uniqueId;
  116020. private _tempInfluences;
  116021. /**
  116022. * Gets or sets a boolean indicating if normals must be morphed
  116023. */
  116024. enableNormalMorphing: boolean;
  116025. /**
  116026. * Gets or sets a boolean indicating if tangents must be morphed
  116027. */
  116028. enableTangentMorphing: boolean;
  116029. /**
  116030. * Gets or sets a boolean indicating if UV must be morphed
  116031. */
  116032. enableUVMorphing: boolean;
  116033. /**
  116034. * Creates a new MorphTargetManager
  116035. * @param scene defines the current scene
  116036. */
  116037. constructor(scene?: Nullable<Scene>);
  116038. /**
  116039. * Gets the unique ID of this manager
  116040. */
  116041. get uniqueId(): number;
  116042. /**
  116043. * Gets the number of vertices handled by this manager
  116044. */
  116045. get vertexCount(): number;
  116046. /**
  116047. * Gets a boolean indicating if this manager supports morphing of normals
  116048. */
  116049. get supportsNormals(): boolean;
  116050. /**
  116051. * Gets a boolean indicating if this manager supports morphing of tangents
  116052. */
  116053. get supportsTangents(): boolean;
  116054. /**
  116055. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  116056. */
  116057. get supportsUVs(): boolean;
  116058. /**
  116059. * Gets the number of targets stored in this manager
  116060. */
  116061. get numTargets(): number;
  116062. /**
  116063. * Gets the number of influencers (ie. the number of targets with influences > 0)
  116064. */
  116065. get numInfluencers(): number;
  116066. /**
  116067. * Gets the list of influences (one per target)
  116068. */
  116069. get influences(): Float32Array;
  116070. /**
  116071. * Gets the active target at specified index. An active target is a target with an influence > 0
  116072. * @param index defines the index to check
  116073. * @returns the requested target
  116074. */
  116075. getActiveTarget(index: number): MorphTarget;
  116076. /**
  116077. * Gets the target at specified index
  116078. * @param index defines the index to check
  116079. * @returns the requested target
  116080. */
  116081. getTarget(index: number): MorphTarget;
  116082. /**
  116083. * Add a new target to this manager
  116084. * @param target defines the target to add
  116085. */
  116086. addTarget(target: MorphTarget): void;
  116087. /**
  116088. * Removes a target from the manager
  116089. * @param target defines the target to remove
  116090. */
  116091. removeTarget(target: MorphTarget): void;
  116092. /**
  116093. * Clone the current manager
  116094. * @returns a new MorphTargetManager
  116095. */
  116096. clone(): MorphTargetManager;
  116097. /**
  116098. * Serializes the current manager into a Serialization object
  116099. * @returns the serialized object
  116100. */
  116101. serialize(): any;
  116102. private _syncActiveTargets;
  116103. /**
  116104. * Syncrhonize the targets with all the meshes using this morph target manager
  116105. */
  116106. synchronize(): void;
  116107. /**
  116108. * Creates a new MorphTargetManager from serialized data
  116109. * @param serializationObject defines the serialized data
  116110. * @param scene defines the hosting scene
  116111. * @returns the new MorphTargetManager
  116112. */
  116113. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  116114. }
  116115. }
  116116. declare module BABYLON {
  116117. /**
  116118. * Class used to represent a specific level of detail of a mesh
  116119. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  116120. */
  116121. export class MeshLODLevel {
  116122. /** Defines the distance where this level should start being displayed */
  116123. distance: number;
  116124. /** Defines the mesh to use to render this level */
  116125. mesh: Nullable<Mesh>;
  116126. /**
  116127. * Creates a new LOD level
  116128. * @param distance defines the distance where this level should star being displayed
  116129. * @param mesh defines the mesh to use to render this level
  116130. */
  116131. constructor(
  116132. /** Defines the distance where this level should start being displayed */
  116133. distance: number,
  116134. /** Defines the mesh to use to render this level */
  116135. mesh: Nullable<Mesh>);
  116136. }
  116137. }
  116138. declare module BABYLON {
  116139. /**
  116140. * Helper class used to generate a canvas to manipulate images
  116141. */
  116142. export class CanvasGenerator {
  116143. /**
  116144. * Create a new canvas (or offscreen canvas depending on the context)
  116145. * @param width defines the expected width
  116146. * @param height defines the expected height
  116147. * @return a new canvas or offscreen canvas
  116148. */
  116149. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  116150. }
  116151. }
  116152. declare module BABYLON {
  116153. /**
  116154. * Mesh representing the gorund
  116155. */
  116156. export class GroundMesh extends Mesh {
  116157. /** If octree should be generated */
  116158. generateOctree: boolean;
  116159. private _heightQuads;
  116160. /** @hidden */
  116161. _subdivisionsX: number;
  116162. /** @hidden */
  116163. _subdivisionsY: number;
  116164. /** @hidden */
  116165. _width: number;
  116166. /** @hidden */
  116167. _height: number;
  116168. /** @hidden */
  116169. _minX: number;
  116170. /** @hidden */
  116171. _maxX: number;
  116172. /** @hidden */
  116173. _minZ: number;
  116174. /** @hidden */
  116175. _maxZ: number;
  116176. constructor(name: string, scene: Scene);
  116177. /**
  116178. * "GroundMesh"
  116179. * @returns "GroundMesh"
  116180. */
  116181. getClassName(): string;
  116182. /**
  116183. * The minimum of x and y subdivisions
  116184. */
  116185. get subdivisions(): number;
  116186. /**
  116187. * X subdivisions
  116188. */
  116189. get subdivisionsX(): number;
  116190. /**
  116191. * Y subdivisions
  116192. */
  116193. get subdivisionsY(): number;
  116194. /**
  116195. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  116196. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116197. * @param chunksCount the number of subdivisions for x and y
  116198. * @param octreeBlocksSize (Default: 32)
  116199. */
  116200. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  116201. /**
  116202. * Returns a height (y) value in the Worl system :
  116203. * the ground altitude at the coordinates (x, z) expressed in the World system.
  116204. * @param x x coordinate
  116205. * @param z z coordinate
  116206. * @returns the ground y position if (x, z) are outside the ground surface.
  116207. */
  116208. getHeightAtCoordinates(x: number, z: number): number;
  116209. /**
  116210. * Returns a normalized vector (Vector3) orthogonal to the ground
  116211. * at the ground coordinates (x, z) expressed in the World system.
  116212. * @param x x coordinate
  116213. * @param z z coordinate
  116214. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  116215. */
  116216. getNormalAtCoordinates(x: number, z: number): Vector3;
  116217. /**
  116218. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  116219. * at the ground coordinates (x, z) expressed in the World system.
  116220. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  116221. * @param x x coordinate
  116222. * @param z z coordinate
  116223. * @param ref vector to store the result
  116224. * @returns the GroundMesh.
  116225. */
  116226. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  116227. /**
  116228. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  116229. * if the ground has been updated.
  116230. * This can be used in the render loop.
  116231. * @returns the GroundMesh.
  116232. */
  116233. updateCoordinateHeights(): GroundMesh;
  116234. private _getFacetAt;
  116235. private _initHeightQuads;
  116236. private _computeHeightQuads;
  116237. /**
  116238. * Serializes this ground mesh
  116239. * @param serializationObject object to write serialization to
  116240. */
  116241. serialize(serializationObject: any): void;
  116242. /**
  116243. * Parses a serialized ground mesh
  116244. * @param parsedMesh the serialized mesh
  116245. * @param scene the scene to create the ground mesh in
  116246. * @returns the created ground mesh
  116247. */
  116248. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  116249. }
  116250. }
  116251. declare module BABYLON {
  116252. /**
  116253. * Interface for Physics-Joint data
  116254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116255. */
  116256. export interface PhysicsJointData {
  116257. /**
  116258. * The main pivot of the joint
  116259. */
  116260. mainPivot?: Vector3;
  116261. /**
  116262. * The connected pivot of the joint
  116263. */
  116264. connectedPivot?: Vector3;
  116265. /**
  116266. * The main axis of the joint
  116267. */
  116268. mainAxis?: Vector3;
  116269. /**
  116270. * The connected axis of the joint
  116271. */
  116272. connectedAxis?: Vector3;
  116273. /**
  116274. * The collision of the joint
  116275. */
  116276. collision?: boolean;
  116277. /**
  116278. * Native Oimo/Cannon/Energy data
  116279. */
  116280. nativeParams?: any;
  116281. }
  116282. /**
  116283. * This is a holder class for the physics joint created by the physics plugin
  116284. * It holds a set of functions to control the underlying joint
  116285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116286. */
  116287. export class PhysicsJoint {
  116288. /**
  116289. * The type of the physics joint
  116290. */
  116291. type: number;
  116292. /**
  116293. * The data for the physics joint
  116294. */
  116295. jointData: PhysicsJointData;
  116296. private _physicsJoint;
  116297. protected _physicsPlugin: IPhysicsEnginePlugin;
  116298. /**
  116299. * Initializes the physics joint
  116300. * @param type The type of the physics joint
  116301. * @param jointData The data for the physics joint
  116302. */
  116303. constructor(
  116304. /**
  116305. * The type of the physics joint
  116306. */
  116307. type: number,
  116308. /**
  116309. * The data for the physics joint
  116310. */
  116311. jointData: PhysicsJointData);
  116312. /**
  116313. * Gets the physics joint
  116314. */
  116315. get physicsJoint(): any;
  116316. /**
  116317. * Sets the physics joint
  116318. */
  116319. set physicsJoint(newJoint: any);
  116320. /**
  116321. * Sets the physics plugin
  116322. */
  116323. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  116324. /**
  116325. * Execute a function that is physics-plugin specific.
  116326. * @param {Function} func the function that will be executed.
  116327. * It accepts two parameters: the physics world and the physics joint
  116328. */
  116329. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  116330. /**
  116331. * Distance-Joint type
  116332. */
  116333. static DistanceJoint: number;
  116334. /**
  116335. * Hinge-Joint type
  116336. */
  116337. static HingeJoint: number;
  116338. /**
  116339. * Ball-and-Socket joint type
  116340. */
  116341. static BallAndSocketJoint: number;
  116342. /**
  116343. * Wheel-Joint type
  116344. */
  116345. static WheelJoint: number;
  116346. /**
  116347. * Slider-Joint type
  116348. */
  116349. static SliderJoint: number;
  116350. /**
  116351. * Prismatic-Joint type
  116352. */
  116353. static PrismaticJoint: number;
  116354. /**
  116355. * Universal-Joint type
  116356. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  116357. */
  116358. static UniversalJoint: number;
  116359. /**
  116360. * Hinge-Joint 2 type
  116361. */
  116362. static Hinge2Joint: number;
  116363. /**
  116364. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  116365. */
  116366. static PointToPointJoint: number;
  116367. /**
  116368. * Spring-Joint type
  116369. */
  116370. static SpringJoint: number;
  116371. /**
  116372. * Lock-Joint type
  116373. */
  116374. static LockJoint: number;
  116375. }
  116376. /**
  116377. * A class representing a physics distance joint
  116378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116379. */
  116380. export class DistanceJoint extends PhysicsJoint {
  116381. /**
  116382. *
  116383. * @param jointData The data for the Distance-Joint
  116384. */
  116385. constructor(jointData: DistanceJointData);
  116386. /**
  116387. * Update the predefined distance.
  116388. * @param maxDistance The maximum preferred distance
  116389. * @param minDistance The minimum preferred distance
  116390. */
  116391. updateDistance(maxDistance: number, minDistance?: number): void;
  116392. }
  116393. /**
  116394. * Represents a Motor-Enabled Joint
  116395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116396. */
  116397. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  116398. /**
  116399. * Initializes the Motor-Enabled Joint
  116400. * @param type The type of the joint
  116401. * @param jointData The physica joint data for the joint
  116402. */
  116403. constructor(type: number, jointData: PhysicsJointData);
  116404. /**
  116405. * Set the motor values.
  116406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116407. * @param force the force to apply
  116408. * @param maxForce max force for this motor.
  116409. */
  116410. setMotor(force?: number, maxForce?: number): void;
  116411. /**
  116412. * Set the motor's limits.
  116413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116414. * @param upperLimit The upper limit of the motor
  116415. * @param lowerLimit The lower limit of the motor
  116416. */
  116417. setLimit(upperLimit: number, lowerLimit?: number): void;
  116418. }
  116419. /**
  116420. * This class represents a single physics Hinge-Joint
  116421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116422. */
  116423. export class HingeJoint extends MotorEnabledJoint {
  116424. /**
  116425. * Initializes the Hinge-Joint
  116426. * @param jointData The joint data for the Hinge-Joint
  116427. */
  116428. constructor(jointData: PhysicsJointData);
  116429. /**
  116430. * Set the motor values.
  116431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116432. * @param {number} force the force to apply
  116433. * @param {number} maxForce max force for this motor.
  116434. */
  116435. setMotor(force?: number, maxForce?: number): void;
  116436. /**
  116437. * Set the motor's limits.
  116438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116439. * @param upperLimit The upper limit of the motor
  116440. * @param lowerLimit The lower limit of the motor
  116441. */
  116442. setLimit(upperLimit: number, lowerLimit?: number): void;
  116443. }
  116444. /**
  116445. * This class represents a dual hinge physics joint (same as wheel joint)
  116446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116447. */
  116448. export class Hinge2Joint extends MotorEnabledJoint {
  116449. /**
  116450. * Initializes the Hinge2-Joint
  116451. * @param jointData The joint data for the Hinge2-Joint
  116452. */
  116453. constructor(jointData: PhysicsJointData);
  116454. /**
  116455. * Set the motor values.
  116456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116457. * @param {number} targetSpeed the speed the motor is to reach
  116458. * @param {number} maxForce max force for this motor.
  116459. * @param {motorIndex} the motor's index, 0 or 1.
  116460. */
  116461. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  116462. /**
  116463. * Set the motor limits.
  116464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116465. * @param {number} upperLimit the upper limit
  116466. * @param {number} lowerLimit lower limit
  116467. * @param {motorIndex} the motor's index, 0 or 1.
  116468. */
  116469. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116470. }
  116471. /**
  116472. * Interface for a motor enabled joint
  116473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116474. */
  116475. export interface IMotorEnabledJoint {
  116476. /**
  116477. * Physics joint
  116478. */
  116479. physicsJoint: any;
  116480. /**
  116481. * Sets the motor of the motor-enabled joint
  116482. * @param force The force of the motor
  116483. * @param maxForce The maximum force of the motor
  116484. * @param motorIndex The index of the motor
  116485. */
  116486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  116487. /**
  116488. * Sets the limit of the motor
  116489. * @param upperLimit The upper limit of the motor
  116490. * @param lowerLimit The lower limit of the motor
  116491. * @param motorIndex The index of the motor
  116492. */
  116493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116494. }
  116495. /**
  116496. * Joint data for a Distance-Joint
  116497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116498. */
  116499. export interface DistanceJointData extends PhysicsJointData {
  116500. /**
  116501. * Max distance the 2 joint objects can be apart
  116502. */
  116503. maxDistance: number;
  116504. }
  116505. /**
  116506. * Joint data from a spring joint
  116507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116508. */
  116509. export interface SpringJointData extends PhysicsJointData {
  116510. /**
  116511. * Length of the spring
  116512. */
  116513. length: number;
  116514. /**
  116515. * Stiffness of the spring
  116516. */
  116517. stiffness: number;
  116518. /**
  116519. * Damping of the spring
  116520. */
  116521. damping: number;
  116522. /** this callback will be called when applying the force to the impostors. */
  116523. forceApplicationCallback: () => void;
  116524. }
  116525. }
  116526. declare module BABYLON {
  116527. /**
  116528. * Holds the data for the raycast result
  116529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116530. */
  116531. export class PhysicsRaycastResult {
  116532. private _hasHit;
  116533. private _hitDistance;
  116534. private _hitNormalWorld;
  116535. private _hitPointWorld;
  116536. private _rayFromWorld;
  116537. private _rayToWorld;
  116538. /**
  116539. * Gets if there was a hit
  116540. */
  116541. get hasHit(): boolean;
  116542. /**
  116543. * Gets the distance from the hit
  116544. */
  116545. get hitDistance(): number;
  116546. /**
  116547. * Gets the hit normal/direction in the world
  116548. */
  116549. get hitNormalWorld(): Vector3;
  116550. /**
  116551. * Gets the hit point in the world
  116552. */
  116553. get hitPointWorld(): Vector3;
  116554. /**
  116555. * Gets the ray "start point" of the ray in the world
  116556. */
  116557. get rayFromWorld(): Vector3;
  116558. /**
  116559. * Gets the ray "end point" of the ray in the world
  116560. */
  116561. get rayToWorld(): Vector3;
  116562. /**
  116563. * Sets the hit data (normal & point in world space)
  116564. * @param hitNormalWorld defines the normal in world space
  116565. * @param hitPointWorld defines the point in world space
  116566. */
  116567. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  116568. /**
  116569. * Sets the distance from the start point to the hit point
  116570. * @param distance
  116571. */
  116572. setHitDistance(distance: number): void;
  116573. /**
  116574. * Calculates the distance manually
  116575. */
  116576. calculateHitDistance(): void;
  116577. /**
  116578. * Resets all the values to default
  116579. * @param from The from point on world space
  116580. * @param to The to point on world space
  116581. */
  116582. reset(from?: Vector3, to?: Vector3): void;
  116583. }
  116584. /**
  116585. * Interface for the size containing width and height
  116586. */
  116587. interface IXYZ {
  116588. /**
  116589. * X
  116590. */
  116591. x: number;
  116592. /**
  116593. * Y
  116594. */
  116595. y: number;
  116596. /**
  116597. * Z
  116598. */
  116599. z: number;
  116600. }
  116601. }
  116602. declare module BABYLON {
  116603. /**
  116604. * Interface used to describe a physics joint
  116605. */
  116606. export interface PhysicsImpostorJoint {
  116607. /** Defines the main impostor to which the joint is linked */
  116608. mainImpostor: PhysicsImpostor;
  116609. /** Defines the impostor that is connected to the main impostor using this joint */
  116610. connectedImpostor: PhysicsImpostor;
  116611. /** Defines the joint itself */
  116612. joint: PhysicsJoint;
  116613. }
  116614. /** @hidden */
  116615. export interface IPhysicsEnginePlugin {
  116616. world: any;
  116617. name: string;
  116618. setGravity(gravity: Vector3): void;
  116619. setTimeStep(timeStep: number): void;
  116620. getTimeStep(): number;
  116621. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116625. removePhysicsBody(impostor: PhysicsImpostor): void;
  116626. generateJoint(joint: PhysicsImpostorJoint): void;
  116627. removeJoint(joint: PhysicsImpostorJoint): void;
  116628. isSupported(): boolean;
  116629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  116632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  116633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116636. getBodyMass(impostor: PhysicsImpostor): number;
  116637. getBodyFriction(impostor: PhysicsImpostor): number;
  116638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116639. getBodyRestitution(impostor: PhysicsImpostor): number;
  116640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116641. getBodyPressure?(impostor: PhysicsImpostor): number;
  116642. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  116643. getBodyStiffness?(impostor: PhysicsImpostor): number;
  116644. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  116645. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  116646. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  116647. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  116648. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  116649. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  116650. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  116651. sleepBody(impostor: PhysicsImpostor): void;
  116652. wakeUpBody(impostor: PhysicsImpostor): void;
  116653. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116655. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  116656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116657. getRadius(impostor: PhysicsImpostor): number;
  116658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116660. dispose(): void;
  116661. }
  116662. /**
  116663. * Interface used to define a physics engine
  116664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116665. */
  116666. export interface IPhysicsEngine {
  116667. /**
  116668. * Gets the gravity vector used by the simulation
  116669. */
  116670. gravity: Vector3;
  116671. /**
  116672. * Sets the gravity vector used by the simulation
  116673. * @param gravity defines the gravity vector to use
  116674. */
  116675. setGravity(gravity: Vector3): void;
  116676. /**
  116677. * Set the time step of the physics engine.
  116678. * Default is 1/60.
  116679. * To slow it down, enter 1/600 for example.
  116680. * To speed it up, 1/30
  116681. * @param newTimeStep the new timestep to apply to this world.
  116682. */
  116683. setTimeStep(newTimeStep: number): void;
  116684. /**
  116685. * Get the time step of the physics engine.
  116686. * @returns the current time step
  116687. */
  116688. getTimeStep(): number;
  116689. /**
  116690. * Set the sub time step of the physics engine.
  116691. * Default is 0 meaning there is no sub steps
  116692. * To increase physics resolution precision, set a small value (like 1 ms)
  116693. * @param subTimeStep defines the new sub timestep used for physics resolution.
  116694. */
  116695. setSubTimeStep(subTimeStep: number): void;
  116696. /**
  116697. * Get the sub time step of the physics engine.
  116698. * @returns the current sub time step
  116699. */
  116700. getSubTimeStep(): number;
  116701. /**
  116702. * Release all resources
  116703. */
  116704. dispose(): void;
  116705. /**
  116706. * Gets the name of the current physics plugin
  116707. * @returns the name of the plugin
  116708. */
  116709. getPhysicsPluginName(): string;
  116710. /**
  116711. * Adding a new impostor for the impostor tracking.
  116712. * This will be done by the impostor itself.
  116713. * @param impostor the impostor to add
  116714. */
  116715. addImpostor(impostor: PhysicsImpostor): void;
  116716. /**
  116717. * Remove an impostor from the engine.
  116718. * This impostor and its mesh will not longer be updated by the physics engine.
  116719. * @param impostor the impostor to remove
  116720. */
  116721. removeImpostor(impostor: PhysicsImpostor): void;
  116722. /**
  116723. * Add a joint to the physics engine
  116724. * @param mainImpostor defines the main impostor to which the joint is added.
  116725. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116726. * @param joint defines the joint that will connect both impostors.
  116727. */
  116728. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116729. /**
  116730. * Removes a joint from the simulation
  116731. * @param mainImpostor defines the impostor used with the joint
  116732. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116733. * @param joint defines the joint to remove
  116734. */
  116735. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116736. /**
  116737. * Gets the current plugin used to run the simulation
  116738. * @returns current plugin
  116739. */
  116740. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116741. /**
  116742. * Gets the list of physic impostors
  116743. * @returns an array of PhysicsImpostor
  116744. */
  116745. getImpostors(): Array<PhysicsImpostor>;
  116746. /**
  116747. * Gets the impostor for a physics enabled object
  116748. * @param object defines the object impersonated by the impostor
  116749. * @returns the PhysicsImpostor or null if not found
  116750. */
  116751. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116752. /**
  116753. * Gets the impostor for a physics body object
  116754. * @param body defines physics body used by the impostor
  116755. * @returns the PhysicsImpostor or null if not found
  116756. */
  116757. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116758. /**
  116759. * Does a raycast in the physics world
  116760. * @param from when should the ray start?
  116761. * @param to when should the ray end?
  116762. * @returns PhysicsRaycastResult
  116763. */
  116764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116765. /**
  116766. * Called by the scene. No need to call it.
  116767. * @param delta defines the timespam between frames
  116768. */
  116769. _step(delta: number): void;
  116770. }
  116771. }
  116772. declare module BABYLON {
  116773. /**
  116774. * The interface for the physics imposter parameters
  116775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116776. */
  116777. export interface PhysicsImpostorParameters {
  116778. /**
  116779. * The mass of the physics imposter
  116780. */
  116781. mass: number;
  116782. /**
  116783. * The friction of the physics imposter
  116784. */
  116785. friction?: number;
  116786. /**
  116787. * The coefficient of restitution of the physics imposter
  116788. */
  116789. restitution?: number;
  116790. /**
  116791. * The native options of the physics imposter
  116792. */
  116793. nativeOptions?: any;
  116794. /**
  116795. * Specifies if the parent should be ignored
  116796. */
  116797. ignoreParent?: boolean;
  116798. /**
  116799. * Specifies if bi-directional transformations should be disabled
  116800. */
  116801. disableBidirectionalTransformation?: boolean;
  116802. /**
  116803. * The pressure inside the physics imposter, soft object only
  116804. */
  116805. pressure?: number;
  116806. /**
  116807. * The stiffness the physics imposter, soft object only
  116808. */
  116809. stiffness?: number;
  116810. /**
  116811. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  116812. */
  116813. velocityIterations?: number;
  116814. /**
  116815. * The number of iterations used in maintaining consistent vertex positions, soft object only
  116816. */
  116817. positionIterations?: number;
  116818. /**
  116819. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  116820. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  116821. * Add to fix multiple points
  116822. */
  116823. fixedPoints?: number;
  116824. /**
  116825. * The collision margin around a soft object
  116826. */
  116827. margin?: number;
  116828. /**
  116829. * The collision margin around a soft object
  116830. */
  116831. damping?: number;
  116832. /**
  116833. * The path for a rope based on an extrusion
  116834. */
  116835. path?: any;
  116836. /**
  116837. * The shape of an extrusion used for a rope based on an extrusion
  116838. */
  116839. shape?: any;
  116840. }
  116841. /**
  116842. * Interface for a physics-enabled object
  116843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116844. */
  116845. export interface IPhysicsEnabledObject {
  116846. /**
  116847. * The position of the physics-enabled object
  116848. */
  116849. position: Vector3;
  116850. /**
  116851. * The rotation of the physics-enabled object
  116852. */
  116853. rotationQuaternion: Nullable<Quaternion>;
  116854. /**
  116855. * The scale of the physics-enabled object
  116856. */
  116857. scaling: Vector3;
  116858. /**
  116859. * The rotation of the physics-enabled object
  116860. */
  116861. rotation?: Vector3;
  116862. /**
  116863. * The parent of the physics-enabled object
  116864. */
  116865. parent?: any;
  116866. /**
  116867. * The bounding info of the physics-enabled object
  116868. * @returns The bounding info of the physics-enabled object
  116869. */
  116870. getBoundingInfo(): BoundingInfo;
  116871. /**
  116872. * Computes the world matrix
  116873. * @param force Specifies if the world matrix should be computed by force
  116874. * @returns A world matrix
  116875. */
  116876. computeWorldMatrix(force: boolean): Matrix;
  116877. /**
  116878. * Gets the world matrix
  116879. * @returns A world matrix
  116880. */
  116881. getWorldMatrix?(): Matrix;
  116882. /**
  116883. * Gets the child meshes
  116884. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  116885. * @returns An array of abstract meshes
  116886. */
  116887. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  116888. /**
  116889. * Gets the vertex data
  116890. * @param kind The type of vertex data
  116891. * @returns A nullable array of numbers, or a float32 array
  116892. */
  116893. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  116894. /**
  116895. * Gets the indices from the mesh
  116896. * @returns A nullable array of index arrays
  116897. */
  116898. getIndices?(): Nullable<IndicesArray>;
  116899. /**
  116900. * Gets the scene from the mesh
  116901. * @returns the indices array or null
  116902. */
  116903. getScene?(): Scene;
  116904. /**
  116905. * Gets the absolute position from the mesh
  116906. * @returns the absolute position
  116907. */
  116908. getAbsolutePosition(): Vector3;
  116909. /**
  116910. * Gets the absolute pivot point from the mesh
  116911. * @returns the absolute pivot point
  116912. */
  116913. getAbsolutePivotPoint(): Vector3;
  116914. /**
  116915. * Rotates the mesh
  116916. * @param axis The axis of rotation
  116917. * @param amount The amount of rotation
  116918. * @param space The space of the rotation
  116919. * @returns The rotation transform node
  116920. */
  116921. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  116922. /**
  116923. * Translates the mesh
  116924. * @param axis The axis of translation
  116925. * @param distance The distance of translation
  116926. * @param space The space of the translation
  116927. * @returns The transform node
  116928. */
  116929. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  116930. /**
  116931. * Sets the absolute position of the mesh
  116932. * @param absolutePosition The absolute position of the mesh
  116933. * @returns The transform node
  116934. */
  116935. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  116936. /**
  116937. * Gets the class name of the mesh
  116938. * @returns The class name
  116939. */
  116940. getClassName(): string;
  116941. }
  116942. /**
  116943. * Represents a physics imposter
  116944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116945. */
  116946. export class PhysicsImpostor {
  116947. /**
  116948. * The physics-enabled object used as the physics imposter
  116949. */
  116950. object: IPhysicsEnabledObject;
  116951. /**
  116952. * The type of the physics imposter
  116953. */
  116954. type: number;
  116955. private _options;
  116956. private _scene?;
  116957. /**
  116958. * The default object size of the imposter
  116959. */
  116960. static DEFAULT_OBJECT_SIZE: Vector3;
  116961. /**
  116962. * The identity quaternion of the imposter
  116963. */
  116964. static IDENTITY_QUATERNION: Quaternion;
  116965. /** @hidden */
  116966. _pluginData: any;
  116967. private _physicsEngine;
  116968. private _physicsBody;
  116969. private _bodyUpdateRequired;
  116970. private _onBeforePhysicsStepCallbacks;
  116971. private _onAfterPhysicsStepCallbacks;
  116972. /** @hidden */
  116973. _onPhysicsCollideCallbacks: Array<{
  116974. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  116975. otherImpostors: Array<PhysicsImpostor>;
  116976. }>;
  116977. private _deltaPosition;
  116978. private _deltaRotation;
  116979. private _deltaRotationConjugated;
  116980. /** @hidden */
  116981. _isFromLine: boolean;
  116982. private _parent;
  116983. private _isDisposed;
  116984. private static _tmpVecs;
  116985. private static _tmpQuat;
  116986. /**
  116987. * Specifies if the physics imposter is disposed
  116988. */
  116989. get isDisposed(): boolean;
  116990. /**
  116991. * Gets the mass of the physics imposter
  116992. */
  116993. get mass(): number;
  116994. set mass(value: number);
  116995. /**
  116996. * Gets the coefficient of friction
  116997. */
  116998. get friction(): number;
  116999. /**
  117000. * Sets the coefficient of friction
  117001. */
  117002. set friction(value: number);
  117003. /**
  117004. * Gets the coefficient of restitution
  117005. */
  117006. get restitution(): number;
  117007. /**
  117008. * Sets the coefficient of restitution
  117009. */
  117010. set restitution(value: number);
  117011. /**
  117012. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117013. */
  117014. get pressure(): number;
  117015. /**
  117016. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117017. */
  117018. set pressure(value: number);
  117019. /**
  117020. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117021. */
  117022. get stiffness(): number;
  117023. /**
  117024. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117025. */
  117026. set stiffness(value: number);
  117027. /**
  117028. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117029. */
  117030. get velocityIterations(): number;
  117031. /**
  117032. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117033. */
  117034. set velocityIterations(value: number);
  117035. /**
  117036. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117037. */
  117038. get positionIterations(): number;
  117039. /**
  117040. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117041. */
  117042. set positionIterations(value: number);
  117043. /**
  117044. * The unique id of the physics imposter
  117045. * set by the physics engine when adding this impostor to the array
  117046. */
  117047. uniqueId: number;
  117048. /**
  117049. * @hidden
  117050. */
  117051. soft: boolean;
  117052. /**
  117053. * @hidden
  117054. */
  117055. segments: number;
  117056. private _joints;
  117057. /**
  117058. * Initializes the physics imposter
  117059. * @param object The physics-enabled object used as the physics imposter
  117060. * @param type The type of the physics imposter
  117061. * @param _options The options for the physics imposter
  117062. * @param _scene The Babylon scene
  117063. */
  117064. constructor(
  117065. /**
  117066. * The physics-enabled object used as the physics imposter
  117067. */
  117068. object: IPhysicsEnabledObject,
  117069. /**
  117070. * The type of the physics imposter
  117071. */
  117072. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  117073. /**
  117074. * This function will completly initialize this impostor.
  117075. * It will create a new body - but only if this mesh has no parent.
  117076. * If it has, this impostor will not be used other than to define the impostor
  117077. * of the child mesh.
  117078. * @hidden
  117079. */
  117080. _init(): void;
  117081. private _getPhysicsParent;
  117082. /**
  117083. * Should a new body be generated.
  117084. * @returns boolean specifying if body initialization is required
  117085. */
  117086. isBodyInitRequired(): boolean;
  117087. /**
  117088. * Sets the updated scaling
  117089. * @param updated Specifies if the scaling is updated
  117090. */
  117091. setScalingUpdated(): void;
  117092. /**
  117093. * Force a regeneration of this or the parent's impostor's body.
  117094. * Use under cautious - This will remove all joints already implemented.
  117095. */
  117096. forceUpdate(): void;
  117097. /**
  117098. * Gets the body that holds this impostor. Either its own, or its parent.
  117099. */
  117100. get physicsBody(): any;
  117101. /**
  117102. * Get the parent of the physics imposter
  117103. * @returns Physics imposter or null
  117104. */
  117105. get parent(): Nullable<PhysicsImpostor>;
  117106. /**
  117107. * Sets the parent of the physics imposter
  117108. */
  117109. set parent(value: Nullable<PhysicsImpostor>);
  117110. /**
  117111. * Set the physics body. Used mainly by the physics engine/plugin
  117112. */
  117113. set physicsBody(physicsBody: any);
  117114. /**
  117115. * Resets the update flags
  117116. */
  117117. resetUpdateFlags(): void;
  117118. /**
  117119. * Gets the object extend size
  117120. * @returns the object extend size
  117121. */
  117122. getObjectExtendSize(): Vector3;
  117123. /**
  117124. * Gets the object center
  117125. * @returns The object center
  117126. */
  117127. getObjectCenter(): Vector3;
  117128. /**
  117129. * Get a specific parameter from the options parameters
  117130. * @param paramName The object parameter name
  117131. * @returns The object parameter
  117132. */
  117133. getParam(paramName: string): any;
  117134. /**
  117135. * Sets a specific parameter in the options given to the physics plugin
  117136. * @param paramName The parameter name
  117137. * @param value The value of the parameter
  117138. */
  117139. setParam(paramName: string, value: number): void;
  117140. /**
  117141. * Specifically change the body's mass option. Won't recreate the physics body object
  117142. * @param mass The mass of the physics imposter
  117143. */
  117144. setMass(mass: number): void;
  117145. /**
  117146. * Gets the linear velocity
  117147. * @returns linear velocity or null
  117148. */
  117149. getLinearVelocity(): Nullable<Vector3>;
  117150. /**
  117151. * Sets the linear velocity
  117152. * @param velocity linear velocity or null
  117153. */
  117154. setLinearVelocity(velocity: Nullable<Vector3>): void;
  117155. /**
  117156. * Gets the angular velocity
  117157. * @returns angular velocity or null
  117158. */
  117159. getAngularVelocity(): Nullable<Vector3>;
  117160. /**
  117161. * Sets the angular velocity
  117162. * @param velocity The velocity or null
  117163. */
  117164. setAngularVelocity(velocity: Nullable<Vector3>): void;
  117165. /**
  117166. * Execute a function with the physics plugin native code
  117167. * Provide a function the will have two variables - the world object and the physics body object
  117168. * @param func The function to execute with the physics plugin native code
  117169. */
  117170. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  117171. /**
  117172. * Register a function that will be executed before the physics world is stepping forward
  117173. * @param func The function to execute before the physics world is stepped forward
  117174. */
  117175. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117176. /**
  117177. * Unregister a function that will be executed before the physics world is stepping forward
  117178. * @param func The function to execute before the physics world is stepped forward
  117179. */
  117180. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117181. /**
  117182. * Register a function that will be executed after the physics step
  117183. * @param func The function to execute after physics step
  117184. */
  117185. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117186. /**
  117187. * Unregisters a function that will be executed after the physics step
  117188. * @param func The function to execute after physics step
  117189. */
  117190. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117191. /**
  117192. * register a function that will be executed when this impostor collides against a different body
  117193. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  117194. * @param func Callback that is executed on collision
  117195. */
  117196. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  117197. /**
  117198. * Unregisters the physics imposter on contact
  117199. * @param collideAgainst The physics object to collide against
  117200. * @param func Callback to execute on collision
  117201. */
  117202. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  117203. private _tmpQuat;
  117204. private _tmpQuat2;
  117205. /**
  117206. * Get the parent rotation
  117207. * @returns The parent rotation
  117208. */
  117209. getParentsRotation(): Quaternion;
  117210. /**
  117211. * this function is executed by the physics engine.
  117212. */
  117213. beforeStep: () => void;
  117214. /**
  117215. * this function is executed by the physics engine
  117216. */
  117217. afterStep: () => void;
  117218. /**
  117219. * Legacy collision detection event support
  117220. */
  117221. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  117222. /**
  117223. * event and body object due to cannon's event-based architecture.
  117224. */
  117225. onCollide: (e: {
  117226. body: any;
  117227. point: Nullable<Vector3>;
  117228. }) => void;
  117229. /**
  117230. * Apply a force
  117231. * @param force The force to apply
  117232. * @param contactPoint The contact point for the force
  117233. * @returns The physics imposter
  117234. */
  117235. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117236. /**
  117237. * Apply an impulse
  117238. * @param force The impulse force
  117239. * @param contactPoint The contact point for the impulse force
  117240. * @returns The physics imposter
  117241. */
  117242. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117243. /**
  117244. * A help function to create a joint
  117245. * @param otherImpostor A physics imposter used to create a joint
  117246. * @param jointType The type of joint
  117247. * @param jointData The data for the joint
  117248. * @returns The physics imposter
  117249. */
  117250. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  117251. /**
  117252. * Add a joint to this impostor with a different impostor
  117253. * @param otherImpostor A physics imposter used to add a joint
  117254. * @param joint The joint to add
  117255. * @returns The physics imposter
  117256. */
  117257. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  117258. /**
  117259. * Add an anchor to a cloth impostor
  117260. * @param otherImpostor rigid impostor to anchor to
  117261. * @param width ratio across width from 0 to 1
  117262. * @param height ratio up height from 0 to 1
  117263. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117264. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  117265. * @returns impostor the soft imposter
  117266. */
  117267. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117268. /**
  117269. * Add a hook to a rope impostor
  117270. * @param otherImpostor rigid impostor to anchor to
  117271. * @param length ratio across rope from 0 to 1
  117272. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  117273. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117274. * @returns impostor the rope imposter
  117275. */
  117276. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117277. /**
  117278. * Will keep this body still, in a sleep mode.
  117279. * @returns the physics imposter
  117280. */
  117281. sleep(): PhysicsImpostor;
  117282. /**
  117283. * Wake the body up.
  117284. * @returns The physics imposter
  117285. */
  117286. wakeUp(): PhysicsImpostor;
  117287. /**
  117288. * Clones the physics imposter
  117289. * @param newObject The physics imposter clones to this physics-enabled object
  117290. * @returns A nullable physics imposter
  117291. */
  117292. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117293. /**
  117294. * Disposes the physics imposter
  117295. */
  117296. dispose(): void;
  117297. /**
  117298. * Sets the delta position
  117299. * @param position The delta position amount
  117300. */
  117301. setDeltaPosition(position: Vector3): void;
  117302. /**
  117303. * Sets the delta rotation
  117304. * @param rotation The delta rotation amount
  117305. */
  117306. setDeltaRotation(rotation: Quaternion): void;
  117307. /**
  117308. * Gets the box size of the physics imposter and stores the result in the input parameter
  117309. * @param result Stores the box size
  117310. * @returns The physics imposter
  117311. */
  117312. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  117313. /**
  117314. * Gets the radius of the physics imposter
  117315. * @returns Radius of the physics imposter
  117316. */
  117317. getRadius(): number;
  117318. /**
  117319. * Sync a bone with this impostor
  117320. * @param bone The bone to sync to the impostor.
  117321. * @param boneMesh The mesh that the bone is influencing.
  117322. * @param jointPivot The pivot of the joint / bone in local space.
  117323. * @param distToJoint Optional distance from the impostor to the joint.
  117324. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117325. */
  117326. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  117327. /**
  117328. * Sync impostor to a bone
  117329. * @param bone The bone that the impostor will be synced to.
  117330. * @param boneMesh The mesh that the bone is influencing.
  117331. * @param jointPivot The pivot of the joint / bone in local space.
  117332. * @param distToJoint Optional distance from the impostor to the joint.
  117333. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117334. * @param boneAxis Optional vector3 axis the bone is aligned with
  117335. */
  117336. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  117337. /**
  117338. * No-Imposter type
  117339. */
  117340. static NoImpostor: number;
  117341. /**
  117342. * Sphere-Imposter type
  117343. */
  117344. static SphereImpostor: number;
  117345. /**
  117346. * Box-Imposter type
  117347. */
  117348. static BoxImpostor: number;
  117349. /**
  117350. * Plane-Imposter type
  117351. */
  117352. static PlaneImpostor: number;
  117353. /**
  117354. * Mesh-imposter type
  117355. */
  117356. static MeshImpostor: number;
  117357. /**
  117358. * Capsule-Impostor type (Ammo.js plugin only)
  117359. */
  117360. static CapsuleImpostor: number;
  117361. /**
  117362. * Cylinder-Imposter type
  117363. */
  117364. static CylinderImpostor: number;
  117365. /**
  117366. * Particle-Imposter type
  117367. */
  117368. static ParticleImpostor: number;
  117369. /**
  117370. * Heightmap-Imposter type
  117371. */
  117372. static HeightmapImpostor: number;
  117373. /**
  117374. * ConvexHull-Impostor type (Ammo.js plugin only)
  117375. */
  117376. static ConvexHullImpostor: number;
  117377. /**
  117378. * Custom-Imposter type (Ammo.js plugin only)
  117379. */
  117380. static CustomImpostor: number;
  117381. /**
  117382. * Rope-Imposter type
  117383. */
  117384. static RopeImpostor: number;
  117385. /**
  117386. * Cloth-Imposter type
  117387. */
  117388. static ClothImpostor: number;
  117389. /**
  117390. * Softbody-Imposter type
  117391. */
  117392. static SoftbodyImpostor: number;
  117393. }
  117394. }
  117395. declare module BABYLON {
  117396. /**
  117397. * @hidden
  117398. **/
  117399. export class _CreationDataStorage {
  117400. closePath?: boolean;
  117401. closeArray?: boolean;
  117402. idx: number[];
  117403. dashSize: number;
  117404. gapSize: number;
  117405. path3D: Path3D;
  117406. pathArray: Vector3[][];
  117407. arc: number;
  117408. radius: number;
  117409. cap: number;
  117410. tessellation: number;
  117411. }
  117412. /**
  117413. * @hidden
  117414. **/
  117415. class _InstanceDataStorage {
  117416. visibleInstances: any;
  117417. batchCache: _InstancesBatch;
  117418. instancesBufferSize: number;
  117419. instancesBuffer: Nullable<Buffer>;
  117420. instancesData: Float32Array;
  117421. overridenInstanceCount: number;
  117422. isFrozen: boolean;
  117423. previousBatch: Nullable<_InstancesBatch>;
  117424. hardwareInstancedRendering: boolean;
  117425. sideOrientation: number;
  117426. manualUpdate: boolean;
  117427. previousRenderId: number;
  117428. }
  117429. /**
  117430. * @hidden
  117431. **/
  117432. export class _InstancesBatch {
  117433. mustReturn: boolean;
  117434. visibleInstances: Nullable<InstancedMesh[]>[];
  117435. renderSelf: boolean[];
  117436. hardwareInstancedRendering: boolean[];
  117437. }
  117438. /**
  117439. * @hidden
  117440. **/
  117441. class _ThinInstanceDataStorage {
  117442. instancesCount: number;
  117443. matrixBuffer: Nullable<Buffer>;
  117444. matrixBufferSize: number;
  117445. matrixData: Nullable<Float32Array>;
  117446. boundingVectors: Array<Vector3>;
  117447. worldMatrices: Nullable<Matrix[]>;
  117448. }
  117449. /**
  117450. * Class used to represent renderable models
  117451. */
  117452. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  117453. /**
  117454. * Mesh side orientation : usually the external or front surface
  117455. */
  117456. static readonly FRONTSIDE: number;
  117457. /**
  117458. * Mesh side orientation : usually the internal or back surface
  117459. */
  117460. static readonly BACKSIDE: number;
  117461. /**
  117462. * Mesh side orientation : both internal and external or front and back surfaces
  117463. */
  117464. static readonly DOUBLESIDE: number;
  117465. /**
  117466. * Mesh side orientation : by default, `FRONTSIDE`
  117467. */
  117468. static readonly DEFAULTSIDE: number;
  117469. /**
  117470. * Mesh cap setting : no cap
  117471. */
  117472. static readonly NO_CAP: number;
  117473. /**
  117474. * Mesh cap setting : one cap at the beginning of the mesh
  117475. */
  117476. static readonly CAP_START: number;
  117477. /**
  117478. * Mesh cap setting : one cap at the end of the mesh
  117479. */
  117480. static readonly CAP_END: number;
  117481. /**
  117482. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  117483. */
  117484. static readonly CAP_ALL: number;
  117485. /**
  117486. * Mesh pattern setting : no flip or rotate
  117487. */
  117488. static readonly NO_FLIP: number;
  117489. /**
  117490. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  117491. */
  117492. static readonly FLIP_TILE: number;
  117493. /**
  117494. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  117495. */
  117496. static readonly ROTATE_TILE: number;
  117497. /**
  117498. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  117499. */
  117500. static readonly FLIP_ROW: number;
  117501. /**
  117502. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  117503. */
  117504. static readonly ROTATE_ROW: number;
  117505. /**
  117506. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  117507. */
  117508. static readonly FLIP_N_ROTATE_TILE: number;
  117509. /**
  117510. * Mesh pattern setting : rotate pattern and rotate
  117511. */
  117512. static readonly FLIP_N_ROTATE_ROW: number;
  117513. /**
  117514. * Mesh tile positioning : part tiles same on left/right or top/bottom
  117515. */
  117516. static readonly CENTER: number;
  117517. /**
  117518. * Mesh tile positioning : part tiles on left
  117519. */
  117520. static readonly LEFT: number;
  117521. /**
  117522. * Mesh tile positioning : part tiles on right
  117523. */
  117524. static readonly RIGHT: number;
  117525. /**
  117526. * Mesh tile positioning : part tiles on top
  117527. */
  117528. static readonly TOP: number;
  117529. /**
  117530. * Mesh tile positioning : part tiles on bottom
  117531. */
  117532. static readonly BOTTOM: number;
  117533. /**
  117534. * Gets the default side orientation.
  117535. * @param orientation the orientation to value to attempt to get
  117536. * @returns the default orientation
  117537. * @hidden
  117538. */
  117539. static _GetDefaultSideOrientation(orientation?: number): number;
  117540. private _internalMeshDataInfo;
  117541. get computeBonesUsingShaders(): boolean;
  117542. set computeBonesUsingShaders(value: boolean);
  117543. /**
  117544. * An event triggered before rendering the mesh
  117545. */
  117546. get onBeforeRenderObservable(): Observable<Mesh>;
  117547. /**
  117548. * An event triggered before binding the mesh
  117549. */
  117550. get onBeforeBindObservable(): Observable<Mesh>;
  117551. /**
  117552. * An event triggered after rendering the mesh
  117553. */
  117554. get onAfterRenderObservable(): Observable<Mesh>;
  117555. /**
  117556. * An event triggered before drawing the mesh
  117557. */
  117558. get onBeforeDrawObservable(): Observable<Mesh>;
  117559. private _onBeforeDrawObserver;
  117560. /**
  117561. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  117562. */
  117563. set onBeforeDraw(callback: () => void);
  117564. get hasInstances(): boolean;
  117565. get hasThinInstances(): boolean;
  117566. /**
  117567. * Gets the delay loading state of the mesh (when delay loading is turned on)
  117568. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  117569. */
  117570. delayLoadState: number;
  117571. /**
  117572. * Gets the list of instances created from this mesh
  117573. * it is not supposed to be modified manually.
  117574. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  117575. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117576. */
  117577. instances: InstancedMesh[];
  117578. /**
  117579. * Gets the file containing delay loading data for this mesh
  117580. */
  117581. delayLoadingFile: string;
  117582. /** @hidden */
  117583. _binaryInfo: any;
  117584. /**
  117585. * User defined function used to change how LOD level selection is done
  117586. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117587. */
  117588. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  117589. /**
  117590. * Gets or sets the morph target manager
  117591. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  117592. */
  117593. get morphTargetManager(): Nullable<MorphTargetManager>;
  117594. set morphTargetManager(value: Nullable<MorphTargetManager>);
  117595. /** @hidden */
  117596. _creationDataStorage: Nullable<_CreationDataStorage>;
  117597. /** @hidden */
  117598. _geometry: Nullable<Geometry>;
  117599. /** @hidden */
  117600. _delayInfo: Array<string>;
  117601. /** @hidden */
  117602. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  117603. /** @hidden */
  117604. _instanceDataStorage: _InstanceDataStorage;
  117605. /** @hidden */
  117606. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  117607. private _effectiveMaterial;
  117608. /** @hidden */
  117609. _shouldGenerateFlatShading: boolean;
  117610. /** @hidden */
  117611. _originalBuilderSideOrientation: number;
  117612. /**
  117613. * Use this property to change the original side orientation defined at construction time
  117614. */
  117615. overrideMaterialSideOrientation: Nullable<number>;
  117616. /**
  117617. * Gets the source mesh (the one used to clone this one from)
  117618. */
  117619. get source(): Nullable<Mesh>;
  117620. /**
  117621. * Gets the list of clones of this mesh
  117622. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  117623. * Note that useClonedMeshMap=true is the default setting
  117624. */
  117625. get cloneMeshMap(): Nullable<{
  117626. [id: string]: Mesh | undefined;
  117627. }>;
  117628. /**
  117629. * Gets or sets a boolean indicating that this mesh does not use index buffer
  117630. */
  117631. get isUnIndexed(): boolean;
  117632. set isUnIndexed(value: boolean);
  117633. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  117634. get worldMatrixInstancedBuffer(): Float32Array;
  117635. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  117636. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  117637. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  117638. /**
  117639. * @constructor
  117640. * @param name The value used by scene.getMeshByName() to do a lookup.
  117641. * @param scene The scene to add this mesh to.
  117642. * @param parent The parent of this mesh, if it has one
  117643. * @param source An optional Mesh from which geometry is shared, cloned.
  117644. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  117645. * When false, achieved by calling a clone(), also passing False.
  117646. * This will make creation of children, recursive.
  117647. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  117648. */
  117649. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  117650. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  117651. doNotInstantiate: boolean;
  117652. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  117653. /**
  117654. * Gets the class name
  117655. * @returns the string "Mesh".
  117656. */
  117657. getClassName(): string;
  117658. /** @hidden */
  117659. get _isMesh(): boolean;
  117660. /**
  117661. * Returns a description of this mesh
  117662. * @param fullDetails define if full details about this mesh must be used
  117663. * @returns a descriptive string representing this mesh
  117664. */
  117665. toString(fullDetails?: boolean): string;
  117666. /** @hidden */
  117667. _unBindEffect(): void;
  117668. /**
  117669. * Gets a boolean indicating if this mesh has LOD
  117670. */
  117671. get hasLODLevels(): boolean;
  117672. /**
  117673. * Gets the list of MeshLODLevel associated with the current mesh
  117674. * @returns an array of MeshLODLevel
  117675. */
  117676. getLODLevels(): MeshLODLevel[];
  117677. private _sortLODLevels;
  117678. /**
  117679. * Add a mesh as LOD level triggered at the given distance.
  117680. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117681. * @param distance The distance from the center of the object to show this level
  117682. * @param mesh The mesh to be added as LOD level (can be null)
  117683. * @return This mesh (for chaining)
  117684. */
  117685. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  117686. /**
  117687. * Returns the LOD level mesh at the passed distance or null if not found.
  117688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117689. * @param distance The distance from the center of the object to show this level
  117690. * @returns a Mesh or `null`
  117691. */
  117692. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  117693. /**
  117694. * Remove a mesh from the LOD array
  117695. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117696. * @param mesh defines the mesh to be removed
  117697. * @return This mesh (for chaining)
  117698. */
  117699. removeLODLevel(mesh: Mesh): Mesh;
  117700. /**
  117701. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  117702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117703. * @param camera defines the camera to use to compute distance
  117704. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  117705. * @return This mesh (for chaining)
  117706. */
  117707. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  117708. /**
  117709. * Gets the mesh internal Geometry object
  117710. */
  117711. get geometry(): Nullable<Geometry>;
  117712. /**
  117713. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  117714. * @returns the total number of vertices
  117715. */
  117716. getTotalVertices(): number;
  117717. /**
  117718. * Returns the content of an associated vertex buffer
  117719. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  117720. * - VertexBuffer.PositionKind
  117721. * - VertexBuffer.UVKind
  117722. * - VertexBuffer.UV2Kind
  117723. * - VertexBuffer.UV3Kind
  117724. * - VertexBuffer.UV4Kind
  117725. * - VertexBuffer.UV5Kind
  117726. * - VertexBuffer.UV6Kind
  117727. * - VertexBuffer.ColorKind
  117728. * - VertexBuffer.MatricesIndicesKind
  117729. * - VertexBuffer.MatricesIndicesExtraKind
  117730. * - VertexBuffer.MatricesWeightsKind
  117731. * - VertexBuffer.MatricesWeightsExtraKind
  117732. * @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
  117733. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  117734. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  117735. */
  117736. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  117737. /**
  117738. * Returns the mesh VertexBuffer object from the requested `kind`
  117739. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  117740. * - VertexBuffer.PositionKind
  117741. * - VertexBuffer.NormalKind
  117742. * - VertexBuffer.UVKind
  117743. * - VertexBuffer.UV2Kind
  117744. * - VertexBuffer.UV3Kind
  117745. * - VertexBuffer.UV4Kind
  117746. * - VertexBuffer.UV5Kind
  117747. * - VertexBuffer.UV6Kind
  117748. * - VertexBuffer.ColorKind
  117749. * - VertexBuffer.MatricesIndicesKind
  117750. * - VertexBuffer.MatricesIndicesExtraKind
  117751. * - VertexBuffer.MatricesWeightsKind
  117752. * - VertexBuffer.MatricesWeightsExtraKind
  117753. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  117754. */
  117755. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  117756. /**
  117757. * Tests if a specific vertex buffer is associated with this mesh
  117758. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  117759. * - VertexBuffer.PositionKind
  117760. * - VertexBuffer.NormalKind
  117761. * - VertexBuffer.UVKind
  117762. * - VertexBuffer.UV2Kind
  117763. * - VertexBuffer.UV3Kind
  117764. * - VertexBuffer.UV4Kind
  117765. * - VertexBuffer.UV5Kind
  117766. * - VertexBuffer.UV6Kind
  117767. * - VertexBuffer.ColorKind
  117768. * - VertexBuffer.MatricesIndicesKind
  117769. * - VertexBuffer.MatricesIndicesExtraKind
  117770. * - VertexBuffer.MatricesWeightsKind
  117771. * - VertexBuffer.MatricesWeightsExtraKind
  117772. * @returns a boolean
  117773. */
  117774. isVerticesDataPresent(kind: string): boolean;
  117775. /**
  117776. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  117777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  117778. * - VertexBuffer.PositionKind
  117779. * - VertexBuffer.UVKind
  117780. * - VertexBuffer.UV2Kind
  117781. * - VertexBuffer.UV3Kind
  117782. * - VertexBuffer.UV4Kind
  117783. * - VertexBuffer.UV5Kind
  117784. * - VertexBuffer.UV6Kind
  117785. * - VertexBuffer.ColorKind
  117786. * - VertexBuffer.MatricesIndicesKind
  117787. * - VertexBuffer.MatricesIndicesExtraKind
  117788. * - VertexBuffer.MatricesWeightsKind
  117789. * - VertexBuffer.MatricesWeightsExtraKind
  117790. * @returns a boolean
  117791. */
  117792. isVertexBufferUpdatable(kind: string): boolean;
  117793. /**
  117794. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  117795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  117796. * - VertexBuffer.PositionKind
  117797. * - VertexBuffer.NormalKind
  117798. * - VertexBuffer.UVKind
  117799. * - VertexBuffer.UV2Kind
  117800. * - VertexBuffer.UV3Kind
  117801. * - VertexBuffer.UV4Kind
  117802. * - VertexBuffer.UV5Kind
  117803. * - VertexBuffer.UV6Kind
  117804. * - VertexBuffer.ColorKind
  117805. * - VertexBuffer.MatricesIndicesKind
  117806. * - VertexBuffer.MatricesIndicesExtraKind
  117807. * - VertexBuffer.MatricesWeightsKind
  117808. * - VertexBuffer.MatricesWeightsExtraKind
  117809. * @returns an array of strings
  117810. */
  117811. getVerticesDataKinds(): string[];
  117812. /**
  117813. * Returns a positive integer : the total number of indices in this mesh geometry.
  117814. * @returns the numner of indices or zero if the mesh has no geometry.
  117815. */
  117816. getTotalIndices(): number;
  117817. /**
  117818. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  117819. * @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.
  117820. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  117821. * @returns the indices array or an empty array if the mesh has no geometry
  117822. */
  117823. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  117824. get isBlocked(): boolean;
  117825. /**
  117826. * Determine if the current mesh is ready to be rendered
  117827. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117828. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  117829. * @returns true if all associated assets are ready (material, textures, shaders)
  117830. */
  117831. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  117832. /**
  117833. * 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.
  117834. */
  117835. get areNormalsFrozen(): boolean;
  117836. /**
  117837. * 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.
  117838. * @returns the current mesh
  117839. */
  117840. freezeNormals(): Mesh;
  117841. /**
  117842. * 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
  117843. * @returns the current mesh
  117844. */
  117845. unfreezeNormals(): Mesh;
  117846. /**
  117847. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  117848. */
  117849. set overridenInstanceCount(count: number);
  117850. /** @hidden */
  117851. _preActivate(): Mesh;
  117852. /** @hidden */
  117853. _preActivateForIntermediateRendering(renderId: number): Mesh;
  117854. /** @hidden */
  117855. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  117856. protected _afterComputeWorldMatrix(): void;
  117857. /** @hidden */
  117858. _postActivate(): void;
  117859. /**
  117860. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117861. * This means the mesh underlying bounding box and sphere are recomputed.
  117862. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117863. * @returns the current mesh
  117864. */
  117865. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  117866. /** @hidden */
  117867. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  117868. /**
  117869. * This function will subdivide the mesh into multiple submeshes
  117870. * @param count defines the expected number of submeshes
  117871. */
  117872. subdivide(count: number): void;
  117873. /**
  117874. * Copy a FloatArray into a specific associated vertex buffer
  117875. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  117876. * - VertexBuffer.PositionKind
  117877. * - VertexBuffer.UVKind
  117878. * - VertexBuffer.UV2Kind
  117879. * - VertexBuffer.UV3Kind
  117880. * - VertexBuffer.UV4Kind
  117881. * - VertexBuffer.UV5Kind
  117882. * - VertexBuffer.UV6Kind
  117883. * - VertexBuffer.ColorKind
  117884. * - VertexBuffer.MatricesIndicesKind
  117885. * - VertexBuffer.MatricesIndicesExtraKind
  117886. * - VertexBuffer.MatricesWeightsKind
  117887. * - VertexBuffer.MatricesWeightsExtraKind
  117888. * @param data defines the data source
  117889. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  117890. * @param stride defines the data stride size (can be null)
  117891. * @returns the current mesh
  117892. */
  117893. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117894. /**
  117895. * Delete a vertex buffer associated with this mesh
  117896. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  117897. * - VertexBuffer.PositionKind
  117898. * - VertexBuffer.UVKind
  117899. * - VertexBuffer.UV2Kind
  117900. * - VertexBuffer.UV3Kind
  117901. * - VertexBuffer.UV4Kind
  117902. * - VertexBuffer.UV5Kind
  117903. * - VertexBuffer.UV6Kind
  117904. * - VertexBuffer.ColorKind
  117905. * - VertexBuffer.MatricesIndicesKind
  117906. * - VertexBuffer.MatricesIndicesExtraKind
  117907. * - VertexBuffer.MatricesWeightsKind
  117908. * - VertexBuffer.MatricesWeightsExtraKind
  117909. */
  117910. removeVerticesData(kind: string): void;
  117911. /**
  117912. * Flags an associated vertex buffer as updatable
  117913. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  117914. * - VertexBuffer.PositionKind
  117915. * - VertexBuffer.UVKind
  117916. * - VertexBuffer.UV2Kind
  117917. * - VertexBuffer.UV3Kind
  117918. * - VertexBuffer.UV4Kind
  117919. * - VertexBuffer.UV5Kind
  117920. * - VertexBuffer.UV6Kind
  117921. * - VertexBuffer.ColorKind
  117922. * - VertexBuffer.MatricesIndicesKind
  117923. * - VertexBuffer.MatricesIndicesExtraKind
  117924. * - VertexBuffer.MatricesWeightsKind
  117925. * - VertexBuffer.MatricesWeightsExtraKind
  117926. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  117927. */
  117928. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  117929. /**
  117930. * Sets the mesh global Vertex Buffer
  117931. * @param buffer defines the buffer to use
  117932. * @returns the current mesh
  117933. */
  117934. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  117935. /**
  117936. * Update a specific associated vertex buffer
  117937. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  117938. * - VertexBuffer.PositionKind
  117939. * - VertexBuffer.UVKind
  117940. * - VertexBuffer.UV2Kind
  117941. * - VertexBuffer.UV3Kind
  117942. * - VertexBuffer.UV4Kind
  117943. * - VertexBuffer.UV5Kind
  117944. * - VertexBuffer.UV6Kind
  117945. * - VertexBuffer.ColorKind
  117946. * - VertexBuffer.MatricesIndicesKind
  117947. * - VertexBuffer.MatricesIndicesExtraKind
  117948. * - VertexBuffer.MatricesWeightsKind
  117949. * - VertexBuffer.MatricesWeightsExtraKind
  117950. * @param data defines the data source
  117951. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  117952. * @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)
  117953. * @returns the current mesh
  117954. */
  117955. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117956. /**
  117957. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  117958. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  117959. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  117960. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  117961. * @returns the current mesh
  117962. */
  117963. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  117964. /**
  117965. * Creates a un-shared specific occurence of the geometry for the mesh.
  117966. * @returns the current mesh
  117967. */
  117968. makeGeometryUnique(): Mesh;
  117969. /**
  117970. * Set the index buffer of this mesh
  117971. * @param indices defines the source data
  117972. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  117973. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  117974. * @returns the current mesh
  117975. */
  117976. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  117977. /**
  117978. * Update the current index buffer
  117979. * @param indices defines the source data
  117980. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117981. * @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)
  117982. * @returns the current mesh
  117983. */
  117984. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117985. /**
  117986. * Invert the geometry to move from a right handed system to a left handed one.
  117987. * @returns the current mesh
  117988. */
  117989. toLeftHanded(): Mesh;
  117990. /** @hidden */
  117991. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  117992. /** @hidden */
  117993. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  117994. /**
  117995. * Registers for this mesh a javascript function called just before the rendering process
  117996. * @param func defines the function to call before rendering this mesh
  117997. * @returns the current mesh
  117998. */
  117999. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118000. /**
  118001. * Disposes a previously registered javascript function called before the rendering
  118002. * @param func defines the function to remove
  118003. * @returns the current mesh
  118004. */
  118005. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118006. /**
  118007. * Registers for this mesh a javascript function called just after the rendering is complete
  118008. * @param func defines the function to call after rendering this mesh
  118009. * @returns the current mesh
  118010. */
  118011. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118012. /**
  118013. * Disposes a previously registered javascript function called after the rendering.
  118014. * @param func defines the function to remove
  118015. * @returns the current mesh
  118016. */
  118017. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118018. /** @hidden */
  118019. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  118020. /** @hidden */
  118021. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  118022. /** @hidden */
  118023. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  118024. /** @hidden */
  118025. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  118026. /** @hidden */
  118027. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  118028. /** @hidden */
  118029. _rebuild(): void;
  118030. /** @hidden */
  118031. _freeze(): void;
  118032. /** @hidden */
  118033. _unFreeze(): void;
  118034. /**
  118035. * 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
  118036. * @param subMesh defines the subMesh to render
  118037. * @param enableAlphaMode defines if alpha mode can be changed
  118038. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  118039. * @returns the current mesh
  118040. */
  118041. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  118042. private _onBeforeDraw;
  118043. /**
  118044. * Renormalize the mesh and patch it up if there are no weights
  118045. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  118046. * However in the case of zero weights then we set just a single influence to 1.
  118047. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  118048. */
  118049. cleanMatrixWeights(): void;
  118050. private normalizeSkinFourWeights;
  118051. private normalizeSkinWeightsAndExtra;
  118052. /**
  118053. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  118054. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  118055. * the user know there was an issue with importing the mesh
  118056. * @returns a validation object with skinned, valid and report string
  118057. */
  118058. validateSkinning(): {
  118059. skinned: boolean;
  118060. valid: boolean;
  118061. report: string;
  118062. };
  118063. /** @hidden */
  118064. _checkDelayState(): Mesh;
  118065. private _queueLoad;
  118066. /**
  118067. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  118068. * A mesh is in the frustum if its bounding box intersects the frustum
  118069. * @param frustumPlanes defines the frustum to test
  118070. * @returns true if the mesh is in the frustum planes
  118071. */
  118072. isInFrustum(frustumPlanes: Plane[]): boolean;
  118073. /**
  118074. * Sets the mesh material by the material or multiMaterial `id` property
  118075. * @param id is a string identifying the material or the multiMaterial
  118076. * @returns the current mesh
  118077. */
  118078. setMaterialByID(id: string): Mesh;
  118079. /**
  118080. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  118081. * @returns an array of IAnimatable
  118082. */
  118083. getAnimatables(): IAnimatable[];
  118084. /**
  118085. * Modifies the mesh geometry according to the passed transformation matrix.
  118086. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  118087. * The mesh normals are modified using the same transformation.
  118088. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118089. * @param transform defines the transform matrix to use
  118090. * @see https://doc.babylonjs.com/resources/baking_transformations
  118091. * @returns the current mesh
  118092. */
  118093. bakeTransformIntoVertices(transform: Matrix): Mesh;
  118094. /**
  118095. * Modifies the mesh geometry according to its own current World Matrix.
  118096. * The mesh World Matrix is then reset.
  118097. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  118098. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118099. * @see https://doc.babylonjs.com/resources/baking_transformations
  118100. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  118101. * @returns the current mesh
  118102. */
  118103. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  118104. /** @hidden */
  118105. get _positions(): Nullable<Vector3[]>;
  118106. /** @hidden */
  118107. _resetPointsArrayCache(): Mesh;
  118108. /** @hidden */
  118109. _generatePointsArray(): boolean;
  118110. /**
  118111. * Returns a new Mesh object generated from the current mesh properties.
  118112. * This method must not get confused with createInstance()
  118113. * @param name is a string, the name given to the new mesh
  118114. * @param newParent can be any Node object (default `null`)
  118115. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  118116. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  118117. * @returns a new mesh
  118118. */
  118119. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  118120. /**
  118121. * Releases resources associated with this mesh.
  118122. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118123. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118124. */
  118125. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118126. /** @hidden */
  118127. _disposeInstanceSpecificData(): void;
  118128. /** @hidden */
  118129. _disposeThinInstanceSpecificData(): void;
  118130. /**
  118131. * Modifies the mesh geometry according to a displacement map.
  118132. * 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.
  118133. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118134. * @param url is a string, the URL from the image file is to be downloaded.
  118135. * @param minHeight is the lower limit of the displacement.
  118136. * @param maxHeight is the upper limit of the displacement.
  118137. * @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.
  118138. * @param uvOffset is an optional vector2 used to offset UV.
  118139. * @param uvScale is an optional vector2 used to scale UV.
  118140. * @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.
  118141. * @returns the Mesh.
  118142. */
  118143. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118144. /**
  118145. * Modifies the mesh geometry according to a displacementMap buffer.
  118146. * 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.
  118147. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118148. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  118149. * @param heightMapWidth is the width of the buffer image.
  118150. * @param heightMapHeight is the height of the buffer image.
  118151. * @param minHeight is the lower limit of the displacement.
  118152. * @param maxHeight is the upper limit of the displacement.
  118153. * @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.
  118154. * @param uvOffset is an optional vector2 used to offset UV.
  118155. * @param uvScale is an optional vector2 used to scale UV.
  118156. * @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.
  118157. * @returns the Mesh.
  118158. */
  118159. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118160. /**
  118161. * Modify the mesh to get a flat shading rendering.
  118162. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  118163. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  118164. * @returns current mesh
  118165. */
  118166. convertToFlatShadedMesh(): Mesh;
  118167. /**
  118168. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  118169. * In other words, more vertices, no more indices and a single bigger VBO.
  118170. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  118171. * @returns current mesh
  118172. */
  118173. convertToUnIndexedMesh(): Mesh;
  118174. /**
  118175. * Inverses facet orientations.
  118176. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118177. * @param flipNormals will also inverts the normals
  118178. * @returns current mesh
  118179. */
  118180. flipFaces(flipNormals?: boolean): Mesh;
  118181. /**
  118182. * Increase the number of facets and hence vertices in a mesh
  118183. * Vertex normals are interpolated from existing vertex normals
  118184. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118185. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  118186. */
  118187. increaseVertices(numberPerEdge: number): void;
  118188. /**
  118189. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  118190. * This will undo any application of covertToFlatShadedMesh
  118191. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118192. */
  118193. forceSharedVertices(): void;
  118194. /** @hidden */
  118195. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  118196. /** @hidden */
  118197. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  118198. /**
  118199. * Creates a new InstancedMesh object from the mesh model.
  118200. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118201. * @param name defines the name of the new instance
  118202. * @returns a new InstancedMesh
  118203. */
  118204. createInstance(name: string): InstancedMesh;
  118205. /**
  118206. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  118207. * After this call, all the mesh instances have the same submeshes than the current mesh.
  118208. * @returns the current mesh
  118209. */
  118210. synchronizeInstances(): Mesh;
  118211. /**
  118212. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  118213. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  118214. * This should be used together with the simplification to avoid disappearing triangles.
  118215. * @param successCallback an optional success callback to be called after the optimization finished.
  118216. * @returns the current mesh
  118217. */
  118218. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  118219. /**
  118220. * Serialize current mesh
  118221. * @param serializationObject defines the object which will receive the serialization data
  118222. */
  118223. serialize(serializationObject: any): void;
  118224. /** @hidden */
  118225. _syncGeometryWithMorphTargetManager(): void;
  118226. /** @hidden */
  118227. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  118228. /**
  118229. * Returns a new Mesh object parsed from the source provided.
  118230. * @param parsedMesh is the source
  118231. * @param scene defines the hosting scene
  118232. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  118233. * @returns a new Mesh
  118234. */
  118235. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  118236. /**
  118237. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  118238. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118239. * @param name defines the name of the mesh to create
  118240. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  118241. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  118242. * @param closePath creates a seam between the first and the last points of each path of the path array
  118243. * @param offset is taken in account only if the `pathArray` is containing a single path
  118244. * @param scene defines the hosting scene
  118245. * @param updatable defines if the mesh must be flagged as updatable
  118246. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118247. * @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)
  118248. * @returns a new Mesh
  118249. */
  118250. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118251. /**
  118252. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  118253. * @param name defines the name of the mesh to create
  118254. * @param radius sets the radius size (float) of the polygon (default 0.5)
  118255. * @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
  118256. * @param scene defines the hosting scene
  118257. * @param updatable defines if the mesh must be flagged as updatable
  118258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118259. * @returns a new Mesh
  118260. */
  118261. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118262. /**
  118263. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  118264. * @param name defines the name of the mesh to create
  118265. * @param size sets the size (float) of each box side (default 1)
  118266. * @param scene defines the hosting scene
  118267. * @param updatable defines if the mesh must be flagged as updatable
  118268. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118269. * @returns a new Mesh
  118270. */
  118271. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118272. /**
  118273. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  118274. * @param name defines the name of the mesh to create
  118275. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118276. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118277. * @param scene defines the hosting scene
  118278. * @param updatable defines if the mesh must be flagged as updatable
  118279. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118280. * @returns a new Mesh
  118281. */
  118282. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118283. /**
  118284. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  118285. * @param name defines the name of the mesh to create
  118286. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118287. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118288. * @param scene defines the hosting scene
  118289. * @returns a new Mesh
  118290. */
  118291. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  118292. /**
  118293. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  118294. * @param name defines the name of the mesh to create
  118295. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  118296. * @param diameterTop set the top cap diameter (floats, default 1)
  118297. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  118298. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  118299. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  118300. * @param scene defines the hosting scene
  118301. * @param updatable defines if the mesh must be flagged as updatable
  118302. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118303. * @returns a new Mesh
  118304. */
  118305. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  118306. /**
  118307. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  118308. * @param name defines the name of the mesh to create
  118309. * @param diameter sets the diameter size (float) of the torus (default 1)
  118310. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  118311. * @param tessellation sets the number of torus sides (postive integer, default 16)
  118312. * @param scene defines the hosting scene
  118313. * @param updatable defines if the mesh must be flagged as updatable
  118314. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118315. * @returns a new Mesh
  118316. */
  118317. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118318. /**
  118319. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  118320. * @param name defines the name of the mesh to create
  118321. * @param radius sets the global radius size (float) of the torus knot (default 2)
  118322. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  118323. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  118324. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  118325. * @param p the number of windings on X axis (positive integers, default 2)
  118326. * @param q the number of windings on Y axis (positive integers, default 3)
  118327. * @param scene defines the hosting scene
  118328. * @param updatable defines if the mesh must be flagged as updatable
  118329. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118330. * @returns a new Mesh
  118331. */
  118332. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118333. /**
  118334. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  118335. * @param name defines the name of the mesh to create
  118336. * @param points is an array successive Vector3
  118337. * @param scene defines the hosting scene
  118338. * @param updatable defines if the mesh must be flagged as updatable
  118339. * @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).
  118340. * @returns a new Mesh
  118341. */
  118342. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  118343. /**
  118344. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  118345. * @param name defines the name of the mesh to create
  118346. * @param points is an array successive Vector3
  118347. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  118348. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118349. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  118350. * @param scene defines the hosting scene
  118351. * @param updatable defines if the mesh must be flagged as updatable
  118352. * @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)
  118353. * @returns a new Mesh
  118354. */
  118355. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  118356. /**
  118357. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  118358. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  118359. * 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.
  118360. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118361. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118362. * Remember you can only change the shape positions, not their number when updating a polygon.
  118363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118364. * @param name defines the name of the mesh to create
  118365. * @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
  118366. * @param scene defines the hosting scene
  118367. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  118368. * @param updatable defines if the mesh must be flagged as updatable
  118369. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118370. * @param earcutInjection can be used to inject your own earcut reference
  118371. * @returns a new Mesh
  118372. */
  118373. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  118374. /**
  118375. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  118376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  118377. * @param name defines the name of the mesh to create
  118378. * @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
  118379. * @param depth defines the height of extrusion
  118380. * @param scene defines the hosting scene
  118381. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  118382. * @param updatable defines if the mesh must be flagged as updatable
  118383. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118384. * @param earcutInjection can be used to inject your own earcut reference
  118385. * @returns a new Mesh
  118386. */
  118387. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  118388. /**
  118389. * Creates an extruded shape mesh.
  118390. * 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
  118391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118393. * @param name defines the name of the mesh to create
  118394. * @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
  118395. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  118396. * @param scale is the value to scale the shape
  118397. * @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
  118398. * @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
  118399. * @param scene defines the hosting scene
  118400. * @param updatable defines if the mesh must be flagged as updatable
  118401. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118402. * @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)
  118403. * @returns a new Mesh
  118404. */
  118405. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118406. /**
  118407. * Creates an custom extruded shape mesh.
  118408. * The custom extrusion is a parametric shape.
  118409. * It has no predefined shape. Its final shape will depend on the input parameters.
  118410. * Please consider using the same method from the MeshBuilder class instead
  118411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118412. * @param name defines the name of the mesh to create
  118413. * @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
  118414. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  118415. * @param scaleFunction is a custom Javascript function called on each path point
  118416. * @param rotationFunction is a custom Javascript function called on each path point
  118417. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118418. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  118419. * @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
  118420. * @param scene defines the hosting scene
  118421. * @param updatable defines if the mesh must be flagged as updatable
  118422. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118423. * @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)
  118424. * @returns a new Mesh
  118425. */
  118426. 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;
  118427. /**
  118428. * Creates lathe mesh.
  118429. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  118430. * Please consider using the same method from the MeshBuilder class instead
  118431. * @param name defines the name of the mesh to create
  118432. * @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
  118433. * @param radius is the radius value of the lathe
  118434. * @param tessellation is the side number of the lathe.
  118435. * @param scene defines the hosting scene
  118436. * @param updatable defines if the mesh must be flagged as updatable
  118437. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118438. * @returns a new Mesh
  118439. */
  118440. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118441. /**
  118442. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  118443. * @param name defines the name of the mesh to create
  118444. * @param size sets the size (float) of both sides of the plane at once (default 1)
  118445. * @param scene defines the hosting scene
  118446. * @param updatable defines if the mesh must be flagged as updatable
  118447. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118448. * @returns a new Mesh
  118449. */
  118450. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118451. /**
  118452. * Creates a ground mesh.
  118453. * Please consider using the same method from the MeshBuilder class instead
  118454. * @param name defines the name of the mesh to create
  118455. * @param width set the width of the ground
  118456. * @param height set the height of the ground
  118457. * @param subdivisions sets the number of subdivisions per side
  118458. * @param scene defines the hosting scene
  118459. * @param updatable defines if the mesh must be flagged as updatable
  118460. * @returns a new Mesh
  118461. */
  118462. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  118463. /**
  118464. * Creates a tiled ground mesh.
  118465. * Please consider using the same method from the MeshBuilder class instead
  118466. * @param name defines the name of the mesh to create
  118467. * @param xmin set the ground minimum X coordinate
  118468. * @param zmin set the ground minimum Y coordinate
  118469. * @param xmax set the ground maximum X coordinate
  118470. * @param zmax set the ground maximum Z coordinate
  118471. * @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
  118472. * @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
  118473. * @param scene defines the hosting scene
  118474. * @param updatable defines if the mesh must be flagged as updatable
  118475. * @returns a new Mesh
  118476. */
  118477. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  118478. w: number;
  118479. h: number;
  118480. }, precision: {
  118481. w: number;
  118482. h: number;
  118483. }, scene: Scene, updatable?: boolean): Mesh;
  118484. /**
  118485. * Creates a ground mesh from a height map.
  118486. * Please consider using the same method from the MeshBuilder class instead
  118487. * @see https://doc.babylonjs.com/babylon101/height_map
  118488. * @param name defines the name of the mesh to create
  118489. * @param url sets the URL of the height map image resource
  118490. * @param width set the ground width size
  118491. * @param height set the ground height size
  118492. * @param subdivisions sets the number of subdivision per side
  118493. * @param minHeight is the minimum altitude on the ground
  118494. * @param maxHeight is the maximum altitude on the ground
  118495. * @param scene defines the hosting scene
  118496. * @param updatable defines if the mesh must be flagged as updatable
  118497. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  118498. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118499. * @returns a new Mesh
  118500. */
  118501. 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;
  118502. /**
  118503. * Creates a tube mesh.
  118504. * The tube is a parametric shape.
  118505. * It has no predefined shape. Its final shape will depend on the input parameters.
  118506. * Please consider using the same method from the MeshBuilder class instead
  118507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118508. * @param name defines the name of the mesh to create
  118509. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  118510. * @param radius sets the tube radius size
  118511. * @param tessellation is the number of sides on the tubular surface
  118512. * @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
  118513. * @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
  118514. * @param scene defines the hosting scene
  118515. * @param updatable defines if the mesh must be flagged as updatable
  118516. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118517. * @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)
  118518. * @returns a new Mesh
  118519. */
  118520. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  118521. (i: number, distance: number): number;
  118522. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118523. /**
  118524. * Creates a polyhedron mesh.
  118525. * Please consider using the same method from the MeshBuilder class instead.
  118526. * * 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
  118527. * * The parameter `size` (positive float, default 1) sets the polygon size
  118528. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118529. * * 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`
  118530. * * 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
  118531. * * 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)`)
  118532. * * 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
  118533. * * 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
  118534. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118535. * * 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
  118536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118537. * @param name defines the name of the mesh to create
  118538. * @param options defines the options used to create the mesh
  118539. * @param scene defines the hosting scene
  118540. * @returns a new Mesh
  118541. */
  118542. static CreatePolyhedron(name: string, options: {
  118543. type?: number;
  118544. size?: number;
  118545. sizeX?: number;
  118546. sizeY?: number;
  118547. sizeZ?: number;
  118548. custom?: any;
  118549. faceUV?: Vector4[];
  118550. faceColors?: Color4[];
  118551. updatable?: boolean;
  118552. sideOrientation?: number;
  118553. }, scene: Scene): Mesh;
  118554. /**
  118555. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118556. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118557. * * 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`)
  118558. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118559. * * 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
  118560. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118561. * * 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
  118562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118563. * @param name defines the name of the mesh
  118564. * @param options defines the options used to create the mesh
  118565. * @param scene defines the hosting scene
  118566. * @returns a new Mesh
  118567. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118568. */
  118569. static CreateIcoSphere(name: string, options: {
  118570. radius?: number;
  118571. flat?: boolean;
  118572. subdivisions?: number;
  118573. sideOrientation?: number;
  118574. updatable?: boolean;
  118575. }, scene: Scene): Mesh;
  118576. /**
  118577. * Creates a decal mesh.
  118578. * Please consider using the same method from the MeshBuilder class instead.
  118579. * A decal is a mesh usually applied as a model onto the surface of another mesh
  118580. * @param name defines the name of the mesh
  118581. * @param sourceMesh defines the mesh receiving the decal
  118582. * @param position sets the position of the decal in world coordinates
  118583. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  118584. * @param size sets the decal scaling
  118585. * @param angle sets the angle to rotate the decal
  118586. * @returns a new Mesh
  118587. */
  118588. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  118589. /** Creates a Capsule Mesh
  118590. * @param name defines the name of the mesh.
  118591. * @param options the constructors options used to shape the mesh.
  118592. * @param scene defines the scene the mesh is scoped to.
  118593. * @returns the capsule mesh
  118594. * @see https://doc.babylonjs.com/how_to/capsule_shape
  118595. */
  118596. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  118597. /**
  118598. * Prepare internal position array for software CPU skinning
  118599. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  118600. */
  118601. setPositionsForCPUSkinning(): Float32Array;
  118602. /**
  118603. * Prepare internal normal array for software CPU skinning
  118604. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  118605. */
  118606. setNormalsForCPUSkinning(): Float32Array;
  118607. /**
  118608. * Updates the vertex buffer by applying transformation from the bones
  118609. * @param skeleton defines the skeleton to apply to current mesh
  118610. * @returns the current mesh
  118611. */
  118612. applySkeleton(skeleton: Skeleton): Mesh;
  118613. /**
  118614. * 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
  118615. * @param meshes defines the list of meshes to scan
  118616. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  118617. */
  118618. static MinMax(meshes: AbstractMesh[]): {
  118619. min: Vector3;
  118620. max: Vector3;
  118621. };
  118622. /**
  118623. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  118624. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  118625. * @returns a vector3
  118626. */
  118627. static Center(meshesOrMinMaxVector: {
  118628. min: Vector3;
  118629. max: Vector3;
  118630. } | AbstractMesh[]): Vector3;
  118631. /**
  118632. * Merge the array of meshes into a single mesh for performance reasons.
  118633. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  118634. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  118635. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  118636. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  118637. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  118638. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  118639. * @returns a new mesh
  118640. */
  118641. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  118642. /** @hidden */
  118643. addInstance(instance: InstancedMesh): void;
  118644. /** @hidden */
  118645. removeInstance(instance: InstancedMesh): void;
  118646. }
  118647. }
  118648. declare module BABYLON {
  118649. /**
  118650. * The options Interface for creating a Capsule Mesh
  118651. */
  118652. export interface ICreateCapsuleOptions {
  118653. /** The Orientation of the capsule. Default : Vector3.Up() */
  118654. orientation?: Vector3;
  118655. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  118656. subdivisions: number;
  118657. /** Number of cylindrical segments on the capsule. */
  118658. tessellation: number;
  118659. /** Height or Length of the capsule. */
  118660. height: number;
  118661. /** Radius of the capsule. */
  118662. radius: number;
  118663. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  118664. capSubdivisions: number;
  118665. /** Overwrite for the top radius. */
  118666. radiusTop?: number;
  118667. /** Overwrite for the bottom radius. */
  118668. radiusBottom?: number;
  118669. /** Overwrite for the top capSubdivisions. */
  118670. topCapSubdivisions?: number;
  118671. /** Overwrite for the bottom capSubdivisions. */
  118672. bottomCapSubdivisions?: number;
  118673. }
  118674. /**
  118675. * Class containing static functions to help procedurally build meshes
  118676. */
  118677. export class CapsuleBuilder {
  118678. /**
  118679. * Creates a capsule or a pill mesh
  118680. * @param name defines the name of the mesh
  118681. * @param options The constructors options.
  118682. * @param scene The scene the mesh is scoped to.
  118683. * @returns Capsule Mesh
  118684. */
  118685. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  118686. }
  118687. }
  118688. declare module BABYLON {
  118689. /**
  118690. * Define an interface for all classes that will get and set the data on vertices
  118691. */
  118692. export interface IGetSetVerticesData {
  118693. /**
  118694. * Gets a boolean indicating if specific vertex data is present
  118695. * @param kind defines the vertex data kind to use
  118696. * @returns true is data kind is present
  118697. */
  118698. isVerticesDataPresent(kind: string): boolean;
  118699. /**
  118700. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  118701. * @param kind defines the data kind (Position, normal, etc...)
  118702. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  118703. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  118704. * @returns a float array containing vertex data
  118705. */
  118706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  118707. /**
  118708. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  118709. * @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.
  118710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  118711. * @returns the indices array or an empty array if the mesh has no geometry
  118712. */
  118713. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  118714. /**
  118715. * Set specific vertex data
  118716. * @param kind defines the data kind (Position, normal, etc...)
  118717. * @param data defines the vertex data to use
  118718. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  118719. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  118720. */
  118721. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  118722. /**
  118723. * Update a specific associated vertex buffer
  118724. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  118725. * - VertexBuffer.PositionKind
  118726. * - VertexBuffer.UVKind
  118727. * - VertexBuffer.UV2Kind
  118728. * - VertexBuffer.UV3Kind
  118729. * - VertexBuffer.UV4Kind
  118730. * - VertexBuffer.UV5Kind
  118731. * - VertexBuffer.UV6Kind
  118732. * - VertexBuffer.ColorKind
  118733. * - VertexBuffer.MatricesIndicesKind
  118734. * - VertexBuffer.MatricesIndicesExtraKind
  118735. * - VertexBuffer.MatricesWeightsKind
  118736. * - VertexBuffer.MatricesWeightsExtraKind
  118737. * @param data defines the data source
  118738. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  118739. * @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)
  118740. */
  118741. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  118742. /**
  118743. * Creates a new index buffer
  118744. * @param indices defines the indices to store in the index buffer
  118745. * @param totalVertices defines the total number of vertices (could be null)
  118746. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  118747. */
  118748. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  118749. }
  118750. /**
  118751. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  118752. */
  118753. export class VertexData {
  118754. /**
  118755. * Mesh side orientation : usually the external or front surface
  118756. */
  118757. static readonly FRONTSIDE: number;
  118758. /**
  118759. * Mesh side orientation : usually the internal or back surface
  118760. */
  118761. static readonly BACKSIDE: number;
  118762. /**
  118763. * Mesh side orientation : both internal and external or front and back surfaces
  118764. */
  118765. static readonly DOUBLESIDE: number;
  118766. /**
  118767. * Mesh side orientation : by default, `FRONTSIDE`
  118768. */
  118769. static readonly DEFAULTSIDE: number;
  118770. /**
  118771. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  118772. */
  118773. positions: Nullable<FloatArray>;
  118774. /**
  118775. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  118776. */
  118777. normals: Nullable<FloatArray>;
  118778. /**
  118779. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  118780. */
  118781. tangents: Nullable<FloatArray>;
  118782. /**
  118783. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118784. */
  118785. uvs: Nullable<FloatArray>;
  118786. /**
  118787. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118788. */
  118789. uvs2: Nullable<FloatArray>;
  118790. /**
  118791. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118792. */
  118793. uvs3: Nullable<FloatArray>;
  118794. /**
  118795. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118796. */
  118797. uvs4: Nullable<FloatArray>;
  118798. /**
  118799. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118800. */
  118801. uvs5: Nullable<FloatArray>;
  118802. /**
  118803. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118804. */
  118805. uvs6: Nullable<FloatArray>;
  118806. /**
  118807. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  118808. */
  118809. colors: Nullable<FloatArray>;
  118810. /**
  118811. * 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).
  118812. */
  118813. matricesIndices: Nullable<FloatArray>;
  118814. /**
  118815. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  118816. */
  118817. matricesWeights: Nullable<FloatArray>;
  118818. /**
  118819. * An array extending the number of possible indices
  118820. */
  118821. matricesIndicesExtra: Nullable<FloatArray>;
  118822. /**
  118823. * An array extending the number of possible weights when the number of indices is extended
  118824. */
  118825. matricesWeightsExtra: Nullable<FloatArray>;
  118826. /**
  118827. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  118828. */
  118829. indices: Nullable<IndicesArray>;
  118830. /**
  118831. * Uses the passed data array to set the set the values for the specified kind of data
  118832. * @param data a linear array of floating numbers
  118833. * @param kind the type of data that is being set, eg positions, colors etc
  118834. */
  118835. set(data: FloatArray, kind: string): void;
  118836. /**
  118837. * Associates the vertexData to the passed Mesh.
  118838. * Sets it as updatable or not (default `false`)
  118839. * @param mesh the mesh the vertexData is applied to
  118840. * @param updatable when used and having the value true allows new data to update the vertexData
  118841. * @returns the VertexData
  118842. */
  118843. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  118844. /**
  118845. * Associates the vertexData to the passed Geometry.
  118846. * Sets it as updatable or not (default `false`)
  118847. * @param geometry the geometry the vertexData is applied to
  118848. * @param updatable when used and having the value true allows new data to update the vertexData
  118849. * @returns VertexData
  118850. */
  118851. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  118852. /**
  118853. * Updates the associated mesh
  118854. * @param mesh the mesh to be updated
  118855. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  118856. * @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
  118857. * @returns VertexData
  118858. */
  118859. updateMesh(mesh: Mesh): VertexData;
  118860. /**
  118861. * Updates the associated geometry
  118862. * @param geometry the geometry to be updated
  118863. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  118864. * @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
  118865. * @returns VertexData.
  118866. */
  118867. updateGeometry(geometry: Geometry): VertexData;
  118868. private _applyTo;
  118869. private _update;
  118870. /**
  118871. * Transforms each position and each normal of the vertexData according to the passed Matrix
  118872. * @param matrix the transforming matrix
  118873. * @returns the VertexData
  118874. */
  118875. transform(matrix: Matrix): VertexData;
  118876. /**
  118877. * Merges the passed VertexData into the current one
  118878. * @param other the VertexData to be merged into the current one
  118879. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  118880. * @returns the modified VertexData
  118881. */
  118882. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  118883. private _mergeElement;
  118884. private _validate;
  118885. /**
  118886. * Serializes the VertexData
  118887. * @returns a serialized object
  118888. */
  118889. serialize(): any;
  118890. /**
  118891. * Extracts the vertexData from a mesh
  118892. * @param mesh the mesh from which to extract the VertexData
  118893. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  118894. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  118895. * @returns the object VertexData associated to the passed mesh
  118896. */
  118897. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  118898. /**
  118899. * Extracts the vertexData from the geometry
  118900. * @param geometry the geometry from which to extract the VertexData
  118901. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  118902. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  118903. * @returns the object VertexData associated to the passed mesh
  118904. */
  118905. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  118906. private static _ExtractFrom;
  118907. /**
  118908. * Creates the VertexData for a Ribbon
  118909. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  118910. * * pathArray array of paths, each of which an array of successive Vector3
  118911. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  118912. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  118913. * * 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
  118914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118915. * * 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)
  118916. * * 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)
  118917. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  118918. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  118919. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  118920. * @returns the VertexData of the ribbon
  118921. */
  118922. static CreateRibbon(options: {
  118923. pathArray: Vector3[][];
  118924. closeArray?: boolean;
  118925. closePath?: boolean;
  118926. offset?: number;
  118927. sideOrientation?: number;
  118928. frontUVs?: Vector4;
  118929. backUVs?: Vector4;
  118930. invertUV?: boolean;
  118931. uvs?: Vector2[];
  118932. colors?: Color4[];
  118933. }): VertexData;
  118934. /**
  118935. * Creates the VertexData for a box
  118936. * @param options an object used to set the following optional parameters for the box, required but can be empty
  118937. * * size sets the width, height and depth of the box to the value of size, optional default 1
  118938. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  118939. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  118940. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  118941. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  118942. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  118943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118944. * * 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)
  118945. * * 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)
  118946. * @returns the VertexData of the box
  118947. */
  118948. static CreateBox(options: {
  118949. size?: number;
  118950. width?: number;
  118951. height?: number;
  118952. depth?: number;
  118953. faceUV?: Vector4[];
  118954. faceColors?: Color4[];
  118955. sideOrientation?: number;
  118956. frontUVs?: Vector4;
  118957. backUVs?: Vector4;
  118958. }): VertexData;
  118959. /**
  118960. * Creates the VertexData for a tiled box
  118961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  118962. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118963. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  118964. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  118965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118966. * @returns the VertexData of the box
  118967. */
  118968. static CreateTiledBox(options: {
  118969. pattern?: number;
  118970. width?: number;
  118971. height?: number;
  118972. depth?: number;
  118973. tileSize?: number;
  118974. tileWidth?: number;
  118975. tileHeight?: number;
  118976. alignHorizontal?: number;
  118977. alignVertical?: number;
  118978. faceUV?: Vector4[];
  118979. faceColors?: Color4[];
  118980. sideOrientation?: number;
  118981. }): VertexData;
  118982. /**
  118983. * Creates the VertexData for a tiled plane
  118984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  118985. * * pattern a limited pattern arrangement depending on the number
  118986. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  118987. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  118988. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  118989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118990. * * 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)
  118991. * * 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)
  118992. * @returns the VertexData of the tiled plane
  118993. */
  118994. static CreateTiledPlane(options: {
  118995. pattern?: number;
  118996. tileSize?: number;
  118997. tileWidth?: number;
  118998. tileHeight?: number;
  118999. size?: number;
  119000. width?: number;
  119001. height?: number;
  119002. alignHorizontal?: number;
  119003. alignVertical?: number;
  119004. sideOrientation?: number;
  119005. frontUVs?: Vector4;
  119006. backUVs?: Vector4;
  119007. }): VertexData;
  119008. /**
  119009. * Creates the VertexData for an ellipsoid, defaults to a sphere
  119010. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119011. * * segments sets the number of horizontal strips optional, default 32
  119012. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  119013. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  119014. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  119015. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  119016. * * 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
  119017. * * 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
  119018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119019. * * 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)
  119020. * * 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)
  119021. * @returns the VertexData of the ellipsoid
  119022. */
  119023. static CreateSphere(options: {
  119024. segments?: number;
  119025. diameter?: number;
  119026. diameterX?: number;
  119027. diameterY?: number;
  119028. diameterZ?: number;
  119029. arc?: number;
  119030. slice?: number;
  119031. sideOrientation?: number;
  119032. frontUVs?: Vector4;
  119033. backUVs?: Vector4;
  119034. }): VertexData;
  119035. /**
  119036. * Creates the VertexData for a cylinder, cone or prism
  119037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119038. * * height sets the height (y direction) of the cylinder, optional, default 2
  119039. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  119040. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  119041. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  119042. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119043. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  119044. * * 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
  119045. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119046. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119047. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  119048. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  119049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119050. * * 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)
  119051. * * 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)
  119052. * @returns the VertexData of the cylinder, cone or prism
  119053. */
  119054. static CreateCylinder(options: {
  119055. height?: number;
  119056. diameterTop?: number;
  119057. diameterBottom?: number;
  119058. diameter?: number;
  119059. tessellation?: number;
  119060. subdivisions?: number;
  119061. arc?: number;
  119062. faceColors?: Color4[];
  119063. faceUV?: Vector4[];
  119064. hasRings?: boolean;
  119065. enclose?: boolean;
  119066. sideOrientation?: number;
  119067. frontUVs?: Vector4;
  119068. backUVs?: Vector4;
  119069. }): VertexData;
  119070. /**
  119071. * Creates the VertexData for a torus
  119072. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119073. * * diameter the diameter of the torus, optional default 1
  119074. * * thickness the diameter of the tube forming the torus, optional default 0.5
  119075. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119077. * * 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)
  119078. * * 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)
  119079. * @returns the VertexData of the torus
  119080. */
  119081. static CreateTorus(options: {
  119082. diameter?: number;
  119083. thickness?: number;
  119084. tessellation?: number;
  119085. sideOrientation?: number;
  119086. frontUVs?: Vector4;
  119087. backUVs?: Vector4;
  119088. }): VertexData;
  119089. /**
  119090. * Creates the VertexData of the LineSystem
  119091. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  119092. * - lines an array of lines, each line being an array of successive Vector3
  119093. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  119094. * @returns the VertexData of the LineSystem
  119095. */
  119096. static CreateLineSystem(options: {
  119097. lines: Vector3[][];
  119098. colors?: Nullable<Color4[][]>;
  119099. }): VertexData;
  119100. /**
  119101. * Create the VertexData for a DashedLines
  119102. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  119103. * - points an array successive Vector3
  119104. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  119105. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  119106. * - dashNb the intended total number of dashes, optional, default 200
  119107. * @returns the VertexData for the DashedLines
  119108. */
  119109. static CreateDashedLines(options: {
  119110. points: Vector3[];
  119111. dashSize?: number;
  119112. gapSize?: number;
  119113. dashNb?: number;
  119114. }): VertexData;
  119115. /**
  119116. * Creates the VertexData for a Ground
  119117. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119118. * - width the width (x direction) of the ground, optional, default 1
  119119. * - height the height (z direction) of the ground, optional, default 1
  119120. * - subdivisions the number of subdivisions per side, optional, default 1
  119121. * @returns the VertexData of the Ground
  119122. */
  119123. static CreateGround(options: {
  119124. width?: number;
  119125. height?: number;
  119126. subdivisions?: number;
  119127. subdivisionsX?: number;
  119128. subdivisionsY?: number;
  119129. }): VertexData;
  119130. /**
  119131. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  119132. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119133. * * xmin the ground minimum X coordinate, optional, default -1
  119134. * * zmin the ground minimum Z coordinate, optional, default -1
  119135. * * xmax the ground maximum X coordinate, optional, default 1
  119136. * * zmax the ground maximum Z coordinate, optional, default 1
  119137. * * 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}
  119138. * * 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}
  119139. * @returns the VertexData of the TiledGround
  119140. */
  119141. static CreateTiledGround(options: {
  119142. xmin: number;
  119143. zmin: number;
  119144. xmax: number;
  119145. zmax: number;
  119146. subdivisions?: {
  119147. w: number;
  119148. h: number;
  119149. };
  119150. precision?: {
  119151. w: number;
  119152. h: number;
  119153. };
  119154. }): VertexData;
  119155. /**
  119156. * Creates the VertexData of the Ground designed from a heightmap
  119157. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  119158. * * width the width (x direction) of the ground
  119159. * * height the height (z direction) of the ground
  119160. * * subdivisions the number of subdivisions per side
  119161. * * minHeight the minimum altitude on the ground, optional, default 0
  119162. * * maxHeight the maximum altitude on the ground, optional default 1
  119163. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  119164. * * buffer the array holding the image color data
  119165. * * bufferWidth the width of image
  119166. * * bufferHeight the height of image
  119167. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  119168. * @returns the VertexData of the Ground designed from a heightmap
  119169. */
  119170. static CreateGroundFromHeightMap(options: {
  119171. width: number;
  119172. height: number;
  119173. subdivisions: number;
  119174. minHeight: number;
  119175. maxHeight: number;
  119176. colorFilter: Color3;
  119177. buffer: Uint8Array;
  119178. bufferWidth: number;
  119179. bufferHeight: number;
  119180. alphaFilter: number;
  119181. }): VertexData;
  119182. /**
  119183. * Creates the VertexData for a Plane
  119184. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  119185. * * size sets the width and height of the plane to the value of size, optional default 1
  119186. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  119187. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  119188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119189. * * 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)
  119190. * * 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)
  119191. * @returns the VertexData of the box
  119192. */
  119193. static CreatePlane(options: {
  119194. size?: number;
  119195. width?: number;
  119196. height?: number;
  119197. sideOrientation?: number;
  119198. frontUVs?: Vector4;
  119199. backUVs?: Vector4;
  119200. }): VertexData;
  119201. /**
  119202. * Creates the VertexData of the Disc or regular Polygon
  119203. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  119204. * * radius the radius of the disc, optional default 0.5
  119205. * * tessellation the number of polygon sides, optional, default 64
  119206. * * 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
  119207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119208. * * 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)
  119209. * * 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)
  119210. * @returns the VertexData of the box
  119211. */
  119212. static CreateDisc(options: {
  119213. radius?: number;
  119214. tessellation?: number;
  119215. arc?: number;
  119216. sideOrientation?: number;
  119217. frontUVs?: Vector4;
  119218. backUVs?: Vector4;
  119219. }): VertexData;
  119220. /**
  119221. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  119222. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  119223. * @param polygon a mesh built from polygonTriangulation.build()
  119224. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119225. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119226. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119227. * @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)
  119228. * @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)
  119229. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  119230. * @returns the VertexData of the Polygon
  119231. */
  119232. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  119233. /**
  119234. * Creates the VertexData of the IcoSphere
  119235. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  119236. * * radius the radius of the IcoSphere, optional default 1
  119237. * * radiusX allows stretching in the x direction, optional, default radius
  119238. * * radiusY allows stretching in the y direction, optional, default radius
  119239. * * radiusZ allows stretching in the z direction, optional, default radius
  119240. * * flat when true creates a flat shaded mesh, optional, default true
  119241. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119243. * * 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)
  119244. * * 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)
  119245. * @returns the VertexData of the IcoSphere
  119246. */
  119247. static CreateIcoSphere(options: {
  119248. radius?: number;
  119249. radiusX?: number;
  119250. radiusY?: number;
  119251. radiusZ?: number;
  119252. flat?: boolean;
  119253. subdivisions?: number;
  119254. sideOrientation?: number;
  119255. frontUVs?: Vector4;
  119256. backUVs?: Vector4;
  119257. }): VertexData;
  119258. /**
  119259. * Creates the VertexData for a Polyhedron
  119260. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  119261. * * type provided types are:
  119262. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  119263. * * 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)
  119264. * * size the size of the IcoSphere, optional default 1
  119265. * * sizeX allows stretching in the x direction, optional, default size
  119266. * * sizeY allows stretching in the y direction, optional, default size
  119267. * * sizeZ allows stretching in the z direction, optional, default size
  119268. * * 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
  119269. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119271. * * flat when true creates a flat shaded mesh, optional, default true
  119272. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119274. * * 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)
  119275. * * 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)
  119276. * @returns the VertexData of the Polyhedron
  119277. */
  119278. static CreatePolyhedron(options: {
  119279. type?: number;
  119280. size?: number;
  119281. sizeX?: number;
  119282. sizeY?: number;
  119283. sizeZ?: number;
  119284. custom?: any;
  119285. faceUV?: Vector4[];
  119286. faceColors?: Color4[];
  119287. flat?: boolean;
  119288. sideOrientation?: number;
  119289. frontUVs?: Vector4;
  119290. backUVs?: Vector4;
  119291. }): VertexData;
  119292. /**
  119293. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  119294. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  119295. * @returns the VertexData of the Capsule
  119296. */
  119297. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  119298. /**
  119299. * Creates the VertexData for a TorusKnot
  119300. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  119301. * * radius the radius of the torus knot, optional, default 2
  119302. * * tube the thickness of the tube, optional, default 0.5
  119303. * * radialSegments the number of sides on each tube segments, optional, default 32
  119304. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  119305. * * p the number of windings around the z axis, optional, default 2
  119306. * * q the number of windings around the x axis, optional, default 3
  119307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119308. * * 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)
  119309. * * 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)
  119310. * @returns the VertexData of the Torus Knot
  119311. */
  119312. static CreateTorusKnot(options: {
  119313. radius?: number;
  119314. tube?: number;
  119315. radialSegments?: number;
  119316. tubularSegments?: number;
  119317. p?: number;
  119318. q?: number;
  119319. sideOrientation?: number;
  119320. frontUVs?: Vector4;
  119321. backUVs?: Vector4;
  119322. }): VertexData;
  119323. /**
  119324. * Compute normals for given positions and indices
  119325. * @param positions an array of vertex positions, [...., x, y, z, ......]
  119326. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  119327. * @param normals an array of vertex normals, [...., x, y, z, ......]
  119328. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  119329. * * facetNormals : optional array of facet normals (vector3)
  119330. * * facetPositions : optional array of facet positions (vector3)
  119331. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  119332. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  119333. * * bInfo : optional bounding info, required for facetPartitioning computation
  119334. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  119335. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  119336. * * useRightHandedSystem: optional boolean to for right handed system computation
  119337. * * depthSort : optional boolean to enable the facet depth sort computation
  119338. * * distanceTo : optional Vector3 to compute the facet depth from this location
  119339. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  119340. */
  119341. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  119342. facetNormals?: any;
  119343. facetPositions?: any;
  119344. facetPartitioning?: any;
  119345. ratio?: number;
  119346. bInfo?: any;
  119347. bbSize?: Vector3;
  119348. subDiv?: any;
  119349. useRightHandedSystem?: boolean;
  119350. depthSort?: boolean;
  119351. distanceTo?: Vector3;
  119352. depthSortedFacets?: any;
  119353. }): void;
  119354. /** @hidden */
  119355. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  119356. /**
  119357. * Applies VertexData created from the imported parameters to the geometry
  119358. * @param parsedVertexData the parsed data from an imported file
  119359. * @param geometry the geometry to apply the VertexData to
  119360. */
  119361. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /**
  119366. * Class containing static functions to help procedurally build meshes
  119367. */
  119368. export class DiscBuilder {
  119369. /**
  119370. * Creates a plane polygonal mesh. By default, this is a disc
  119371. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119372. * * 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
  119373. * * 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
  119374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119375. * * 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
  119376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119377. * @param name defines the name of the mesh
  119378. * @param options defines the options used to create the mesh
  119379. * @param scene defines the hosting scene
  119380. * @returns the plane polygonal mesh
  119381. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119382. */
  119383. static CreateDisc(name: string, options: {
  119384. radius?: number;
  119385. tessellation?: number;
  119386. arc?: number;
  119387. updatable?: boolean;
  119388. sideOrientation?: number;
  119389. frontUVs?: Vector4;
  119390. backUVs?: Vector4;
  119391. }, scene?: Nullable<Scene>): Mesh;
  119392. }
  119393. }
  119394. declare module BABYLON {
  119395. /**
  119396. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  119397. *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.
  119398. * The SPS is also a particle system. It provides some methods to manage the particles.
  119399. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  119400. *
  119401. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  119402. */
  119403. export class SolidParticleSystem implements IDisposable {
  119404. /**
  119405. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  119406. * Example : var p = SPS.particles[i];
  119407. */
  119408. particles: SolidParticle[];
  119409. /**
  119410. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  119411. */
  119412. nbParticles: number;
  119413. /**
  119414. * If the particles must ever face the camera (default false). Useful for planar particles.
  119415. */
  119416. billboard: boolean;
  119417. /**
  119418. * Recompute normals when adding a shape
  119419. */
  119420. recomputeNormals: boolean;
  119421. /**
  119422. * This a counter ofr your own usage. It's not set by any SPS functions.
  119423. */
  119424. counter: number;
  119425. /**
  119426. * The SPS name. This name is also given to the underlying mesh.
  119427. */
  119428. name: string;
  119429. /**
  119430. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  119431. */
  119432. mesh: Mesh;
  119433. /**
  119434. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  119435. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  119436. */
  119437. vars: any;
  119438. /**
  119439. * This array is populated when the SPS is set as 'pickable'.
  119440. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  119441. * Each element of this array is an object `{idx: int, faceId: int}`.
  119442. * `idx` is the picked particle index in the `SPS.particles` array
  119443. * `faceId` is the picked face index counted within this particle.
  119444. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  119445. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  119446. * Use the method SPS.pickedParticle(pickingInfo) instead.
  119447. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  119448. */
  119449. pickedParticles: {
  119450. idx: number;
  119451. faceId: number;
  119452. }[];
  119453. /**
  119454. * This array is populated when the SPS is set as 'pickable'
  119455. * Each key of this array is a submesh index.
  119456. * Each element of this array is a second array defined like this :
  119457. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  119458. * Each element of this second array is an object `{idx: int, faceId: int}`.
  119459. * `idx` is the picked particle index in the `SPS.particles` array
  119460. * `faceId` is the picked face index counted within this particle.
  119461. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  119462. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  119463. */
  119464. pickedBySubMesh: {
  119465. idx: number;
  119466. faceId: number;
  119467. }[][];
  119468. /**
  119469. * This array is populated when `enableDepthSort` is set to true.
  119470. * Each element of this array is an instance of the class DepthSortedParticle.
  119471. */
  119472. depthSortedParticles: DepthSortedParticle[];
  119473. /**
  119474. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  119475. * @hidden
  119476. */
  119477. _bSphereOnly: boolean;
  119478. /**
  119479. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  119480. * @hidden
  119481. */
  119482. _bSphereRadiusFactor: number;
  119483. private _scene;
  119484. private _positions;
  119485. private _indices;
  119486. private _normals;
  119487. private _colors;
  119488. private _uvs;
  119489. private _indices32;
  119490. private _positions32;
  119491. private _normals32;
  119492. private _fixedNormal32;
  119493. private _colors32;
  119494. private _uvs32;
  119495. private _index;
  119496. private _updatable;
  119497. private _pickable;
  119498. private _isVisibilityBoxLocked;
  119499. private _alwaysVisible;
  119500. private _depthSort;
  119501. private _expandable;
  119502. private _shapeCounter;
  119503. private _copy;
  119504. private _color;
  119505. private _computeParticleColor;
  119506. private _computeParticleTexture;
  119507. private _computeParticleRotation;
  119508. private _computeParticleVertex;
  119509. private _computeBoundingBox;
  119510. private _depthSortParticles;
  119511. private _camera;
  119512. private _mustUnrotateFixedNormals;
  119513. private _particlesIntersect;
  119514. private _needs32Bits;
  119515. private _isNotBuilt;
  119516. private _lastParticleId;
  119517. private _idxOfId;
  119518. private _multimaterialEnabled;
  119519. private _useModelMaterial;
  119520. private _indicesByMaterial;
  119521. private _materialIndexes;
  119522. private _depthSortFunction;
  119523. private _materialSortFunction;
  119524. private _materials;
  119525. private _multimaterial;
  119526. private _materialIndexesById;
  119527. private _defaultMaterial;
  119528. private _autoUpdateSubMeshes;
  119529. private _tmpVertex;
  119530. /**
  119531. * Creates a SPS (Solid Particle System) object.
  119532. * @param name (String) is the SPS name, this will be the underlying mesh name.
  119533. * @param scene (Scene) is the scene in which the SPS is added.
  119534. * @param options defines the options of the sps e.g.
  119535. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  119536. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  119537. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  119538. * * 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.
  119539. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  119540. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  119541. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  119542. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  119543. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  119544. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  119545. */
  119546. constructor(name: string, scene: Scene, options?: {
  119547. updatable?: boolean;
  119548. isPickable?: boolean;
  119549. enableDepthSort?: boolean;
  119550. particleIntersection?: boolean;
  119551. boundingSphereOnly?: boolean;
  119552. bSphereRadiusFactor?: number;
  119553. expandable?: boolean;
  119554. useModelMaterial?: boolean;
  119555. enableMultiMaterial?: boolean;
  119556. });
  119557. /**
  119558. * Builds the SPS underlying mesh. Returns a standard Mesh.
  119559. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  119560. * @returns the created mesh
  119561. */
  119562. buildMesh(): Mesh;
  119563. /**
  119564. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  119565. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  119566. * Thus the particles generated from `digest()` have their property `position` set yet.
  119567. * @param mesh ( Mesh ) is the mesh to be digested
  119568. * @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
  119569. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  119570. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  119571. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  119572. * @returns the current SPS
  119573. */
  119574. digest(mesh: Mesh, options?: {
  119575. facetNb?: number;
  119576. number?: number;
  119577. delta?: number;
  119578. storage?: [];
  119579. }): SolidParticleSystem;
  119580. /**
  119581. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  119582. * @hidden
  119583. */
  119584. private _unrotateFixedNormals;
  119585. /**
  119586. * Resets the temporary working copy particle
  119587. * @hidden
  119588. */
  119589. private _resetCopy;
  119590. /**
  119591. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  119592. * @param p the current index in the positions array to be updated
  119593. * @param ind the current index in the indices array
  119594. * @param shape a Vector3 array, the shape geometry
  119595. * @param positions the positions array to be updated
  119596. * @param meshInd the shape indices array
  119597. * @param indices the indices array to be updated
  119598. * @param meshUV the shape uv array
  119599. * @param uvs the uv array to be updated
  119600. * @param meshCol the shape color array
  119601. * @param colors the color array to be updated
  119602. * @param meshNor the shape normals array
  119603. * @param normals the normals array to be updated
  119604. * @param idx the particle index
  119605. * @param idxInShape the particle index in its shape
  119606. * @param options the addShape() method passed options
  119607. * @model the particle model
  119608. * @hidden
  119609. */
  119610. private _meshBuilder;
  119611. /**
  119612. * Returns a shape Vector3 array from positions float array
  119613. * @param positions float array
  119614. * @returns a vector3 array
  119615. * @hidden
  119616. */
  119617. private _posToShape;
  119618. /**
  119619. * Returns a shapeUV array from a float uvs (array deep copy)
  119620. * @param uvs as a float array
  119621. * @returns a shapeUV array
  119622. * @hidden
  119623. */
  119624. private _uvsToShapeUV;
  119625. /**
  119626. * Adds a new particle object in the particles array
  119627. * @param idx particle index in particles array
  119628. * @param id particle id
  119629. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  119630. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  119631. * @param model particle ModelShape object
  119632. * @param shapeId model shape identifier
  119633. * @param idxInShape index of the particle in the current model
  119634. * @param bInfo model bounding info object
  119635. * @param storage target storage array, if any
  119636. * @hidden
  119637. */
  119638. private _addParticle;
  119639. /**
  119640. * Adds some particles to the SPS from the model shape. Returns the shape id.
  119641. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  119642. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  119643. * @param nb (positive integer) the number of particles to be created from this model
  119644. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  119645. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  119646. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  119647. * @returns the number of shapes in the system
  119648. */
  119649. addShape(mesh: Mesh, nb: number, options?: {
  119650. positionFunction?: any;
  119651. vertexFunction?: any;
  119652. storage?: [];
  119653. }): number;
  119654. /**
  119655. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  119656. * @hidden
  119657. */
  119658. private _rebuildParticle;
  119659. /**
  119660. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  119661. * @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.
  119662. * @returns the SPS.
  119663. */
  119664. rebuildMesh(reset?: boolean): SolidParticleSystem;
  119665. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  119666. * Returns an array with the removed particles.
  119667. * 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.
  119668. * The SPS can't be empty so at least one particle needs to remain in place.
  119669. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  119670. * @param start index of the first particle to remove
  119671. * @param end index of the last particle to remove (included)
  119672. * @returns an array populated with the removed particles
  119673. */
  119674. removeParticles(start: number, end: number): SolidParticle[];
  119675. /**
  119676. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  119677. * @param solidParticleArray an array populated with Solid Particles objects
  119678. * @returns the SPS
  119679. */
  119680. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  119681. /**
  119682. * Creates a new particle and modifies the SPS mesh geometry :
  119683. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  119684. * - calls _addParticle() to populate the particle array
  119685. * factorized code from addShape() and insertParticlesFromArray()
  119686. * @param idx particle index in the particles array
  119687. * @param i particle index in its shape
  119688. * @param modelShape particle ModelShape object
  119689. * @param shape shape vertex array
  119690. * @param meshInd shape indices array
  119691. * @param meshUV shape uv array
  119692. * @param meshCol shape color array
  119693. * @param meshNor shape normals array
  119694. * @param bbInfo shape bounding info
  119695. * @param storage target particle storage
  119696. * @options addShape() passed options
  119697. * @hidden
  119698. */
  119699. private _insertNewParticle;
  119700. /**
  119701. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  119702. * This method calls `updateParticle()` for each particle of the SPS.
  119703. * For an animated SPS, it is usually called within the render loop.
  119704. * 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.
  119705. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  119706. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  119707. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  119708. * @returns the SPS.
  119709. */
  119710. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  119711. /**
  119712. * Disposes the SPS.
  119713. */
  119714. dispose(): void;
  119715. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  119716. * idx is the particle index in the SPS
  119717. * faceId is the picked face index counted within this particle.
  119718. * Returns null if the pickInfo can't identify a picked particle.
  119719. * @param pickingInfo (PickingInfo object)
  119720. * @returns {idx: number, faceId: number} or null
  119721. */
  119722. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  119723. idx: number;
  119724. faceId: number;
  119725. }>;
  119726. /**
  119727. * Returns a SolidParticle object from its identifier : particle.id
  119728. * @param id (integer) the particle Id
  119729. * @returns the searched particle or null if not found in the SPS.
  119730. */
  119731. getParticleById(id: number): Nullable<SolidParticle>;
  119732. /**
  119733. * Returns a new array populated with the particles having the passed shapeId.
  119734. * @param shapeId (integer) the shape identifier
  119735. * @returns a new solid particle array
  119736. */
  119737. getParticlesByShapeId(shapeId: number): SolidParticle[];
  119738. /**
  119739. * Populates the passed array "ref" with the particles having the passed shapeId.
  119740. * @param shapeId the shape identifier
  119741. * @returns the SPS
  119742. * @param ref
  119743. */
  119744. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  119745. /**
  119746. * Computes the required SubMeshes according the materials assigned to the particles.
  119747. * @returns the solid particle system.
  119748. * Does nothing if called before the SPS mesh is built.
  119749. */
  119750. computeSubMeshes(): SolidParticleSystem;
  119751. /**
  119752. * Sorts the solid particles by material when MultiMaterial is enabled.
  119753. * Updates the indices32 array.
  119754. * Updates the indicesByMaterial array.
  119755. * Updates the mesh indices array.
  119756. * @returns the SPS
  119757. * @hidden
  119758. */
  119759. private _sortParticlesByMaterial;
  119760. /**
  119761. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  119762. * @hidden
  119763. */
  119764. private _setMaterialIndexesById;
  119765. /**
  119766. * Returns an array with unique values of Materials from the passed array
  119767. * @param array the material array to be checked and filtered
  119768. * @hidden
  119769. */
  119770. private _filterUniqueMaterialId;
  119771. /**
  119772. * Sets a new Standard Material as _defaultMaterial if not already set.
  119773. * @hidden
  119774. */
  119775. private _setDefaultMaterial;
  119776. /**
  119777. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  119778. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119779. * @returns the SPS.
  119780. */
  119781. refreshVisibleSize(): SolidParticleSystem;
  119782. /**
  119783. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  119784. * @param size the size (float) of the visibility box
  119785. * note : this doesn't lock the SPS mesh bounding box.
  119786. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119787. */
  119788. setVisibilityBox(size: number): void;
  119789. /**
  119790. * Gets whether the SPS as always visible or not
  119791. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119792. */
  119793. get isAlwaysVisible(): boolean;
  119794. /**
  119795. * Sets the SPS as always visible or not
  119796. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119797. */
  119798. set isAlwaysVisible(val: boolean);
  119799. /**
  119800. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  119801. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119802. */
  119803. set isVisibilityBoxLocked(val: boolean);
  119804. /**
  119805. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  119806. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119807. */
  119808. get isVisibilityBoxLocked(): boolean;
  119809. /**
  119810. * Tells to `setParticles()` to compute the particle rotations or not.
  119811. * Default value : true. The SPS is faster when it's set to false.
  119812. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  119813. */
  119814. set computeParticleRotation(val: boolean);
  119815. /**
  119816. * Tells to `setParticles()` to compute the particle colors or not.
  119817. * Default value : true. The SPS is faster when it's set to false.
  119818. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  119819. */
  119820. set computeParticleColor(val: boolean);
  119821. set computeParticleTexture(val: boolean);
  119822. /**
  119823. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  119824. * Default value : false. The SPS is faster when it's set to false.
  119825. * Note : the particle custom vertex positions aren't stored values.
  119826. */
  119827. set computeParticleVertex(val: boolean);
  119828. /**
  119829. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  119830. */
  119831. set computeBoundingBox(val: boolean);
  119832. /**
  119833. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  119834. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  119835. * Default : `true`
  119836. */
  119837. set depthSortParticles(val: boolean);
  119838. /**
  119839. * Gets if `setParticles()` computes the particle rotations or not.
  119840. * Default value : true. The SPS is faster when it's set to false.
  119841. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  119842. */
  119843. get computeParticleRotation(): boolean;
  119844. /**
  119845. * Gets if `setParticles()` computes the particle colors or not.
  119846. * Default value : true. The SPS is faster when it's set to false.
  119847. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  119848. */
  119849. get computeParticleColor(): boolean;
  119850. /**
  119851. * Gets if `setParticles()` computes the particle textures or not.
  119852. * Default value : true. The SPS is faster when it's set to false.
  119853. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  119854. */
  119855. get computeParticleTexture(): boolean;
  119856. /**
  119857. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  119858. * Default value : false. The SPS is faster when it's set to false.
  119859. * Note : the particle custom vertex positions aren't stored values.
  119860. */
  119861. get computeParticleVertex(): boolean;
  119862. /**
  119863. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  119864. */
  119865. get computeBoundingBox(): boolean;
  119866. /**
  119867. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  119868. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  119869. * Default : `true`
  119870. */
  119871. get depthSortParticles(): boolean;
  119872. /**
  119873. * Gets if the SPS is created as expandable at construction time.
  119874. * Default : `false`
  119875. */
  119876. get expandable(): boolean;
  119877. /**
  119878. * Gets if the SPS supports the Multi Materials
  119879. */
  119880. get multimaterialEnabled(): boolean;
  119881. /**
  119882. * Gets if the SPS uses the model materials for its own multimaterial.
  119883. */
  119884. get useModelMaterial(): boolean;
  119885. /**
  119886. * The SPS used material array.
  119887. */
  119888. get materials(): Material[];
  119889. /**
  119890. * Sets the SPS MultiMaterial from the passed materials.
  119891. * Note : the passed array is internally copied and not used then by reference.
  119892. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  119893. */
  119894. setMultiMaterial(materials: Material[]): void;
  119895. /**
  119896. * The SPS computed multimaterial object
  119897. */
  119898. get multimaterial(): MultiMaterial;
  119899. set multimaterial(mm: MultiMaterial);
  119900. /**
  119901. * If the subMeshes must be updated on the next call to setParticles()
  119902. */
  119903. get autoUpdateSubMeshes(): boolean;
  119904. set autoUpdateSubMeshes(val: boolean);
  119905. /**
  119906. * This function does nothing. It may be overwritten to set all the particle first values.
  119907. * The SPS doesn't call this function, you may have to call it by your own.
  119908. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  119909. */
  119910. initParticles(): void;
  119911. /**
  119912. * This function does nothing. It may be overwritten to recycle a particle.
  119913. * The SPS doesn't call this function, you may have to call it by your own.
  119914. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  119915. * @param particle The particle to recycle
  119916. * @returns the recycled particle
  119917. */
  119918. recycleParticle(particle: SolidParticle): SolidParticle;
  119919. /**
  119920. * Updates a particle : this function should be overwritten by the user.
  119921. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  119922. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  119923. * @example : just set a particle position or velocity and recycle conditions
  119924. * @param particle The particle to update
  119925. * @returns the updated particle
  119926. */
  119927. updateParticle(particle: SolidParticle): SolidParticle;
  119928. /**
  119929. * Updates a vertex of a particle : it can be overwritten by the user.
  119930. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  119931. * @param particle the current particle
  119932. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  119933. * @param pt the index of the current vertex in the particle shape
  119934. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  119935. * @example : just set a vertex particle position or color
  119936. * @returns the sps
  119937. */
  119938. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  119939. /**
  119940. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  119941. * This does nothing and may be overwritten by the user.
  119942. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119943. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119944. * @param update the boolean update value actually passed to setParticles()
  119945. */
  119946. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  119947. /**
  119948. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  119949. * This will be passed three parameters.
  119950. * This does nothing and may be overwritten by the user.
  119951. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119952. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119953. * @param update the boolean update value actually passed to setParticles()
  119954. */
  119955. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  119956. }
  119957. }
  119958. declare module BABYLON {
  119959. /**
  119960. * Represents one particle of a solid particle system.
  119961. */
  119962. export class SolidParticle {
  119963. /**
  119964. * particle global index
  119965. */
  119966. idx: number;
  119967. /**
  119968. * particle identifier
  119969. */
  119970. id: number;
  119971. /**
  119972. * The color of the particle
  119973. */
  119974. color: Nullable<Color4>;
  119975. /**
  119976. * The world space position of the particle.
  119977. */
  119978. position: Vector3;
  119979. /**
  119980. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  119981. */
  119982. rotation: Vector3;
  119983. /**
  119984. * The world space rotation quaternion of the particle.
  119985. */
  119986. rotationQuaternion: Nullable<Quaternion>;
  119987. /**
  119988. * The scaling of the particle.
  119989. */
  119990. scaling: Vector3;
  119991. /**
  119992. * The uvs of the particle.
  119993. */
  119994. uvs: Vector4;
  119995. /**
  119996. * The current speed of the particle.
  119997. */
  119998. velocity: Vector3;
  119999. /**
  120000. * The pivot point in the particle local space.
  120001. */
  120002. pivot: Vector3;
  120003. /**
  120004. * Must the particle be translated from its pivot point in its local space ?
  120005. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  120006. * Default : false
  120007. */
  120008. translateFromPivot: boolean;
  120009. /**
  120010. * Is the particle active or not ?
  120011. */
  120012. alive: boolean;
  120013. /**
  120014. * Is the particle visible or not ?
  120015. */
  120016. isVisible: boolean;
  120017. /**
  120018. * Index of this particle in the global "positions" array (Internal use)
  120019. * @hidden
  120020. */
  120021. _pos: number;
  120022. /**
  120023. * @hidden Index of this particle in the global "indices" array (Internal use)
  120024. */
  120025. _ind: number;
  120026. /**
  120027. * @hidden ModelShape of this particle (Internal use)
  120028. */
  120029. _model: ModelShape;
  120030. /**
  120031. * ModelShape id of this particle
  120032. */
  120033. shapeId: number;
  120034. /**
  120035. * Index of the particle in its shape id
  120036. */
  120037. idxInShape: number;
  120038. /**
  120039. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  120040. */
  120041. _modelBoundingInfo: BoundingInfo;
  120042. /**
  120043. * @hidden Particle BoundingInfo object (Internal use)
  120044. */
  120045. _boundingInfo: BoundingInfo;
  120046. /**
  120047. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  120048. */
  120049. _sps: SolidParticleSystem;
  120050. /**
  120051. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  120052. */
  120053. _stillInvisible: boolean;
  120054. /**
  120055. * @hidden Last computed particle rotation matrix
  120056. */
  120057. _rotationMatrix: number[];
  120058. /**
  120059. * Parent particle Id, if any.
  120060. * Default null.
  120061. */
  120062. parentId: Nullable<number>;
  120063. /**
  120064. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  120065. */
  120066. materialIndex: Nullable<number>;
  120067. /**
  120068. * Custom object or properties.
  120069. */
  120070. props: Nullable<any>;
  120071. /**
  120072. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  120073. * The possible values are :
  120074. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120075. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120076. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120077. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120078. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120079. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  120080. * */
  120081. cullingStrategy: number;
  120082. /**
  120083. * @hidden Internal global position in the SPS.
  120084. */
  120085. _globalPosition: Vector3;
  120086. /**
  120087. * Creates a Solid Particle object.
  120088. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  120089. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  120090. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  120091. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  120092. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  120093. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  120094. * @param shapeId (integer) is the model shape identifier in the SPS.
  120095. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  120096. * @param sps defines the sps it is associated to
  120097. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  120098. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  120099. */
  120100. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  120101. /**
  120102. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  120103. * @param target the particle target
  120104. * @returns the current particle
  120105. */
  120106. copyToRef(target: SolidParticle): SolidParticle;
  120107. /**
  120108. * Legacy support, changed scale to scaling
  120109. */
  120110. get scale(): Vector3;
  120111. /**
  120112. * Legacy support, changed scale to scaling
  120113. */
  120114. set scale(scale: Vector3);
  120115. /**
  120116. * Legacy support, changed quaternion to rotationQuaternion
  120117. */
  120118. get quaternion(): Nullable<Quaternion>;
  120119. /**
  120120. * Legacy support, changed quaternion to rotationQuaternion
  120121. */
  120122. set quaternion(q: Nullable<Quaternion>);
  120123. /**
  120124. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  120125. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  120126. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  120127. * @returns true if it intersects
  120128. */
  120129. intersectsMesh(target: Mesh | SolidParticle): boolean;
  120130. /**
  120131. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  120132. * A particle is in the frustum if its bounding box intersects the frustum
  120133. * @param frustumPlanes defines the frustum to test
  120134. * @returns true if the particle is in the frustum planes
  120135. */
  120136. isInFrustum(frustumPlanes: Plane[]): boolean;
  120137. /**
  120138. * get the rotation matrix of the particle
  120139. * @hidden
  120140. */
  120141. getRotationMatrix(m: Matrix): void;
  120142. }
  120143. /**
  120144. * Represents the shape of the model used by one particle of a solid particle system.
  120145. * SPS internal tool, don't use it manually.
  120146. */
  120147. export class ModelShape {
  120148. /**
  120149. * The shape id
  120150. * @hidden
  120151. */
  120152. shapeID: number;
  120153. /**
  120154. * flat array of model positions (internal use)
  120155. * @hidden
  120156. */
  120157. _shape: Vector3[];
  120158. /**
  120159. * flat array of model UVs (internal use)
  120160. * @hidden
  120161. */
  120162. _shapeUV: number[];
  120163. /**
  120164. * color array of the model
  120165. * @hidden
  120166. */
  120167. _shapeColors: number[];
  120168. /**
  120169. * indices array of the model
  120170. * @hidden
  120171. */
  120172. _indices: number[];
  120173. /**
  120174. * normals array of the model
  120175. * @hidden
  120176. */
  120177. _normals: number[];
  120178. /**
  120179. * length of the shape in the model indices array (internal use)
  120180. * @hidden
  120181. */
  120182. _indicesLength: number;
  120183. /**
  120184. * Custom position function (internal use)
  120185. * @hidden
  120186. */
  120187. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  120188. /**
  120189. * Custom vertex function (internal use)
  120190. * @hidden
  120191. */
  120192. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  120193. /**
  120194. * Model material (internal use)
  120195. * @hidden
  120196. */
  120197. _material: Nullable<Material>;
  120198. /**
  120199. * 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.
  120200. * SPS internal tool, don't use it manually.
  120201. * @hidden
  120202. */
  120203. 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>);
  120204. }
  120205. /**
  120206. * Represents a Depth Sorted Particle in the solid particle system.
  120207. * @hidden
  120208. */
  120209. export class DepthSortedParticle {
  120210. /**
  120211. * Particle index
  120212. */
  120213. idx: number;
  120214. /**
  120215. * Index of the particle in the "indices" array
  120216. */
  120217. ind: number;
  120218. /**
  120219. * Length of the particle shape in the "indices" array
  120220. */
  120221. indicesLength: number;
  120222. /**
  120223. * Squared distance from the particle to the camera
  120224. */
  120225. sqDistance: number;
  120226. /**
  120227. * Material index when used with MultiMaterials
  120228. */
  120229. materialIndex: number;
  120230. /**
  120231. * Creates a new sorted particle
  120232. * @param materialIndex
  120233. */
  120234. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  120235. }
  120236. /**
  120237. * Represents a solid particle vertex
  120238. */
  120239. export class SolidParticleVertex {
  120240. /**
  120241. * Vertex position
  120242. */
  120243. position: Vector3;
  120244. /**
  120245. * Vertex color
  120246. */
  120247. color: Color4;
  120248. /**
  120249. * Vertex UV
  120250. */
  120251. uv: Vector2;
  120252. /**
  120253. * Creates a new solid particle vertex
  120254. */
  120255. constructor();
  120256. /** Vertex x coordinate */
  120257. get x(): number;
  120258. set x(val: number);
  120259. /** Vertex y coordinate */
  120260. get y(): number;
  120261. set y(val: number);
  120262. /** Vertex z coordinate */
  120263. get z(): number;
  120264. set z(val: number);
  120265. }
  120266. }
  120267. declare module BABYLON {
  120268. /**
  120269. * @hidden
  120270. */
  120271. export class _MeshCollisionData {
  120272. _checkCollisions: boolean;
  120273. _collisionMask: number;
  120274. _collisionGroup: number;
  120275. _surroundingMeshes: Nullable<AbstractMesh[]>;
  120276. _collider: Nullable<Collider>;
  120277. _oldPositionForCollisions: Vector3;
  120278. _diffPositionForCollisions: Vector3;
  120279. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  120280. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  120281. _collisionResponse: boolean;
  120282. }
  120283. }
  120284. declare module BABYLON {
  120285. /** @hidden */
  120286. class _FacetDataStorage {
  120287. facetPositions: Vector3[];
  120288. facetNormals: Vector3[];
  120289. facetPartitioning: number[][];
  120290. facetNb: number;
  120291. partitioningSubdivisions: number;
  120292. partitioningBBoxRatio: number;
  120293. facetDataEnabled: boolean;
  120294. facetParameters: any;
  120295. bbSize: Vector3;
  120296. subDiv: {
  120297. max: number;
  120298. X: number;
  120299. Y: number;
  120300. Z: number;
  120301. };
  120302. facetDepthSort: boolean;
  120303. facetDepthSortEnabled: boolean;
  120304. depthSortedIndices: IndicesArray;
  120305. depthSortedFacets: {
  120306. ind: number;
  120307. sqDistance: number;
  120308. }[];
  120309. facetDepthSortFunction: (f1: {
  120310. ind: number;
  120311. sqDistance: number;
  120312. }, f2: {
  120313. ind: number;
  120314. sqDistance: number;
  120315. }) => number;
  120316. facetDepthSortFrom: Vector3;
  120317. facetDepthSortOrigin: Vector3;
  120318. invertedMatrix: Matrix;
  120319. }
  120320. /**
  120321. * @hidden
  120322. **/
  120323. class _InternalAbstractMeshDataInfo {
  120324. _hasVertexAlpha: boolean;
  120325. _useVertexColors: boolean;
  120326. _numBoneInfluencers: number;
  120327. _applyFog: boolean;
  120328. _receiveShadows: boolean;
  120329. _facetData: _FacetDataStorage;
  120330. _visibility: number;
  120331. _skeleton: Nullable<Skeleton>;
  120332. _layerMask: number;
  120333. _computeBonesUsingShaders: boolean;
  120334. _isActive: boolean;
  120335. _onlyForInstances: boolean;
  120336. _isActiveIntermediate: boolean;
  120337. _onlyForInstancesIntermediate: boolean;
  120338. _actAsRegularMesh: boolean;
  120339. _currentLOD: Nullable<AbstractMesh>;
  120340. _currentLODIsUpToDate: boolean;
  120341. }
  120342. /**
  120343. * Class used to store all common mesh properties
  120344. */
  120345. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  120346. /** No occlusion */
  120347. static OCCLUSION_TYPE_NONE: number;
  120348. /** Occlusion set to optimisitic */
  120349. static OCCLUSION_TYPE_OPTIMISTIC: number;
  120350. /** Occlusion set to strict */
  120351. static OCCLUSION_TYPE_STRICT: number;
  120352. /** Use an accurante occlusion algorithm */
  120353. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  120354. /** Use a conservative occlusion algorithm */
  120355. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  120356. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  120357. * Test order :
  120358. * Is the bounding sphere outside the frustum ?
  120359. * If not, are the bounding box vertices outside the frustum ?
  120360. * It not, then the cullable object is in the frustum.
  120361. */
  120362. static readonly CULLINGSTRATEGY_STANDARD: number;
  120363. /** Culling strategy : Bounding Sphere Only.
  120364. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  120365. * It's also less accurate than the standard because some not visible objects can still be selected.
  120366. * Test : is the bounding sphere outside the frustum ?
  120367. * If not, then the cullable object is in the frustum.
  120368. */
  120369. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  120370. /** Culling strategy : Optimistic Inclusion.
  120371. * This in an inclusion test first, then the standard exclusion test.
  120372. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  120373. * 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.
  120374. * Anyway, it's as accurate as the standard strategy.
  120375. * Test :
  120376. * Is the cullable object bounding sphere center in the frustum ?
  120377. * If not, apply the default culling strategy.
  120378. */
  120379. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  120380. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  120381. * This in an inclusion test first, then the bounding sphere only exclusion test.
  120382. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  120383. * 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.
  120384. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  120385. * Test :
  120386. * Is the cullable object bounding sphere center in the frustum ?
  120387. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  120388. */
  120389. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  120390. /**
  120391. * No billboard
  120392. */
  120393. static get BILLBOARDMODE_NONE(): number;
  120394. /** Billboard on X axis */
  120395. static get BILLBOARDMODE_X(): number;
  120396. /** Billboard on Y axis */
  120397. static get BILLBOARDMODE_Y(): number;
  120398. /** Billboard on Z axis */
  120399. static get BILLBOARDMODE_Z(): number;
  120400. /** Billboard on all axes */
  120401. static get BILLBOARDMODE_ALL(): number;
  120402. /** Billboard on using position instead of orientation */
  120403. static get BILLBOARDMODE_USE_POSITION(): number;
  120404. /** @hidden */
  120405. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  120406. /**
  120407. * The culling strategy to use to check whether the mesh must be rendered or not.
  120408. * This value can be changed at any time and will be used on the next render mesh selection.
  120409. * The possible values are :
  120410. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120411. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120412. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120413. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120414. * Please read each static variable documentation to get details about the culling process.
  120415. * */
  120416. cullingStrategy: number;
  120417. /**
  120418. * Gets the number of facets in the mesh
  120419. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  120420. */
  120421. get facetNb(): number;
  120422. /**
  120423. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  120424. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  120425. */
  120426. get partitioningSubdivisions(): number;
  120427. set partitioningSubdivisions(nb: number);
  120428. /**
  120429. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  120430. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  120431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  120432. */
  120433. get partitioningBBoxRatio(): number;
  120434. set partitioningBBoxRatio(ratio: number);
  120435. /**
  120436. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  120437. * Works only for updatable meshes.
  120438. * Doesn't work with multi-materials
  120439. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  120440. */
  120441. get mustDepthSortFacets(): boolean;
  120442. set mustDepthSortFacets(sort: boolean);
  120443. /**
  120444. * The location (Vector3) where the facet depth sort must be computed from.
  120445. * By default, the active camera position.
  120446. * Used only when facet depth sort is enabled
  120447. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  120448. */
  120449. get facetDepthSortFrom(): Vector3;
  120450. set facetDepthSortFrom(location: Vector3);
  120451. /**
  120452. * gets a boolean indicating if facetData is enabled
  120453. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  120454. */
  120455. get isFacetDataEnabled(): boolean;
  120456. /** @hidden */
  120457. _updateNonUniformScalingState(value: boolean): boolean;
  120458. /**
  120459. * An event triggered when this mesh collides with another one
  120460. */
  120461. onCollideObservable: Observable<AbstractMesh>;
  120462. /** Set a function to call when this mesh collides with another one */
  120463. set onCollide(callback: () => void);
  120464. /**
  120465. * An event triggered when the collision's position changes
  120466. */
  120467. onCollisionPositionChangeObservable: Observable<Vector3>;
  120468. /** Set a function to call when the collision's position changes */
  120469. set onCollisionPositionChange(callback: () => void);
  120470. /**
  120471. * An event triggered when material is changed
  120472. */
  120473. onMaterialChangedObservable: Observable<AbstractMesh>;
  120474. /**
  120475. * Gets or sets the orientation for POV movement & rotation
  120476. */
  120477. definedFacingForward: boolean;
  120478. /** @hidden */
  120479. _occlusionQuery: Nullable<WebGLQuery>;
  120480. /** @hidden */
  120481. _renderingGroup: Nullable<RenderingGroup>;
  120482. /**
  120483. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  120484. */
  120485. get visibility(): number;
  120486. /**
  120487. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  120488. */
  120489. set visibility(value: number);
  120490. /** Gets or sets the alpha index used to sort transparent meshes
  120491. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  120492. */
  120493. alphaIndex: number;
  120494. /**
  120495. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  120496. */
  120497. isVisible: boolean;
  120498. /**
  120499. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  120500. */
  120501. isPickable: boolean;
  120502. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  120503. showSubMeshesBoundingBox: boolean;
  120504. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  120505. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120506. */
  120507. isBlocker: boolean;
  120508. /**
  120509. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  120510. */
  120511. enablePointerMoveEvents: boolean;
  120512. private _renderingGroupId;
  120513. /**
  120514. * Specifies the rendering group id for this mesh (0 by default)
  120515. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  120516. */
  120517. get renderingGroupId(): number;
  120518. set renderingGroupId(value: number);
  120519. private _material;
  120520. /** Gets or sets current material */
  120521. get material(): Nullable<Material>;
  120522. set material(value: Nullable<Material>);
  120523. /**
  120524. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  120525. * @see https://doc.babylonjs.com/babylon101/shadows
  120526. */
  120527. get receiveShadows(): boolean;
  120528. set receiveShadows(value: boolean);
  120529. /** Defines color to use when rendering outline */
  120530. outlineColor: Color3;
  120531. /** Define width to use when rendering outline */
  120532. outlineWidth: number;
  120533. /** Defines color to use when rendering overlay */
  120534. overlayColor: Color3;
  120535. /** Defines alpha to use when rendering overlay */
  120536. overlayAlpha: number;
  120537. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  120538. get hasVertexAlpha(): boolean;
  120539. set hasVertexAlpha(value: boolean);
  120540. /** 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) */
  120541. get useVertexColors(): boolean;
  120542. set useVertexColors(value: boolean);
  120543. /**
  120544. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  120545. */
  120546. get computeBonesUsingShaders(): boolean;
  120547. set computeBonesUsingShaders(value: boolean);
  120548. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  120549. get numBoneInfluencers(): number;
  120550. set numBoneInfluencers(value: number);
  120551. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  120552. get applyFog(): boolean;
  120553. set applyFog(value: boolean);
  120554. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  120555. useOctreeForRenderingSelection: boolean;
  120556. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  120557. useOctreeForPicking: boolean;
  120558. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  120559. useOctreeForCollisions: boolean;
  120560. /**
  120561. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  120562. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  120563. */
  120564. get layerMask(): number;
  120565. set layerMask(value: number);
  120566. /**
  120567. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  120568. */
  120569. alwaysSelectAsActiveMesh: boolean;
  120570. /**
  120571. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  120572. */
  120573. doNotSyncBoundingInfo: boolean;
  120574. /**
  120575. * Gets or sets the current action manager
  120576. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120577. */
  120578. actionManager: Nullable<AbstractActionManager>;
  120579. private _meshCollisionData;
  120580. /**
  120581. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  120582. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120583. */
  120584. ellipsoid: Vector3;
  120585. /**
  120586. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  120587. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120588. */
  120589. ellipsoidOffset: Vector3;
  120590. /**
  120591. * Gets or sets a collision mask used to mask collisions (default is -1).
  120592. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  120593. */
  120594. get collisionMask(): number;
  120595. set collisionMask(mask: number);
  120596. /**
  120597. * Gets or sets a collision response flag (default is true).
  120598. * when collisionResponse is false, events are still triggered but colliding entity has no response
  120599. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  120600. * to respond to the collision.
  120601. */
  120602. get collisionResponse(): boolean;
  120603. set collisionResponse(response: boolean);
  120604. /**
  120605. * Gets or sets the current collision group mask (-1 by default).
  120606. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  120607. */
  120608. get collisionGroup(): number;
  120609. set collisionGroup(mask: number);
  120610. /**
  120611. * Gets or sets current surrounding meshes (null by default).
  120612. *
  120613. * By default collision detection is tested against every mesh in the scene.
  120614. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  120615. * meshes will be tested for the collision.
  120616. *
  120617. * Note: if set to an empty array no collision will happen when this mesh is moved.
  120618. */
  120619. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  120620. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  120621. /**
  120622. * Defines edge width used when edgesRenderer is enabled
  120623. * @see https://www.babylonjs-playground.com/#10OJSG#13
  120624. */
  120625. edgesWidth: number;
  120626. /**
  120627. * Defines edge color used when edgesRenderer is enabled
  120628. * @see https://www.babylonjs-playground.com/#10OJSG#13
  120629. */
  120630. edgesColor: Color4;
  120631. /** @hidden */
  120632. _edgesRenderer: Nullable<IEdgesRenderer>;
  120633. /** @hidden */
  120634. _masterMesh: Nullable<AbstractMesh>;
  120635. /** @hidden */
  120636. _boundingInfo: Nullable<BoundingInfo>;
  120637. /** @hidden */
  120638. _renderId: number;
  120639. /**
  120640. * Gets or sets the list of subMeshes
  120641. * @see https://doc.babylonjs.com/how_to/multi_materials
  120642. */
  120643. subMeshes: SubMesh[];
  120644. /** @hidden */
  120645. _intersectionsInProgress: AbstractMesh[];
  120646. /** @hidden */
  120647. _unIndexed: boolean;
  120648. /** @hidden */
  120649. _lightSources: Light[];
  120650. /** Gets the list of lights affecting that mesh */
  120651. get lightSources(): Light[];
  120652. /** @hidden */
  120653. get _positions(): Nullable<Vector3[]>;
  120654. /** @hidden */
  120655. _waitingData: {
  120656. lods: Nullable<any>;
  120657. actions: Nullable<any>;
  120658. freezeWorldMatrix: Nullable<boolean>;
  120659. };
  120660. /** @hidden */
  120661. _bonesTransformMatrices: Nullable<Float32Array>;
  120662. /** @hidden */
  120663. _transformMatrixTexture: Nullable<RawTexture>;
  120664. /**
  120665. * Gets or sets a skeleton to apply skining transformations
  120666. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120667. */
  120668. set skeleton(value: Nullable<Skeleton>);
  120669. get skeleton(): Nullable<Skeleton>;
  120670. /**
  120671. * An event triggered when the mesh is rebuilt.
  120672. */
  120673. onRebuildObservable: Observable<AbstractMesh>;
  120674. /**
  120675. * The current mesh unifom buffer.
  120676. * @hidden Internal use only.
  120677. */
  120678. _uniformBuffer: UniformBuffer;
  120679. /**
  120680. * Creates a new AbstractMesh
  120681. * @param name defines the name of the mesh
  120682. * @param scene defines the hosting scene
  120683. */
  120684. constructor(name: string, scene?: Nullable<Scene>);
  120685. protected _buildUniformLayout(): void;
  120686. /**
  120687. * Transfer the mesh values to its UBO.
  120688. * @param world The world matrix associated with the mesh
  120689. */
  120690. transferToEffect(world: Matrix): void;
  120691. /**
  120692. * Gets the mesh uniform buffer.
  120693. * @return the uniform buffer of the mesh.
  120694. */
  120695. getMeshUniformBuffer(): UniformBuffer;
  120696. /**
  120697. * Returns the string "AbstractMesh"
  120698. * @returns "AbstractMesh"
  120699. */
  120700. getClassName(): string;
  120701. /**
  120702. * Gets a string representation of the current mesh
  120703. * @param fullDetails defines a boolean indicating if full details must be included
  120704. * @returns a string representation of the current mesh
  120705. */
  120706. toString(fullDetails?: boolean): string;
  120707. /**
  120708. * @hidden
  120709. */
  120710. protected _getEffectiveParent(): Nullable<Node>;
  120711. /** @hidden */
  120712. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  120713. /** @hidden */
  120714. _rebuild(): void;
  120715. /** @hidden */
  120716. _resyncLightSources(): void;
  120717. /** @hidden */
  120718. _resyncLightSource(light: Light): void;
  120719. /** @hidden */
  120720. _unBindEffect(): void;
  120721. /** @hidden */
  120722. _removeLightSource(light: Light, dispose: boolean): void;
  120723. private _markSubMeshesAsDirty;
  120724. /** @hidden */
  120725. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  120726. /** @hidden */
  120727. _markSubMeshesAsAttributesDirty(): void;
  120728. /** @hidden */
  120729. _markSubMeshesAsMiscDirty(): void;
  120730. /**
  120731. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  120732. */
  120733. get scaling(): Vector3;
  120734. set scaling(newScaling: Vector3);
  120735. /**
  120736. * Returns true if the mesh is blocked. Implemented by child classes
  120737. */
  120738. get isBlocked(): boolean;
  120739. /**
  120740. * Returns the mesh itself by default. Implemented by child classes
  120741. * @param camera defines the camera to use to pick the right LOD level
  120742. * @returns the currentAbstractMesh
  120743. */
  120744. getLOD(camera: Camera): Nullable<AbstractMesh>;
  120745. /**
  120746. * Returns 0 by default. Implemented by child classes
  120747. * @returns an integer
  120748. */
  120749. getTotalVertices(): number;
  120750. /**
  120751. * Returns a positive integer : the total number of indices in this mesh geometry.
  120752. * @returns the numner of indices or zero if the mesh has no geometry.
  120753. */
  120754. getTotalIndices(): number;
  120755. /**
  120756. * Returns null by default. Implemented by child classes
  120757. * @returns null
  120758. */
  120759. getIndices(): Nullable<IndicesArray>;
  120760. /**
  120761. * Returns the array of the requested vertex data kind. Implemented by child classes
  120762. * @param kind defines the vertex data kind to use
  120763. * @returns null
  120764. */
  120765. getVerticesData(kind: string): Nullable<FloatArray>;
  120766. /**
  120767. * Sets the vertex data of the mesh geometry for the requested `kind`.
  120768. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  120769. * Note that a new underlying VertexBuffer object is created each call.
  120770. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  120771. * @param kind defines vertex data kind:
  120772. * * VertexBuffer.PositionKind
  120773. * * VertexBuffer.UVKind
  120774. * * VertexBuffer.UV2Kind
  120775. * * VertexBuffer.UV3Kind
  120776. * * VertexBuffer.UV4Kind
  120777. * * VertexBuffer.UV5Kind
  120778. * * VertexBuffer.UV6Kind
  120779. * * VertexBuffer.ColorKind
  120780. * * VertexBuffer.MatricesIndicesKind
  120781. * * VertexBuffer.MatricesIndicesExtraKind
  120782. * * VertexBuffer.MatricesWeightsKind
  120783. * * VertexBuffer.MatricesWeightsExtraKind
  120784. * @param data defines the data source
  120785. * @param updatable defines if the data must be flagged as updatable (or static)
  120786. * @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
  120787. * @returns the current mesh
  120788. */
  120789. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  120790. /**
  120791. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  120792. * If the mesh has no geometry, it is simply returned as it is.
  120793. * @param kind defines vertex data kind:
  120794. * * VertexBuffer.PositionKind
  120795. * * VertexBuffer.UVKind
  120796. * * VertexBuffer.UV2Kind
  120797. * * VertexBuffer.UV3Kind
  120798. * * VertexBuffer.UV4Kind
  120799. * * VertexBuffer.UV5Kind
  120800. * * VertexBuffer.UV6Kind
  120801. * * VertexBuffer.ColorKind
  120802. * * VertexBuffer.MatricesIndicesKind
  120803. * * VertexBuffer.MatricesIndicesExtraKind
  120804. * * VertexBuffer.MatricesWeightsKind
  120805. * * VertexBuffer.MatricesWeightsExtraKind
  120806. * @param data defines the data source
  120807. * @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
  120808. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  120809. * @returns the current mesh
  120810. */
  120811. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  120812. /**
  120813. * Sets the mesh indices,
  120814. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  120815. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  120816. * @param totalVertices Defines the total number of vertices
  120817. * @returns the current mesh
  120818. */
  120819. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  120820. /**
  120821. * Gets a boolean indicating if specific vertex data is present
  120822. * @param kind defines the vertex data kind to use
  120823. * @returns true is data kind is present
  120824. */
  120825. isVerticesDataPresent(kind: string): boolean;
  120826. /**
  120827. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  120828. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  120829. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  120830. * @returns a BoundingInfo
  120831. */
  120832. getBoundingInfo(): BoundingInfo;
  120833. /**
  120834. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  120835. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  120836. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  120837. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  120838. * @returns the current mesh
  120839. */
  120840. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  120841. /**
  120842. * Overwrite the current bounding info
  120843. * @param boundingInfo defines the new bounding info
  120844. * @returns the current mesh
  120845. */
  120846. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  120847. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  120848. get useBones(): boolean;
  120849. /** @hidden */
  120850. _preActivate(): void;
  120851. /** @hidden */
  120852. _preActivateForIntermediateRendering(renderId: number): void;
  120853. /** @hidden */
  120854. _activate(renderId: number, intermediateRendering: boolean): boolean;
  120855. /** @hidden */
  120856. _postActivate(): void;
  120857. /** @hidden */
  120858. _freeze(): void;
  120859. /** @hidden */
  120860. _unFreeze(): void;
  120861. /**
  120862. * Gets the current world matrix
  120863. * @returns a Matrix
  120864. */
  120865. getWorldMatrix(): Matrix;
  120866. /** @hidden */
  120867. _getWorldMatrixDeterminant(): number;
  120868. /**
  120869. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  120870. */
  120871. get isAnInstance(): boolean;
  120872. /**
  120873. * Gets a boolean indicating if this mesh has instances
  120874. */
  120875. get hasInstances(): boolean;
  120876. /**
  120877. * Gets a boolean indicating if this mesh has thin instances
  120878. */
  120879. get hasThinInstances(): boolean;
  120880. /**
  120881. * Perform relative position change from the point of view of behind the front of the mesh.
  120882. * This is performed taking into account the meshes current rotation, so you do not have to care.
  120883. * Supports definition of mesh facing forward or backward
  120884. * @param amountRight defines the distance on the right axis
  120885. * @param amountUp defines the distance on the up axis
  120886. * @param amountForward defines the distance on the forward axis
  120887. * @returns the current mesh
  120888. */
  120889. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  120890. /**
  120891. * Calculate relative position change from the point of view of behind the front of the mesh.
  120892. * This is performed taking into account the meshes current rotation, so you do not have to care.
  120893. * Supports definition of mesh facing forward or backward
  120894. * @param amountRight defines the distance on the right axis
  120895. * @param amountUp defines the distance on the up axis
  120896. * @param amountForward defines the distance on the forward axis
  120897. * @returns the new displacement vector
  120898. */
  120899. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  120900. /**
  120901. * Perform relative rotation change from the point of view of behind the front of the mesh.
  120902. * Supports definition of mesh facing forward or backward
  120903. * @param flipBack defines the flip
  120904. * @param twirlClockwise defines the twirl
  120905. * @param tiltRight defines the tilt
  120906. * @returns the current mesh
  120907. */
  120908. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  120909. /**
  120910. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  120911. * Supports definition of mesh facing forward or backward.
  120912. * @param flipBack defines the flip
  120913. * @param twirlClockwise defines the twirl
  120914. * @param tiltRight defines the tilt
  120915. * @returns the new rotation vector
  120916. */
  120917. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  120918. /**
  120919. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  120920. * This means the mesh underlying bounding box and sphere are recomputed.
  120921. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  120922. * @returns the current mesh
  120923. */
  120924. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  120925. /** @hidden */
  120926. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  120927. /** @hidden */
  120928. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  120929. /** @hidden */
  120930. _updateBoundingInfo(): AbstractMesh;
  120931. /** @hidden */
  120932. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  120933. /** @hidden */
  120934. protected _afterComputeWorldMatrix(): void;
  120935. /** @hidden */
  120936. get _effectiveMesh(): AbstractMesh;
  120937. /**
  120938. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  120939. * A mesh is in the frustum if its bounding box intersects the frustum
  120940. * @param frustumPlanes defines the frustum to test
  120941. * @returns true if the mesh is in the frustum planes
  120942. */
  120943. isInFrustum(frustumPlanes: Plane[]): boolean;
  120944. /**
  120945. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  120946. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  120947. * @param frustumPlanes defines the frustum to test
  120948. * @returns true if the mesh is completely in the frustum planes
  120949. */
  120950. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  120951. /**
  120952. * True if the mesh intersects another mesh or a SolidParticle object
  120953. * @param mesh defines a target mesh or SolidParticle to test
  120954. * @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)
  120955. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  120956. * @returns true if there is an intersection
  120957. */
  120958. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  120959. /**
  120960. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  120961. * @param point defines the point to test
  120962. * @returns true if there is an intersection
  120963. */
  120964. intersectsPoint(point: Vector3): boolean;
  120965. /**
  120966. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  120967. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120968. */
  120969. get checkCollisions(): boolean;
  120970. set checkCollisions(collisionEnabled: boolean);
  120971. /**
  120972. * Gets Collider object used to compute collisions (not physics)
  120973. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120974. */
  120975. get collider(): Nullable<Collider>;
  120976. /**
  120977. * Move the mesh using collision engine
  120978. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120979. * @param displacement defines the requested displacement vector
  120980. * @returns the current mesh
  120981. */
  120982. moveWithCollisions(displacement: Vector3): AbstractMesh;
  120983. private _onCollisionPositionChange;
  120984. /** @hidden */
  120985. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  120986. /** @hidden */
  120987. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  120988. /** @hidden */
  120989. _checkCollision(collider: Collider): AbstractMesh;
  120990. /** @hidden */
  120991. _generatePointsArray(): boolean;
  120992. /**
  120993. * Checks if the passed Ray intersects with the mesh
  120994. * @param ray defines the ray to use
  120995. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  120996. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120997. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  120998. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  120999. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  121000. * @returns the picking info
  121001. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  121002. */
  121003. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  121004. /**
  121005. * Clones the current mesh
  121006. * @param name defines the mesh name
  121007. * @param newParent defines the new mesh parent
  121008. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  121009. * @returns the new mesh
  121010. */
  121011. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  121012. /**
  121013. * Disposes all the submeshes of the current meshnp
  121014. * @returns the current mesh
  121015. */
  121016. releaseSubMeshes(): AbstractMesh;
  121017. /**
  121018. * Releases resources associated with this abstract mesh.
  121019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121021. */
  121022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121023. /**
  121024. * Adds the passed mesh as a child to the current mesh
  121025. * @param mesh defines the child mesh
  121026. * @returns the current mesh
  121027. */
  121028. addChild(mesh: AbstractMesh): AbstractMesh;
  121029. /**
  121030. * Removes the passed mesh from the current mesh children list
  121031. * @param mesh defines the child mesh
  121032. * @returns the current mesh
  121033. */
  121034. removeChild(mesh: AbstractMesh): AbstractMesh;
  121035. /** @hidden */
  121036. private _initFacetData;
  121037. /**
  121038. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  121039. * This method can be called within the render loop.
  121040. * 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
  121041. * @returns the current mesh
  121042. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121043. */
  121044. updateFacetData(): AbstractMesh;
  121045. /**
  121046. * Returns the facetLocalNormals array.
  121047. * The normals are expressed in the mesh local spac
  121048. * @returns an array of Vector3
  121049. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121050. */
  121051. getFacetLocalNormals(): Vector3[];
  121052. /**
  121053. * Returns the facetLocalPositions array.
  121054. * The facet positions are expressed in the mesh local space
  121055. * @returns an array of Vector3
  121056. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121057. */
  121058. getFacetLocalPositions(): Vector3[];
  121059. /**
  121060. * Returns the facetLocalPartioning array
  121061. * @returns an array of array of numbers
  121062. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121063. */
  121064. getFacetLocalPartitioning(): number[][];
  121065. /**
  121066. * Returns the i-th facet position in the world system.
  121067. * This method allocates a new Vector3 per call
  121068. * @param i defines the facet index
  121069. * @returns a new Vector3
  121070. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121071. */
  121072. getFacetPosition(i: number): Vector3;
  121073. /**
  121074. * Sets the reference Vector3 with the i-th facet position in the world system
  121075. * @param i defines the facet index
  121076. * @param ref defines the target vector
  121077. * @returns the current mesh
  121078. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121079. */
  121080. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  121081. /**
  121082. * Returns the i-th facet normal in the world system.
  121083. * This method allocates a new Vector3 per call
  121084. * @param i defines the facet index
  121085. * @returns a new Vector3
  121086. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121087. */
  121088. getFacetNormal(i: number): Vector3;
  121089. /**
  121090. * Sets the reference Vector3 with the i-th facet normal in the world system
  121091. * @param i defines the facet index
  121092. * @param ref defines the target vector
  121093. * @returns the current mesh
  121094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121095. */
  121096. getFacetNormalToRef(i: number, ref: Vector3): this;
  121097. /**
  121098. * 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)
  121099. * @param x defines x coordinate
  121100. * @param y defines y coordinate
  121101. * @param z defines z coordinate
  121102. * @returns the array of facet indexes
  121103. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121104. */
  121105. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  121106. /**
  121107. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  121108. * @param projected sets as the (x,y,z) world projection on the facet
  121109. * @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
  121110. * @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
  121111. * @param x defines x coordinate
  121112. * @param y defines y coordinate
  121113. * @param z defines z coordinate
  121114. * @returns the face index if found (or null instead)
  121115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121116. */
  121117. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121118. /**
  121119. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  121120. * @param projected sets as the (x,y,z) local projection on the facet
  121121. * @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
  121122. * @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
  121123. * @param x defines x coordinate
  121124. * @param y defines y coordinate
  121125. * @param z defines z coordinate
  121126. * @returns the face index if found (or null instead)
  121127. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121128. */
  121129. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121130. /**
  121131. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  121132. * @returns the parameters
  121133. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121134. */
  121135. getFacetDataParameters(): any;
  121136. /**
  121137. * Disables the feature FacetData and frees the related memory
  121138. * @returns the current mesh
  121139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121140. */
  121141. disableFacetData(): AbstractMesh;
  121142. /**
  121143. * Updates the AbstractMesh indices array
  121144. * @param indices defines the data source
  121145. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  121146. * @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)
  121147. * @returns the current mesh
  121148. */
  121149. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  121150. /**
  121151. * Creates new normals data for the mesh
  121152. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  121153. * @returns the current mesh
  121154. */
  121155. createNormals(updatable: boolean): AbstractMesh;
  121156. /**
  121157. * Align the mesh with a normal
  121158. * @param normal defines the normal to use
  121159. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  121160. * @returns the current mesh
  121161. */
  121162. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  121163. /** @hidden */
  121164. _checkOcclusionQuery(): boolean;
  121165. /**
  121166. * Disables the mesh edge rendering mode
  121167. * @returns the currentAbstractMesh
  121168. */
  121169. disableEdgesRendering(): AbstractMesh;
  121170. /**
  121171. * Enables the edge rendering mode on the mesh.
  121172. * This mode makes the mesh edges visible
  121173. * @param epsilon defines the maximal distance between two angles to detect a face
  121174. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  121175. * @param options options to the edge renderer
  121176. * @returns the currentAbstractMesh
  121177. * @see https://www.babylonjs-playground.com/#19O9TU#0
  121178. */
  121179. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  121180. /**
  121181. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  121182. * @returns an array of particle systems in the scene that use the mesh as an emitter
  121183. */
  121184. getConnectedParticleSystems(): IParticleSystem[];
  121185. }
  121186. }
  121187. declare module BABYLON {
  121188. /**
  121189. * Interface used to define ActionEvent
  121190. */
  121191. export interface IActionEvent {
  121192. /** The mesh or sprite that triggered the action */
  121193. source: any;
  121194. /** The X mouse cursor position at the time of the event */
  121195. pointerX: number;
  121196. /** The Y mouse cursor position at the time of the event */
  121197. pointerY: number;
  121198. /** The mesh that is currently pointed at (can be null) */
  121199. meshUnderPointer: Nullable<AbstractMesh>;
  121200. /** the original (browser) event that triggered the ActionEvent */
  121201. sourceEvent?: any;
  121202. /** additional data for the event */
  121203. additionalData?: any;
  121204. }
  121205. /**
  121206. * ActionEvent is the event being sent when an action is triggered.
  121207. */
  121208. export class ActionEvent implements IActionEvent {
  121209. /** The mesh or sprite that triggered the action */
  121210. source: any;
  121211. /** The X mouse cursor position at the time of the event */
  121212. pointerX: number;
  121213. /** The Y mouse cursor position at the time of the event */
  121214. pointerY: number;
  121215. /** The mesh that is currently pointed at (can be null) */
  121216. meshUnderPointer: Nullable<AbstractMesh>;
  121217. /** the original (browser) event that triggered the ActionEvent */
  121218. sourceEvent?: any;
  121219. /** additional data for the event */
  121220. additionalData?: any;
  121221. /**
  121222. * Creates a new ActionEvent
  121223. * @param source The mesh or sprite that triggered the action
  121224. * @param pointerX The X mouse cursor position at the time of the event
  121225. * @param pointerY The Y mouse cursor position at the time of the event
  121226. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  121227. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  121228. * @param additionalData additional data for the event
  121229. */
  121230. constructor(
  121231. /** The mesh or sprite that triggered the action */
  121232. source: any,
  121233. /** The X mouse cursor position at the time of the event */
  121234. pointerX: number,
  121235. /** The Y mouse cursor position at the time of the event */
  121236. pointerY: number,
  121237. /** The mesh that is currently pointed at (can be null) */
  121238. meshUnderPointer: Nullable<AbstractMesh>,
  121239. /** the original (browser) event that triggered the ActionEvent */
  121240. sourceEvent?: any,
  121241. /** additional data for the event */
  121242. additionalData?: any);
  121243. /**
  121244. * Helper function to auto-create an ActionEvent from a source mesh.
  121245. * @param source The source mesh that triggered the event
  121246. * @param evt The original (browser) event
  121247. * @param additionalData additional data for the event
  121248. * @returns the new ActionEvent
  121249. */
  121250. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  121251. /**
  121252. * Helper function to auto-create an ActionEvent from a source sprite
  121253. * @param source The source sprite that triggered the event
  121254. * @param scene Scene associated with the sprite
  121255. * @param evt The original (browser) event
  121256. * @param additionalData additional data for the event
  121257. * @returns the new ActionEvent
  121258. */
  121259. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  121260. /**
  121261. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  121262. * @param scene the scene where the event occurred
  121263. * @param evt The original (browser) event
  121264. * @returns the new ActionEvent
  121265. */
  121266. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  121267. /**
  121268. * Helper function to auto-create an ActionEvent from a primitive
  121269. * @param prim defines the target primitive
  121270. * @param pointerPos defines the pointer position
  121271. * @param evt The original (browser) event
  121272. * @param additionalData additional data for the event
  121273. * @returns the new ActionEvent
  121274. */
  121275. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  121276. }
  121277. }
  121278. declare module BABYLON {
  121279. /**
  121280. * Abstract class used to decouple action Manager from scene and meshes.
  121281. * Do not instantiate.
  121282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121283. */
  121284. export abstract class AbstractActionManager implements IDisposable {
  121285. /** Gets the list of active triggers */
  121286. static Triggers: {
  121287. [key: string]: number;
  121288. };
  121289. /** Gets the cursor to use when hovering items */
  121290. hoverCursor: string;
  121291. /** Gets the list of actions */
  121292. actions: IAction[];
  121293. /**
  121294. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  121295. */
  121296. isRecursive: boolean;
  121297. /**
  121298. * Releases all associated resources
  121299. */
  121300. abstract dispose(): void;
  121301. /**
  121302. * Does this action manager has pointer triggers
  121303. */
  121304. abstract get hasPointerTriggers(): boolean;
  121305. /**
  121306. * Does this action manager has pick triggers
  121307. */
  121308. abstract get hasPickTriggers(): boolean;
  121309. /**
  121310. * Process a specific trigger
  121311. * @param trigger defines the trigger to process
  121312. * @param evt defines the event details to be processed
  121313. */
  121314. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  121315. /**
  121316. * Does this action manager handles actions of any of the given triggers
  121317. * @param triggers defines the triggers to be tested
  121318. * @return a boolean indicating whether one (or more) of the triggers is handled
  121319. */
  121320. abstract hasSpecificTriggers(triggers: number[]): boolean;
  121321. /**
  121322. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  121323. * speed.
  121324. * @param triggerA defines the trigger to be tested
  121325. * @param triggerB defines the trigger to be tested
  121326. * @return a boolean indicating whether one (or more) of the triggers is handled
  121327. */
  121328. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  121329. /**
  121330. * Does this action manager handles actions of a given trigger
  121331. * @param trigger defines the trigger to be tested
  121332. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  121333. * @return whether the trigger is handled
  121334. */
  121335. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  121336. /**
  121337. * Serialize this manager to a JSON object
  121338. * @param name defines the property name to store this manager
  121339. * @returns a JSON representation of this manager
  121340. */
  121341. abstract serialize(name: string): any;
  121342. /**
  121343. * Registers an action to this action manager
  121344. * @param action defines the action to be registered
  121345. * @return the action amended (prepared) after registration
  121346. */
  121347. abstract registerAction(action: IAction): Nullable<IAction>;
  121348. /**
  121349. * Unregisters an action to this action manager
  121350. * @param action defines the action to be unregistered
  121351. * @return a boolean indicating whether the action has been unregistered
  121352. */
  121353. abstract unregisterAction(action: IAction): Boolean;
  121354. /**
  121355. * Does exist one action manager with at least one trigger
  121356. **/
  121357. static get HasTriggers(): boolean;
  121358. /**
  121359. * Does exist one action manager with at least one pick trigger
  121360. **/
  121361. static get HasPickTriggers(): boolean;
  121362. /**
  121363. * Does exist one action manager that handles actions of a given trigger
  121364. * @param trigger defines the trigger to be tested
  121365. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  121366. **/
  121367. static HasSpecificTrigger(trigger: number): boolean;
  121368. }
  121369. }
  121370. declare module BABYLON {
  121371. /**
  121372. * Defines how a node can be built from a string name.
  121373. */
  121374. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  121375. /**
  121376. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  121377. */
  121378. export class Node implements IBehaviorAware<Node> {
  121379. /** @hidden */
  121380. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  121381. private static _NodeConstructors;
  121382. /**
  121383. * Add a new node constructor
  121384. * @param type defines the type name of the node to construct
  121385. * @param constructorFunc defines the constructor function
  121386. */
  121387. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  121388. /**
  121389. * Returns a node constructor based on type name
  121390. * @param type defines the type name
  121391. * @param name defines the new node name
  121392. * @param scene defines the hosting scene
  121393. * @param options defines optional options to transmit to constructors
  121394. * @returns the new constructor or null
  121395. */
  121396. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  121397. /**
  121398. * Gets or sets the name of the node
  121399. */
  121400. name: string;
  121401. /**
  121402. * Gets or sets the id of the node
  121403. */
  121404. id: string;
  121405. /**
  121406. * Gets or sets the unique id of the node
  121407. */
  121408. uniqueId: number;
  121409. /**
  121410. * Gets or sets a string used to store user defined state for the node
  121411. */
  121412. state: string;
  121413. /**
  121414. * Gets or sets an object used to store user defined information for the node
  121415. */
  121416. metadata: any;
  121417. /**
  121418. * For internal use only. Please do not use.
  121419. */
  121420. reservedDataStore: any;
  121421. /**
  121422. * List of inspectable custom properties (used by the Inspector)
  121423. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121424. */
  121425. inspectableCustomProperties: IInspectable[];
  121426. private _doNotSerialize;
  121427. /**
  121428. * Gets or sets a boolean used to define if the node must be serialized
  121429. */
  121430. get doNotSerialize(): boolean;
  121431. set doNotSerialize(value: boolean);
  121432. /** @hidden */
  121433. _isDisposed: boolean;
  121434. /**
  121435. * Gets a list of Animations associated with the node
  121436. */
  121437. animations: Animation[];
  121438. protected _ranges: {
  121439. [name: string]: Nullable<AnimationRange>;
  121440. };
  121441. /**
  121442. * Callback raised when the node is ready to be used
  121443. */
  121444. onReady: Nullable<(node: Node) => void>;
  121445. private _isEnabled;
  121446. private _isParentEnabled;
  121447. private _isReady;
  121448. /** @hidden */
  121449. _currentRenderId: number;
  121450. private _parentUpdateId;
  121451. /** @hidden */
  121452. _childUpdateId: number;
  121453. /** @hidden */
  121454. _waitingParentId: Nullable<string>;
  121455. /** @hidden */
  121456. _scene: Scene;
  121457. /** @hidden */
  121458. _cache: any;
  121459. private _parentNode;
  121460. private _children;
  121461. /** @hidden */
  121462. _worldMatrix: Matrix;
  121463. /** @hidden */
  121464. _worldMatrixDeterminant: number;
  121465. /** @hidden */
  121466. _worldMatrixDeterminantIsDirty: boolean;
  121467. /** @hidden */
  121468. private _sceneRootNodesIndex;
  121469. /**
  121470. * Gets a boolean indicating if the node has been disposed
  121471. * @returns true if the node was disposed
  121472. */
  121473. isDisposed(): boolean;
  121474. /**
  121475. * Gets or sets the parent of the node (without keeping the current position in the scene)
  121476. * @see https://doc.babylonjs.com/how_to/parenting
  121477. */
  121478. set parent(parent: Nullable<Node>);
  121479. get parent(): Nullable<Node>;
  121480. /** @hidden */
  121481. _addToSceneRootNodes(): void;
  121482. /** @hidden */
  121483. _removeFromSceneRootNodes(): void;
  121484. private _animationPropertiesOverride;
  121485. /**
  121486. * Gets or sets the animation properties override
  121487. */
  121488. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  121489. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  121490. /**
  121491. * Gets a string identifying the name of the class
  121492. * @returns "Node" string
  121493. */
  121494. getClassName(): string;
  121495. /** @hidden */
  121496. readonly _isNode: boolean;
  121497. /**
  121498. * An event triggered when the mesh is disposed
  121499. */
  121500. onDisposeObservable: Observable<Node>;
  121501. private _onDisposeObserver;
  121502. /**
  121503. * Sets a callback that will be raised when the node will be disposed
  121504. */
  121505. set onDispose(callback: () => void);
  121506. /**
  121507. * Creates a new Node
  121508. * @param name the name and id to be given to this node
  121509. * @param scene the scene this node will be added to
  121510. */
  121511. constructor(name: string, scene?: Nullable<Scene>);
  121512. /**
  121513. * Gets the scene of the node
  121514. * @returns a scene
  121515. */
  121516. getScene(): Scene;
  121517. /**
  121518. * Gets the engine of the node
  121519. * @returns a Engine
  121520. */
  121521. getEngine(): Engine;
  121522. private _behaviors;
  121523. /**
  121524. * Attach a behavior to the node
  121525. * @see https://doc.babylonjs.com/features/behaviour
  121526. * @param behavior defines the behavior to attach
  121527. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  121528. * @returns the current Node
  121529. */
  121530. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  121531. /**
  121532. * Remove an attached behavior
  121533. * @see https://doc.babylonjs.com/features/behaviour
  121534. * @param behavior defines the behavior to attach
  121535. * @returns the current Node
  121536. */
  121537. removeBehavior(behavior: Behavior<Node>): Node;
  121538. /**
  121539. * Gets the list of attached behaviors
  121540. * @see https://doc.babylonjs.com/features/behaviour
  121541. */
  121542. get behaviors(): Behavior<Node>[];
  121543. /**
  121544. * Gets an attached behavior by name
  121545. * @param name defines the name of the behavior to look for
  121546. * @see https://doc.babylonjs.com/features/behaviour
  121547. * @returns null if behavior was not found else the requested behavior
  121548. */
  121549. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  121550. /**
  121551. * Returns the latest update of the World matrix
  121552. * @returns a Matrix
  121553. */
  121554. getWorldMatrix(): Matrix;
  121555. /** @hidden */
  121556. _getWorldMatrixDeterminant(): number;
  121557. /**
  121558. * Returns directly the latest state of the mesh World matrix.
  121559. * A Matrix is returned.
  121560. */
  121561. get worldMatrixFromCache(): Matrix;
  121562. /** @hidden */
  121563. _initCache(): void;
  121564. /** @hidden */
  121565. updateCache(force?: boolean): void;
  121566. /** @hidden */
  121567. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  121568. /** @hidden */
  121569. _updateCache(ignoreParentClass?: boolean): void;
  121570. /** @hidden */
  121571. _isSynchronized(): boolean;
  121572. /** @hidden */
  121573. _markSyncedWithParent(): void;
  121574. /** @hidden */
  121575. isSynchronizedWithParent(): boolean;
  121576. /** @hidden */
  121577. isSynchronized(): boolean;
  121578. /**
  121579. * Is this node ready to be used/rendered
  121580. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  121581. * @return true if the node is ready
  121582. */
  121583. isReady(completeCheck?: boolean): boolean;
  121584. /**
  121585. * Is this node enabled?
  121586. * 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
  121587. * @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
  121588. * @return whether this node (and its parent) is enabled
  121589. */
  121590. isEnabled(checkAncestors?: boolean): boolean;
  121591. /** @hidden */
  121592. protected _syncParentEnabledState(): void;
  121593. /**
  121594. * Set the enabled state of this node
  121595. * @param value defines the new enabled state
  121596. */
  121597. setEnabled(value: boolean): void;
  121598. /**
  121599. * Is this node a descendant of the given node?
  121600. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  121601. * @param ancestor defines the parent node to inspect
  121602. * @returns a boolean indicating if this node is a descendant of the given node
  121603. */
  121604. isDescendantOf(ancestor: Node): boolean;
  121605. /** @hidden */
  121606. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  121607. /**
  121608. * Will return all nodes that have this node as ascendant
  121609. * @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
  121610. * @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
  121611. * @return all children nodes of all types
  121612. */
  121613. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  121614. /**
  121615. * Get all child-meshes of this node
  121616. * @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)
  121617. * @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
  121618. * @returns an array of AbstractMesh
  121619. */
  121620. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  121621. /**
  121622. * Get all direct children of this node
  121623. * @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
  121624. * @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)
  121625. * @returns an array of Node
  121626. */
  121627. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  121628. /** @hidden */
  121629. _setReady(state: boolean): void;
  121630. /**
  121631. * Get an animation by name
  121632. * @param name defines the name of the animation to look for
  121633. * @returns null if not found else the requested animation
  121634. */
  121635. getAnimationByName(name: string): Nullable<Animation>;
  121636. /**
  121637. * Creates an animation range for this node
  121638. * @param name defines the name of the range
  121639. * @param from defines the starting key
  121640. * @param to defines the end key
  121641. */
  121642. createAnimationRange(name: string, from: number, to: number): void;
  121643. /**
  121644. * Delete a specific animation range
  121645. * @param name defines the name of the range to delete
  121646. * @param deleteFrames defines if animation frames from the range must be deleted as well
  121647. */
  121648. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  121649. /**
  121650. * Get an animation range by name
  121651. * @param name defines the name of the animation range to look for
  121652. * @returns null if not found else the requested animation range
  121653. */
  121654. getAnimationRange(name: string): Nullable<AnimationRange>;
  121655. /**
  121656. * Gets the list of all animation ranges defined on this node
  121657. * @returns an array
  121658. */
  121659. getAnimationRanges(): Nullable<AnimationRange>[];
  121660. /**
  121661. * Will start the animation sequence
  121662. * @param name defines the range frames for animation sequence
  121663. * @param loop defines if the animation should loop (false by default)
  121664. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  121665. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  121666. * @returns the object created for this animation. If range does not exist, it will return null
  121667. */
  121668. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  121669. /**
  121670. * Serialize animation ranges into a JSON compatible object
  121671. * @returns serialization object
  121672. */
  121673. serializeAnimationRanges(): any;
  121674. /**
  121675. * Computes the world matrix of the node
  121676. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  121677. * @returns the world matrix
  121678. */
  121679. computeWorldMatrix(force?: boolean): Matrix;
  121680. /**
  121681. * Releases resources associated with this node.
  121682. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121683. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121684. */
  121685. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121686. /**
  121687. * Parse animation range data from a serialization object and store them into a given node
  121688. * @param node defines where to store the animation ranges
  121689. * @param parsedNode defines the serialization object to read data from
  121690. * @param scene defines the hosting scene
  121691. */
  121692. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  121693. /**
  121694. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  121695. * @param includeDescendants Include bounding info from descendants as well (true by default)
  121696. * @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
  121697. * @returns the new bounding vectors
  121698. */
  121699. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  121700. min: Vector3;
  121701. max: Vector3;
  121702. };
  121703. }
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * @hidden
  121708. */
  121709. export class _IAnimationState {
  121710. key: number;
  121711. repeatCount: number;
  121712. workValue?: any;
  121713. loopMode?: number;
  121714. offsetValue?: any;
  121715. highLimitValue?: any;
  121716. }
  121717. /**
  121718. * Class used to store any kind of animation
  121719. */
  121720. export class Animation {
  121721. /**Name of the animation */
  121722. name: string;
  121723. /**Property to animate */
  121724. targetProperty: string;
  121725. /**The frames per second of the animation */
  121726. framePerSecond: number;
  121727. /**The data type of the animation */
  121728. dataType: number;
  121729. /**The loop mode of the animation */
  121730. loopMode?: number | undefined;
  121731. /**Specifies if blending should be enabled */
  121732. enableBlending?: boolean | undefined;
  121733. /**
  121734. * Use matrix interpolation instead of using direct key value when animating matrices
  121735. */
  121736. static AllowMatricesInterpolation: boolean;
  121737. /**
  121738. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  121739. */
  121740. static AllowMatrixDecomposeForInterpolation: boolean;
  121741. /** Define the Url to load snippets */
  121742. static SnippetUrl: string;
  121743. /** Snippet ID if the animation was created from the snippet server */
  121744. snippetId: string;
  121745. /**
  121746. * Stores the key frames of the animation
  121747. */
  121748. private _keys;
  121749. /**
  121750. * Stores the easing function of the animation
  121751. */
  121752. private _easingFunction;
  121753. /**
  121754. * @hidden Internal use only
  121755. */
  121756. _runtimeAnimations: RuntimeAnimation[];
  121757. /**
  121758. * The set of event that will be linked to this animation
  121759. */
  121760. private _events;
  121761. /**
  121762. * Stores an array of target property paths
  121763. */
  121764. targetPropertyPath: string[];
  121765. /**
  121766. * Stores the blending speed of the animation
  121767. */
  121768. blendingSpeed: number;
  121769. /**
  121770. * Stores the animation ranges for the animation
  121771. */
  121772. private _ranges;
  121773. /**
  121774. * @hidden Internal use
  121775. */
  121776. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  121777. /**
  121778. * Sets up an animation
  121779. * @param property The property to animate
  121780. * @param animationType The animation type to apply
  121781. * @param framePerSecond The frames per second of the animation
  121782. * @param easingFunction The easing function used in the animation
  121783. * @returns The created animation
  121784. */
  121785. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  121786. /**
  121787. * Create and start an animation on a node
  121788. * @param name defines the name of the global animation that will be run on all nodes
  121789. * @param node defines the root node where the animation will take place
  121790. * @param targetProperty defines property to animate
  121791. * @param framePerSecond defines the number of frame per second yo use
  121792. * @param totalFrame defines the number of frames in total
  121793. * @param from defines the initial value
  121794. * @param to defines the final value
  121795. * @param loopMode defines which loop mode you want to use (off by default)
  121796. * @param easingFunction defines the easing function to use (linear by default)
  121797. * @param onAnimationEnd defines the callback to call when animation end
  121798. * @returns the animatable created for this animation
  121799. */
  121800. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  121801. /**
  121802. * Create and start an animation on a node and its descendants
  121803. * @param name defines the name of the global animation that will be run on all nodes
  121804. * @param node defines the root node where the animation will take place
  121805. * @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
  121806. * @param targetProperty defines property to animate
  121807. * @param framePerSecond defines the number of frame per second to use
  121808. * @param totalFrame defines the number of frames in total
  121809. * @param from defines the initial value
  121810. * @param to defines the final value
  121811. * @param loopMode defines which loop mode you want to use (off by default)
  121812. * @param easingFunction defines the easing function to use (linear by default)
  121813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  121814. * @returns the list of animatables created for all nodes
  121815. * @example https://www.babylonjs-playground.com/#MH0VLI
  121816. */
  121817. 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[]>;
  121818. /**
  121819. * Creates a new animation, merges it with the existing animations and starts it
  121820. * @param name Name of the animation
  121821. * @param node Node which contains the scene that begins the animations
  121822. * @param targetProperty Specifies which property to animate
  121823. * @param framePerSecond The frames per second of the animation
  121824. * @param totalFrame The total number of frames
  121825. * @param from The frame at the beginning of the animation
  121826. * @param to The frame at the end of the animation
  121827. * @param loopMode Specifies the loop mode of the animation
  121828. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  121829. * @param onAnimationEnd Callback to run once the animation is complete
  121830. * @returns Nullable animation
  121831. */
  121832. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  121833. /**
  121834. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  121835. * @param sourceAnimation defines the Animation containing keyframes to convert
  121836. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  121837. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  121838. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  121839. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  121840. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  121841. */
  121842. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  121843. /**
  121844. * Transition property of an host to the target Value
  121845. * @param property The property to transition
  121846. * @param targetValue The target Value of the property
  121847. * @param host The object where the property to animate belongs
  121848. * @param scene Scene used to run the animation
  121849. * @param frameRate Framerate (in frame/s) to use
  121850. * @param transition The transition type we want to use
  121851. * @param duration The duration of the animation, in milliseconds
  121852. * @param onAnimationEnd Callback trigger at the end of the animation
  121853. * @returns Nullable animation
  121854. */
  121855. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  121856. /**
  121857. * Return the array of runtime animations currently using this animation
  121858. */
  121859. get runtimeAnimations(): RuntimeAnimation[];
  121860. /**
  121861. * Specifies if any of the runtime animations are currently running
  121862. */
  121863. get hasRunningRuntimeAnimations(): boolean;
  121864. /**
  121865. * Initializes the animation
  121866. * @param name Name of the animation
  121867. * @param targetProperty Property to animate
  121868. * @param framePerSecond The frames per second of the animation
  121869. * @param dataType The data type of the animation
  121870. * @param loopMode The loop mode of the animation
  121871. * @param enableBlending Specifies if blending should be enabled
  121872. */
  121873. constructor(
  121874. /**Name of the animation */
  121875. name: string,
  121876. /**Property to animate */
  121877. targetProperty: string,
  121878. /**The frames per second of the animation */
  121879. framePerSecond: number,
  121880. /**The data type of the animation */
  121881. dataType: number,
  121882. /**The loop mode of the animation */
  121883. loopMode?: number | undefined,
  121884. /**Specifies if blending should be enabled */
  121885. enableBlending?: boolean | undefined);
  121886. /**
  121887. * Converts the animation to a string
  121888. * @param fullDetails support for multiple levels of logging within scene loading
  121889. * @returns String form of the animation
  121890. */
  121891. toString(fullDetails?: boolean): string;
  121892. /**
  121893. * Add an event to this animation
  121894. * @param event Event to add
  121895. */
  121896. addEvent(event: AnimationEvent): void;
  121897. /**
  121898. * Remove all events found at the given frame
  121899. * @param frame The frame to remove events from
  121900. */
  121901. removeEvents(frame: number): void;
  121902. /**
  121903. * Retrieves all the events from the animation
  121904. * @returns Events from the animation
  121905. */
  121906. getEvents(): AnimationEvent[];
  121907. /**
  121908. * Creates an animation range
  121909. * @param name Name of the animation range
  121910. * @param from Starting frame of the animation range
  121911. * @param to Ending frame of the animation
  121912. */
  121913. createRange(name: string, from: number, to: number): void;
  121914. /**
  121915. * Deletes an animation range by name
  121916. * @param name Name of the animation range to delete
  121917. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  121918. */
  121919. deleteRange(name: string, deleteFrames?: boolean): void;
  121920. /**
  121921. * Gets the animation range by name, or null if not defined
  121922. * @param name Name of the animation range
  121923. * @returns Nullable animation range
  121924. */
  121925. getRange(name: string): Nullable<AnimationRange>;
  121926. /**
  121927. * Gets the key frames from the animation
  121928. * @returns The key frames of the animation
  121929. */
  121930. getKeys(): Array<IAnimationKey>;
  121931. /**
  121932. * Gets the highest frame rate of the animation
  121933. * @returns Highest frame rate of the animation
  121934. */
  121935. getHighestFrame(): number;
  121936. /**
  121937. * Gets the easing function of the animation
  121938. * @returns Easing function of the animation
  121939. */
  121940. getEasingFunction(): IEasingFunction;
  121941. /**
  121942. * Sets the easing function of the animation
  121943. * @param easingFunction A custom mathematical formula for animation
  121944. */
  121945. setEasingFunction(easingFunction: EasingFunction): void;
  121946. /**
  121947. * Interpolates a scalar linearly
  121948. * @param startValue Start value of the animation curve
  121949. * @param endValue End value of the animation curve
  121950. * @param gradient Scalar amount to interpolate
  121951. * @returns Interpolated scalar value
  121952. */
  121953. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  121954. /**
  121955. * Interpolates a scalar cubically
  121956. * @param startValue Start value of the animation curve
  121957. * @param outTangent End tangent of the animation
  121958. * @param endValue End value of the animation curve
  121959. * @param inTangent Start tangent of the animation curve
  121960. * @param gradient Scalar amount to interpolate
  121961. * @returns Interpolated scalar value
  121962. */
  121963. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  121964. /**
  121965. * Interpolates a quaternion using a spherical linear interpolation
  121966. * @param startValue Start value of the animation curve
  121967. * @param endValue End value of the animation curve
  121968. * @param gradient Scalar amount to interpolate
  121969. * @returns Interpolated quaternion value
  121970. */
  121971. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  121972. /**
  121973. * Interpolates a quaternion cubically
  121974. * @param startValue Start value of the animation curve
  121975. * @param outTangent End tangent of the animation curve
  121976. * @param endValue End value of the animation curve
  121977. * @param inTangent Start tangent of the animation curve
  121978. * @param gradient Scalar amount to interpolate
  121979. * @returns Interpolated quaternion value
  121980. */
  121981. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  121982. /**
  121983. * Interpolates a Vector3 linearl
  121984. * @param startValue Start value of the animation curve
  121985. * @param endValue End value of the animation curve
  121986. * @param gradient Scalar amount to interpolate
  121987. * @returns Interpolated scalar value
  121988. */
  121989. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  121990. /**
  121991. * Interpolates a Vector3 cubically
  121992. * @param startValue Start value of the animation curve
  121993. * @param outTangent End tangent of the animation
  121994. * @param endValue End value of the animation curve
  121995. * @param inTangent Start tangent of the animation curve
  121996. * @param gradient Scalar amount to interpolate
  121997. * @returns InterpolatedVector3 value
  121998. */
  121999. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  122000. /**
  122001. * Interpolates a Vector2 linearly
  122002. * @param startValue Start value of the animation curve
  122003. * @param endValue End value of the animation curve
  122004. * @param gradient Scalar amount to interpolate
  122005. * @returns Interpolated Vector2 value
  122006. */
  122007. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  122008. /**
  122009. * Interpolates a Vector2 cubically
  122010. * @param startValue Start value of the animation curve
  122011. * @param outTangent End tangent of the animation
  122012. * @param endValue End value of the animation curve
  122013. * @param inTangent Start tangent of the animation curve
  122014. * @param gradient Scalar amount to interpolate
  122015. * @returns Interpolated Vector2 value
  122016. */
  122017. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  122018. /**
  122019. * Interpolates a size linearly
  122020. * @param startValue Start value of the animation curve
  122021. * @param endValue End value of the animation curve
  122022. * @param gradient Scalar amount to interpolate
  122023. * @returns Interpolated Size value
  122024. */
  122025. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  122026. /**
  122027. * Interpolates a Color3 linearly
  122028. * @param startValue Start value of the animation curve
  122029. * @param endValue End value of the animation curve
  122030. * @param gradient Scalar amount to interpolate
  122031. * @returns Interpolated Color3 value
  122032. */
  122033. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  122034. /**
  122035. * Interpolates a Color4 linearly
  122036. * @param startValue Start value of the animation curve
  122037. * @param endValue End value of the animation curve
  122038. * @param gradient Scalar amount to interpolate
  122039. * @returns Interpolated Color3 value
  122040. */
  122041. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  122042. /**
  122043. * @hidden Internal use only
  122044. */
  122045. _getKeyValue(value: any): any;
  122046. /**
  122047. * @hidden Internal use only
  122048. */
  122049. _interpolate(currentFrame: number, state: _IAnimationState): any;
  122050. /**
  122051. * Defines the function to use to interpolate matrices
  122052. * @param startValue defines the start matrix
  122053. * @param endValue defines the end matrix
  122054. * @param gradient defines the gradient between both matrices
  122055. * @param result defines an optional target matrix where to store the interpolation
  122056. * @returns the interpolated matrix
  122057. */
  122058. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  122059. /**
  122060. * Makes a copy of the animation
  122061. * @returns Cloned animation
  122062. */
  122063. clone(): Animation;
  122064. /**
  122065. * Sets the key frames of the animation
  122066. * @param values The animation key frames to set
  122067. */
  122068. setKeys(values: Array<IAnimationKey>): void;
  122069. /**
  122070. * Serializes the animation to an object
  122071. * @returns Serialized object
  122072. */
  122073. serialize(): any;
  122074. /**
  122075. * Float animation type
  122076. */
  122077. static readonly ANIMATIONTYPE_FLOAT: number;
  122078. /**
  122079. * Vector3 animation type
  122080. */
  122081. static readonly ANIMATIONTYPE_VECTOR3: number;
  122082. /**
  122083. * Quaternion animation type
  122084. */
  122085. static readonly ANIMATIONTYPE_QUATERNION: number;
  122086. /**
  122087. * Matrix animation type
  122088. */
  122089. static readonly ANIMATIONTYPE_MATRIX: number;
  122090. /**
  122091. * Color3 animation type
  122092. */
  122093. static readonly ANIMATIONTYPE_COLOR3: number;
  122094. /**
  122095. * Color3 animation type
  122096. */
  122097. static readonly ANIMATIONTYPE_COLOR4: number;
  122098. /**
  122099. * Vector2 animation type
  122100. */
  122101. static readonly ANIMATIONTYPE_VECTOR2: number;
  122102. /**
  122103. * Size animation type
  122104. */
  122105. static readonly ANIMATIONTYPE_SIZE: number;
  122106. /**
  122107. * Relative Loop Mode
  122108. */
  122109. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  122110. /**
  122111. * Cycle Loop Mode
  122112. */
  122113. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  122114. /**
  122115. * Constant Loop Mode
  122116. */
  122117. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  122118. /** @hidden */
  122119. static _UniversalLerp(left: any, right: any, amount: number): any;
  122120. /**
  122121. * Parses an animation object and creates an animation
  122122. * @param parsedAnimation Parsed animation object
  122123. * @returns Animation object
  122124. */
  122125. static Parse(parsedAnimation: any): Animation;
  122126. /**
  122127. * Appends the serialized animations from the source animations
  122128. * @param source Source containing the animations
  122129. * @param destination Target to store the animations
  122130. */
  122131. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122132. /**
  122133. * Creates a new animation or an array of animations from a snippet saved in a remote file
  122134. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  122135. * @param url defines the url to load from
  122136. * @returns a promise that will resolve to the new animation or an array of animations
  122137. */
  122138. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  122139. /**
  122140. * Creates an animation or an array of animations from a snippet saved by the Inspector
  122141. * @param snippetId defines the snippet to load
  122142. * @returns a promise that will resolve to the new animation or a new array of animations
  122143. */
  122144. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  122145. }
  122146. }
  122147. declare module BABYLON {
  122148. /**
  122149. * Interface containing an array of animations
  122150. */
  122151. export interface IAnimatable {
  122152. /**
  122153. * Array of animations
  122154. */
  122155. animations: Nullable<Array<Animation>>;
  122156. }
  122157. }
  122158. declare module BABYLON {
  122159. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  122160. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122161. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122162. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122163. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122164. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122165. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122166. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122167. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122168. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122169. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122170. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122171. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122172. /**
  122173. * Decorator used to define property that can be serialized as reference to a camera
  122174. * @param sourceName defines the name of the property to decorate
  122175. */
  122176. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122177. /**
  122178. * Class used to help serialization objects
  122179. */
  122180. export class SerializationHelper {
  122181. /** @hidden */
  122182. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  122183. /** @hidden */
  122184. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  122185. /** @hidden */
  122186. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  122187. /** @hidden */
  122188. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  122189. /**
  122190. * Appends the serialized animations from the source animations
  122191. * @param source Source containing the animations
  122192. * @param destination Target to store the animations
  122193. */
  122194. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122195. /**
  122196. * Static function used to serialized a specific entity
  122197. * @param entity defines the entity to serialize
  122198. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  122199. * @returns a JSON compatible object representing the serialization of the entity
  122200. */
  122201. static Serialize<T>(entity: T, serializationObject?: any): any;
  122202. /**
  122203. * Creates a new entity from a serialization data object
  122204. * @param creationFunction defines a function used to instanciated the new entity
  122205. * @param source defines the source serialization data
  122206. * @param scene defines the hosting scene
  122207. * @param rootUrl defines the root url for resources
  122208. * @returns a new entity
  122209. */
  122210. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  122211. /**
  122212. * Clones an object
  122213. * @param creationFunction defines the function used to instanciate the new object
  122214. * @param source defines the source object
  122215. * @returns the cloned object
  122216. */
  122217. static Clone<T>(creationFunction: () => T, source: T): T;
  122218. /**
  122219. * Instanciates a new object based on a source one (some data will be shared between both object)
  122220. * @param creationFunction defines the function used to instanciate the new object
  122221. * @param source defines the source object
  122222. * @returns the new object
  122223. */
  122224. static Instanciate<T>(creationFunction: () => T, source: T): T;
  122225. }
  122226. }
  122227. declare module BABYLON {
  122228. /**
  122229. * This is the base class of all the camera used in the application.
  122230. * @see https://doc.babylonjs.com/features/cameras
  122231. */
  122232. export class Camera extends Node {
  122233. /** @hidden */
  122234. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  122235. /**
  122236. * This is the default projection mode used by the cameras.
  122237. * It helps recreating a feeling of perspective and better appreciate depth.
  122238. * This is the best way to simulate real life cameras.
  122239. */
  122240. static readonly PERSPECTIVE_CAMERA: number;
  122241. /**
  122242. * This helps creating camera with an orthographic mode.
  122243. * 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.
  122244. */
  122245. static readonly ORTHOGRAPHIC_CAMERA: number;
  122246. /**
  122247. * This is the default FOV mode for perspective cameras.
  122248. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  122249. */
  122250. static readonly FOVMODE_VERTICAL_FIXED: number;
  122251. /**
  122252. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  122253. */
  122254. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  122255. /**
  122256. * This specifies ther is no need for a camera rig.
  122257. * Basically only one eye is rendered corresponding to the camera.
  122258. */
  122259. static readonly RIG_MODE_NONE: number;
  122260. /**
  122261. * Simulates a camera Rig with one blue eye and one red eye.
  122262. * This can be use with 3d blue and red glasses.
  122263. */
  122264. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  122265. /**
  122266. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  122267. */
  122268. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  122269. /**
  122270. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  122271. */
  122272. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  122273. /**
  122274. * Defines that both eyes of the camera will be rendered over under each other.
  122275. */
  122276. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  122277. /**
  122278. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  122279. */
  122280. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  122281. /**
  122282. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  122283. */
  122284. static readonly RIG_MODE_VR: number;
  122285. /**
  122286. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  122287. */
  122288. static readonly RIG_MODE_WEBVR: number;
  122289. /**
  122290. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  122291. */
  122292. static readonly RIG_MODE_CUSTOM: number;
  122293. /**
  122294. * Defines if by default attaching controls should prevent the default javascript event to continue.
  122295. */
  122296. static ForceAttachControlToAlwaysPreventDefault: boolean;
  122297. /**
  122298. * Define the input manager associated with the camera.
  122299. */
  122300. inputs: CameraInputsManager<Camera>;
  122301. /** @hidden */
  122302. _position: Vector3;
  122303. /**
  122304. * Define the current local position of the camera in the scene
  122305. */
  122306. get position(): Vector3;
  122307. set position(newPosition: Vector3);
  122308. protected _upVector: Vector3;
  122309. /**
  122310. * The vector the camera should consider as up.
  122311. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  122312. */
  122313. set upVector(vec: Vector3);
  122314. get upVector(): Vector3;
  122315. /**
  122316. * Define the current limit on the left side for an orthographic camera
  122317. * In scene unit
  122318. */
  122319. orthoLeft: Nullable<number>;
  122320. /**
  122321. * Define the current limit on the right side for an orthographic camera
  122322. * In scene unit
  122323. */
  122324. orthoRight: Nullable<number>;
  122325. /**
  122326. * Define the current limit on the bottom side for an orthographic camera
  122327. * In scene unit
  122328. */
  122329. orthoBottom: Nullable<number>;
  122330. /**
  122331. * Define the current limit on the top side for an orthographic camera
  122332. * In scene unit
  122333. */
  122334. orthoTop: Nullable<number>;
  122335. /**
  122336. * Field Of View is set in Radians. (default is 0.8)
  122337. */
  122338. fov: number;
  122339. /**
  122340. * Define the minimum distance the camera can see from.
  122341. * This is important to note that the depth buffer are not infinite and the closer it starts
  122342. * the more your scene might encounter depth fighting issue.
  122343. */
  122344. minZ: number;
  122345. /**
  122346. * Define the maximum distance the camera can see to.
  122347. * This is important to note that the depth buffer are not infinite and the further it end
  122348. * the more your scene might encounter depth fighting issue.
  122349. */
  122350. maxZ: number;
  122351. /**
  122352. * Define the default inertia of the camera.
  122353. * This helps giving a smooth feeling to the camera movement.
  122354. */
  122355. inertia: number;
  122356. /**
  122357. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  122358. */
  122359. mode: number;
  122360. /**
  122361. * Define whether the camera is intermediate.
  122362. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  122363. */
  122364. isIntermediate: boolean;
  122365. /**
  122366. * Define the viewport of the camera.
  122367. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  122368. */
  122369. viewport: Viewport;
  122370. /**
  122371. * Restricts the camera to viewing objects with the same layerMask.
  122372. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  122373. */
  122374. layerMask: number;
  122375. /**
  122376. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  122377. */
  122378. fovMode: number;
  122379. /**
  122380. * Rig mode of the camera.
  122381. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  122382. * This is normally controlled byt the camera themselves as internal use.
  122383. */
  122384. cameraRigMode: number;
  122385. /**
  122386. * Defines the distance between both "eyes" in case of a RIG
  122387. */
  122388. interaxialDistance: number;
  122389. /**
  122390. * Defines if stereoscopic rendering is done side by side or over under.
  122391. */
  122392. isStereoscopicSideBySide: boolean;
  122393. /**
  122394. * 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
  122395. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  122396. * else in the scene. (Eg. security camera)
  122397. *
  122398. * 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)
  122399. */
  122400. customRenderTargets: RenderTargetTexture[];
  122401. /**
  122402. * When set, the camera will render to this render target instead of the default canvas
  122403. *
  122404. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  122405. */
  122406. outputRenderTarget: Nullable<RenderTargetTexture>;
  122407. /**
  122408. * Observable triggered when the camera view matrix has changed.
  122409. */
  122410. onViewMatrixChangedObservable: Observable<Camera>;
  122411. /**
  122412. * Observable triggered when the camera Projection matrix has changed.
  122413. */
  122414. onProjectionMatrixChangedObservable: Observable<Camera>;
  122415. /**
  122416. * Observable triggered when the inputs have been processed.
  122417. */
  122418. onAfterCheckInputsObservable: Observable<Camera>;
  122419. /**
  122420. * Observable triggered when reset has been called and applied to the camera.
  122421. */
  122422. onRestoreStateObservable: Observable<Camera>;
  122423. /**
  122424. * Is this camera a part of a rig system?
  122425. */
  122426. isRigCamera: boolean;
  122427. /**
  122428. * If isRigCamera set to true this will be set with the parent camera.
  122429. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  122430. */
  122431. rigParent?: Camera;
  122432. /** @hidden */
  122433. _cameraRigParams: any;
  122434. /** @hidden */
  122435. _rigCameras: Camera[];
  122436. /** @hidden */
  122437. _rigPostProcess: Nullable<PostProcess>;
  122438. protected _webvrViewMatrix: Matrix;
  122439. /** @hidden */
  122440. _skipRendering: boolean;
  122441. /** @hidden */
  122442. _projectionMatrix: Matrix;
  122443. /** @hidden */
  122444. _postProcesses: Nullable<PostProcess>[];
  122445. /** @hidden */
  122446. _activeMeshes: SmartArray<AbstractMesh>;
  122447. protected _globalPosition: Vector3;
  122448. /** @hidden */
  122449. _computedViewMatrix: Matrix;
  122450. private _doNotComputeProjectionMatrix;
  122451. private _transformMatrix;
  122452. private _frustumPlanes;
  122453. private _refreshFrustumPlanes;
  122454. private _storedFov;
  122455. private _stateStored;
  122456. /**
  122457. * Instantiates a new camera object.
  122458. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  122459. * @see https://doc.babylonjs.com/features/cameras
  122460. * @param name Defines the name of the camera in the scene
  122461. * @param position Defines the position of the camera
  122462. * @param scene Defines the scene the camera belongs too
  122463. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  122464. */
  122465. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122466. /**
  122467. * Store current camera state (fov, position, etc..)
  122468. * @returns the camera
  122469. */
  122470. storeState(): Camera;
  122471. /**
  122472. * Restores the camera state values if it has been stored. You must call storeState() first
  122473. */
  122474. protected _restoreStateValues(): boolean;
  122475. /**
  122476. * Restored camera state. You must call storeState() first.
  122477. * @returns true if restored and false otherwise
  122478. */
  122479. restoreState(): boolean;
  122480. /**
  122481. * Gets the class name of the camera.
  122482. * @returns the class name
  122483. */
  122484. getClassName(): string;
  122485. /** @hidden */
  122486. readonly _isCamera: boolean;
  122487. /**
  122488. * Gets a string representation of the camera useful for debug purpose.
  122489. * @param fullDetails Defines that a more verboe level of logging is required
  122490. * @returns the string representation
  122491. */
  122492. toString(fullDetails?: boolean): string;
  122493. /**
  122494. * Gets the current world space position of the camera.
  122495. */
  122496. get globalPosition(): Vector3;
  122497. /**
  122498. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  122499. * @returns the active meshe list
  122500. */
  122501. getActiveMeshes(): SmartArray<AbstractMesh>;
  122502. /**
  122503. * Check whether a mesh is part of the current active mesh list of the camera
  122504. * @param mesh Defines the mesh to check
  122505. * @returns true if active, false otherwise
  122506. */
  122507. isActiveMesh(mesh: Mesh): boolean;
  122508. /**
  122509. * Is this camera ready to be used/rendered
  122510. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  122511. * @return true if the camera is ready
  122512. */
  122513. isReady(completeCheck?: boolean): boolean;
  122514. /** @hidden */
  122515. _initCache(): void;
  122516. /** @hidden */
  122517. _updateCache(ignoreParentClass?: boolean): void;
  122518. /** @hidden */
  122519. _isSynchronized(): boolean;
  122520. /** @hidden */
  122521. _isSynchronizedViewMatrix(): boolean;
  122522. /** @hidden */
  122523. _isSynchronizedProjectionMatrix(): boolean;
  122524. /**
  122525. * Attach the input controls to a specific dom element to get the input from.
  122526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122527. */
  122528. attachControl(noPreventDefault?: boolean): void;
  122529. /**
  122530. * Attach the input controls to a specific dom element to get the input from.
  122531. * @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
  122532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122533. * BACK COMPAT SIGNATURE ONLY.
  122534. */
  122535. attachControl(ignored: any, noPreventDefault?: boolean): void;
  122536. /**
  122537. * Detach the current controls from the specified dom element.
  122538. */
  122539. detachControl(): void;
  122540. /**
  122541. * Detach the current controls from the specified dom element.
  122542. * @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
  122543. */
  122544. detachControl(ignored: any): void;
  122545. /**
  122546. * Update the camera state according to the different inputs gathered during the frame.
  122547. */
  122548. update(): void;
  122549. /** @hidden */
  122550. _checkInputs(): void;
  122551. /** @hidden */
  122552. get rigCameras(): Camera[];
  122553. /**
  122554. * Gets the post process used by the rig cameras
  122555. */
  122556. get rigPostProcess(): Nullable<PostProcess>;
  122557. /**
  122558. * Internal, gets the first post proces.
  122559. * @returns the first post process to be run on this camera.
  122560. */
  122561. _getFirstPostProcess(): Nullable<PostProcess>;
  122562. private _cascadePostProcessesToRigCams;
  122563. /**
  122564. * Attach a post process to the camera.
  122565. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  122566. * @param postProcess The post process to attach to the camera
  122567. * @param insertAt The position of the post process in case several of them are in use in the scene
  122568. * @returns the position the post process has been inserted at
  122569. */
  122570. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  122571. /**
  122572. * Detach a post process to the camera.
  122573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  122574. * @param postProcess The post process to detach from the camera
  122575. */
  122576. detachPostProcess(postProcess: PostProcess): void;
  122577. /**
  122578. * Gets the current world matrix of the camera
  122579. */
  122580. getWorldMatrix(): Matrix;
  122581. /** @hidden */
  122582. _getViewMatrix(): Matrix;
  122583. /**
  122584. * Gets the current view matrix of the camera.
  122585. * @param force forces the camera to recompute the matrix without looking at the cached state
  122586. * @returns the view matrix
  122587. */
  122588. getViewMatrix(force?: boolean): Matrix;
  122589. /**
  122590. * Freeze the projection matrix.
  122591. * It will prevent the cache check of the camera projection compute and can speed up perf
  122592. * if no parameter of the camera are meant to change
  122593. * @param projection Defines manually a projection if necessary
  122594. */
  122595. freezeProjectionMatrix(projection?: Matrix): void;
  122596. /**
  122597. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  122598. */
  122599. unfreezeProjectionMatrix(): void;
  122600. /**
  122601. * Gets the current projection matrix of the camera.
  122602. * @param force forces the camera to recompute the matrix without looking at the cached state
  122603. * @returns the projection matrix
  122604. */
  122605. getProjectionMatrix(force?: boolean): Matrix;
  122606. /**
  122607. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  122608. * @returns a Matrix
  122609. */
  122610. getTransformationMatrix(): Matrix;
  122611. private _updateFrustumPlanes;
  122612. /**
  122613. * Checks if a cullable object (mesh...) is in the camera frustum
  122614. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  122615. * @param target The object to check
  122616. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  122617. * @returns true if the object is in frustum otherwise false
  122618. */
  122619. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  122620. /**
  122621. * Checks if a cullable object (mesh...) is in the camera frustum
  122622. * Unlike isInFrustum this cheks the full bounding box
  122623. * @param target The object to check
  122624. * @returns true if the object is in frustum otherwise false
  122625. */
  122626. isCompletelyInFrustum(target: ICullable): boolean;
  122627. /**
  122628. * Gets a ray in the forward direction from the camera.
  122629. * @param length Defines the length of the ray to create
  122630. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  122631. * @param origin Defines the start point of the ray which defaults to the camera position
  122632. * @returns the forward ray
  122633. */
  122634. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  122635. /**
  122636. * Gets a ray in the forward direction from the camera.
  122637. * @param refRay the ray to (re)use when setting the values
  122638. * @param length Defines the length of the ray to create
  122639. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  122640. * @param origin Defines the start point of the ray which defaults to the camera position
  122641. * @returns the forward ray
  122642. */
  122643. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  122644. /**
  122645. * Releases resources associated with this node.
  122646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122648. */
  122649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122650. /** @hidden */
  122651. _isLeftCamera: boolean;
  122652. /**
  122653. * Gets the left camera of a rig setup in case of Rigged Camera
  122654. */
  122655. get isLeftCamera(): boolean;
  122656. /** @hidden */
  122657. _isRightCamera: boolean;
  122658. /**
  122659. * Gets the right camera of a rig setup in case of Rigged Camera
  122660. */
  122661. get isRightCamera(): boolean;
  122662. /**
  122663. * Gets the left camera of a rig setup in case of Rigged Camera
  122664. */
  122665. get leftCamera(): Nullable<FreeCamera>;
  122666. /**
  122667. * Gets the right camera of a rig setup in case of Rigged Camera
  122668. */
  122669. get rightCamera(): Nullable<FreeCamera>;
  122670. /**
  122671. * Gets the left camera target of a rig setup in case of Rigged Camera
  122672. * @returns the target position
  122673. */
  122674. getLeftTarget(): Nullable<Vector3>;
  122675. /**
  122676. * Gets the right camera target of a rig setup in case of Rigged Camera
  122677. * @returns the target position
  122678. */
  122679. getRightTarget(): Nullable<Vector3>;
  122680. /**
  122681. * @hidden
  122682. */
  122683. setCameraRigMode(mode: number, rigParams: any): void;
  122684. /** @hidden */
  122685. static _setStereoscopicRigMode(camera: Camera): void;
  122686. /** @hidden */
  122687. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  122688. /** @hidden */
  122689. static _setVRRigMode(camera: Camera, rigParams: any): void;
  122690. /** @hidden */
  122691. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  122692. /** @hidden */
  122693. _getVRProjectionMatrix(): Matrix;
  122694. protected _updateCameraRotationMatrix(): void;
  122695. protected _updateWebVRCameraRotationMatrix(): void;
  122696. /**
  122697. * This function MUST be overwritten by the different WebVR cameras available.
  122698. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  122699. * @hidden
  122700. */
  122701. _getWebVRProjectionMatrix(): Matrix;
  122702. /**
  122703. * This function MUST be overwritten by the different WebVR cameras available.
  122704. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  122705. * @hidden
  122706. */
  122707. _getWebVRViewMatrix(): Matrix;
  122708. /** @hidden */
  122709. setCameraRigParameter(name: string, value: any): void;
  122710. /**
  122711. * needs to be overridden by children so sub has required properties to be copied
  122712. * @hidden
  122713. */
  122714. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  122715. /**
  122716. * May need to be overridden by children
  122717. * @hidden
  122718. */
  122719. _updateRigCameras(): void;
  122720. /** @hidden */
  122721. _setupInputs(): void;
  122722. /**
  122723. * Serialiaze the camera setup to a json represention
  122724. * @returns the JSON representation
  122725. */
  122726. serialize(): any;
  122727. /**
  122728. * Clones the current camera.
  122729. * @param name The cloned camera name
  122730. * @returns the cloned camera
  122731. */
  122732. clone(name: string): Camera;
  122733. /**
  122734. * Gets the direction of the camera relative to a given local axis.
  122735. * @param localAxis Defines the reference axis to provide a relative direction.
  122736. * @return the direction
  122737. */
  122738. getDirection(localAxis: Vector3): Vector3;
  122739. /**
  122740. * Returns the current camera absolute rotation
  122741. */
  122742. get absoluteRotation(): Quaternion;
  122743. /**
  122744. * Gets the direction of the camera relative to a given local axis into a passed vector.
  122745. * @param localAxis Defines the reference axis to provide a relative direction.
  122746. * @param result Defines the vector to store the result in
  122747. */
  122748. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  122749. /**
  122750. * Gets a camera constructor for a given camera type
  122751. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  122752. * @param name The name of the camera the result will be able to instantiate
  122753. * @param scene The scene the result will construct the camera in
  122754. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  122755. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  122756. * @returns a factory method to construc the camera
  122757. */
  122758. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  122759. /**
  122760. * Compute the world matrix of the camera.
  122761. * @returns the camera world matrix
  122762. */
  122763. computeWorldMatrix(): Matrix;
  122764. /**
  122765. * Parse a JSON and creates the camera from the parsed information
  122766. * @param parsedCamera The JSON to parse
  122767. * @param scene The scene to instantiate the camera in
  122768. * @returns the newly constructed camera
  122769. */
  122770. static Parse(parsedCamera: any, scene: Scene): Camera;
  122771. }
  122772. }
  122773. declare module BABYLON {
  122774. /**
  122775. * PostProcessManager is used to manage one or more post processes or post process pipelines
  122776. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122777. */
  122778. export class PostProcessManager {
  122779. private _scene;
  122780. private _indexBuffer;
  122781. private _vertexBuffers;
  122782. /**
  122783. * Creates a new instance PostProcess
  122784. * @param scene The scene that the post process is associated with.
  122785. */
  122786. constructor(scene: Scene);
  122787. private _prepareBuffers;
  122788. private _buildIndexBuffer;
  122789. /**
  122790. * Rebuilds the vertex buffers of the manager.
  122791. * @hidden
  122792. */
  122793. _rebuild(): void;
  122794. /**
  122795. * Prepares a frame to be run through a post process.
  122796. * @param sourceTexture The input texture to the post procesess. (default: null)
  122797. * @param postProcesses An array of post processes to be run. (default: null)
  122798. * @returns True if the post processes were able to be run.
  122799. * @hidden
  122800. */
  122801. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  122802. /**
  122803. * Manually render a set of post processes to a texture.
  122804. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  122805. * @param postProcesses An array of post processes to be run.
  122806. * @param targetTexture The target texture to render to.
  122807. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  122808. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  122809. * @param lodLevel defines which lod of the texture to render to
  122810. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  122811. */
  122812. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  122813. /**
  122814. * Finalize the result of the output of the postprocesses.
  122815. * @param doNotPresent If true the result will not be displayed to the screen.
  122816. * @param targetTexture The target texture to render to.
  122817. * @param faceIndex The index of the face to bind the target texture to.
  122818. * @param postProcesses The array of post processes to render.
  122819. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  122820. * @hidden
  122821. */
  122822. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  122823. /**
  122824. * Disposes of the post process manager.
  122825. */
  122826. dispose(): void;
  122827. }
  122828. }
  122829. declare module BABYLON {
  122830. /**
  122831. * This Helps creating a texture that will be created from a camera in your scene.
  122832. * It is basically a dynamic texture that could be used to create special effects for instance.
  122833. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  122834. */
  122835. export class RenderTargetTexture extends Texture {
  122836. /**
  122837. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  122838. */
  122839. static readonly REFRESHRATE_RENDER_ONCE: number;
  122840. /**
  122841. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  122842. */
  122843. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  122844. /**
  122845. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  122846. * the central point of your effect and can save a lot of performances.
  122847. */
  122848. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  122849. /**
  122850. * Use this predicate to dynamically define the list of mesh you want to render.
  122851. * If set, the renderList property will be overwritten.
  122852. */
  122853. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  122854. private _renderList;
  122855. /**
  122856. * Use this list to define the list of mesh you want to render.
  122857. */
  122858. get renderList(): Nullable<Array<AbstractMesh>>;
  122859. set renderList(value: Nullable<Array<AbstractMesh>>);
  122860. /**
  122861. * Use this function to overload the renderList array at rendering time.
  122862. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  122863. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  122864. * the cube (if the RTT is a cube, else layerOrFace=0).
  122865. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  122866. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  122867. * hold dummy elements!
  122868. */
  122869. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  122870. private _hookArray;
  122871. /**
  122872. * Define if particles should be rendered in your texture.
  122873. */
  122874. renderParticles: boolean;
  122875. /**
  122876. * Define if sprites should be rendered in your texture.
  122877. */
  122878. renderSprites: boolean;
  122879. /**
  122880. * Define the camera used to render the texture.
  122881. */
  122882. activeCamera: Nullable<Camera>;
  122883. /**
  122884. * Override the mesh isReady function with your own one.
  122885. */
  122886. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  122887. /**
  122888. * Override the render function of the texture with your own one.
  122889. */
  122890. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  122891. /**
  122892. * Define if camera post processes should be use while rendering the texture.
  122893. */
  122894. useCameraPostProcesses: boolean;
  122895. /**
  122896. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  122897. */
  122898. ignoreCameraViewport: boolean;
  122899. private _postProcessManager;
  122900. private _postProcesses;
  122901. private _resizeObserver;
  122902. /**
  122903. * An event triggered when the texture is unbind.
  122904. */
  122905. onBeforeBindObservable: Observable<RenderTargetTexture>;
  122906. /**
  122907. * An event triggered when the texture is unbind.
  122908. */
  122909. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  122910. private _onAfterUnbindObserver;
  122911. /**
  122912. * Set a after unbind callback in the texture.
  122913. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  122914. */
  122915. set onAfterUnbind(callback: () => void);
  122916. /**
  122917. * An event triggered before rendering the texture
  122918. */
  122919. onBeforeRenderObservable: Observable<number>;
  122920. private _onBeforeRenderObserver;
  122921. /**
  122922. * Set a before render callback in the texture.
  122923. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  122924. */
  122925. set onBeforeRender(callback: (faceIndex: number) => void);
  122926. /**
  122927. * An event triggered after rendering the texture
  122928. */
  122929. onAfterRenderObservable: Observable<number>;
  122930. private _onAfterRenderObserver;
  122931. /**
  122932. * Set a after render callback in the texture.
  122933. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  122934. */
  122935. set onAfterRender(callback: (faceIndex: number) => void);
  122936. /**
  122937. * An event triggered after the texture clear
  122938. */
  122939. onClearObservable: Observable<Engine>;
  122940. private _onClearObserver;
  122941. /**
  122942. * Set a clear callback in the texture.
  122943. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  122944. */
  122945. set onClear(callback: (Engine: Engine) => void);
  122946. /**
  122947. * An event triggered when the texture is resized.
  122948. */
  122949. onResizeObservable: Observable<RenderTargetTexture>;
  122950. /**
  122951. * Define the clear color of the Render Target if it should be different from the scene.
  122952. */
  122953. clearColor: Color4;
  122954. protected _size: number | {
  122955. width: number;
  122956. height: number;
  122957. layers?: number;
  122958. };
  122959. protected _initialSizeParameter: number | {
  122960. width: number;
  122961. height: number;
  122962. } | {
  122963. ratio: number;
  122964. };
  122965. protected _sizeRatio: Nullable<number>;
  122966. /** @hidden */
  122967. _generateMipMaps: boolean;
  122968. protected _renderingManager: RenderingManager;
  122969. /** @hidden */
  122970. _waitingRenderList?: string[];
  122971. protected _doNotChangeAspectRatio: boolean;
  122972. protected _currentRefreshId: number;
  122973. protected _refreshRate: number;
  122974. protected _textureMatrix: Matrix;
  122975. protected _samples: number;
  122976. protected _renderTargetOptions: RenderTargetCreationOptions;
  122977. /**
  122978. * Gets render target creation options that were used.
  122979. */
  122980. get renderTargetOptions(): RenderTargetCreationOptions;
  122981. protected _onRatioRescale(): void;
  122982. /**
  122983. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  122984. * It must define where the camera used to render the texture is set
  122985. */
  122986. boundingBoxPosition: Vector3;
  122987. private _boundingBoxSize;
  122988. /**
  122989. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  122990. * When defined, the cubemap will switch to local mode
  122991. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  122992. * @example https://www.babylonjs-playground.com/#RNASML
  122993. */
  122994. set boundingBoxSize(value: Vector3);
  122995. get boundingBoxSize(): Vector3;
  122996. /**
  122997. * In case the RTT has been created with a depth texture, get the associated
  122998. * depth texture.
  122999. * Otherwise, return null.
  123000. */
  123001. get depthStencilTexture(): Nullable<InternalTexture>;
  123002. /**
  123003. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  123004. * or used a shadow, depth texture...
  123005. * @param name The friendly name of the texture
  123006. * @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)
  123007. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  123008. * @param generateMipMaps True if mip maps need to be generated after render.
  123009. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  123010. * @param type The type of the buffer in the RTT (int, half float, float...)
  123011. * @param isCube True if a cube texture needs to be created
  123012. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  123013. * @param generateDepthBuffer True to generate a depth buffer
  123014. * @param generateStencilBuffer True to generate a stencil buffer
  123015. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  123016. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  123017. * @param delayAllocation if the texture allocation should be delayed (default: false)
  123018. * @param samples sample count to use when creating the RTT
  123019. */
  123020. constructor(name: string, size: number | {
  123021. width: number;
  123022. height: number;
  123023. layers?: number;
  123024. } | {
  123025. ratio: number;
  123026. }, 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);
  123027. /**
  123028. * Creates a depth stencil texture.
  123029. * This is only available in WebGL 2 or with the depth texture extension available.
  123030. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  123031. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  123032. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  123033. * @param samples sample count of the depth/stencil texture
  123034. */
  123035. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  123036. private _processSizeParameter;
  123037. /**
  123038. * Define the number of samples to use in case of MSAA.
  123039. * It defaults to one meaning no MSAA has been enabled.
  123040. */
  123041. get samples(): number;
  123042. set samples(value: number);
  123043. /**
  123044. * Resets the refresh counter of the texture and start bak from scratch.
  123045. * Could be useful to regenerate the texture if it is setup to render only once.
  123046. */
  123047. resetRefreshCounter(): void;
  123048. /**
  123049. * Define the refresh rate of the texture or the rendering frequency.
  123050. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  123051. */
  123052. get refreshRate(): number;
  123053. set refreshRate(value: number);
  123054. /**
  123055. * Adds a post process to the render target rendering passes.
  123056. * @param postProcess define the post process to add
  123057. */
  123058. addPostProcess(postProcess: PostProcess): void;
  123059. /**
  123060. * Clear all the post processes attached to the render target
  123061. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  123062. */
  123063. clearPostProcesses(dispose?: boolean): void;
  123064. /**
  123065. * Remove one of the post process from the list of attached post processes to the texture
  123066. * @param postProcess define the post process to remove from the list
  123067. */
  123068. removePostProcess(postProcess: PostProcess): void;
  123069. /** @hidden */
  123070. _shouldRender(): boolean;
  123071. /**
  123072. * Gets the actual render size of the texture.
  123073. * @returns the width of the render size
  123074. */
  123075. getRenderSize(): number;
  123076. /**
  123077. * Gets the actual render width of the texture.
  123078. * @returns the width of the render size
  123079. */
  123080. getRenderWidth(): number;
  123081. /**
  123082. * Gets the actual render height of the texture.
  123083. * @returns the height of the render size
  123084. */
  123085. getRenderHeight(): number;
  123086. /**
  123087. * Gets the actual number of layers of the texture.
  123088. * @returns the number of layers
  123089. */
  123090. getRenderLayers(): number;
  123091. /**
  123092. * Get if the texture can be rescaled or not.
  123093. */
  123094. get canRescale(): boolean;
  123095. /**
  123096. * Resize the texture using a ratio.
  123097. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  123098. */
  123099. scale(ratio: number): void;
  123100. /**
  123101. * Get the texture reflection matrix used to rotate/transform the reflection.
  123102. * @returns the reflection matrix
  123103. */
  123104. getReflectionTextureMatrix(): Matrix;
  123105. /**
  123106. * Resize the texture to a new desired size.
  123107. * Be carrefull as it will recreate all the data in the new texture.
  123108. * @param size Define the new size. It can be:
  123109. * - a number for squared texture,
  123110. * - an object containing { width: number, height: number }
  123111. * - or an object containing a ratio { ratio: number }
  123112. */
  123113. resize(size: number | {
  123114. width: number;
  123115. height: number;
  123116. } | {
  123117. ratio: number;
  123118. }): void;
  123119. private _defaultRenderListPrepared;
  123120. /**
  123121. * Renders all the objects from the render list into the texture.
  123122. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  123123. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  123124. */
  123125. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  123126. private _bestReflectionRenderTargetDimension;
  123127. private _prepareRenderingManager;
  123128. /**
  123129. * @hidden
  123130. * @param faceIndex face index to bind to if this is a cubetexture
  123131. * @param layer defines the index of the texture to bind in the array
  123132. */
  123133. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  123134. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123135. private renderToTarget;
  123136. /**
  123137. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  123138. * This allowed control for front to back rendering or reversly depending of the special needs.
  123139. *
  123140. * @param renderingGroupId The rendering group id corresponding to its index
  123141. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  123142. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  123143. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  123144. */
  123145. 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;
  123146. /**
  123147. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  123148. *
  123149. * @param renderingGroupId The rendering group id corresponding to its index
  123150. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123151. */
  123152. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  123153. /**
  123154. * Clones the texture.
  123155. * @returns the cloned texture
  123156. */
  123157. clone(): RenderTargetTexture;
  123158. /**
  123159. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  123160. * @returns The JSON representation of the texture
  123161. */
  123162. serialize(): any;
  123163. /**
  123164. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  123165. */
  123166. disposeFramebufferObjects(): void;
  123167. /**
  123168. * Dispose the texture and release its associated resources.
  123169. */
  123170. dispose(): void;
  123171. /** @hidden */
  123172. _rebuild(): void;
  123173. /**
  123174. * Clear the info related to rendering groups preventing retention point in material dispose.
  123175. */
  123176. freeRenderingGroups(): void;
  123177. /**
  123178. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  123179. * @returns the view count
  123180. */
  123181. getViewCount(): number;
  123182. }
  123183. }
  123184. declare module BABYLON {
  123185. /**
  123186. * Options to be used when creating an effect.
  123187. */
  123188. export interface IEffectCreationOptions {
  123189. /**
  123190. * Atrributes that will be used in the shader.
  123191. */
  123192. attributes: string[];
  123193. /**
  123194. * Uniform varible names that will be set in the shader.
  123195. */
  123196. uniformsNames: string[];
  123197. /**
  123198. * Uniform buffer variable names that will be set in the shader.
  123199. */
  123200. uniformBuffersNames: string[];
  123201. /**
  123202. * Sampler texture variable names that will be set in the shader.
  123203. */
  123204. samplers: string[];
  123205. /**
  123206. * Define statements that will be set in the shader.
  123207. */
  123208. defines: any;
  123209. /**
  123210. * Possible fallbacks for this effect to improve performance when needed.
  123211. */
  123212. fallbacks: Nullable<IEffectFallbacks>;
  123213. /**
  123214. * Callback that will be called when the shader is compiled.
  123215. */
  123216. onCompiled: Nullable<(effect: Effect) => void>;
  123217. /**
  123218. * Callback that will be called if an error occurs during shader compilation.
  123219. */
  123220. onError: Nullable<(effect: Effect, errors: string) => void>;
  123221. /**
  123222. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123223. */
  123224. indexParameters?: any;
  123225. /**
  123226. * Max number of lights that can be used in the shader.
  123227. */
  123228. maxSimultaneousLights?: number;
  123229. /**
  123230. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  123231. */
  123232. transformFeedbackVaryings?: Nullable<string[]>;
  123233. /**
  123234. * 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
  123235. */
  123236. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  123237. /**
  123238. * Is this effect rendering to several color attachments ?
  123239. */
  123240. multiTarget?: boolean;
  123241. }
  123242. /**
  123243. * Effect containing vertex and fragment shader that can be executed on an object.
  123244. */
  123245. export class Effect implements IDisposable {
  123246. /**
  123247. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  123248. */
  123249. static ShadersRepository: string;
  123250. /**
  123251. * Enable logging of the shader code when a compilation error occurs
  123252. */
  123253. static LogShaderCodeOnCompilationError: boolean;
  123254. /**
  123255. * Name of the effect.
  123256. */
  123257. name: any;
  123258. /**
  123259. * String container all the define statements that should be set on the shader.
  123260. */
  123261. defines: string;
  123262. /**
  123263. * Callback that will be called when the shader is compiled.
  123264. */
  123265. onCompiled: Nullable<(effect: Effect) => void>;
  123266. /**
  123267. * Callback that will be called if an error occurs during shader compilation.
  123268. */
  123269. onError: Nullable<(effect: Effect, errors: string) => void>;
  123270. /**
  123271. * Callback that will be called when effect is bound.
  123272. */
  123273. onBind: Nullable<(effect: Effect) => void>;
  123274. /**
  123275. * Unique ID of the effect.
  123276. */
  123277. uniqueId: number;
  123278. /**
  123279. * Observable that will be called when the shader is compiled.
  123280. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  123281. */
  123282. onCompileObservable: Observable<Effect>;
  123283. /**
  123284. * Observable that will be called if an error occurs during shader compilation.
  123285. */
  123286. onErrorObservable: Observable<Effect>;
  123287. /** @hidden */
  123288. _onBindObservable: Nullable<Observable<Effect>>;
  123289. /**
  123290. * @hidden
  123291. * Specifies if the effect was previously ready
  123292. */
  123293. _wasPreviouslyReady: boolean;
  123294. /**
  123295. * Observable that will be called when effect is bound.
  123296. */
  123297. get onBindObservable(): Observable<Effect>;
  123298. /** @hidden */
  123299. _bonesComputationForcedToCPU: boolean;
  123300. /** @hidden */
  123301. _uniformBuffersNames: {
  123302. [key: string]: number;
  123303. };
  123304. /** @hidden */
  123305. _samplerList: string[];
  123306. /** @hidden */
  123307. _multiTarget: boolean;
  123308. private static _uniqueIdSeed;
  123309. private _engine;
  123310. private _uniformBuffersNamesList;
  123311. private _uniformsNames;
  123312. private _samplers;
  123313. private _isReady;
  123314. private _compilationError;
  123315. private _allFallbacksProcessed;
  123316. private _attributesNames;
  123317. private _attributes;
  123318. private _attributeLocationByName;
  123319. private _uniforms;
  123320. /**
  123321. * Key for the effect.
  123322. * @hidden
  123323. */
  123324. _key: string;
  123325. private _indexParameters;
  123326. private _fallbacks;
  123327. private _vertexSourceCodeOverride;
  123328. private _fragmentSourceCodeOverride;
  123329. private _transformFeedbackVaryings;
  123330. /**
  123331. * Compiled shader to webGL program.
  123332. * @hidden
  123333. */
  123334. _pipelineContext: Nullable<IPipelineContext>;
  123335. /** @hidden */
  123336. _vertexSourceCode: string;
  123337. /** @hidden */
  123338. _fragmentSourceCode: string;
  123339. /** @hidden */
  123340. private _rawVertexSourceCode;
  123341. /** @hidden */
  123342. private _rawFragmentSourceCode;
  123343. private static _baseCache;
  123344. private _processingContext;
  123345. /**
  123346. * Instantiates an effect.
  123347. * An effect can be used to create/manage/execute vertex and fragment shaders.
  123348. * @param baseName Name of the effect.
  123349. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  123350. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  123351. * @param samplers List of sampler variables that will be passed to the shader.
  123352. * @param engine Engine to be used to render the effect
  123353. * @param defines Define statements to be added to the shader.
  123354. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  123355. * @param onCompiled Callback that will be called when the shader is compiled.
  123356. * @param onError Callback that will be called if an error occurs during shader compilation.
  123357. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123358. * @param key Effect Key identifying uniquely compiled shader variants
  123359. */
  123360. 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);
  123361. private _useFinalCode;
  123362. /**
  123363. * Unique key for this effect
  123364. */
  123365. get key(): string;
  123366. /**
  123367. * If the effect has been compiled and prepared.
  123368. * @returns if the effect is compiled and prepared.
  123369. */
  123370. isReady(): boolean;
  123371. private _isReadyInternal;
  123372. /**
  123373. * The engine the effect was initialized with.
  123374. * @returns the engine.
  123375. */
  123376. getEngine(): Engine;
  123377. /**
  123378. * The pipeline context for this effect
  123379. * @returns the associated pipeline context
  123380. */
  123381. getPipelineContext(): Nullable<IPipelineContext>;
  123382. /**
  123383. * The set of names of attribute variables for the shader.
  123384. * @returns An array of attribute names.
  123385. */
  123386. getAttributesNames(): string[];
  123387. /**
  123388. * Returns the attribute at the given index.
  123389. * @param index The index of the attribute.
  123390. * @returns The location of the attribute.
  123391. */
  123392. getAttributeLocation(index: number): number;
  123393. /**
  123394. * Returns the attribute based on the name of the variable.
  123395. * @param name of the attribute to look up.
  123396. * @returns the attribute location.
  123397. */
  123398. getAttributeLocationByName(name: string): number;
  123399. /**
  123400. * The number of attributes.
  123401. * @returns the numnber of attributes.
  123402. */
  123403. getAttributesCount(): number;
  123404. /**
  123405. * Gets the index of a uniform variable.
  123406. * @param uniformName of the uniform to look up.
  123407. * @returns the index.
  123408. */
  123409. getUniformIndex(uniformName: string): number;
  123410. /**
  123411. * Returns the attribute based on the name of the variable.
  123412. * @param uniformName of the uniform to look up.
  123413. * @returns the location of the uniform.
  123414. */
  123415. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  123416. /**
  123417. * Returns an array of sampler variable names
  123418. * @returns The array of sampler variable names.
  123419. */
  123420. getSamplers(): string[];
  123421. /**
  123422. * Returns an array of uniform variable names
  123423. * @returns The array of uniform variable names.
  123424. */
  123425. getUniformNames(): string[];
  123426. /**
  123427. * Returns an array of uniform buffer variable names
  123428. * @returns The array of uniform buffer variable names.
  123429. */
  123430. getUniformBuffersNames(): string[];
  123431. /**
  123432. * Returns the index parameters used to create the effect
  123433. * @returns The index parameters object
  123434. */
  123435. getIndexParameters(): any;
  123436. /**
  123437. * The error from the last compilation.
  123438. * @returns the error string.
  123439. */
  123440. getCompilationError(): string;
  123441. /**
  123442. * Gets a boolean indicating that all fallbacks were used during compilation
  123443. * @returns true if all fallbacks were used
  123444. */
  123445. allFallbacksProcessed(): boolean;
  123446. /**
  123447. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  123448. * @param func The callback to be used.
  123449. */
  123450. executeWhenCompiled(func: (effect: Effect) => void): void;
  123451. private _checkIsReady;
  123452. private _loadShader;
  123453. /**
  123454. * Gets the vertex shader source code of this effect
  123455. */
  123456. get vertexSourceCode(): string;
  123457. /**
  123458. * Gets the fragment shader source code of this effect
  123459. */
  123460. get fragmentSourceCode(): string;
  123461. /**
  123462. * Gets the vertex shader source code before it has been processed by the preprocessor
  123463. */
  123464. get rawVertexSourceCode(): string;
  123465. /**
  123466. * Gets the fragment shader source code before it has been processed by the preprocessor
  123467. */
  123468. get rawFragmentSourceCode(): string;
  123469. /**
  123470. * Recompiles the webGL program
  123471. * @param vertexSourceCode The source code for the vertex shader.
  123472. * @param fragmentSourceCode The source code for the fragment shader.
  123473. * @param onCompiled Callback called when completed.
  123474. * @param onError Callback called on error.
  123475. * @hidden
  123476. */
  123477. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  123478. /**
  123479. * Prepares the effect
  123480. * @hidden
  123481. */
  123482. _prepareEffect(): void;
  123483. private _getShaderCodeAndErrorLine;
  123484. private _processCompilationErrors;
  123485. /**
  123486. * Checks if the effect is supported. (Must be called after compilation)
  123487. */
  123488. get isSupported(): boolean;
  123489. /**
  123490. * Binds a texture to the engine to be used as output of the shader.
  123491. * @param channel Name of the output variable.
  123492. * @param texture Texture to bind.
  123493. * @hidden
  123494. */
  123495. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  123496. /**
  123497. * Sets a texture on the engine to be used in the shader.
  123498. * @param channel Name of the sampler variable.
  123499. * @param texture Texture to set.
  123500. */
  123501. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  123502. /**
  123503. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  123504. * @param channel Name of the sampler variable.
  123505. * @param texture Texture to set.
  123506. */
  123507. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  123508. /**
  123509. * Sets an array of textures on the engine to be used in the shader.
  123510. * @param channel Name of the variable.
  123511. * @param textures Textures to set.
  123512. */
  123513. setTextureArray(channel: string, textures: ThinTexture[]): void;
  123514. /**
  123515. * 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)
  123516. * @param channel Name of the sampler variable.
  123517. * @param postProcess Post process to get the input texture from.
  123518. */
  123519. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  123520. /**
  123521. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  123522. * 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)
  123523. * @param channel Name of the sampler variable.
  123524. * @param postProcess Post process to get the output texture from.
  123525. */
  123526. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  123527. /**
  123528. * Binds a buffer to a uniform.
  123529. * @param buffer Buffer to bind.
  123530. * @param name Name of the uniform variable to bind to.
  123531. */
  123532. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  123533. /**
  123534. * Binds block to a uniform.
  123535. * @param blockName Name of the block to bind.
  123536. * @param index Index to bind.
  123537. */
  123538. bindUniformBlock(blockName: string, index: number): void;
  123539. /**
  123540. * Sets an interger value on a uniform variable.
  123541. * @param uniformName Name of the variable.
  123542. * @param value Value to be set.
  123543. * @returns this effect.
  123544. */
  123545. setInt(uniformName: string, value: number): Effect;
  123546. /**
  123547. * Sets an int2 value on a uniform variable.
  123548. * @param uniformName Name of the variable.
  123549. * @param x First int in int2.
  123550. * @param y Second int in int2.
  123551. * @returns this effect.
  123552. */
  123553. setInt2(uniformName: string, x: number, y: number): Effect;
  123554. /**
  123555. * Sets an int3 value on a uniform variable.
  123556. * @param uniformName Name of the variable.
  123557. * @param x First int in int3.
  123558. * @param y Second int in int3.
  123559. * @param z Third int in int3.
  123560. * @returns this effect.
  123561. */
  123562. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  123563. /**
  123564. * Sets an int4 value on a uniform variable.
  123565. * @param uniformName Name of the variable.
  123566. * @param x First int in int4.
  123567. * @param y Second int in int4.
  123568. * @param z Third int in int4.
  123569. * @param w Fourth int in int4.
  123570. * @returns this effect.
  123571. */
  123572. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  123573. /**
  123574. * Sets an int array on a uniform variable.
  123575. * @param uniformName Name of the variable.
  123576. * @param array array to be set.
  123577. * @returns this effect.
  123578. */
  123579. setIntArray(uniformName: string, array: Int32Array): Effect;
  123580. /**
  123581. * 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)
  123582. * @param uniformName Name of the variable.
  123583. * @param array array to be set.
  123584. * @returns this effect.
  123585. */
  123586. setIntArray2(uniformName: string, array: Int32Array): Effect;
  123587. /**
  123588. * 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)
  123589. * @param uniformName Name of the variable.
  123590. * @param array array to be set.
  123591. * @returns this effect.
  123592. */
  123593. setIntArray3(uniformName: string, array: Int32Array): Effect;
  123594. /**
  123595. * 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)
  123596. * @param uniformName Name of the variable.
  123597. * @param array array to be set.
  123598. * @returns this effect.
  123599. */
  123600. setIntArray4(uniformName: string, array: Int32Array): Effect;
  123601. /**
  123602. * Sets an float array on a uniform variable.
  123603. * @param uniformName Name of the variable.
  123604. * @param array array to be set.
  123605. * @returns this effect.
  123606. */
  123607. setFloatArray(uniformName: string, array: FloatArray): Effect;
  123608. /**
  123609. * 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)
  123610. * @param uniformName Name of the variable.
  123611. * @param array array to be set.
  123612. * @returns this effect.
  123613. */
  123614. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  123615. /**
  123616. * 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)
  123617. * @param uniformName Name of the variable.
  123618. * @param array array to be set.
  123619. * @returns this effect.
  123620. */
  123621. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  123622. /**
  123623. * 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)
  123624. * @param uniformName Name of the variable.
  123625. * @param array array to be set.
  123626. * @returns this effect.
  123627. */
  123628. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  123629. /**
  123630. * Sets an array on a uniform variable.
  123631. * @param uniformName Name of the variable.
  123632. * @param array array to be set.
  123633. * @returns this effect.
  123634. */
  123635. setArray(uniformName: string, array: number[]): Effect;
  123636. /**
  123637. * 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)
  123638. * @param uniformName Name of the variable.
  123639. * @param array array to be set.
  123640. * @returns this effect.
  123641. */
  123642. setArray2(uniformName: string, array: number[]): Effect;
  123643. /**
  123644. * 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)
  123645. * @param uniformName Name of the variable.
  123646. * @param array array to be set.
  123647. * @returns this effect.
  123648. */
  123649. setArray3(uniformName: string, array: number[]): Effect;
  123650. /**
  123651. * 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)
  123652. * @param uniformName Name of the variable.
  123653. * @param array array to be set.
  123654. * @returns this effect.
  123655. */
  123656. setArray4(uniformName: string, array: number[]): Effect;
  123657. /**
  123658. * Sets matrices on a uniform variable.
  123659. * @param uniformName Name of the variable.
  123660. * @param matrices matrices to be set.
  123661. * @returns this effect.
  123662. */
  123663. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  123664. /**
  123665. * Sets matrix on a uniform variable.
  123666. * @param uniformName Name of the variable.
  123667. * @param matrix matrix to be set.
  123668. * @returns this effect.
  123669. */
  123670. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  123671. /**
  123672. * 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)
  123673. * @param uniformName Name of the variable.
  123674. * @param matrix matrix to be set.
  123675. * @returns this effect.
  123676. */
  123677. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  123678. /**
  123679. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  123680. * @param uniformName Name of the variable.
  123681. * @param matrix matrix to be set.
  123682. * @returns this effect.
  123683. */
  123684. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  123685. /**
  123686. * Sets a float on a uniform variable.
  123687. * @param uniformName Name of the variable.
  123688. * @param value value to be set.
  123689. * @returns this effect.
  123690. */
  123691. setFloat(uniformName: string, value: number): Effect;
  123692. /**
  123693. * Sets a boolean on a uniform variable.
  123694. * @param uniformName Name of the variable.
  123695. * @param bool value to be set.
  123696. * @returns this effect.
  123697. */
  123698. setBool(uniformName: string, bool: boolean): Effect;
  123699. /**
  123700. * Sets a Vector2 on a uniform variable.
  123701. * @param uniformName Name of the variable.
  123702. * @param vector2 vector2 to be set.
  123703. * @returns this effect.
  123704. */
  123705. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  123706. /**
  123707. * Sets a float2 on a uniform variable.
  123708. * @param uniformName Name of the variable.
  123709. * @param x First float in float2.
  123710. * @param y Second float in float2.
  123711. * @returns this effect.
  123712. */
  123713. setFloat2(uniformName: string, x: number, y: number): Effect;
  123714. /**
  123715. * Sets a Vector3 on a uniform variable.
  123716. * @param uniformName Name of the variable.
  123717. * @param vector3 Value to be set.
  123718. * @returns this effect.
  123719. */
  123720. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  123721. /**
  123722. * Sets a float3 on a uniform variable.
  123723. * @param uniformName Name of the variable.
  123724. * @param x First float in float3.
  123725. * @param y Second float in float3.
  123726. * @param z Third float in float3.
  123727. * @returns this effect.
  123728. */
  123729. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  123730. /**
  123731. * Sets a Vector4 on a uniform variable.
  123732. * @param uniformName Name of the variable.
  123733. * @param vector4 Value to be set.
  123734. * @returns this effect.
  123735. */
  123736. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  123737. /**
  123738. * Sets a float4 on a uniform variable.
  123739. * @param uniformName Name of the variable.
  123740. * @param x First float in float4.
  123741. * @param y Second float in float4.
  123742. * @param z Third float in float4.
  123743. * @param w Fourth float in float4.
  123744. * @returns this effect.
  123745. */
  123746. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  123747. /**
  123748. * Sets a Color3 on a uniform variable.
  123749. * @param uniformName Name of the variable.
  123750. * @param color3 Value to be set.
  123751. * @returns this effect.
  123752. */
  123753. setColor3(uniformName: string, color3: IColor3Like): Effect;
  123754. /**
  123755. * Sets a Color4 on a uniform variable.
  123756. * @param uniformName Name of the variable.
  123757. * @param color3 Value to be set.
  123758. * @param alpha Alpha value to be set.
  123759. * @returns this effect.
  123760. */
  123761. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  123762. /**
  123763. * Sets a Color4 on a uniform variable
  123764. * @param uniformName defines the name of the variable
  123765. * @param color4 defines the value to be set
  123766. * @returns this effect.
  123767. */
  123768. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  123769. /**
  123770. * Release all associated resources.
  123771. **/
  123772. dispose(): void;
  123773. /**
  123774. * This function will add a new shader to the shader store
  123775. * @param name the name of the shader
  123776. * @param pixelShader optional pixel shader content
  123777. * @param vertexShader optional vertex shader content
  123778. */
  123779. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  123780. /**
  123781. * Store of each shader (The can be looked up using effect.key)
  123782. */
  123783. static ShadersStore: {
  123784. [key: string]: string;
  123785. };
  123786. /**
  123787. * Store of each included file for a shader (The can be looked up using effect.key)
  123788. */
  123789. static IncludesShadersStore: {
  123790. [key: string]: string;
  123791. };
  123792. /**
  123793. * Resets the cache of effects.
  123794. */
  123795. static ResetCache(): void;
  123796. }
  123797. }
  123798. declare module BABYLON {
  123799. /**
  123800. * Interface used to describe the capabilities of the engine relatively to the current browser
  123801. */
  123802. export interface EngineCapabilities {
  123803. /** Maximum textures units per fragment shader */
  123804. maxTexturesImageUnits: number;
  123805. /** Maximum texture units per vertex shader */
  123806. maxVertexTextureImageUnits: number;
  123807. /** Maximum textures units in the entire pipeline */
  123808. maxCombinedTexturesImageUnits: number;
  123809. /** Maximum texture size */
  123810. maxTextureSize: number;
  123811. /** Maximum texture samples */
  123812. maxSamples?: number;
  123813. /** Maximum cube texture size */
  123814. maxCubemapTextureSize: number;
  123815. /** Maximum render texture size */
  123816. maxRenderTextureSize: number;
  123817. /** Maximum number of vertex attributes */
  123818. maxVertexAttribs: number;
  123819. /** Maximum number of varyings */
  123820. maxVaryingVectors: number;
  123821. /** Maximum number of uniforms per vertex shader */
  123822. maxVertexUniformVectors: number;
  123823. /** Maximum number of uniforms per fragment shader */
  123824. maxFragmentUniformVectors: number;
  123825. /** Defines if standard derivates (dx/dy) are supported */
  123826. standardDerivatives: boolean;
  123827. /** Defines if s3tc texture compression is supported */
  123828. s3tc?: WEBGL_compressed_texture_s3tc;
  123829. /** Defines if pvrtc texture compression is supported */
  123830. pvrtc: any;
  123831. /** Defines if etc1 texture compression is supported */
  123832. etc1: any;
  123833. /** Defines if etc2 texture compression is supported */
  123834. etc2: any;
  123835. /** Defines if astc texture compression is supported */
  123836. astc: any;
  123837. /** Defines if bptc texture compression is supported */
  123838. bptc: any;
  123839. /** Defines if float textures are supported */
  123840. textureFloat: boolean;
  123841. /** Defines if vertex array objects are supported */
  123842. vertexArrayObject: boolean;
  123843. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  123844. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  123845. /** Gets the maximum level of anisotropy supported */
  123846. maxAnisotropy: number;
  123847. /** Defines if instancing is supported */
  123848. instancedArrays: boolean;
  123849. /** Defines if 32 bits indices are supported */
  123850. uintIndices: boolean;
  123851. /** Defines if high precision shaders are supported */
  123852. highPrecisionShaderSupported: boolean;
  123853. /** Defines if depth reading in the fragment shader is supported */
  123854. fragmentDepthSupported: boolean;
  123855. /** Defines if float texture linear filtering is supported*/
  123856. textureFloatLinearFiltering: boolean;
  123857. /** Defines if rendering to float textures is supported */
  123858. textureFloatRender: boolean;
  123859. /** Defines if half float textures are supported*/
  123860. textureHalfFloat: boolean;
  123861. /** Defines if half float texture linear filtering is supported*/
  123862. textureHalfFloatLinearFiltering: boolean;
  123863. /** Defines if rendering to half float textures is supported */
  123864. textureHalfFloatRender: boolean;
  123865. /** Defines if textureLOD shader command is supported */
  123866. textureLOD: boolean;
  123867. /** Defines if draw buffers extension is supported */
  123868. drawBuffersExtension: boolean;
  123869. /** Defines if depth textures are supported */
  123870. depthTextureExtension: boolean;
  123871. /** Defines if float color buffer are supported */
  123872. colorBufferFloat: boolean;
  123873. /** Gets disjoint timer query extension (null if not supported) */
  123874. timerQuery?: EXT_disjoint_timer_query;
  123875. /** Defines if timestamp can be used with timer query */
  123876. canUseTimestampForTimerQuery: boolean;
  123877. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  123878. multiview?: any;
  123879. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  123880. oculusMultiview?: any;
  123881. /** Function used to let the system compiles shaders in background */
  123882. parallelShaderCompile?: {
  123883. COMPLETION_STATUS_KHR: number;
  123884. };
  123885. /** Max number of texture samples for MSAA */
  123886. maxMSAASamples: number;
  123887. /** Defines if the blend min max extension is supported */
  123888. blendMinMax: boolean;
  123889. /** 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 */
  123890. canUseGLInstanceID: boolean;
  123891. }
  123892. }
  123893. declare module BABYLON {
  123894. /**
  123895. * @hidden
  123896. **/
  123897. export class DepthCullingState {
  123898. private _isDepthTestDirty;
  123899. private _isDepthMaskDirty;
  123900. private _isDepthFuncDirty;
  123901. private _isCullFaceDirty;
  123902. private _isCullDirty;
  123903. private _isZOffsetDirty;
  123904. private _isFrontFaceDirty;
  123905. private _depthTest;
  123906. private _depthMask;
  123907. private _depthFunc;
  123908. private _cull;
  123909. private _cullFace;
  123910. private _zOffset;
  123911. private _frontFace;
  123912. /**
  123913. * Initializes the state.
  123914. */
  123915. constructor();
  123916. get isDirty(): boolean;
  123917. get zOffset(): number;
  123918. set zOffset(value: number);
  123919. get cullFace(): Nullable<number>;
  123920. set cullFace(value: Nullable<number>);
  123921. get cull(): Nullable<boolean>;
  123922. set cull(value: Nullable<boolean>);
  123923. get depthFunc(): Nullable<number>;
  123924. set depthFunc(value: Nullable<number>);
  123925. get depthMask(): boolean;
  123926. set depthMask(value: boolean);
  123927. get depthTest(): boolean;
  123928. set depthTest(value: boolean);
  123929. get frontFace(): Nullable<number>;
  123930. set frontFace(value: Nullable<number>);
  123931. reset(): void;
  123932. apply(gl: WebGLRenderingContext): void;
  123933. }
  123934. }
  123935. declare module BABYLON {
  123936. /**
  123937. * @hidden
  123938. **/
  123939. export class StencilState {
  123940. /** 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 */
  123941. static readonly ALWAYS: number;
  123942. /** Passed to stencilOperation to specify that stencil value must be kept */
  123943. static readonly KEEP: number;
  123944. /** Passed to stencilOperation to specify that stencil value must be replaced */
  123945. static readonly REPLACE: number;
  123946. private _isStencilTestDirty;
  123947. private _isStencilMaskDirty;
  123948. private _isStencilFuncDirty;
  123949. private _isStencilOpDirty;
  123950. private _stencilTest;
  123951. private _stencilMask;
  123952. private _stencilFunc;
  123953. private _stencilFuncRef;
  123954. private _stencilFuncMask;
  123955. private _stencilOpStencilFail;
  123956. private _stencilOpDepthFail;
  123957. private _stencilOpStencilDepthPass;
  123958. get isDirty(): boolean;
  123959. get stencilFunc(): number;
  123960. set stencilFunc(value: number);
  123961. get stencilFuncRef(): number;
  123962. set stencilFuncRef(value: number);
  123963. get stencilFuncMask(): number;
  123964. set stencilFuncMask(value: number);
  123965. get stencilOpStencilFail(): number;
  123966. set stencilOpStencilFail(value: number);
  123967. get stencilOpDepthFail(): number;
  123968. set stencilOpDepthFail(value: number);
  123969. get stencilOpStencilDepthPass(): number;
  123970. set stencilOpStencilDepthPass(value: number);
  123971. get stencilMask(): number;
  123972. set stencilMask(value: number);
  123973. get stencilTest(): boolean;
  123974. set stencilTest(value: boolean);
  123975. constructor();
  123976. reset(): void;
  123977. apply(gl: WebGLRenderingContext): void;
  123978. }
  123979. }
  123980. declare module BABYLON {
  123981. /**
  123982. * @hidden
  123983. **/
  123984. export class AlphaState {
  123985. _blendFunctionParameters: Nullable<number>[];
  123986. _blendEquationParameters: Nullable<number>[];
  123987. _blendConstants: Nullable<number>[];
  123988. _isBlendConstantsDirty: boolean;
  123989. private _alphaBlend;
  123990. private _isAlphaBlendDirty;
  123991. private _isBlendFunctionParametersDirty;
  123992. private _isBlendEquationParametersDirty;
  123993. /**
  123994. * Initializes the state.
  123995. */
  123996. constructor();
  123997. get isDirty(): boolean;
  123998. get alphaBlend(): boolean;
  123999. set alphaBlend(value: boolean);
  124000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  124001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  124002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  124003. reset(): void;
  124004. apply(gl: WebGLRenderingContext): void;
  124005. }
  124006. }
  124007. declare module BABYLON {
  124008. /** @hidden */
  124009. export class WebGLShaderProcessor implements IShaderProcessor {
  124010. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124011. }
  124012. }
  124013. declare module BABYLON {
  124014. /** @hidden */
  124015. export class WebGL2ShaderProcessor implements IShaderProcessor {
  124016. attributeProcessor(attribute: string): string;
  124017. varyingProcessor(varying: string, isFragment: boolean): string;
  124018. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124019. }
  124020. }
  124021. declare module BABYLON {
  124022. /**
  124023. * Interface for attribute information associated with buffer instanciation
  124024. */
  124025. export interface InstancingAttributeInfo {
  124026. /**
  124027. * Name of the GLSL attribute
  124028. * if attribute index is not specified, this is used to retrieve the index from the effect
  124029. */
  124030. attributeName: string;
  124031. /**
  124032. * Index/offset of the attribute in the vertex shader
  124033. * if not specified, this will be computes from the name.
  124034. */
  124035. index?: number;
  124036. /**
  124037. * size of the attribute, 1, 2, 3 or 4
  124038. */
  124039. attributeSize: number;
  124040. /**
  124041. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  124042. */
  124043. offset: number;
  124044. /**
  124045. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  124046. * default to 1
  124047. */
  124048. divisor?: number;
  124049. /**
  124050. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  124051. * default is FLOAT
  124052. */
  124053. attributeType?: number;
  124054. /**
  124055. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  124056. */
  124057. normalized?: boolean;
  124058. }
  124059. }
  124060. declare module BABYLON {
  124061. /** @hidden */
  124062. export interface EngineFeatures {
  124063. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  124064. forceBitmapOverHTMLImageElement: boolean;
  124065. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  124066. supportRenderAndCopyToLodForFloatTextures: boolean;
  124067. /** Indicates that the engine support handling depth/stencil textures */
  124068. supportDepthStencilTexture: boolean;
  124069. /** Indicates that the engine support shadow samplers */
  124070. supportShadowSamplers: boolean;
  124071. /** 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 */
  124072. uniformBufferHardCheckMatrix: boolean;
  124073. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  124074. allowTexturePrefiltering: boolean;
  124075. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  124076. trackUbosInFrame: boolean;
  124077. /** Indicates that the Cascaded Shadow Map technic is supported */
  124078. supportCSM: boolean;
  124079. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  124080. basisNeedsPOT: boolean;
  124081. /** Indicates that the engine supports 3D textures */
  124082. support3DTextures: boolean;
  124083. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  124084. needTypeSuffixInShaderConstants: boolean;
  124085. /** Indicates that MSAA is supported */
  124086. supportMSAA: boolean;
  124087. /** Indicates that SSAO2 is supported */
  124088. supportSSAO2: boolean;
  124089. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  124090. supportExtendedTextureFormats: boolean;
  124091. /** Indicates that the switch/case construct is supported in shaders */
  124092. supportSwitchCaseInShader: boolean;
  124093. /** @hidden */
  124094. _collectUbosUpdatedInFrame: boolean;
  124095. }
  124096. }
  124097. declare module BABYLON {
  124098. /** @hidden */
  124099. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  124100. private _webGLTexture;
  124101. private _context;
  124102. get underlyingResource(): Nullable<WebGLTexture>;
  124103. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  124104. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  124105. set(hardwareTexture: WebGLTexture): void;
  124106. reset(): void;
  124107. release(): void;
  124108. }
  124109. }
  124110. declare module BABYLON {
  124111. interface ThinEngine {
  124112. /**
  124113. * Update a video texture
  124114. * @param texture defines the texture to update
  124115. * @param video defines the video element to use
  124116. * @param invertY defines if data must be stored with Y axis inverted
  124117. */
  124118. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  124119. }
  124120. }
  124121. declare module BABYLON {
  124122. interface ThinEngine {
  124123. /**
  124124. * Creates a dynamic texture
  124125. * @param width defines the width of the texture
  124126. * @param height defines the height of the texture
  124127. * @param generateMipMaps defines if the engine should generate the mip levels
  124128. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  124129. * @returns the dynamic texture inside an InternalTexture
  124130. */
  124131. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  124132. /**
  124133. * Update the content of a dynamic texture
  124134. * @param texture defines the texture to update
  124135. * @param source defines the source containing the data
  124136. * @param invertY defines if data must be stored with Y axis inverted
  124137. * @param premulAlpha defines if alpha is stored as premultiplied
  124138. * @param format defines the format of the data
  124139. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  124140. */
  124141. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  124142. }
  124143. }
  124144. declare module BABYLON {
  124145. /**
  124146. * Settings for finer control over video usage
  124147. */
  124148. export interface VideoTextureSettings {
  124149. /**
  124150. * Applies `autoplay` to video, if specified
  124151. */
  124152. autoPlay?: boolean;
  124153. /**
  124154. * Applies `muted` to video, if specified
  124155. */
  124156. muted?: boolean;
  124157. /**
  124158. * Applies `loop` to video, if specified
  124159. */
  124160. loop?: boolean;
  124161. /**
  124162. * Automatically updates internal texture from video at every frame in the render loop
  124163. */
  124164. autoUpdateTexture: boolean;
  124165. /**
  124166. * Image src displayed during the video loading or until the user interacts with the video.
  124167. */
  124168. poster?: string;
  124169. }
  124170. /**
  124171. * If you want to display a video in your scene, this is the special texture for that.
  124172. * This special texture works similar to other textures, with the exception of a few parameters.
  124173. * @see https://doc.babylonjs.com/how_to/video_texture
  124174. */
  124175. export class VideoTexture extends Texture {
  124176. /**
  124177. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  124178. */
  124179. readonly autoUpdateTexture: boolean;
  124180. /**
  124181. * The video instance used by the texture internally
  124182. */
  124183. readonly video: HTMLVideoElement;
  124184. private _onUserActionRequestedObservable;
  124185. /**
  124186. * Event triggerd when a dom action is required by the user to play the video.
  124187. * This happens due to recent changes in browser policies preventing video to auto start.
  124188. */
  124189. get onUserActionRequestedObservable(): Observable<Texture>;
  124190. private _generateMipMaps;
  124191. private _stillImageCaptured;
  124192. private _displayingPosterTexture;
  124193. private _settings;
  124194. private _createInternalTextureOnEvent;
  124195. private _frameId;
  124196. private _currentSrc;
  124197. /**
  124198. * Creates a video texture.
  124199. * If you want to display a video in your scene, this is the special texture for that.
  124200. * This special texture works similar to other textures, with the exception of a few parameters.
  124201. * @see https://doc.babylonjs.com/how_to/video_texture
  124202. * @param name optional name, will detect from video source, if not defined
  124203. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  124204. * @param scene is obviously the current scene.
  124205. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  124206. * @param invertY is false by default but can be used to invert video on Y axis
  124207. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  124208. * @param settings allows finer control over video usage
  124209. */
  124210. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  124211. private _getName;
  124212. private _getVideo;
  124213. private _createInternalTexture;
  124214. private reset;
  124215. /**
  124216. * @hidden Internal method to initiate `update`.
  124217. */
  124218. _rebuild(): void;
  124219. /**
  124220. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  124221. */
  124222. update(): void;
  124223. /**
  124224. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  124225. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  124226. */
  124227. updateTexture(isVisible: boolean): void;
  124228. protected _updateInternalTexture: () => void;
  124229. /**
  124230. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  124231. * @param url New url.
  124232. */
  124233. updateURL(url: string): void;
  124234. /**
  124235. * Clones the texture.
  124236. * @returns the cloned texture
  124237. */
  124238. clone(): VideoTexture;
  124239. /**
  124240. * Dispose the texture and release its associated resources.
  124241. */
  124242. dispose(): void;
  124243. /**
  124244. * Creates a video texture straight from a stream.
  124245. * @param scene Define the scene the texture should be created in
  124246. * @param stream Define the stream the texture should be created from
  124247. * @returns The created video texture as a promise
  124248. */
  124249. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  124250. /**
  124251. * Creates a video texture straight from your WebCam video feed.
  124252. * @param scene Define the scene the texture should be created in
  124253. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124254. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124255. * @returns The created video texture as a promise
  124256. */
  124257. static CreateFromWebCamAsync(scene: Scene, constraints: {
  124258. minWidth: number;
  124259. maxWidth: number;
  124260. minHeight: number;
  124261. maxHeight: number;
  124262. deviceId: string;
  124263. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  124264. /**
  124265. * Creates a video texture straight from your WebCam video feed.
  124266. * @param scene Define the scene the texture should be created in
  124267. * @param onReady Define a callback to triggered once the texture will be ready
  124268. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124269. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124270. */
  124271. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  124272. minWidth: number;
  124273. maxWidth: number;
  124274. minHeight: number;
  124275. maxHeight: number;
  124276. deviceId: string;
  124277. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  124278. }
  124279. }
  124280. declare module BABYLON {
  124281. /**
  124282. * Defines the interface used by objects working like Scene
  124283. * @hidden
  124284. */
  124285. export interface ISceneLike {
  124286. _addPendingData(data: any): void;
  124287. _removePendingData(data: any): void;
  124288. offlineProvider: IOfflineProvider;
  124289. }
  124290. /**
  124291. * Information about the current host
  124292. */
  124293. export interface HostInformation {
  124294. /**
  124295. * Defines if the current host is a mobile
  124296. */
  124297. isMobile: boolean;
  124298. }
  124299. /** Interface defining initialization parameters for Engine class */
  124300. export interface EngineOptions extends WebGLContextAttributes {
  124301. /**
  124302. * Defines if the engine should no exceed a specified device ratio
  124303. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  124304. */
  124305. limitDeviceRatio?: number;
  124306. /**
  124307. * Defines if webvr should be enabled automatically
  124308. * @see https://doc.babylonjs.com/how_to/webvr_camera
  124309. */
  124310. autoEnableWebVR?: boolean;
  124311. /**
  124312. * Defines if webgl2 should be turned off even if supported
  124313. * @see https://doc.babylonjs.com/features/webgl2
  124314. */
  124315. disableWebGL2Support?: boolean;
  124316. /**
  124317. * Defines if webaudio should be initialized as well
  124318. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  124319. */
  124320. audioEngine?: boolean;
  124321. /**
  124322. * Defines if animations should run using a deterministic lock step
  124323. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124324. */
  124325. deterministicLockstep?: boolean;
  124326. /** Defines the maximum steps to use with deterministic lock step mode */
  124327. lockstepMaxSteps?: number;
  124328. /** Defines the seconds between each deterministic lock step */
  124329. timeStep?: number;
  124330. /**
  124331. * Defines that engine should ignore context lost events
  124332. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  124333. */
  124334. doNotHandleContextLost?: boolean;
  124335. /**
  124336. * Defines that engine should ignore modifying touch action attribute and style
  124337. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  124338. */
  124339. doNotHandleTouchAction?: boolean;
  124340. /**
  124341. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  124342. */
  124343. useHighPrecisionFloats?: boolean;
  124344. /**
  124345. * Make the canvas XR Compatible for XR sessions
  124346. */
  124347. xrCompatible?: boolean;
  124348. /**
  124349. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  124350. */
  124351. useHighPrecisionMatrix?: boolean;
  124352. /**
  124353. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  124354. */
  124355. failIfMajorPerformanceCaveat?: boolean;
  124356. }
  124357. /**
  124358. * The base engine class (root of all engines)
  124359. */
  124360. export class ThinEngine {
  124361. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  124362. static ExceptionList: ({
  124363. key: string;
  124364. capture: string;
  124365. captureConstraint: number;
  124366. targets: string[];
  124367. } | {
  124368. key: string;
  124369. capture: null;
  124370. captureConstraint: null;
  124371. targets: string[];
  124372. })[];
  124373. /** @hidden */
  124374. static _TextureLoaders: IInternalTextureLoader[];
  124375. /**
  124376. * Returns the current npm package of the sdk
  124377. */
  124378. static get NpmPackage(): string;
  124379. /**
  124380. * Returns the current version of the framework
  124381. */
  124382. static get Version(): string;
  124383. /**
  124384. * Returns a string describing the current engine
  124385. */
  124386. get description(): string;
  124387. /**
  124388. * Returns the name of the engine
  124389. */
  124390. get name(): string;
  124391. /**
  124392. * Returns the version of the engine
  124393. */
  124394. get version(): number;
  124395. /**
  124396. * Gets or sets the epsilon value used by collision engine
  124397. */
  124398. static CollisionsEpsilon: number;
  124399. /**
  124400. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  124401. */
  124402. static get ShadersRepository(): string;
  124403. static set ShadersRepository(value: string);
  124404. /** @hidden */
  124405. _shaderProcessor: Nullable<IShaderProcessor>;
  124406. /**
  124407. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  124408. */
  124409. forcePOTTextures: boolean;
  124410. /**
  124411. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  124412. */
  124413. isFullscreen: boolean;
  124414. /**
  124415. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  124416. */
  124417. cullBackFaces: boolean;
  124418. /**
  124419. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  124420. */
  124421. renderEvenInBackground: boolean;
  124422. /**
  124423. * Gets or sets a boolean indicating that cache can be kept between frames
  124424. */
  124425. preventCacheWipeBetweenFrames: boolean;
  124426. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  124427. validateShaderPrograms: boolean;
  124428. /**
  124429. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  124430. * This can provide greater z depth for distant objects.
  124431. */
  124432. useReverseDepthBuffer: boolean;
  124433. /**
  124434. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  124435. */
  124436. disableUniformBuffers: boolean;
  124437. private _frameId;
  124438. /**
  124439. * Gets the current frame id
  124440. */
  124441. get frameId(): number;
  124442. /** @hidden */
  124443. _uniformBuffers: UniformBuffer[];
  124444. /**
  124445. * Gets a boolean indicating that the engine supports uniform buffers
  124446. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  124447. */
  124448. get supportsUniformBuffers(): boolean;
  124449. /** @hidden */
  124450. _gl: WebGLRenderingContext;
  124451. /** @hidden */
  124452. _webGLVersion: number;
  124453. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  124454. protected _windowIsBackground: boolean;
  124455. protected _creationOptions: EngineOptions;
  124456. protected _highPrecisionShadersAllowed: boolean;
  124457. /** @hidden */
  124458. get _shouldUseHighPrecisionShader(): boolean;
  124459. /**
  124460. * Gets a boolean indicating that only power of 2 textures are supported
  124461. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  124462. */
  124463. get needPOTTextures(): boolean;
  124464. /** @hidden */
  124465. _badOS: boolean;
  124466. /** @hidden */
  124467. _badDesktopOS: boolean;
  124468. protected _hardwareScalingLevel: number;
  124469. /** @hidden */
  124470. _caps: EngineCapabilities;
  124471. /** @hidden */
  124472. _features: EngineFeatures;
  124473. protected _isStencilEnable: boolean;
  124474. private _glVersion;
  124475. private _glRenderer;
  124476. private _glVendor;
  124477. /** @hidden */
  124478. _videoTextureSupported: boolean;
  124479. protected _renderingQueueLaunched: boolean;
  124480. protected _activeRenderLoops: (() => void)[];
  124481. /**
  124482. * Observable signaled when a context lost event is raised
  124483. */
  124484. onContextLostObservable: Observable<ThinEngine>;
  124485. /**
  124486. * Observable signaled when a context restored event is raised
  124487. */
  124488. onContextRestoredObservable: Observable<ThinEngine>;
  124489. private _onContextLost;
  124490. private _onContextRestored;
  124491. protected _contextWasLost: boolean;
  124492. /** @hidden */
  124493. _doNotHandleContextLost: boolean;
  124494. /**
  124495. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  124496. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  124497. */
  124498. get doNotHandleContextLost(): boolean;
  124499. set doNotHandleContextLost(value: boolean);
  124500. /**
  124501. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  124502. */
  124503. disableVertexArrayObjects: boolean;
  124504. /** @hidden */
  124505. protected _colorWrite: boolean;
  124506. /** @hidden */
  124507. protected _colorWriteChanged: boolean;
  124508. /** @hidden */
  124509. protected _depthCullingState: DepthCullingState;
  124510. /** @hidden */
  124511. protected _stencilState: StencilState;
  124512. /** @hidden */
  124513. _alphaState: AlphaState;
  124514. /** @hidden */
  124515. _alphaMode: number;
  124516. /** @hidden */
  124517. _alphaEquation: number;
  124518. /** @hidden */
  124519. _internalTexturesCache: InternalTexture[];
  124520. /** @hidden */
  124521. protected _activeChannel: number;
  124522. private _currentTextureChannel;
  124523. /** @hidden */
  124524. protected _boundTexturesCache: {
  124525. [key: string]: Nullable<InternalTexture>;
  124526. };
  124527. /** @hidden */
  124528. protected _currentEffect: Nullable<Effect>;
  124529. /** @hidden */
  124530. protected _currentProgram: Nullable<WebGLProgram>;
  124531. protected _compiledEffects: {
  124532. [key: string]: Effect;
  124533. };
  124534. private _vertexAttribArraysEnabled;
  124535. /** @hidden */
  124536. protected _cachedViewport: Nullable<IViewportLike>;
  124537. private _cachedVertexArrayObject;
  124538. /** @hidden */
  124539. protected _cachedVertexBuffers: any;
  124540. /** @hidden */
  124541. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  124542. /** @hidden */
  124543. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  124544. /** @hidden */
  124545. _currentRenderTarget: Nullable<InternalTexture>;
  124546. private _uintIndicesCurrentlySet;
  124547. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  124548. /** @hidden */
  124549. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  124550. /** @hidden */
  124551. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  124552. private _currentBufferPointers;
  124553. private _currentInstanceLocations;
  124554. private _currentInstanceBuffers;
  124555. private _textureUnits;
  124556. /** @hidden */
  124557. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  124558. /** @hidden */
  124559. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  124560. /** @hidden */
  124561. _boundRenderFunction: any;
  124562. private _vaoRecordInProgress;
  124563. private _mustWipeVertexAttributes;
  124564. private _emptyTexture;
  124565. private _emptyCubeTexture;
  124566. private _emptyTexture3D;
  124567. private _emptyTexture2DArray;
  124568. /** @hidden */
  124569. _frameHandler: number;
  124570. private _nextFreeTextureSlots;
  124571. private _maxSimultaneousTextures;
  124572. private _activeRequests;
  124573. /** @hidden */
  124574. _transformTextureUrl: Nullable<(url: string) => string>;
  124575. /**
  124576. * Gets information about the current host
  124577. */
  124578. hostInformation: HostInformation;
  124579. protected get _supportsHardwareTextureRescaling(): boolean;
  124580. private _framebufferDimensionsObject;
  124581. /**
  124582. * sets the object from which width and height will be taken from when getting render width and height
  124583. * Will fallback to the gl object
  124584. * @param dimensions the framebuffer width and height that will be used.
  124585. */
  124586. set framebufferDimensionsObject(dimensions: Nullable<{
  124587. framebufferWidth: number;
  124588. framebufferHeight: number;
  124589. }>);
  124590. /**
  124591. * Gets the current viewport
  124592. */
  124593. get currentViewport(): Nullable<IViewportLike>;
  124594. /**
  124595. * Gets the default empty texture
  124596. */
  124597. get emptyTexture(): InternalTexture;
  124598. /**
  124599. * Gets the default empty 3D texture
  124600. */
  124601. get emptyTexture3D(): InternalTexture;
  124602. /**
  124603. * Gets the default empty 2D array texture
  124604. */
  124605. get emptyTexture2DArray(): InternalTexture;
  124606. /**
  124607. * Gets the default empty cube texture
  124608. */
  124609. get emptyCubeTexture(): InternalTexture;
  124610. /**
  124611. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  124612. */
  124613. premultipliedAlpha: boolean;
  124614. /**
  124615. * Observable event triggered before each texture is initialized
  124616. */
  124617. onBeforeTextureInitObservable: Observable<Texture>;
  124618. /** @hidden */
  124619. protected _isWebGPU: boolean;
  124620. /**
  124621. * Gets a boolean indicating if the engine runs in WebGPU or not.
  124622. */
  124623. get isWebGPU(): boolean;
  124624. /** @hidden */
  124625. protected _shaderPlatformName: string;
  124626. /**
  124627. * Gets the shader platfrom name used by the effects.
  124628. */
  124629. get shaderPlatformName(): string;
  124630. /**
  124631. * Creates a new engine
  124632. * @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
  124633. * @param antialias defines enable antialiasing (default: false)
  124634. * @param options defines further options to be sent to the getContext() function
  124635. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  124636. */
  124637. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  124638. /**
  124639. * @hidden
  124640. */
  124641. _debugPushGroup(groupName: string, targetObject?: number): void;
  124642. /**
  124643. * @hidden
  124644. */
  124645. _debugPopGroup(targetObject?: number): void;
  124646. /**
  124647. * @hidden
  124648. */
  124649. _debugInsertMarker(text: string, targetObject?: number): void;
  124650. /**
  124651. * Shared initialization across engines types.
  124652. * @param canvas The canvas associated with this instance of the engine.
  124653. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  124654. * @param audioEngine Defines if an audio engine should be created by default
  124655. */
  124656. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  124657. /**
  124658. * Gets a shader processor implementation fitting with the current engine type.
  124659. * @returns The shader processor implementation.
  124660. */
  124661. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  124662. /** @hidden */
  124663. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  124664. private _rebuildInternalTextures;
  124665. private _rebuildEffects;
  124666. /**
  124667. * Gets a boolean indicating if all created effects are ready
  124668. * @returns true if all effects are ready
  124669. */
  124670. areAllEffectsReady(): boolean;
  124671. protected _rebuildBuffers(): void;
  124672. protected _initGLContext(): void;
  124673. protected _initFeatures(): void;
  124674. /**
  124675. * Gets version of the current webGL context
  124676. * Keep it for back compat - use version instead
  124677. */
  124678. get webGLVersion(): number;
  124679. /**
  124680. * Gets a string identifying the name of the class
  124681. * @returns "Engine" string
  124682. */
  124683. getClassName(): string;
  124684. /**
  124685. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  124686. */
  124687. get isStencilEnable(): boolean;
  124688. /** @hidden */
  124689. _prepareWorkingCanvas(): void;
  124690. /**
  124691. * Reset the texture cache to empty state
  124692. */
  124693. resetTextureCache(): void;
  124694. /**
  124695. * Gets an object containing information about the current webGL context
  124696. * @returns an object containing the vender, the renderer and the version of the current webGL context
  124697. */
  124698. getGlInfo(): {
  124699. vendor: string;
  124700. renderer: string;
  124701. version: string;
  124702. };
  124703. /**
  124704. * Defines the hardware scaling level.
  124705. * By default the hardware scaling level is computed from the window device ratio.
  124706. * 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.
  124707. * @param level defines the level to use
  124708. */
  124709. setHardwareScalingLevel(level: number): void;
  124710. /**
  124711. * Gets the current hardware scaling level.
  124712. * By default the hardware scaling level is computed from the window device ratio.
  124713. * 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.
  124714. * @returns a number indicating the current hardware scaling level
  124715. */
  124716. getHardwareScalingLevel(): number;
  124717. /**
  124718. * Gets the list of loaded textures
  124719. * @returns an array containing all loaded textures
  124720. */
  124721. getLoadedTexturesCache(): InternalTexture[];
  124722. /**
  124723. * Gets the object containing all engine capabilities
  124724. * @returns the EngineCapabilities object
  124725. */
  124726. getCaps(): EngineCapabilities;
  124727. /**
  124728. * stop executing a render loop function and remove it from the execution array
  124729. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  124730. */
  124731. stopRenderLoop(renderFunction?: () => void): void;
  124732. /** @hidden */
  124733. _renderLoop(): void;
  124734. /**
  124735. * Gets the HTML canvas attached with the current webGL context
  124736. * @returns a HTML canvas
  124737. */
  124738. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  124739. /**
  124740. * Gets host window
  124741. * @returns the host window object
  124742. */
  124743. getHostWindow(): Nullable<Window>;
  124744. /**
  124745. * Gets the current render width
  124746. * @param useScreen defines if screen size must be used (or the current render target if any)
  124747. * @returns a number defining the current render width
  124748. */
  124749. getRenderWidth(useScreen?: boolean): number;
  124750. /**
  124751. * Gets the current render height
  124752. * @param useScreen defines if screen size must be used (or the current render target if any)
  124753. * @returns a number defining the current render height
  124754. */
  124755. getRenderHeight(useScreen?: boolean): number;
  124756. /**
  124757. * Can be used to override the current requestAnimationFrame requester.
  124758. * @hidden
  124759. */
  124760. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124761. /**
  124762. * Register and execute a render loop. The engine can have more than one render function
  124763. * @param renderFunction defines the function to continuously execute
  124764. */
  124765. runRenderLoop(renderFunction: () => void): void;
  124766. /**
  124767. * Clear the current render buffer or the current render target (if any is set up)
  124768. * @param color defines the color to use
  124769. * @param backBuffer defines if the back buffer must be cleared
  124770. * @param depth defines if the depth buffer must be cleared
  124771. * @param stencil defines if the stencil buffer must be cleared
  124772. */
  124773. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124774. protected _viewportCached: {
  124775. x: number;
  124776. y: number;
  124777. z: number;
  124778. w: number;
  124779. };
  124780. /** @hidden */
  124781. _viewport(x: number, y: number, width: number, height: number): void;
  124782. /**
  124783. * Set the WebGL's viewport
  124784. * @param viewport defines the viewport element to be used
  124785. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  124786. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  124787. */
  124788. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  124789. /**
  124790. * Begin a new frame
  124791. */
  124792. beginFrame(): void;
  124793. /**
  124794. * Enf the current frame
  124795. */
  124796. endFrame(): void;
  124797. /**
  124798. * Resize the view according to the canvas' size
  124799. * @param forceSetSize true to force setting the sizes of the underlying canvas
  124800. */
  124801. resize(forceSetSize?: boolean): void;
  124802. /**
  124803. * Force a specific size of the canvas
  124804. * @param width defines the new canvas' width
  124805. * @param height defines the new canvas' height
  124806. * @param forceSetSize true to force setting the sizes of the underlying canvas
  124807. * @returns true if the size was changed
  124808. */
  124809. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  124810. /**
  124811. * Binds the frame buffer to the specified texture.
  124812. * @param texture The texture to render to or null for the default canvas
  124813. * @param faceIndex The face of the texture to render to in case of cube texture
  124814. * @param requiredWidth The width of the target to render to
  124815. * @param requiredHeight The height of the target to render to
  124816. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  124817. * @param lodLevel defines the lod level to bind to the frame buffer
  124818. * @param layer defines the 2d array index to bind to frame buffer to
  124819. */
  124820. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  124821. /** @hidden */
  124822. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124823. /**
  124824. * Unbind the current render target texture from the webGL context
  124825. * @param texture defines the render target texture to unbind
  124826. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  124827. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  124828. */
  124829. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124830. /**
  124831. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  124832. */
  124833. flushFramebuffer(): void;
  124834. /**
  124835. * Unbind the current render target and bind the default framebuffer
  124836. */
  124837. restoreDefaultFramebuffer(): void;
  124838. /** @hidden */
  124839. protected _resetVertexBufferBinding(): void;
  124840. /**
  124841. * Creates a vertex buffer
  124842. * @param data the data for the vertex buffer
  124843. * @returns the new WebGL static buffer
  124844. */
  124845. createVertexBuffer(data: DataArray): DataBuffer;
  124846. private _createVertexBuffer;
  124847. /**
  124848. * Creates a dynamic vertex buffer
  124849. * @param data the data for the dynamic vertex buffer
  124850. * @returns the new WebGL dynamic buffer
  124851. */
  124852. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124853. protected _resetIndexBufferBinding(): void;
  124854. /**
  124855. * Creates a new index buffer
  124856. * @param indices defines the content of the index buffer
  124857. * @param updatable defines if the index buffer must be updatable
  124858. * @returns a new webGL buffer
  124859. */
  124860. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  124861. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  124862. /**
  124863. * Bind a webGL buffer to the webGL context
  124864. * @param buffer defines the buffer to bind
  124865. */
  124866. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  124867. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  124868. private bindBuffer;
  124869. /**
  124870. * update the bound buffer with the given data
  124871. * @param data defines the data to update
  124872. */
  124873. updateArrayBuffer(data: Float32Array): void;
  124874. private _vertexAttribPointer;
  124875. /** @hidden */
  124876. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  124877. private _bindVertexBuffersAttributes;
  124878. /**
  124879. * Records a vertex array object
  124880. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  124881. * @param vertexBuffers defines the list of vertex buffers to store
  124882. * @param indexBuffer defines the index buffer to store
  124883. * @param effect defines the effect to store
  124884. * @returns the new vertex array object
  124885. */
  124886. recordVertexArrayObject(vertexBuffers: {
  124887. [key: string]: VertexBuffer;
  124888. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124889. /**
  124890. * Bind a specific vertex array object
  124891. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  124892. * @param vertexArrayObject defines the vertex array object to bind
  124893. * @param indexBuffer defines the index buffer to bind
  124894. */
  124895. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  124896. /**
  124897. * Bind webGl buffers directly to the webGL context
  124898. * @param vertexBuffer defines the vertex buffer to bind
  124899. * @param indexBuffer defines the index buffer to bind
  124900. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  124901. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  124902. * @param effect defines the effect associated with the vertex buffer
  124903. */
  124904. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  124905. private _unbindVertexArrayObject;
  124906. /**
  124907. * Bind a list of vertex buffers to the webGL context
  124908. * @param vertexBuffers defines the list of vertex buffers to bind
  124909. * @param indexBuffer defines the index buffer to bind
  124910. * @param effect defines the effect associated with the vertex buffers
  124911. */
  124912. bindBuffers(vertexBuffers: {
  124913. [key: string]: Nullable<VertexBuffer>;
  124914. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  124915. /**
  124916. * Unbind all instance attributes
  124917. */
  124918. unbindInstanceAttributes(): void;
  124919. /**
  124920. * Release and free the memory of a vertex array object
  124921. * @param vao defines the vertex array object to delete
  124922. */
  124923. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  124924. /** @hidden */
  124925. _releaseBuffer(buffer: DataBuffer): boolean;
  124926. protected _deleteBuffer(buffer: DataBuffer): void;
  124927. /**
  124928. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  124929. * @param instancesBuffer defines the webGL buffer to update and bind
  124930. * @param data defines the data to store in the buffer
  124931. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  124932. */
  124933. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  124934. /**
  124935. * Bind the content of a webGL buffer used with instantiation
  124936. * @param instancesBuffer defines the webGL buffer to bind
  124937. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  124938. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  124939. */
  124940. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  124941. /**
  124942. * Disable the instance attribute corresponding to the name in parameter
  124943. * @param name defines the name of the attribute to disable
  124944. */
  124945. disableInstanceAttributeByName(name: string): void;
  124946. /**
  124947. * Disable the instance attribute corresponding to the location in parameter
  124948. * @param attributeLocation defines the attribute location of the attribute to disable
  124949. */
  124950. disableInstanceAttribute(attributeLocation: number): void;
  124951. /**
  124952. * Disable the attribute corresponding to the location in parameter
  124953. * @param attributeLocation defines the attribute location of the attribute to disable
  124954. */
  124955. disableAttributeByIndex(attributeLocation: number): void;
  124956. /**
  124957. * Send a draw order
  124958. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  124959. * @param indexStart defines the starting index
  124960. * @param indexCount defines the number of index to draw
  124961. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124962. */
  124963. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  124964. /**
  124965. * Draw a list of points
  124966. * @param verticesStart defines the index of first vertex to draw
  124967. * @param verticesCount defines the count of vertices to draw
  124968. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124969. */
  124970. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124971. /**
  124972. * Draw a list of unindexed primitives
  124973. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  124974. * @param verticesStart defines the index of first vertex to draw
  124975. * @param verticesCount defines the count of vertices to draw
  124976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124977. */
  124978. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124979. /**
  124980. * Draw a list of indexed primitives
  124981. * @param fillMode defines the primitive to use
  124982. * @param indexStart defines the starting index
  124983. * @param indexCount defines the number of index to draw
  124984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124985. */
  124986. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124987. /**
  124988. * Draw a list of unindexed primitives
  124989. * @param fillMode defines the primitive to use
  124990. * @param verticesStart defines the index of first vertex to draw
  124991. * @param verticesCount defines the count of vertices to draw
  124992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124993. */
  124994. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124995. private _drawMode;
  124996. /** @hidden */
  124997. protected _reportDrawCall(): void;
  124998. /** @hidden */
  124999. _releaseEffect(effect: Effect): void;
  125000. /** @hidden */
  125001. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  125002. /**
  125003. * Create a new effect (used to store vertex/fragment shaders)
  125004. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  125005. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  125006. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  125007. * @param samplers defines an array of string used to represent textures
  125008. * @param defines defines the string containing the defines to use to compile the shaders
  125009. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125010. * @param onCompiled defines a function to call when the effect creation is successful
  125011. * @param onError defines a function to call when the effect creation has failed
  125012. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  125013. * @returns the new Effect
  125014. */
  125015. 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;
  125016. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  125017. private _compileShader;
  125018. private _compileRawShader;
  125019. /** @hidden */
  125020. _getShaderSource(shader: WebGLShader): Nullable<string>;
  125021. /**
  125022. * Directly creates a webGL program
  125023. * @param pipelineContext defines the pipeline context to attach to
  125024. * @param vertexCode defines the vertex shader code to use
  125025. * @param fragmentCode defines the fragment shader code to use
  125026. * @param context defines the webGL context to use (if not set, the current one will be used)
  125027. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125028. * @returns the new webGL program
  125029. */
  125030. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125031. /**
  125032. * Creates a webGL program
  125033. * @param pipelineContext defines the pipeline context to attach to
  125034. * @param vertexCode defines the vertex shader code to use
  125035. * @param fragmentCode defines the fragment shader code to use
  125036. * @param defines defines the string containing the defines to use to compile the shaders
  125037. * @param context defines the webGL context to use (if not set, the current one will be used)
  125038. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125039. * @returns the new webGL program
  125040. */
  125041. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125042. /**
  125043. * Creates a new pipeline context
  125044. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  125045. * @returns the new pipeline
  125046. */
  125047. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  125048. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125049. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  125050. /** @hidden */
  125051. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  125052. /** @hidden */
  125053. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  125054. /** @hidden */
  125055. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  125056. /**
  125057. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  125058. * @param pipelineContext defines the pipeline context to use
  125059. * @param uniformsNames defines the list of uniform names
  125060. * @returns an array of webGL uniform locations
  125061. */
  125062. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  125063. /**
  125064. * Gets the list of active attributes for a given webGL program
  125065. * @param pipelineContext defines the pipeline context to use
  125066. * @param attributesNames defines the list of attribute names to get
  125067. * @returns an array of indices indicating the offset of each attribute
  125068. */
  125069. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  125070. /**
  125071. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  125072. * @param effect defines the effect to activate
  125073. */
  125074. enableEffect(effect: Nullable<Effect>): void;
  125075. /**
  125076. * Set the value of an uniform to a number (int)
  125077. * @param uniform defines the webGL uniform location where to store the value
  125078. * @param value defines the int number to store
  125079. * @returns true if the value was set
  125080. */
  125081. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125082. /**
  125083. * Set the value of an uniform to a int2
  125084. * @param uniform defines the webGL uniform location where to store the value
  125085. * @param x defines the 1st component of the value
  125086. * @param y defines the 2nd component of the value
  125087. * @returns true if the value was set
  125088. */
  125089. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125090. /**
  125091. * Set the value of an uniform to a int3
  125092. * @param uniform defines the webGL uniform location where to store the value
  125093. * @param x defines the 1st component of the value
  125094. * @param y defines the 2nd component of the value
  125095. * @param z defines the 3rd component of the value
  125096. * @returns true if the value was set
  125097. */
  125098. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125099. /**
  125100. * Set the value of an uniform to a int4
  125101. * @param uniform defines the webGL uniform location where to store the value
  125102. * @param x defines the 1st component of the value
  125103. * @param y defines the 2nd component of the value
  125104. * @param z defines the 3rd component of the value
  125105. * @param w defines the 4th component of the value
  125106. * @returns true if the value was set
  125107. */
  125108. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125109. /**
  125110. * Set the value of an uniform to an array of int32
  125111. * @param uniform defines the webGL uniform location where to store the value
  125112. * @param array defines the array of int32 to store
  125113. * @returns true if the value was set
  125114. */
  125115. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125116. /**
  125117. * Set the value of an uniform to an array of int32 (stored as vec2)
  125118. * @param uniform defines the webGL uniform location where to store the value
  125119. * @param array defines the array of int32 to store
  125120. * @returns true if the value was set
  125121. */
  125122. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125123. /**
  125124. * Set the value of an uniform to an array of int32 (stored as vec3)
  125125. * @param uniform defines the webGL uniform location where to store the value
  125126. * @param array defines the array of int32 to store
  125127. * @returns true if the value was set
  125128. */
  125129. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125130. /**
  125131. * Set the value of an uniform to an array of int32 (stored as vec4)
  125132. * @param uniform defines the webGL uniform location where to store the value
  125133. * @param array defines the array of int32 to store
  125134. * @returns true if the value was set
  125135. */
  125136. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125137. /**
  125138. * Set the value of an uniform to an array of number
  125139. * @param uniform defines the webGL uniform location where to store the value
  125140. * @param array defines the array of number to store
  125141. * @returns true if the value was set
  125142. */
  125143. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125144. /**
  125145. * Set the value of an uniform to an array of number (stored as vec2)
  125146. * @param uniform defines the webGL uniform location where to store the value
  125147. * @param array defines the array of number to store
  125148. * @returns true if the value was set
  125149. */
  125150. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125151. /**
  125152. * Set the value of an uniform to an array of number (stored as vec3)
  125153. * @param uniform defines the webGL uniform location where to store the value
  125154. * @param array defines the array of number to store
  125155. * @returns true if the value was set
  125156. */
  125157. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125158. /**
  125159. * Set the value of an uniform to an array of number (stored as vec4)
  125160. * @param uniform defines the webGL uniform location where to store the value
  125161. * @param array defines the array of number to store
  125162. * @returns true if the value was set
  125163. */
  125164. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125165. /**
  125166. * Set the value of an uniform to an array of float32 (stored as matrices)
  125167. * @param uniform defines the webGL uniform location where to store the value
  125168. * @param matrices defines the array of float32 to store
  125169. * @returns true if the value was set
  125170. */
  125171. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  125172. /**
  125173. * Set the value of an uniform to a matrix (3x3)
  125174. * @param uniform defines the webGL uniform location where to store the value
  125175. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  125176. * @returns true if the value was set
  125177. */
  125178. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125179. /**
  125180. * Set the value of an uniform to a matrix (2x2)
  125181. * @param uniform defines the webGL uniform location where to store the value
  125182. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  125183. * @returns true if the value was set
  125184. */
  125185. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125186. /**
  125187. * Set the value of an uniform to a number (float)
  125188. * @param uniform defines the webGL uniform location where to store the value
  125189. * @param value defines the float number to store
  125190. * @returns true if the value was transfered
  125191. */
  125192. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125193. /**
  125194. * Set the value of an uniform to a vec2
  125195. * @param uniform defines the webGL uniform location where to store the value
  125196. * @param x defines the 1st component of the value
  125197. * @param y defines the 2nd component of the value
  125198. * @returns true if the value was set
  125199. */
  125200. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125201. /**
  125202. * Set the value of an uniform to a vec3
  125203. * @param uniform defines the webGL uniform location where to store the value
  125204. * @param x defines the 1st component of the value
  125205. * @param y defines the 2nd component of the value
  125206. * @param z defines the 3rd component of the value
  125207. * @returns true if the value was set
  125208. */
  125209. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125210. /**
  125211. * Set the value of an uniform to a vec4
  125212. * @param uniform defines the webGL uniform location where to store the value
  125213. * @param x defines the 1st component of the value
  125214. * @param y defines the 2nd component of the value
  125215. * @param z defines the 3rd component of the value
  125216. * @param w defines the 4th component of the value
  125217. * @returns true if the value was set
  125218. */
  125219. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125220. /**
  125221. * Apply all cached states (depth, culling, stencil and alpha)
  125222. */
  125223. applyStates(): void;
  125224. /**
  125225. * Enable or disable color writing
  125226. * @param enable defines the state to set
  125227. */
  125228. setColorWrite(enable: boolean): void;
  125229. /**
  125230. * Gets a boolean indicating if color writing is enabled
  125231. * @returns the current color writing state
  125232. */
  125233. getColorWrite(): boolean;
  125234. /**
  125235. * Gets the depth culling state manager
  125236. */
  125237. get depthCullingState(): DepthCullingState;
  125238. /**
  125239. * Gets the alpha state manager
  125240. */
  125241. get alphaState(): AlphaState;
  125242. /**
  125243. * Gets the stencil state manager
  125244. */
  125245. get stencilState(): StencilState;
  125246. /**
  125247. * Clears the list of texture accessible through engine.
  125248. * This can help preventing texture load conflict due to name collision.
  125249. */
  125250. clearInternalTexturesCache(): void;
  125251. /**
  125252. * Force the entire cache to be cleared
  125253. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  125254. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  125255. */
  125256. wipeCaches(bruteForce?: boolean): void;
  125257. /** @hidden */
  125258. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  125259. min: number;
  125260. mag: number;
  125261. };
  125262. /** @hidden */
  125263. protected _createTexture(): WebGLTexture;
  125264. /** @hidden */
  125265. _createHardwareTexture(): HardwareTextureWrapper;
  125266. 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 | {
  125267. width: number;
  125268. height: number;
  125269. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125270. width: number;
  125271. height: number;
  125272. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125273. width: number;
  125274. height: number;
  125275. }, 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;
  125276. /**
  125277. * Usually called from Texture.ts.
  125278. * Passed information to create a WebGLTexture
  125279. * @param url defines a value which contains one of the following:
  125280. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  125281. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  125282. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  125283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  125284. * @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)
  125285. * @param scene needed for loading to the correct scene
  125286. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  125287. * @param onLoad optional callback to be called upon successful completion
  125288. * @param onError optional callback to be called upon failure
  125289. * @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
  125290. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  125291. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  125292. * @param forcedExtension defines the extension to use to pick the right loader
  125293. * @param mimeType defines an optional mime type
  125294. * @param loaderOptions options to be passed to the loader
  125295. * @returns a InternalTexture for assignment back into BABYLON.Texture
  125296. */
  125297. 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;
  125298. /**
  125299. * Loads an image as an HTMLImageElement.
  125300. * @param input url string, ArrayBuffer, or Blob to load
  125301. * @param onLoad callback called when the image successfully loads
  125302. * @param onError callback called when the image fails to load
  125303. * @param offlineProvider offline provider for caching
  125304. * @param mimeType optional mime type
  125305. * @returns the HTMLImageElement of the loaded image
  125306. * @hidden
  125307. */
  125308. 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>;
  125309. /**
  125310. * @hidden
  125311. */
  125312. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  125313. private _unpackFlipYCached;
  125314. /**
  125315. * In case you are sharing the context with other applications, it might
  125316. * be interested to not cache the unpack flip y state to ensure a consistent
  125317. * value would be set.
  125318. */
  125319. enableUnpackFlipYCached: boolean;
  125320. /** @hidden */
  125321. _unpackFlipY(value: boolean): void;
  125322. /** @hidden */
  125323. _getUnpackAlignement(): number;
  125324. private _getTextureTarget;
  125325. /**
  125326. * Update the sampling mode of a given texture
  125327. * @param samplingMode defines the required sampling mode
  125328. * @param texture defines the texture to update
  125329. * @param generateMipMaps defines whether to generate mipmaps for the texture
  125330. */
  125331. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  125332. /**
  125333. * Update the dimensions of a texture
  125334. * @param texture texture to update
  125335. * @param width new width of the texture
  125336. * @param height new height of the texture
  125337. * @param depth new depth of the texture
  125338. */
  125339. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  125340. /**
  125341. * Update the sampling mode of a given texture
  125342. * @param texture defines the texture to update
  125343. * @param wrapU defines the texture wrap mode of the u coordinates
  125344. * @param wrapV defines the texture wrap mode of the v coordinates
  125345. * @param wrapR defines the texture wrap mode of the r coordinates
  125346. */
  125347. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  125348. /** @hidden */
  125349. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  125350. width: number;
  125351. height: number;
  125352. layers?: number;
  125353. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  125354. /** @hidden */
  125355. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  125356. /** @hidden */
  125357. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  125358. /**
  125359. * Update a portion of an internal texture
  125360. * @param texture defines the texture to update
  125361. * @param imageData defines the data to store into the texture
  125362. * @param xOffset defines the x coordinates of the update rectangle
  125363. * @param yOffset defines the y coordinates of the update rectangle
  125364. * @param width defines the width of the update rectangle
  125365. * @param height defines the height of the update rectangle
  125366. * @param faceIndex defines the face index if texture is a cube (0 by default)
  125367. * @param lod defines the lod level to update (0 by default)
  125368. */
  125369. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  125370. /** @hidden */
  125371. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  125372. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  125373. private _prepareWebGLTexture;
  125374. /** @hidden */
  125375. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  125376. private _getDepthStencilBuffer;
  125377. /** @hidden */
  125378. _releaseFramebufferObjects(texture: InternalTexture): void;
  125379. /** @hidden */
  125380. _releaseTexture(texture: InternalTexture): void;
  125381. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  125382. protected _setProgram(program: WebGLProgram): void;
  125383. protected _boundUniforms: {
  125384. [key: number]: WebGLUniformLocation;
  125385. };
  125386. /**
  125387. * Binds an effect to the webGL context
  125388. * @param effect defines the effect to bind
  125389. */
  125390. bindSamplers(effect: Effect): void;
  125391. private _activateCurrentTexture;
  125392. /** @hidden */
  125393. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  125394. /** @hidden */
  125395. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  125396. /**
  125397. * Unbind all textures from the webGL context
  125398. */
  125399. unbindAllTextures(): void;
  125400. /**
  125401. * Sets a texture to the according uniform.
  125402. * @param channel The texture channel
  125403. * @param uniform The uniform to set
  125404. * @param texture The texture to apply
  125405. * @param name The name of the uniform in the effect
  125406. */
  125407. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  125408. private _bindSamplerUniformToChannel;
  125409. private _getTextureWrapMode;
  125410. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  125411. /**
  125412. * Sets an array of texture to the webGL context
  125413. * @param channel defines the channel where the texture array must be set
  125414. * @param uniform defines the associated uniform location
  125415. * @param textures defines the array of textures to bind
  125416. * @param name name of the channel
  125417. */
  125418. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  125419. /** @hidden */
  125420. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  125421. private _setTextureParameterFloat;
  125422. private _setTextureParameterInteger;
  125423. /**
  125424. * Unbind all vertex attributes from the webGL context
  125425. */
  125426. unbindAllAttributes(): void;
  125427. /**
  125428. * 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
  125429. */
  125430. releaseEffects(): void;
  125431. /**
  125432. * Dispose and release all associated resources
  125433. */
  125434. dispose(): void;
  125435. /**
  125436. * Attach a new callback raised when context lost event is fired
  125437. * @param callback defines the callback to call
  125438. */
  125439. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  125440. /**
  125441. * Attach a new callback raised when context restored event is fired
  125442. * @param callback defines the callback to call
  125443. */
  125444. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  125445. /**
  125446. * Get the current error code of the webGL context
  125447. * @returns the error code
  125448. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  125449. */
  125450. getError(): number;
  125451. private _canRenderToFloatFramebuffer;
  125452. private _canRenderToHalfFloatFramebuffer;
  125453. private _canRenderToFramebuffer;
  125454. /** @hidden */
  125455. _getWebGLTextureType(type: number): number;
  125456. /** @hidden */
  125457. _getInternalFormat(format: number): number;
  125458. /** @hidden */
  125459. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  125460. /** @hidden */
  125461. _getRGBAMultiSampleBufferFormat(type: number): number;
  125462. /** @hidden */
  125463. _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;
  125464. /**
  125465. * Loads a file from a url
  125466. * @param url url to load
  125467. * @param onSuccess callback called when the file successfully loads
  125468. * @param onProgress callback called while file is loading (if the server supports this mode)
  125469. * @param offlineProvider defines the offline provider for caching
  125470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  125471. * @param onError callback called when the file fails to load
  125472. * @returns a file request object
  125473. * @hidden
  125474. */
  125475. 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;
  125476. /**
  125477. * Reads pixels from the current frame buffer. Please note that this function can be slow
  125478. * @param x defines the x coordinate of the rectangle where pixels must be read
  125479. * @param y defines the y coordinate of the rectangle where pixels must be read
  125480. * @param width defines the width of the rectangle where pixels must be read
  125481. * @param height defines the height of the rectangle where pixels must be read
  125482. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  125483. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  125484. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  125485. */
  125486. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  125487. private static _IsSupported;
  125488. private static _HasMajorPerformanceCaveat;
  125489. /**
  125490. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  125491. */
  125492. static get IsSupported(): boolean;
  125493. /**
  125494. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  125495. * @returns true if the engine can be created
  125496. * @ignorenaming
  125497. */
  125498. static isSupported(): boolean;
  125499. /**
  125500. * 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)
  125501. */
  125502. static get HasMajorPerformanceCaveat(): boolean;
  125503. /**
  125504. * Find the next highest power of two.
  125505. * @param x Number to start search from.
  125506. * @return Next highest power of two.
  125507. */
  125508. static CeilingPOT(x: number): number;
  125509. /**
  125510. * Find the next lowest power of two.
  125511. * @param x Number to start search from.
  125512. * @return Next lowest power of two.
  125513. */
  125514. static FloorPOT(x: number): number;
  125515. /**
  125516. * Find the nearest power of two.
  125517. * @param x Number to start search from.
  125518. * @return Next nearest power of two.
  125519. */
  125520. static NearestPOT(x: number): number;
  125521. /**
  125522. * Get the closest exponent of two
  125523. * @param value defines the value to approximate
  125524. * @param max defines the maximum value to return
  125525. * @param mode defines how to define the closest value
  125526. * @returns closest exponent of two of the given value
  125527. */
  125528. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  125529. /**
  125530. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  125531. * @param func - the function to be called
  125532. * @param requester - the object that will request the next frame. Falls back to window.
  125533. * @returns frame number
  125534. */
  125535. static QueueNewFrame(func: () => void, requester?: any): number;
  125536. /**
  125537. * Gets host document
  125538. * @returns the host document object
  125539. */
  125540. getHostDocument(): Nullable<Document>;
  125541. }
  125542. }
  125543. declare module BABYLON {
  125544. /**
  125545. * Defines the source of the internal texture
  125546. */
  125547. export enum InternalTextureSource {
  125548. /**
  125549. * The source of the texture data is unknown
  125550. */
  125551. Unknown = 0,
  125552. /**
  125553. * Texture data comes from an URL
  125554. */
  125555. Url = 1,
  125556. /**
  125557. * Texture data is only used for temporary storage
  125558. */
  125559. Temp = 2,
  125560. /**
  125561. * Texture data comes from raw data (ArrayBuffer)
  125562. */
  125563. Raw = 3,
  125564. /**
  125565. * Texture content is dynamic (video or dynamic texture)
  125566. */
  125567. Dynamic = 4,
  125568. /**
  125569. * Texture content is generated by rendering to it
  125570. */
  125571. RenderTarget = 5,
  125572. /**
  125573. * Texture content is part of a multi render target process
  125574. */
  125575. MultiRenderTarget = 6,
  125576. /**
  125577. * Texture data comes from a cube data file
  125578. */
  125579. Cube = 7,
  125580. /**
  125581. * Texture data comes from a raw cube data
  125582. */
  125583. CubeRaw = 8,
  125584. /**
  125585. * Texture data come from a prefiltered cube data file
  125586. */
  125587. CubePrefiltered = 9,
  125588. /**
  125589. * Texture content is raw 3D data
  125590. */
  125591. Raw3D = 10,
  125592. /**
  125593. * Texture content is raw 2D array data
  125594. */
  125595. Raw2DArray = 11,
  125596. /**
  125597. * Texture content is a depth texture
  125598. */
  125599. Depth = 12,
  125600. /**
  125601. * Texture data comes from a raw cube data encoded with RGBD
  125602. */
  125603. CubeRawRGBD = 13
  125604. }
  125605. /**
  125606. * Class used to store data associated with WebGL texture data for the engine
  125607. * This class should not be used directly
  125608. */
  125609. export class InternalTexture {
  125610. /** @hidden */
  125611. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  125612. /**
  125613. * Defines if the texture is ready
  125614. */
  125615. isReady: boolean;
  125616. /**
  125617. * Defines if the texture is a cube texture
  125618. */
  125619. isCube: boolean;
  125620. /**
  125621. * Defines if the texture contains 3D data
  125622. */
  125623. is3D: boolean;
  125624. /**
  125625. * Defines if the texture contains 2D array data
  125626. */
  125627. is2DArray: boolean;
  125628. /**
  125629. * Defines if the texture contains multiview data
  125630. */
  125631. isMultiview: boolean;
  125632. /**
  125633. * Gets the URL used to load this texture
  125634. */
  125635. url: string;
  125636. /** @hidden */
  125637. _originalUrl: string;
  125638. /**
  125639. * Gets the sampling mode of the texture
  125640. */
  125641. samplingMode: number;
  125642. /**
  125643. * Gets a boolean indicating if the texture needs mipmaps generation
  125644. */
  125645. generateMipMaps: boolean;
  125646. /**
  125647. * Gets the number of samples used by the texture (WebGL2+ only)
  125648. */
  125649. samples: number;
  125650. /**
  125651. * Gets the type of the texture (int, float...)
  125652. */
  125653. type: number;
  125654. /**
  125655. * Gets the format of the texture (RGB, RGBA...)
  125656. */
  125657. format: number;
  125658. /**
  125659. * Observable called when the texture is loaded
  125660. */
  125661. onLoadedObservable: Observable<InternalTexture>;
  125662. /**
  125663. * Gets the width of the texture
  125664. */
  125665. width: number;
  125666. /**
  125667. * Gets the height of the texture
  125668. */
  125669. height: number;
  125670. /**
  125671. * Gets the depth of the texture
  125672. */
  125673. depth: number;
  125674. /**
  125675. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  125676. */
  125677. baseWidth: number;
  125678. /**
  125679. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  125680. */
  125681. baseHeight: number;
  125682. /**
  125683. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  125684. */
  125685. baseDepth: number;
  125686. /**
  125687. * Gets a boolean indicating if the texture is inverted on Y axis
  125688. */
  125689. invertY: boolean;
  125690. /** @hidden */
  125691. _invertVScale: boolean;
  125692. /** @hidden */
  125693. _associatedChannel: number;
  125694. /** @hidden */
  125695. _source: InternalTextureSource;
  125696. /** @hidden */
  125697. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  125698. /** @hidden */
  125699. _bufferView: Nullable<ArrayBufferView>;
  125700. /** @hidden */
  125701. _bufferViewArray: Nullable<ArrayBufferView[]>;
  125702. /** @hidden */
  125703. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  125704. /** @hidden */
  125705. _size: number;
  125706. /** @hidden */
  125707. _extension: string;
  125708. /** @hidden */
  125709. _files: Nullable<string[]>;
  125710. /** @hidden */
  125711. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  125712. /** @hidden */
  125713. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  125714. /** @hidden */
  125715. _framebuffer: Nullable<WebGLFramebuffer>;
  125716. /** @hidden */
  125717. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  125718. /** @hidden */
  125719. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  125720. /** @hidden */
  125721. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  125722. /** @hidden */
  125723. _attachments: Nullable<number[]>;
  125724. /** @hidden */
  125725. _textureArray: Nullable<InternalTexture[]>;
  125726. /** @hidden */
  125727. _cachedCoordinatesMode: Nullable<number>;
  125728. /** @hidden */
  125729. _cachedWrapU: Nullable<number>;
  125730. /** @hidden */
  125731. _cachedWrapV: Nullable<number>;
  125732. /** @hidden */
  125733. _cachedWrapR: Nullable<number>;
  125734. /** @hidden */
  125735. _cachedAnisotropicFilteringLevel: Nullable<number>;
  125736. /** @hidden */
  125737. _isDisabled: boolean;
  125738. /** @hidden */
  125739. _compression: Nullable<string>;
  125740. /** @hidden */
  125741. _generateStencilBuffer: boolean;
  125742. /** @hidden */
  125743. _generateDepthBuffer: boolean;
  125744. /** @hidden */
  125745. _comparisonFunction: number;
  125746. /** @hidden */
  125747. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  125748. /** @hidden */
  125749. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  125750. /** @hidden */
  125751. _sphericalPolynomialComputed: boolean;
  125752. /** @hidden */
  125753. _lodGenerationScale: number;
  125754. /** @hidden */
  125755. _lodGenerationOffset: number;
  125756. /** @hidden */
  125757. _depthStencilTexture: Nullable<InternalTexture>;
  125758. /** @hidden */
  125759. _colorTextureArray: Nullable<WebGLTexture>;
  125760. /** @hidden */
  125761. _depthStencilTextureArray: Nullable<WebGLTexture>;
  125762. /** @hidden */
  125763. _lodTextureHigh: Nullable<BaseTexture>;
  125764. /** @hidden */
  125765. _lodTextureMid: Nullable<BaseTexture>;
  125766. /** @hidden */
  125767. _lodTextureLow: Nullable<BaseTexture>;
  125768. /** @hidden */
  125769. _isRGBD: boolean;
  125770. /** @hidden */
  125771. _linearSpecularLOD: boolean;
  125772. /** @hidden */
  125773. _irradianceTexture: Nullable<BaseTexture>;
  125774. /** @hidden */
  125775. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  125776. /** @hidden */
  125777. _references: number;
  125778. /** @hidden */
  125779. _gammaSpace: Nullable<boolean>;
  125780. /** @hidden */
  125781. _hasAlpha: Nullable<boolean>;
  125782. private _engine;
  125783. private _uniqueId;
  125784. private static _Counter;
  125785. /** Gets the unique id of the internal texture */
  125786. get uniqueId(): number;
  125787. /**
  125788. * Gets the Engine the texture belongs to.
  125789. * @returns The babylon engine
  125790. */
  125791. getEngine(): ThinEngine;
  125792. /**
  125793. * Gets the data source type of the texture
  125794. */
  125795. get source(): InternalTextureSource;
  125796. /**
  125797. * Creates a new InternalTexture
  125798. * @param engine defines the engine to use
  125799. * @param source defines the type of data that will be used
  125800. * @param delayAllocation if the texture allocation should be delayed (default: false)
  125801. */
  125802. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  125803. /**
  125804. * Increments the number of references (ie. the number of Texture that point to it)
  125805. */
  125806. incrementReferences(): void;
  125807. /**
  125808. * Change the size of the texture (not the size of the content)
  125809. * @param width defines the new width
  125810. * @param height defines the new height
  125811. * @param depth defines the new depth (1 by default)
  125812. */
  125813. updateSize(width: int, height: int, depth?: int): void;
  125814. /** @hidden */
  125815. _rebuild(): void;
  125816. /** @hidden */
  125817. _swapAndDie(target: InternalTexture): void;
  125818. /**
  125819. * Dispose the current allocated resources
  125820. */
  125821. dispose(): void;
  125822. }
  125823. }
  125824. declare module BABYLON {
  125825. /**
  125826. * Interface used to present a loading screen while loading a scene
  125827. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125828. */
  125829. export interface ILoadingScreen {
  125830. /**
  125831. * Function called to display the loading screen
  125832. */
  125833. displayLoadingUI: () => void;
  125834. /**
  125835. * Function called to hide the loading screen
  125836. */
  125837. hideLoadingUI: () => void;
  125838. /**
  125839. * Gets or sets the color to use for the background
  125840. */
  125841. loadingUIBackgroundColor: string;
  125842. /**
  125843. * Gets or sets the text to display while loading
  125844. */
  125845. loadingUIText: string;
  125846. }
  125847. /**
  125848. * Class used for the default loading screen
  125849. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125850. */
  125851. export class DefaultLoadingScreen implements ILoadingScreen {
  125852. private _renderingCanvas;
  125853. private _loadingText;
  125854. private _loadingDivBackgroundColor;
  125855. private _loadingDiv;
  125856. private _loadingTextDiv;
  125857. /** Gets or sets the logo url to use for the default loading screen */
  125858. static DefaultLogoUrl: string;
  125859. /** Gets or sets the spinner url to use for the default loading screen */
  125860. static DefaultSpinnerUrl: string;
  125861. /**
  125862. * Creates a new default loading screen
  125863. * @param _renderingCanvas defines the canvas used to render the scene
  125864. * @param _loadingText defines the default text to display
  125865. * @param _loadingDivBackgroundColor defines the default background color
  125866. */
  125867. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  125868. /**
  125869. * Function called to display the loading screen
  125870. */
  125871. displayLoadingUI(): void;
  125872. /**
  125873. * Function called to hide the loading screen
  125874. */
  125875. hideLoadingUI(): void;
  125876. /**
  125877. * Gets or sets the text to display while loading
  125878. */
  125879. set loadingUIText(text: string);
  125880. get loadingUIText(): string;
  125881. /**
  125882. * Gets or sets the color to use for the background
  125883. */
  125884. get loadingUIBackgroundColor(): string;
  125885. set loadingUIBackgroundColor(color: string);
  125886. private _resizeLoadingUI;
  125887. }
  125888. }
  125889. declare module BABYLON {
  125890. /**
  125891. * Interface for any object that can request an animation frame
  125892. */
  125893. export interface ICustomAnimationFrameRequester {
  125894. /**
  125895. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  125896. */
  125897. renderFunction?: Function;
  125898. /**
  125899. * Called to request the next frame to render to
  125900. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  125901. */
  125902. requestAnimationFrame: Function;
  125903. /**
  125904. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  125905. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  125906. */
  125907. requestID?: number;
  125908. }
  125909. }
  125910. declare module BABYLON {
  125911. /**
  125912. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  125913. */
  125914. export class PerformanceMonitor {
  125915. private _enabled;
  125916. private _rollingFrameTime;
  125917. private _lastFrameTimeMs;
  125918. /**
  125919. * constructor
  125920. * @param frameSampleSize The number of samples required to saturate the sliding window
  125921. */
  125922. constructor(frameSampleSize?: number);
  125923. /**
  125924. * Samples current frame
  125925. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  125926. */
  125927. sampleFrame(timeMs?: number): void;
  125928. /**
  125929. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  125930. */
  125931. get averageFrameTime(): number;
  125932. /**
  125933. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  125934. */
  125935. get averageFrameTimeVariance(): number;
  125936. /**
  125937. * Returns the frame time of the most recent frame
  125938. */
  125939. get instantaneousFrameTime(): number;
  125940. /**
  125941. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  125942. */
  125943. get averageFPS(): number;
  125944. /**
  125945. * Returns the average framerate in frames per second using the most recent frame time
  125946. */
  125947. get instantaneousFPS(): number;
  125948. /**
  125949. * Returns true if enough samples have been taken to completely fill the sliding window
  125950. */
  125951. get isSaturated(): boolean;
  125952. /**
  125953. * Enables contributions to the sliding window sample set
  125954. */
  125955. enable(): void;
  125956. /**
  125957. * Disables contributions to the sliding window sample set
  125958. * Samples will not be interpolated over the disabled period
  125959. */
  125960. disable(): void;
  125961. /**
  125962. * Returns true if sampling is enabled
  125963. */
  125964. get isEnabled(): boolean;
  125965. /**
  125966. * Resets performance monitor
  125967. */
  125968. reset(): void;
  125969. }
  125970. /**
  125971. * RollingAverage
  125972. *
  125973. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  125974. */
  125975. export class RollingAverage {
  125976. /**
  125977. * Current average
  125978. */
  125979. average: number;
  125980. /**
  125981. * Current variance
  125982. */
  125983. variance: number;
  125984. protected _samples: Array<number>;
  125985. protected _sampleCount: number;
  125986. protected _pos: number;
  125987. protected _m2: number;
  125988. /**
  125989. * constructor
  125990. * @param length The number of samples required to saturate the sliding window
  125991. */
  125992. constructor(length: number);
  125993. /**
  125994. * Adds a sample to the sample set
  125995. * @param v The sample value
  125996. */
  125997. add(v: number): void;
  125998. /**
  125999. * Returns previously added values or null if outside of history or outside the sliding window domain
  126000. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  126001. * @return Value previously recorded with add() or null if outside of range
  126002. */
  126003. history(i: number): number;
  126004. /**
  126005. * Returns true if enough samples have been taken to completely fill the sliding window
  126006. * @return true if sample-set saturated
  126007. */
  126008. isSaturated(): boolean;
  126009. /**
  126010. * Resets the rolling average (equivalent to 0 samples taken so far)
  126011. */
  126012. reset(): void;
  126013. /**
  126014. * Wraps a value around the sample range boundaries
  126015. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  126016. * @return Wrapped position in sample range
  126017. */
  126018. protected _wrapPosition(i: number): number;
  126019. }
  126020. }
  126021. declare module BABYLON {
  126022. /**
  126023. * This class is used to track a performance counter which is number based.
  126024. * The user has access to many properties which give statistics of different nature.
  126025. *
  126026. * The implementer can track two kinds of Performance Counter: time and count.
  126027. * 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.
  126028. * 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.
  126029. */
  126030. export class PerfCounter {
  126031. /**
  126032. * Gets or sets a global boolean to turn on and off all the counters
  126033. */
  126034. static Enabled: boolean;
  126035. /**
  126036. * Returns the smallest value ever
  126037. */
  126038. get min(): number;
  126039. /**
  126040. * Returns the biggest value ever
  126041. */
  126042. get max(): number;
  126043. /**
  126044. * Returns the average value since the performance counter is running
  126045. */
  126046. get average(): number;
  126047. /**
  126048. * Returns the average value of the last second the counter was monitored
  126049. */
  126050. get lastSecAverage(): number;
  126051. /**
  126052. * Returns the current value
  126053. */
  126054. get current(): number;
  126055. /**
  126056. * Gets the accumulated total
  126057. */
  126058. get total(): number;
  126059. /**
  126060. * Gets the total value count
  126061. */
  126062. get count(): number;
  126063. /**
  126064. * Creates a new counter
  126065. */
  126066. constructor();
  126067. /**
  126068. * Call this method to start monitoring a new frame.
  126069. * 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.
  126070. */
  126071. fetchNewFrame(): void;
  126072. /**
  126073. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  126074. * @param newCount the count value to add to the monitored count
  126075. * @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.
  126076. */
  126077. addCount(newCount: number, fetchResult: boolean): void;
  126078. /**
  126079. * Start monitoring this performance counter
  126080. */
  126081. beginMonitoring(): void;
  126082. /**
  126083. * Compute the time lapsed since the previous beginMonitoring() call.
  126084. * @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
  126085. */
  126086. endMonitoring(newFrame?: boolean): void;
  126087. private _fetchResult;
  126088. private _startMonitoringTime;
  126089. private _min;
  126090. private _max;
  126091. private _average;
  126092. private _current;
  126093. private _totalValueCount;
  126094. private _totalAccumulated;
  126095. private _lastSecAverage;
  126096. private _lastSecAccumulated;
  126097. private _lastSecTime;
  126098. private _lastSecValueCount;
  126099. }
  126100. }
  126101. declare module BABYLON {
  126102. interface ThinEngine {
  126103. /** @hidden */
  126104. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  126105. }
  126106. }
  126107. declare module BABYLON {
  126108. /**
  126109. * Class used to work with sound analyzer using fast fourier transform (FFT)
  126110. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126111. */
  126112. export class Analyser {
  126113. /**
  126114. * Gets or sets the smoothing
  126115. * @ignorenaming
  126116. */
  126117. SMOOTHING: number;
  126118. /**
  126119. * Gets or sets the FFT table size
  126120. * @ignorenaming
  126121. */
  126122. FFT_SIZE: number;
  126123. /**
  126124. * Gets or sets the bar graph amplitude
  126125. * @ignorenaming
  126126. */
  126127. BARGRAPHAMPLITUDE: number;
  126128. /**
  126129. * Gets or sets the position of the debug canvas
  126130. * @ignorenaming
  126131. */
  126132. DEBUGCANVASPOS: {
  126133. x: number;
  126134. y: number;
  126135. };
  126136. /**
  126137. * Gets or sets the debug canvas size
  126138. * @ignorenaming
  126139. */
  126140. DEBUGCANVASSIZE: {
  126141. width: number;
  126142. height: number;
  126143. };
  126144. private _byteFreqs;
  126145. private _byteTime;
  126146. private _floatFreqs;
  126147. private _webAudioAnalyser;
  126148. private _debugCanvas;
  126149. private _debugCanvasContext;
  126150. private _scene;
  126151. private _registerFunc;
  126152. private _audioEngine;
  126153. /**
  126154. * Creates a new analyser
  126155. * @param scene defines hosting scene
  126156. */
  126157. constructor(scene: Scene);
  126158. /**
  126159. * Get the number of data values you will have to play with for the visualization
  126160. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  126161. * @returns a number
  126162. */
  126163. getFrequencyBinCount(): number;
  126164. /**
  126165. * Gets the current frequency data as a byte array
  126166. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126167. * @returns a Uint8Array
  126168. */
  126169. getByteFrequencyData(): Uint8Array;
  126170. /**
  126171. * Gets the current waveform as a byte array
  126172. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  126173. * @returns a Uint8Array
  126174. */
  126175. getByteTimeDomainData(): Uint8Array;
  126176. /**
  126177. * Gets the current frequency data as a float array
  126178. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126179. * @returns a Float32Array
  126180. */
  126181. getFloatFrequencyData(): Float32Array;
  126182. /**
  126183. * Renders the debug canvas
  126184. */
  126185. drawDebugCanvas(): void;
  126186. /**
  126187. * Stops rendering the debug canvas and removes it
  126188. */
  126189. stopDebugCanvas(): void;
  126190. /**
  126191. * Connects two audio nodes
  126192. * @param inputAudioNode defines first node to connect
  126193. * @param outputAudioNode defines second node to connect
  126194. */
  126195. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  126196. /**
  126197. * Releases all associated resources
  126198. */
  126199. dispose(): void;
  126200. }
  126201. }
  126202. declare module BABYLON {
  126203. /**
  126204. * This represents an audio engine and it is responsible
  126205. * to play, synchronize and analyse sounds throughout the application.
  126206. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126207. */
  126208. export interface IAudioEngine extends IDisposable {
  126209. /**
  126210. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126211. */
  126212. readonly canUseWebAudio: boolean;
  126213. /**
  126214. * Gets the current AudioContext if available.
  126215. */
  126216. readonly audioContext: Nullable<AudioContext>;
  126217. /**
  126218. * The master gain node defines the global audio volume of your audio engine.
  126219. */
  126220. readonly masterGain: GainNode;
  126221. /**
  126222. * Gets whether or not mp3 are supported by your browser.
  126223. */
  126224. readonly isMP3supported: boolean;
  126225. /**
  126226. * Gets whether or not ogg are supported by your browser.
  126227. */
  126228. readonly isOGGsupported: boolean;
  126229. /**
  126230. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126231. * @ignoreNaming
  126232. */
  126233. WarnedWebAudioUnsupported: boolean;
  126234. /**
  126235. * Defines if the audio engine relies on a custom unlocked button.
  126236. * In this case, the embedded button will not be displayed.
  126237. */
  126238. useCustomUnlockedButton: boolean;
  126239. /**
  126240. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  126241. */
  126242. readonly unlocked: boolean;
  126243. /**
  126244. * Event raised when audio has been unlocked on the browser.
  126245. */
  126246. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126247. /**
  126248. * Event raised when audio has been locked on the browser.
  126249. */
  126250. onAudioLockedObservable: Observable<IAudioEngine>;
  126251. /**
  126252. * Flags the audio engine in Locked state.
  126253. * This happens due to new browser policies preventing audio to autoplay.
  126254. */
  126255. lock(): void;
  126256. /**
  126257. * Unlocks the audio engine once a user action has been done on the dom.
  126258. * This is helpful to resume play once browser policies have been satisfied.
  126259. */
  126260. unlock(): void;
  126261. /**
  126262. * Gets the global volume sets on the master gain.
  126263. * @returns the global volume if set or -1 otherwise
  126264. */
  126265. getGlobalVolume(): number;
  126266. /**
  126267. * Sets the global volume of your experience (sets on the master gain).
  126268. * @param newVolume Defines the new global volume of the application
  126269. */
  126270. setGlobalVolume(newVolume: number): void;
  126271. /**
  126272. * Connect the audio engine to an audio analyser allowing some amazing
  126273. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126274. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126275. * @param analyser The analyser to connect to the engine
  126276. */
  126277. connectToAnalyser(analyser: Analyser): void;
  126278. }
  126279. }
  126280. declare module BABYLON {
  126281. /**
  126282. * Defines the interface used by display changed events
  126283. */
  126284. export interface IDisplayChangedEventArgs {
  126285. /** Gets the vrDisplay object (if any) */
  126286. vrDisplay: Nullable<any>;
  126287. /** Gets a boolean indicating if webVR is supported */
  126288. vrSupported: boolean;
  126289. }
  126290. /**
  126291. * Defines the interface used by objects containing a viewport (like a camera)
  126292. */
  126293. interface IViewportOwnerLike {
  126294. /**
  126295. * Gets or sets the viewport
  126296. */
  126297. viewport: IViewportLike;
  126298. }
  126299. /**
  126300. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  126301. */
  126302. export class Engine extends ThinEngine {
  126303. /** Defines that alpha blending is disabled */
  126304. static readonly ALPHA_DISABLE: number;
  126305. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  126306. static readonly ALPHA_ADD: number;
  126307. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  126308. static readonly ALPHA_COMBINE: number;
  126309. /** Defines that alpha blending to DEST - SRC * DEST */
  126310. static readonly ALPHA_SUBTRACT: number;
  126311. /** Defines that alpha blending to SRC * DEST */
  126312. static readonly ALPHA_MULTIPLY: number;
  126313. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  126314. static readonly ALPHA_MAXIMIZED: number;
  126315. /** Defines that alpha blending to SRC + DEST */
  126316. static readonly ALPHA_ONEONE: number;
  126317. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  126318. static readonly ALPHA_PREMULTIPLIED: number;
  126319. /**
  126320. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  126321. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  126322. */
  126323. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  126324. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  126325. static readonly ALPHA_INTERPOLATE: number;
  126326. /**
  126327. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  126328. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  126329. */
  126330. static readonly ALPHA_SCREENMODE: number;
  126331. /** Defines that the ressource is not delayed*/
  126332. static readonly DELAYLOADSTATE_NONE: number;
  126333. /** Defines that the ressource was successfully delay loaded */
  126334. static readonly DELAYLOADSTATE_LOADED: number;
  126335. /** Defines that the ressource is currently delay loading */
  126336. static readonly DELAYLOADSTATE_LOADING: number;
  126337. /** Defines that the ressource is delayed and has not started loading */
  126338. static readonly DELAYLOADSTATE_NOTLOADED: number;
  126339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  126340. static readonly NEVER: number;
  126341. /** 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 */
  126342. static readonly ALWAYS: number;
  126343. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  126344. static readonly LESS: number;
  126345. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  126346. static readonly EQUAL: number;
  126347. /** 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 */
  126348. static readonly LEQUAL: number;
  126349. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  126350. static readonly GREATER: number;
  126351. /** 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 */
  126352. static readonly GEQUAL: number;
  126353. /** 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 */
  126354. static readonly NOTEQUAL: number;
  126355. /** Passed to stencilOperation to specify that stencil value must be kept */
  126356. static readonly KEEP: number;
  126357. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126358. static readonly REPLACE: number;
  126359. /** Passed to stencilOperation to specify that stencil value must be incremented */
  126360. static readonly INCR: number;
  126361. /** Passed to stencilOperation to specify that stencil value must be decremented */
  126362. static readonly DECR: number;
  126363. /** Passed to stencilOperation to specify that stencil value must be inverted */
  126364. static readonly INVERT: number;
  126365. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  126366. static readonly INCR_WRAP: number;
  126367. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  126368. static readonly DECR_WRAP: number;
  126369. /** Texture is not repeating outside of 0..1 UVs */
  126370. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  126371. /** Texture is repeating outside of 0..1 UVs */
  126372. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  126373. /** Texture is repeating and mirrored */
  126374. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  126375. /** ALPHA */
  126376. static readonly TEXTUREFORMAT_ALPHA: number;
  126377. /** LUMINANCE */
  126378. static readonly TEXTUREFORMAT_LUMINANCE: number;
  126379. /** LUMINANCE_ALPHA */
  126380. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  126381. /** RGB */
  126382. static readonly TEXTUREFORMAT_RGB: number;
  126383. /** RGBA */
  126384. static readonly TEXTUREFORMAT_RGBA: number;
  126385. /** RED */
  126386. static readonly TEXTUREFORMAT_RED: number;
  126387. /** RED (2nd reference) */
  126388. static readonly TEXTUREFORMAT_R: number;
  126389. /** RG */
  126390. static readonly TEXTUREFORMAT_RG: number;
  126391. /** RED_INTEGER */
  126392. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  126393. /** RED_INTEGER (2nd reference) */
  126394. static readonly TEXTUREFORMAT_R_INTEGER: number;
  126395. /** RG_INTEGER */
  126396. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  126397. /** RGB_INTEGER */
  126398. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  126399. /** RGBA_INTEGER */
  126400. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  126401. /** UNSIGNED_BYTE */
  126402. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  126403. /** UNSIGNED_BYTE (2nd reference) */
  126404. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  126405. /** FLOAT */
  126406. static readonly TEXTURETYPE_FLOAT: number;
  126407. /** HALF_FLOAT */
  126408. static readonly TEXTURETYPE_HALF_FLOAT: number;
  126409. /** BYTE */
  126410. static readonly TEXTURETYPE_BYTE: number;
  126411. /** SHORT */
  126412. static readonly TEXTURETYPE_SHORT: number;
  126413. /** UNSIGNED_SHORT */
  126414. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  126415. /** INT */
  126416. static readonly TEXTURETYPE_INT: number;
  126417. /** UNSIGNED_INT */
  126418. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  126419. /** UNSIGNED_SHORT_4_4_4_4 */
  126420. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  126421. /** UNSIGNED_SHORT_5_5_5_1 */
  126422. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  126423. /** UNSIGNED_SHORT_5_6_5 */
  126424. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  126425. /** UNSIGNED_INT_2_10_10_10_REV */
  126426. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  126427. /** UNSIGNED_INT_24_8 */
  126428. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  126429. /** UNSIGNED_INT_10F_11F_11F_REV */
  126430. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  126431. /** UNSIGNED_INT_5_9_9_9_REV */
  126432. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  126433. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  126434. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126435. /** nearest is mag = nearest and min = nearest and mip = none */
  126436. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  126437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  126438. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  126439. /** Trilinear is mag = linear and min = linear and mip = linear */
  126440. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  126441. /** nearest is mag = nearest and min = nearest and mip = linear */
  126442. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  126443. /** Bilinear is mag = linear and min = linear and mip = nearest */
  126444. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  126445. /** Trilinear is mag = linear and min = linear and mip = linear */
  126446. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  126447. /** mag = nearest and min = nearest and mip = nearest */
  126448. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  126449. /** mag = nearest and min = linear and mip = nearest */
  126450. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  126451. /** mag = nearest and min = linear and mip = linear */
  126452. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  126453. /** mag = nearest and min = linear and mip = none */
  126454. static readonly TEXTURE_NEAREST_LINEAR: number;
  126455. /** mag = nearest and min = nearest and mip = none */
  126456. static readonly TEXTURE_NEAREST_NEAREST: number;
  126457. /** mag = linear and min = nearest and mip = nearest */
  126458. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  126459. /** mag = linear and min = nearest and mip = linear */
  126460. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  126461. /** mag = linear and min = linear and mip = none */
  126462. static readonly TEXTURE_LINEAR_LINEAR: number;
  126463. /** mag = linear and min = nearest and mip = none */
  126464. static readonly TEXTURE_LINEAR_NEAREST: number;
  126465. /** Explicit coordinates mode */
  126466. static readonly TEXTURE_EXPLICIT_MODE: number;
  126467. /** Spherical coordinates mode */
  126468. static readonly TEXTURE_SPHERICAL_MODE: number;
  126469. /** Planar coordinates mode */
  126470. static readonly TEXTURE_PLANAR_MODE: number;
  126471. /** Cubic coordinates mode */
  126472. static readonly TEXTURE_CUBIC_MODE: number;
  126473. /** Projection coordinates mode */
  126474. static readonly TEXTURE_PROJECTION_MODE: number;
  126475. /** Skybox coordinates mode */
  126476. static readonly TEXTURE_SKYBOX_MODE: number;
  126477. /** Inverse Cubic coordinates mode */
  126478. static readonly TEXTURE_INVCUBIC_MODE: number;
  126479. /** Equirectangular coordinates mode */
  126480. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  126481. /** Equirectangular Fixed coordinates mode */
  126482. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  126483. /** Equirectangular Fixed Mirrored coordinates mode */
  126484. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  126485. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  126486. static readonly SCALEMODE_FLOOR: number;
  126487. /** Defines that texture rescaling will look for the nearest power of 2 size */
  126488. static readonly SCALEMODE_NEAREST: number;
  126489. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  126490. static readonly SCALEMODE_CEILING: number;
  126491. /**
  126492. * Returns the current npm package of the sdk
  126493. */
  126494. static get NpmPackage(): string;
  126495. /**
  126496. * Returns the current version of the framework
  126497. */
  126498. static get Version(): string;
  126499. /** Gets the list of created engines */
  126500. static get Instances(): Engine[];
  126501. /**
  126502. * Gets the latest created engine
  126503. */
  126504. static get LastCreatedEngine(): Nullable<Engine>;
  126505. /**
  126506. * Gets the latest created scene
  126507. */
  126508. static get LastCreatedScene(): Nullable<Scene>;
  126509. /**
  126510. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  126511. * @param flag defines which part of the materials must be marked as dirty
  126512. * @param predicate defines a predicate used to filter which materials should be affected
  126513. */
  126514. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126515. /**
  126516. * Method called to create the default loading screen.
  126517. * This can be overriden in your own app.
  126518. * @param canvas The rendering canvas element
  126519. * @returns The loading screen
  126520. */
  126521. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  126522. /**
  126523. * Method called to create the default rescale post process on each engine.
  126524. */
  126525. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  126526. /**
  126527. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  126528. **/
  126529. enableOfflineSupport: boolean;
  126530. /**
  126531. * 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)
  126532. **/
  126533. disableManifestCheck: boolean;
  126534. /**
  126535. * Gets the list of created scenes
  126536. */
  126537. scenes: Scene[];
  126538. /**
  126539. * Event raised when a new scene is created
  126540. */
  126541. onNewSceneAddedObservable: Observable<Scene>;
  126542. /**
  126543. * Gets the list of created postprocesses
  126544. */
  126545. postProcesses: PostProcess[];
  126546. /**
  126547. * Gets a boolean indicating if the pointer is currently locked
  126548. */
  126549. isPointerLock: boolean;
  126550. /**
  126551. * Observable event triggered each time the rendering canvas is resized
  126552. */
  126553. onResizeObservable: Observable<Engine>;
  126554. /**
  126555. * Observable event triggered each time the canvas loses focus
  126556. */
  126557. onCanvasBlurObservable: Observable<Engine>;
  126558. /**
  126559. * Observable event triggered each time the canvas gains focus
  126560. */
  126561. onCanvasFocusObservable: Observable<Engine>;
  126562. /**
  126563. * Observable event triggered each time the canvas receives pointerout event
  126564. */
  126565. onCanvasPointerOutObservable: Observable<PointerEvent>;
  126566. /**
  126567. * Observable raised when the engine begins a new frame
  126568. */
  126569. onBeginFrameObservable: Observable<Engine>;
  126570. /**
  126571. * If set, will be used to request the next animation frame for the render loop
  126572. */
  126573. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  126574. /**
  126575. * Observable raised when the engine ends the current frame
  126576. */
  126577. onEndFrameObservable: Observable<Engine>;
  126578. /**
  126579. * Observable raised when the engine is about to compile a shader
  126580. */
  126581. onBeforeShaderCompilationObservable: Observable<Engine>;
  126582. /**
  126583. * Observable raised when the engine has jsut compiled a shader
  126584. */
  126585. onAfterShaderCompilationObservable: Observable<Engine>;
  126586. /**
  126587. * Gets the audio engine
  126588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126589. * @ignorenaming
  126590. */
  126591. static audioEngine: IAudioEngine;
  126592. /**
  126593. * Default AudioEngine factory responsible of creating the Audio Engine.
  126594. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  126595. */
  126596. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  126597. /**
  126598. * Default offline support factory responsible of creating a tool used to store data locally.
  126599. * By default, this will create a Database object if the workload has been embedded.
  126600. */
  126601. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  126602. private _loadingScreen;
  126603. private _pointerLockRequested;
  126604. private _rescalePostProcess;
  126605. protected _deterministicLockstep: boolean;
  126606. protected _lockstepMaxSteps: number;
  126607. protected _timeStep: number;
  126608. protected get _supportsHardwareTextureRescaling(): boolean;
  126609. private _fps;
  126610. private _deltaTime;
  126611. /** @hidden */
  126612. _drawCalls: PerfCounter;
  126613. /** 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 */
  126614. canvasTabIndex: number;
  126615. /**
  126616. * Turn this value on if you want to pause FPS computation when in background
  126617. */
  126618. disablePerformanceMonitorInBackground: boolean;
  126619. private _performanceMonitor;
  126620. /**
  126621. * Gets the performance monitor attached to this engine
  126622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126623. */
  126624. get performanceMonitor(): PerformanceMonitor;
  126625. private _onFocus;
  126626. private _onBlur;
  126627. private _onCanvasPointerOut;
  126628. private _onCanvasBlur;
  126629. private _onCanvasFocus;
  126630. private _onFullscreenChange;
  126631. private _onPointerLockChange;
  126632. /**
  126633. * Gets the HTML element used to attach event listeners
  126634. * @returns a HTML element
  126635. */
  126636. getInputElement(): Nullable<HTMLElement>;
  126637. /**
  126638. * Creates a new engine
  126639. * @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
  126640. * @param antialias defines enable antialiasing (default: false)
  126641. * @param options defines further options to be sent to the getContext() function
  126642. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  126643. */
  126644. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  126645. /**
  126646. * Shared initialization across engines types.
  126647. * @param canvas The canvas associated with this instance of the engine.
  126648. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  126649. * @param audioEngine Defines if an audio engine should be created by default
  126650. */
  126651. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  126652. /**
  126653. * Gets current aspect ratio
  126654. * @param viewportOwner defines the camera to use to get the aspect ratio
  126655. * @param useScreen defines if screen size must be used (or the current render target if any)
  126656. * @returns a number defining the aspect ratio
  126657. */
  126658. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  126659. /**
  126660. * Gets current screen aspect ratio
  126661. * @returns a number defining the aspect ratio
  126662. */
  126663. getScreenAspectRatio(): number;
  126664. /**
  126665. * Gets the client rect of the HTML canvas attached with the current webGL context
  126666. * @returns a client rectanglee
  126667. */
  126668. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  126669. /**
  126670. * Gets the client rect of the HTML element used for events
  126671. * @returns a client rectanglee
  126672. */
  126673. getInputElementClientRect(): Nullable<ClientRect>;
  126674. /**
  126675. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  126676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126677. * @returns true if engine is in deterministic lock step mode
  126678. */
  126679. isDeterministicLockStep(): boolean;
  126680. /**
  126681. * Gets the max steps when engine is running in deterministic lock step
  126682. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126683. * @returns the max steps
  126684. */
  126685. getLockstepMaxSteps(): number;
  126686. /**
  126687. * Returns the time in ms between steps when using deterministic lock step.
  126688. * @returns time step in (ms)
  126689. */
  126690. getTimeStep(): number;
  126691. /**
  126692. * Force the mipmap generation for the given render target texture
  126693. * @param texture defines the render target texture to use
  126694. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  126695. */
  126696. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  126697. /** States */
  126698. /**
  126699. * Set various states to the webGL context
  126700. * @param culling defines backface culling state
  126701. * @param zOffset defines the value to apply to zOffset (0 by default)
  126702. * @param force defines if states must be applied even if cache is up to date
  126703. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  126704. */
  126705. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  126706. /**
  126707. * Set the z offset to apply to current rendering
  126708. * @param value defines the offset to apply
  126709. */
  126710. setZOffset(value: number): void;
  126711. /**
  126712. * Gets the current value of the zOffset
  126713. * @returns the current zOffset state
  126714. */
  126715. getZOffset(): number;
  126716. /**
  126717. * Gets a boolean indicating if depth testing is enabled
  126718. * @returns the current state
  126719. */
  126720. getDepthBuffer(): boolean;
  126721. /**
  126722. * Enable or disable depth buffering
  126723. * @param enable defines the state to set
  126724. */
  126725. setDepthBuffer(enable: boolean): void;
  126726. /**
  126727. * Gets a boolean indicating if depth writing is enabled
  126728. * @returns the current depth writing state
  126729. */
  126730. getDepthWrite(): boolean;
  126731. /**
  126732. * Enable or disable depth writing
  126733. * @param enable defines the state to set
  126734. */
  126735. setDepthWrite(enable: boolean): void;
  126736. /**
  126737. * Gets a boolean indicating if stencil buffer is enabled
  126738. * @returns the current stencil buffer state
  126739. */
  126740. getStencilBuffer(): boolean;
  126741. /**
  126742. * Enable or disable the stencil buffer
  126743. * @param enable defines if the stencil buffer must be enabled or disabled
  126744. */
  126745. setStencilBuffer(enable: boolean): void;
  126746. /**
  126747. * Gets the current stencil mask
  126748. * @returns a number defining the new stencil mask to use
  126749. */
  126750. getStencilMask(): number;
  126751. /**
  126752. * Sets the current stencil mask
  126753. * @param mask defines the new stencil mask to use
  126754. */
  126755. setStencilMask(mask: number): void;
  126756. /**
  126757. * Gets the current stencil function
  126758. * @returns a number defining the stencil function to use
  126759. */
  126760. getStencilFunction(): number;
  126761. /**
  126762. * Gets the current stencil reference value
  126763. * @returns a number defining the stencil reference value to use
  126764. */
  126765. getStencilFunctionReference(): number;
  126766. /**
  126767. * Gets the current stencil mask
  126768. * @returns a number defining the stencil mask to use
  126769. */
  126770. getStencilFunctionMask(): number;
  126771. /**
  126772. * Sets the current stencil function
  126773. * @param stencilFunc defines the new stencil function to use
  126774. */
  126775. setStencilFunction(stencilFunc: number): void;
  126776. /**
  126777. * Sets the current stencil reference
  126778. * @param reference defines the new stencil reference to use
  126779. */
  126780. setStencilFunctionReference(reference: number): void;
  126781. /**
  126782. * Sets the current stencil mask
  126783. * @param mask defines the new stencil mask to use
  126784. */
  126785. setStencilFunctionMask(mask: number): void;
  126786. /**
  126787. * Gets the current stencil operation when stencil fails
  126788. * @returns a number defining stencil operation to use when stencil fails
  126789. */
  126790. getStencilOperationFail(): number;
  126791. /**
  126792. * Gets the current stencil operation when depth fails
  126793. * @returns a number defining stencil operation to use when depth fails
  126794. */
  126795. getStencilOperationDepthFail(): number;
  126796. /**
  126797. * Gets the current stencil operation when stencil passes
  126798. * @returns a number defining stencil operation to use when stencil passes
  126799. */
  126800. getStencilOperationPass(): number;
  126801. /**
  126802. * Sets the stencil operation to use when stencil fails
  126803. * @param operation defines the stencil operation to use when stencil fails
  126804. */
  126805. setStencilOperationFail(operation: number): void;
  126806. /**
  126807. * Sets the stencil operation to use when depth fails
  126808. * @param operation defines the stencil operation to use when depth fails
  126809. */
  126810. setStencilOperationDepthFail(operation: number): void;
  126811. /**
  126812. * Sets the stencil operation to use when stencil passes
  126813. * @param operation defines the stencil operation to use when stencil passes
  126814. */
  126815. setStencilOperationPass(operation: number): void;
  126816. /**
  126817. * Sets a boolean indicating if the dithering state is enabled or disabled
  126818. * @param value defines the dithering state
  126819. */
  126820. setDitheringState(value: boolean): void;
  126821. /**
  126822. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  126823. * @param value defines the rasterizer state
  126824. */
  126825. setRasterizerState(value: boolean): void;
  126826. /**
  126827. * Gets the current depth function
  126828. * @returns a number defining the depth function
  126829. */
  126830. getDepthFunction(): Nullable<number>;
  126831. /**
  126832. * Sets the current depth function
  126833. * @param depthFunc defines the function to use
  126834. */
  126835. setDepthFunction(depthFunc: number): void;
  126836. /**
  126837. * Sets the current depth function to GREATER
  126838. */
  126839. setDepthFunctionToGreater(): void;
  126840. /**
  126841. * Sets the current depth function to GEQUAL
  126842. */
  126843. setDepthFunctionToGreaterOrEqual(): void;
  126844. /**
  126845. * Sets the current depth function to LESS
  126846. */
  126847. setDepthFunctionToLess(): void;
  126848. /**
  126849. * Sets the current depth function to LEQUAL
  126850. */
  126851. setDepthFunctionToLessOrEqual(): void;
  126852. private _cachedStencilBuffer;
  126853. private _cachedStencilFunction;
  126854. private _cachedStencilMask;
  126855. private _cachedStencilOperationPass;
  126856. private _cachedStencilOperationFail;
  126857. private _cachedStencilOperationDepthFail;
  126858. private _cachedStencilReference;
  126859. /**
  126860. * Caches the the state of the stencil buffer
  126861. */
  126862. cacheStencilState(): void;
  126863. /**
  126864. * Restores the state of the stencil buffer
  126865. */
  126866. restoreStencilState(): void;
  126867. /**
  126868. * Directly set the WebGL Viewport
  126869. * @param x defines the x coordinate of the viewport (in screen space)
  126870. * @param y defines the y coordinate of the viewport (in screen space)
  126871. * @param width defines the width of the viewport (in screen space)
  126872. * @param height defines the height of the viewport (in screen space)
  126873. * @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
  126874. */
  126875. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  126876. /**
  126877. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  126878. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  126879. * @param y defines the y-coordinate of the corner of the clear rectangle
  126880. * @param width defines the width of the clear rectangle
  126881. * @param height defines the height of the clear rectangle
  126882. * @param clearColor defines the clear color
  126883. */
  126884. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  126885. /**
  126886. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  126887. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  126888. * @param y defines the y-coordinate of the corner of the clear rectangle
  126889. * @param width defines the width of the clear rectangle
  126890. * @param height defines the height of the clear rectangle
  126891. */
  126892. enableScissor(x: number, y: number, width: number, height: number): void;
  126893. /**
  126894. * Disable previously set scissor test rectangle
  126895. */
  126896. disableScissor(): void;
  126897. protected _reportDrawCall(): void;
  126898. /**
  126899. * Initializes a webVR display and starts listening to display change events
  126900. * The onVRDisplayChangedObservable will be notified upon these changes
  126901. * @returns The onVRDisplayChangedObservable
  126902. */
  126903. initWebVR(): Observable<IDisplayChangedEventArgs>;
  126904. /** @hidden */
  126905. _prepareVRComponent(): void;
  126906. /** @hidden */
  126907. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  126908. /** @hidden */
  126909. _submitVRFrame(): void;
  126910. /**
  126911. * Call this function to leave webVR mode
  126912. * Will do nothing if webVR is not supported or if there is no webVR device
  126913. * @see https://doc.babylonjs.com/how_to/webvr_camera
  126914. */
  126915. disableVR(): void;
  126916. /**
  126917. * Gets a boolean indicating that the system is in VR mode and is presenting
  126918. * @returns true if VR mode is engaged
  126919. */
  126920. isVRPresenting(): boolean;
  126921. /** @hidden */
  126922. _requestVRFrame(): void;
  126923. /** @hidden */
  126924. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126925. /**
  126926. * Gets the source code of the vertex shader associated with a specific webGL program
  126927. * @param program defines the program to use
  126928. * @returns a string containing the source code of the vertex shader associated with the program
  126929. */
  126930. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  126931. /**
  126932. * Gets the source code of the fragment shader associated with a specific webGL program
  126933. * @param program defines the program to use
  126934. * @returns a string containing the source code of the fragment shader associated with the program
  126935. */
  126936. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  126937. /**
  126938. * Sets a depth stencil texture from a render target to the according uniform.
  126939. * @param channel The texture channel
  126940. * @param uniform The uniform to set
  126941. * @param texture The render target texture containing the depth stencil texture to apply
  126942. * @param name The texture name
  126943. */
  126944. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  126945. /**
  126946. * Sets a texture to the webGL context from a postprocess
  126947. * @param channel defines the channel to use
  126948. * @param postProcess defines the source postprocess
  126949. * @param name name of the channel
  126950. */
  126951. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  126952. /**
  126953. * Binds the output of the passed in post process to the texture channel specified
  126954. * @param channel The channel the texture should be bound to
  126955. * @param postProcess The post process which's output should be bound
  126956. * @param name name of the channel
  126957. */
  126958. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  126959. protected _rebuildBuffers(): void;
  126960. /** @hidden */
  126961. _renderFrame(): void;
  126962. _renderLoop(): void;
  126963. /** @hidden */
  126964. _renderViews(): boolean;
  126965. /**
  126966. * Toggle full screen mode
  126967. * @param requestPointerLock defines if a pointer lock should be requested from the user
  126968. */
  126969. switchFullscreen(requestPointerLock: boolean): void;
  126970. /**
  126971. * Enters full screen mode
  126972. * @param requestPointerLock defines if a pointer lock should be requested from the user
  126973. */
  126974. enterFullscreen(requestPointerLock: boolean): void;
  126975. /**
  126976. * Exits full screen mode
  126977. */
  126978. exitFullscreen(): void;
  126979. /**
  126980. * Enters Pointerlock mode
  126981. */
  126982. enterPointerlock(): void;
  126983. /**
  126984. * Exits Pointerlock mode
  126985. */
  126986. exitPointerlock(): void;
  126987. /**
  126988. * Begin a new frame
  126989. */
  126990. beginFrame(): void;
  126991. /**
  126992. * End the current frame
  126993. */
  126994. endFrame(): void;
  126995. /**
  126996. * Resize the view according to the canvas' size
  126997. * @param forceSetSize true to force setting the sizes of the underlying canvas
  126998. */
  126999. resize(forceSetSize?: boolean): void;
  127000. /**
  127001. * Force a specific size of the canvas
  127002. * @param width defines the new canvas' width
  127003. * @param height defines the new canvas' height
  127004. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127005. * @returns true if the size was changed
  127006. */
  127007. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  127008. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  127009. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127010. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127011. _releaseTexture(texture: InternalTexture): void;
  127012. /**
  127013. * @hidden
  127014. * Rescales a texture
  127015. * @param source input texutre
  127016. * @param destination destination texture
  127017. * @param scene scene to use to render the resize
  127018. * @param internalFormat format to use when resizing
  127019. * @param onComplete callback to be called when resize has completed
  127020. */
  127021. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  127022. /**
  127023. * Gets the current framerate
  127024. * @returns a number representing the framerate
  127025. */
  127026. getFps(): number;
  127027. /**
  127028. * Gets the time spent between current and previous frame
  127029. * @returns a number representing the delta time in ms
  127030. */
  127031. getDeltaTime(): number;
  127032. private _measureFps;
  127033. /** @hidden */
  127034. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  127035. /**
  127036. * Updates the sample count of a render target texture
  127037. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127038. * @param texture defines the texture to update
  127039. * @param samples defines the sample count to set
  127040. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127041. */
  127042. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  127043. /**
  127044. * Updates a depth texture Comparison Mode and Function.
  127045. * If the comparison Function is equal to 0, the mode will be set to none.
  127046. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  127047. * @param texture The texture to set the comparison function for
  127048. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  127049. */
  127050. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  127051. /**
  127052. * Creates a webGL buffer to use with instanciation
  127053. * @param capacity defines the size of the buffer
  127054. * @returns the webGL buffer
  127055. */
  127056. createInstancesBuffer(capacity: number): DataBuffer;
  127057. /**
  127058. * Delete a webGL buffer used with instanciation
  127059. * @param buffer defines the webGL buffer to delete
  127060. */
  127061. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  127062. private _clientWaitAsync;
  127063. /** @hidden */
  127064. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  127065. dispose(): void;
  127066. private _disableTouchAction;
  127067. /**
  127068. * Display the loading screen
  127069. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127070. */
  127071. displayLoadingUI(): void;
  127072. /**
  127073. * Hide the loading screen
  127074. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127075. */
  127076. hideLoadingUI(): void;
  127077. /**
  127078. * Gets the current loading screen object
  127079. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127080. */
  127081. get loadingScreen(): ILoadingScreen;
  127082. /**
  127083. * Sets the current loading screen object
  127084. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127085. */
  127086. set loadingScreen(loadingScreen: ILoadingScreen);
  127087. /**
  127088. * Sets the current loading screen text
  127089. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127090. */
  127091. set loadingUIText(text: string);
  127092. /**
  127093. * Sets the current loading screen background color
  127094. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127095. */
  127096. set loadingUIBackgroundColor(color: string);
  127097. /** Pointerlock and fullscreen */
  127098. /**
  127099. * Ask the browser to promote the current element to pointerlock mode
  127100. * @param element defines the DOM element to promote
  127101. */
  127102. static _RequestPointerlock(element: HTMLElement): void;
  127103. /**
  127104. * Asks the browser to exit pointerlock mode
  127105. */
  127106. static _ExitPointerlock(): void;
  127107. /**
  127108. * Ask the browser to promote the current element to fullscreen rendering mode
  127109. * @param element defines the DOM element to promote
  127110. */
  127111. static _RequestFullscreen(element: HTMLElement): void;
  127112. /**
  127113. * Asks the browser to exit fullscreen mode
  127114. */
  127115. static _ExitFullscreen(): void;
  127116. }
  127117. }
  127118. declare module BABYLON {
  127119. /**
  127120. * The engine store class is responsible to hold all the instances of Engine and Scene created
  127121. * during the life time of the application.
  127122. */
  127123. export class EngineStore {
  127124. /** Gets the list of created engines */
  127125. static Instances: Engine[];
  127126. /** @hidden */
  127127. static _LastCreatedScene: Nullable<Scene>;
  127128. /**
  127129. * Gets the latest created engine
  127130. */
  127131. static get LastCreatedEngine(): Nullable<Engine>;
  127132. /**
  127133. * Gets the latest created scene
  127134. */
  127135. static get LastCreatedScene(): Nullable<Scene>;
  127136. /**
  127137. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127138. * @ignorenaming
  127139. */
  127140. static UseFallbackTexture: boolean;
  127141. /**
  127142. * Texture content used if a texture cannot loaded
  127143. * @ignorenaming
  127144. */
  127145. static FallbackTexture: string;
  127146. }
  127147. }
  127148. declare module BABYLON {
  127149. /**
  127150. * Helper class that provides a small promise polyfill
  127151. */
  127152. export class PromisePolyfill {
  127153. /**
  127154. * Static function used to check if the polyfill is required
  127155. * If this is the case then the function will inject the polyfill to window.Promise
  127156. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  127157. */
  127158. static Apply(force?: boolean): void;
  127159. }
  127160. }
  127161. declare module BABYLON {
  127162. /**
  127163. * Interface for screenshot methods with describe argument called `size` as object with options
  127164. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  127165. */
  127166. export interface IScreenshotSize {
  127167. /**
  127168. * number in pixels for canvas height
  127169. */
  127170. height?: number;
  127171. /**
  127172. * multiplier allowing render at a higher or lower resolution
  127173. * If value is defined then height and width will be ignored and taken from camera
  127174. */
  127175. precision?: number;
  127176. /**
  127177. * number in pixels for canvas width
  127178. */
  127179. width?: number;
  127180. }
  127181. }
  127182. declare module BABYLON {
  127183. interface IColor4Like {
  127184. r: float;
  127185. g: float;
  127186. b: float;
  127187. a: float;
  127188. }
  127189. /**
  127190. * Class containing a set of static utilities functions
  127191. */
  127192. export class Tools {
  127193. /**
  127194. * Gets or sets the base URL to use to load assets
  127195. */
  127196. static get BaseUrl(): string;
  127197. static set BaseUrl(value: string);
  127198. /**
  127199. * Enable/Disable Custom HTTP Request Headers globally.
  127200. * default = false
  127201. * @see CustomRequestHeaders
  127202. */
  127203. static UseCustomRequestHeaders: boolean;
  127204. /**
  127205. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  127206. * i.e. when loading files, where the server/service expects an Authorization header
  127207. */
  127208. static CustomRequestHeaders: {
  127209. [key: string]: string;
  127210. };
  127211. /**
  127212. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  127213. */
  127214. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  127215. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  127216. /**
  127217. * Default behaviour for cors in the application.
  127218. * It can be a string if the expected behavior is identical in the entire app.
  127219. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  127220. */
  127221. static get CorsBehavior(): string | ((url: string | string[]) => string);
  127222. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  127223. /**
  127224. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127225. * @ignorenaming
  127226. */
  127227. static get UseFallbackTexture(): boolean;
  127228. static set UseFallbackTexture(value: boolean);
  127229. /**
  127230. * Use this object to register external classes like custom textures or material
  127231. * to allow the laoders to instantiate them
  127232. */
  127233. static get RegisteredExternalClasses(): {
  127234. [key: string]: Object;
  127235. };
  127236. static set RegisteredExternalClasses(classes: {
  127237. [key: string]: Object;
  127238. });
  127239. /**
  127240. * Texture content used if a texture cannot loaded
  127241. * @ignorenaming
  127242. */
  127243. static get fallbackTexture(): string;
  127244. static set fallbackTexture(value: string);
  127245. /**
  127246. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  127247. * @param u defines the coordinate on X axis
  127248. * @param v defines the coordinate on Y axis
  127249. * @param width defines the width of the source data
  127250. * @param height defines the height of the source data
  127251. * @param pixels defines the source byte array
  127252. * @param color defines the output color
  127253. */
  127254. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  127255. /**
  127256. * Interpolates between a and b via alpha
  127257. * @param a The lower value (returned when alpha = 0)
  127258. * @param b The upper value (returned when alpha = 1)
  127259. * @param alpha The interpolation-factor
  127260. * @return The mixed value
  127261. */
  127262. static Mix(a: number, b: number, alpha: number): number;
  127263. /**
  127264. * Tries to instantiate a new object from a given class name
  127265. * @param className defines the class name to instantiate
  127266. * @returns the new object or null if the system was not able to do the instantiation
  127267. */
  127268. static Instantiate(className: string): any;
  127269. /**
  127270. * Provides a slice function that will work even on IE
  127271. * @param data defines the array to slice
  127272. * @param start defines the start of the data (optional)
  127273. * @param end defines the end of the data (optional)
  127274. * @returns the new sliced array
  127275. */
  127276. static Slice<T>(data: T, start?: number, end?: number): T;
  127277. /**
  127278. * Provides a slice function that will work even on IE
  127279. * The difference between this and Slice is that this will force-convert to array
  127280. * @param data defines the array to slice
  127281. * @param start defines the start of the data (optional)
  127282. * @param end defines the end of the data (optional)
  127283. * @returns the new sliced array
  127284. */
  127285. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  127286. /**
  127287. * Polyfill for setImmediate
  127288. * @param action defines the action to execute after the current execution block
  127289. */
  127290. static SetImmediate(action: () => void): void;
  127291. /**
  127292. * Function indicating if a number is an exponent of 2
  127293. * @param value defines the value to test
  127294. * @returns true if the value is an exponent of 2
  127295. */
  127296. static IsExponentOfTwo(value: number): boolean;
  127297. private static _tmpFloatArray;
  127298. /**
  127299. * Returns the nearest 32-bit single precision float representation of a Number
  127300. * @param value A Number. If the parameter is of a different type, it will get converted
  127301. * to a number or to NaN if it cannot be converted
  127302. * @returns number
  127303. */
  127304. static FloatRound(value: number): number;
  127305. /**
  127306. * Extracts the filename from a path
  127307. * @param path defines the path to use
  127308. * @returns the filename
  127309. */
  127310. static GetFilename(path: string): string;
  127311. /**
  127312. * Extracts the "folder" part of a path (everything before the filename).
  127313. * @param uri The URI to extract the info from
  127314. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  127315. * @returns The "folder" part of the path
  127316. */
  127317. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  127318. /**
  127319. * Extracts text content from a DOM element hierarchy
  127320. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  127321. */
  127322. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  127323. /**
  127324. * Convert an angle in radians to degrees
  127325. * @param angle defines the angle to convert
  127326. * @returns the angle in degrees
  127327. */
  127328. static ToDegrees(angle: number): number;
  127329. /**
  127330. * Convert an angle in degrees to radians
  127331. * @param angle defines the angle to convert
  127332. * @returns the angle in radians
  127333. */
  127334. static ToRadians(angle: number): number;
  127335. /**
  127336. * Returns an array if obj is not an array
  127337. * @param obj defines the object to evaluate as an array
  127338. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  127339. * @returns either obj directly if obj is an array or a new array containing obj
  127340. */
  127341. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  127342. /**
  127343. * Gets the pointer prefix to use
  127344. * @param engine defines the engine we are finding the prefix for
  127345. * @returns "pointer" if touch is enabled. Else returns "mouse"
  127346. */
  127347. static GetPointerPrefix(engine: Engine): string;
  127348. /**
  127349. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  127350. * @param url define the url we are trying
  127351. * @param element define the dom element where to configure the cors policy
  127352. */
  127353. static SetCorsBehavior(url: string | string[], element: {
  127354. crossOrigin: string | null;
  127355. }): void;
  127356. /**
  127357. * Removes unwanted characters from an url
  127358. * @param url defines the url to clean
  127359. * @returns the cleaned url
  127360. */
  127361. static CleanUrl(url: string): string;
  127362. /**
  127363. * Gets or sets a function used to pre-process url before using them to load assets
  127364. */
  127365. static get PreprocessUrl(): (url: string) => string;
  127366. static set PreprocessUrl(processor: (url: string) => string);
  127367. /**
  127368. * Loads an image as an HTMLImageElement.
  127369. * @param input url string, ArrayBuffer, or Blob to load
  127370. * @param onLoad callback called when the image successfully loads
  127371. * @param onError callback called when the image fails to load
  127372. * @param offlineProvider offline provider for caching
  127373. * @param mimeType optional mime type
  127374. * @returns the HTMLImageElement of the loaded image
  127375. */
  127376. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  127377. /**
  127378. * Loads a file from a url
  127379. * @param url url string, ArrayBuffer, or Blob to load
  127380. * @param onSuccess callback called when the file successfully loads
  127381. * @param onProgress callback called while file is loading (if the server supports this mode)
  127382. * @param offlineProvider defines the offline provider for caching
  127383. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127384. * @param onError callback called when the file fails to load
  127385. * @returns a file request object
  127386. */
  127387. 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;
  127388. /**
  127389. * Loads a file from a url
  127390. * @param url the file url to load
  127391. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127392. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  127393. */
  127394. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  127395. /**
  127396. * Load a script (identified by an url). When the url returns, the
  127397. * content of this file is added into a new script element, attached to the DOM (body element)
  127398. * @param scriptUrl defines the url of the script to laod
  127399. * @param onSuccess defines the callback called when the script is loaded
  127400. * @param onError defines the callback to call if an error occurs
  127401. * @param scriptId defines the id of the script element
  127402. */
  127403. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  127404. /**
  127405. * Load an asynchronous script (identified by an url). When the url returns, the
  127406. * content of this file is added into a new script element, attached to the DOM (body element)
  127407. * @param scriptUrl defines the url of the script to laod
  127408. * @param scriptId defines the id of the script element
  127409. * @returns a promise request object
  127410. */
  127411. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  127412. /**
  127413. * Loads a file from a blob
  127414. * @param fileToLoad defines the blob to use
  127415. * @param callback defines the callback to call when data is loaded
  127416. * @param progressCallback defines the callback to call during loading process
  127417. * @returns a file request object
  127418. */
  127419. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  127420. /**
  127421. * Reads a file from a File object
  127422. * @param file defines the file to load
  127423. * @param onSuccess defines the callback to call when data is loaded
  127424. * @param onProgress defines the callback to call during loading process
  127425. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127426. * @param onError defines the callback to call when an error occurs
  127427. * @returns a file request object
  127428. */
  127429. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  127430. /**
  127431. * Creates a data url from a given string content
  127432. * @param content defines the content to convert
  127433. * @returns the new data url link
  127434. */
  127435. static FileAsURL(content: string): string;
  127436. /**
  127437. * Format the given number to a specific decimal format
  127438. * @param value defines the number to format
  127439. * @param decimals defines the number of decimals to use
  127440. * @returns the formatted string
  127441. */
  127442. static Format(value: number, decimals?: number): string;
  127443. /**
  127444. * Tries to copy an object by duplicating every property
  127445. * @param source defines the source object
  127446. * @param destination defines the target object
  127447. * @param doNotCopyList defines a list of properties to avoid
  127448. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  127449. */
  127450. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  127451. /**
  127452. * Gets a boolean indicating if the given object has no own property
  127453. * @param obj defines the object to test
  127454. * @returns true if object has no own property
  127455. */
  127456. static IsEmpty(obj: any): boolean;
  127457. /**
  127458. * Function used to register events at window level
  127459. * @param windowElement defines the Window object to use
  127460. * @param events defines the events to register
  127461. */
  127462. static RegisterTopRootEvents(windowElement: Window, events: {
  127463. name: string;
  127464. handler: Nullable<(e: FocusEvent) => any>;
  127465. }[]): void;
  127466. /**
  127467. * Function used to unregister events from window level
  127468. * @param windowElement defines the Window object to use
  127469. * @param events defines the events to unregister
  127470. */
  127471. static UnregisterTopRootEvents(windowElement: Window, events: {
  127472. name: string;
  127473. handler: Nullable<(e: FocusEvent) => any>;
  127474. }[]): void;
  127475. /**
  127476. * @ignore
  127477. */
  127478. static _ScreenshotCanvas: HTMLCanvasElement;
  127479. /**
  127480. * Dumps the current bound framebuffer
  127481. * @param width defines the rendering width
  127482. * @param height defines the rendering height
  127483. * @param engine defines the hosting engine
  127484. * @param successCallback defines the callback triggered once the data are available
  127485. * @param mimeType defines the mime type of the result
  127486. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127487. * @return a void promise
  127488. */
  127489. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  127490. /**
  127491. * Dumps an array buffer
  127492. * @param width defines the rendering width
  127493. * @param height defines the rendering height
  127494. * @param data the data array
  127495. * @param successCallback defines the callback triggered once the data are available
  127496. * @param mimeType defines the mime type of the result
  127497. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127498. * @param invertY true to invert the picture in the Y dimension
  127499. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  127500. */
  127501. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  127502. /**
  127503. * Dumps an array buffer
  127504. * @param width defines the rendering width
  127505. * @param height defines the rendering height
  127506. * @param data the data array
  127507. * @param successCallback defines the callback triggered once the data are available
  127508. * @param mimeType defines the mime type of the result
  127509. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127510. * @param invertY true to invert the picture in the Y dimension
  127511. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  127512. * @return a promise that resolve to the final data
  127513. */
  127514. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  127515. /**
  127516. * Converts the canvas data to blob.
  127517. * This acts as a polyfill for browsers not supporting the to blob function.
  127518. * @param canvas Defines the canvas to extract the data from
  127519. * @param successCallback Defines the callback triggered once the data are available
  127520. * @param mimeType Defines the mime type of the result
  127521. */
  127522. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  127523. /**
  127524. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  127525. * @param successCallback defines the callback triggered once the data are available
  127526. * @param mimeType defines the mime type of the result
  127527. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  127528. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  127529. */
  127530. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  127531. /**
  127532. * Downloads a blob in the browser
  127533. * @param blob defines the blob to download
  127534. * @param fileName defines the name of the downloaded file
  127535. */
  127536. static Download(blob: Blob, fileName: string): void;
  127537. /**
  127538. * Will return the right value of the noPreventDefault variable
  127539. * Needed to keep backwards compatibility to the old API.
  127540. *
  127541. * @param args arguments passed to the attachControl function
  127542. * @returns the correct value for noPreventDefault
  127543. */
  127544. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  127545. /**
  127546. * Captures a screenshot of the current rendering
  127547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127548. * @param engine defines the rendering engine
  127549. * @param camera defines the source camera
  127550. * @param size This parameter can be set to a single number or to an object with the
  127551. * following (optional) properties: precision, width, height. If a single number is passed,
  127552. * it will be used for both width and height. If an object is passed, the screenshot size
  127553. * will be derived from the parameters. The precision property is a multiplier allowing
  127554. * rendering at a higher or lower resolution
  127555. * @param successCallback defines the callback receives a single parameter which contains the
  127556. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127557. * src parameter of an <img> to display it
  127558. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127559. * Check your browser for supported MIME types
  127560. */
  127561. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127562. /**
  127563. * Captures a screenshot of the current rendering
  127564. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127565. * @param engine defines the rendering engine
  127566. * @param camera defines the source camera
  127567. * @param size This parameter can be set to a single number or to an object with the
  127568. * following (optional) properties: precision, width, height. If a single number is passed,
  127569. * it will be used for both width and height. If an object is passed, the screenshot size
  127570. * will be derived from the parameters. The precision property is a multiplier allowing
  127571. * rendering at a higher or lower resolution
  127572. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127573. * Check your browser for supported MIME types
  127574. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127575. * to the src parameter of an <img> to display it
  127576. */
  127577. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  127578. /**
  127579. * Generates an image screenshot from the specified camera.
  127580. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127581. * @param engine The engine to use for rendering
  127582. * @param camera The camera to use for rendering
  127583. * @param size This parameter can be set to a single number or to an object with the
  127584. * following (optional) properties: precision, width, height. If a single number is passed,
  127585. * it will be used for both width and height. If an object is passed, the screenshot size
  127586. * will be derived from the parameters. The precision property is a multiplier allowing
  127587. * rendering at a higher or lower resolution
  127588. * @param successCallback The callback receives a single parameter which contains the
  127589. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127590. * src parameter of an <img> to display it
  127591. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127592. * Check your browser for supported MIME types
  127593. * @param samples Texture samples (default: 1)
  127594. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127595. * @param fileName A name for for the downloaded file.
  127596. */
  127597. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  127598. /**
  127599. * Generates an image screenshot from the specified camera.
  127600. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127601. * @param engine The engine to use for rendering
  127602. * @param camera The camera to use for rendering
  127603. * @param size This parameter can be set to a single number or to an object with the
  127604. * following (optional) properties: precision, width, height. If a single number is passed,
  127605. * it will be used for both width and height. If an object is passed, the screenshot size
  127606. * will be derived from the parameters. The precision property is a multiplier allowing
  127607. * rendering at a higher or lower resolution
  127608. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127609. * Check your browser for supported MIME types
  127610. * @param samples Texture samples (default: 1)
  127611. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127612. * @param fileName A name for for the downloaded file.
  127613. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127614. * to the src parameter of an <img> to display it
  127615. */
  127616. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  127617. /**
  127618. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  127619. * Be aware Math.random() could cause collisions, but:
  127620. * "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"
  127621. * @returns a pseudo random id
  127622. */
  127623. static RandomId(): string;
  127624. /**
  127625. * Test if the given uri is a base64 string
  127626. * @param uri The uri to test
  127627. * @return True if the uri is a base64 string or false otherwise
  127628. */
  127629. static IsBase64(uri: string): boolean;
  127630. /**
  127631. * Decode the given base64 uri.
  127632. * @param uri The uri to decode
  127633. * @return The decoded base64 data.
  127634. */
  127635. static DecodeBase64(uri: string): ArrayBuffer;
  127636. /**
  127637. * Gets the absolute url.
  127638. * @param url the input url
  127639. * @return the absolute url
  127640. */
  127641. static GetAbsoluteUrl(url: string): string;
  127642. /**
  127643. * No log
  127644. */
  127645. static readonly NoneLogLevel: number;
  127646. /**
  127647. * Only message logs
  127648. */
  127649. static readonly MessageLogLevel: number;
  127650. /**
  127651. * Only warning logs
  127652. */
  127653. static readonly WarningLogLevel: number;
  127654. /**
  127655. * Only error logs
  127656. */
  127657. static readonly ErrorLogLevel: number;
  127658. /**
  127659. * All logs
  127660. */
  127661. static readonly AllLogLevel: number;
  127662. /**
  127663. * Gets a value indicating the number of loading errors
  127664. * @ignorenaming
  127665. */
  127666. static get errorsCount(): number;
  127667. /**
  127668. * Callback called when a new log is added
  127669. */
  127670. static OnNewCacheEntry: (entry: string) => void;
  127671. /**
  127672. * Log a message to the console
  127673. * @param message defines the message to log
  127674. */
  127675. static Log(message: string): void;
  127676. /**
  127677. * Write a warning message to the console
  127678. * @param message defines the message to log
  127679. */
  127680. static Warn(message: string): void;
  127681. /**
  127682. * Write an error message to the console
  127683. * @param message defines the message to log
  127684. */
  127685. static Error(message: string): void;
  127686. /**
  127687. * Gets current log cache (list of logs)
  127688. */
  127689. static get LogCache(): string;
  127690. /**
  127691. * Clears the log cache
  127692. */
  127693. static ClearLogCache(): void;
  127694. /**
  127695. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  127696. */
  127697. static set LogLevels(level: number);
  127698. /**
  127699. * Checks if the window object exists
  127700. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  127701. */
  127702. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  127703. /**
  127704. * No performance log
  127705. */
  127706. static readonly PerformanceNoneLogLevel: number;
  127707. /**
  127708. * Use user marks to log performance
  127709. */
  127710. static readonly PerformanceUserMarkLogLevel: number;
  127711. /**
  127712. * Log performance to the console
  127713. */
  127714. static readonly PerformanceConsoleLogLevel: number;
  127715. private static _performance;
  127716. /**
  127717. * Sets the current performance log level
  127718. */
  127719. static set PerformanceLogLevel(level: number);
  127720. private static _StartPerformanceCounterDisabled;
  127721. private static _EndPerformanceCounterDisabled;
  127722. private static _StartUserMark;
  127723. private static _EndUserMark;
  127724. private static _StartPerformanceConsole;
  127725. private static _EndPerformanceConsole;
  127726. /**
  127727. * Starts a performance counter
  127728. */
  127729. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  127730. /**
  127731. * Ends a specific performance coutner
  127732. */
  127733. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  127734. /**
  127735. * Gets either window.performance.now() if supported or Date.now() else
  127736. */
  127737. static get Now(): number;
  127738. /**
  127739. * This method will return the name of the class used to create the instance of the given object.
  127740. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  127741. * @param object the object to get the class name from
  127742. * @param isType defines if the object is actually a type
  127743. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  127744. */
  127745. static GetClassName(object: any, isType?: boolean): string;
  127746. /**
  127747. * Gets the first element of an array satisfying a given predicate
  127748. * @param array defines the array to browse
  127749. * @param predicate defines the predicate to use
  127750. * @returns null if not found or the element
  127751. */
  127752. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  127753. /**
  127754. * This method will return the name of the full name of the class, including its owning module (if any).
  127755. * 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).
  127756. * @param object the object to get the class name from
  127757. * @param isType defines if the object is actually a type
  127758. * @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.
  127759. * @ignorenaming
  127760. */
  127761. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  127762. /**
  127763. * Returns a promise that resolves after the given amount of time.
  127764. * @param delay Number of milliseconds to delay
  127765. * @returns Promise that resolves after the given amount of time
  127766. */
  127767. static DelayAsync(delay: number): Promise<void>;
  127768. /**
  127769. * Utility function to detect if the current user agent is Safari
  127770. * @returns whether or not the current user agent is safari
  127771. */
  127772. static IsSafari(): boolean;
  127773. }
  127774. /**
  127775. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  127776. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  127777. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  127778. * @param name The name of the class, case should be preserved
  127779. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  127780. */
  127781. export function className(name: string, module?: string): (target: Object) => void;
  127782. /**
  127783. * An implementation of a loop for asynchronous functions.
  127784. */
  127785. export class AsyncLoop {
  127786. /**
  127787. * Defines the number of iterations for the loop
  127788. */
  127789. iterations: number;
  127790. /**
  127791. * Defines the current index of the loop.
  127792. */
  127793. index: number;
  127794. private _done;
  127795. private _fn;
  127796. private _successCallback;
  127797. /**
  127798. * Constructor.
  127799. * @param iterations the number of iterations.
  127800. * @param func the function to run each iteration
  127801. * @param successCallback the callback that will be called upon succesful execution
  127802. * @param offset starting offset.
  127803. */
  127804. constructor(
  127805. /**
  127806. * Defines the number of iterations for the loop
  127807. */
  127808. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  127809. /**
  127810. * Execute the next iteration. Must be called after the last iteration was finished.
  127811. */
  127812. executeNext(): void;
  127813. /**
  127814. * Break the loop and run the success callback.
  127815. */
  127816. breakLoop(): void;
  127817. /**
  127818. * Create and run an async loop.
  127819. * @param iterations the number of iterations.
  127820. * @param fn the function to run each iteration
  127821. * @param successCallback the callback that will be called upon succesful execution
  127822. * @param offset starting offset.
  127823. * @returns the created async loop object
  127824. */
  127825. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  127826. /**
  127827. * A for-loop that will run a given number of iterations synchronous and the rest async.
  127828. * @param iterations total number of iterations
  127829. * @param syncedIterations number of synchronous iterations in each async iteration.
  127830. * @param fn the function to call each iteration.
  127831. * @param callback a success call back that will be called when iterating stops.
  127832. * @param breakFunction a break condition (optional)
  127833. * @param timeout timeout settings for the setTimeout function. default - 0.
  127834. * @returns the created async loop object
  127835. */
  127836. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  127837. }
  127838. }
  127839. declare module BABYLON {
  127840. /**
  127841. * This class implement a typical dictionary using a string as key and the generic type T as value.
  127842. * The underlying implementation relies on an associative array to ensure the best performances.
  127843. * The value can be anything including 'null' but except 'undefined'
  127844. */
  127845. export class StringDictionary<T> {
  127846. /**
  127847. * This will clear this dictionary and copy the content from the 'source' one.
  127848. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  127849. * @param source the dictionary to take the content from and copy to this dictionary
  127850. */
  127851. copyFrom(source: StringDictionary<T>): void;
  127852. /**
  127853. * Get a value based from its key
  127854. * @param key the given key to get the matching value from
  127855. * @return the value if found, otherwise undefined is returned
  127856. */
  127857. get(key: string): T | undefined;
  127858. /**
  127859. * Get a value from its key or add it if it doesn't exist.
  127860. * This method will ensure you that a given key/data will be present in the dictionary.
  127861. * @param key the given key to get the matching value from
  127862. * @param factory the factory that will create the value if the key is not present in the dictionary.
  127863. * The factory will only be invoked if there's no data for the given key.
  127864. * @return the value corresponding to the key.
  127865. */
  127866. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  127867. /**
  127868. * Get a value from its key if present in the dictionary otherwise add it
  127869. * @param key the key to get the value from
  127870. * @param val if there's no such key/value pair in the dictionary add it with this value
  127871. * @return the value corresponding to the key
  127872. */
  127873. getOrAdd(key: string, val: T): T;
  127874. /**
  127875. * Check if there's a given key in the dictionary
  127876. * @param key the key to check for
  127877. * @return true if the key is present, false otherwise
  127878. */
  127879. contains(key: string): boolean;
  127880. /**
  127881. * Add a new key and its corresponding value
  127882. * @param key the key to add
  127883. * @param value the value corresponding to the key
  127884. * @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
  127885. */
  127886. add(key: string, value: T): boolean;
  127887. /**
  127888. * Update a specific value associated to a key
  127889. * @param key defines the key to use
  127890. * @param value defines the value to store
  127891. * @returns true if the value was updated (or false if the key was not found)
  127892. */
  127893. set(key: string, value: T): boolean;
  127894. /**
  127895. * Get the element of the given key and remove it from the dictionary
  127896. * @param key defines the key to search
  127897. * @returns the value associated with the key or null if not found
  127898. */
  127899. getAndRemove(key: string): Nullable<T>;
  127900. /**
  127901. * Remove a key/value from the dictionary.
  127902. * @param key the key to remove
  127903. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  127904. */
  127905. remove(key: string): boolean;
  127906. /**
  127907. * Clear the whole content of the dictionary
  127908. */
  127909. clear(): void;
  127910. /**
  127911. * Gets the current count
  127912. */
  127913. get count(): number;
  127914. /**
  127915. * Execute a callback on each key/val of the dictionary.
  127916. * Note that you can remove any element in this dictionary in the callback implementation
  127917. * @param callback the callback to execute on a given key/value pair
  127918. */
  127919. forEach(callback: (key: string, val: T) => void): void;
  127920. /**
  127921. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  127922. * If the callback returns null or undefined the method will iterate to the next key/value pair
  127923. * Note that you can remove any element in this dictionary in the callback implementation
  127924. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  127925. * @returns the first item
  127926. */
  127927. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  127928. private _count;
  127929. private _data;
  127930. }
  127931. }
  127932. declare module BABYLON {
  127933. /** @hidden */
  127934. export interface ICollisionCoordinator {
  127935. createCollider(): Collider;
  127936. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  127937. init(scene: Scene): void;
  127938. }
  127939. /** @hidden */
  127940. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  127941. private _scene;
  127942. private _scaledPosition;
  127943. private _scaledVelocity;
  127944. private _finalPosition;
  127945. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  127946. createCollider(): Collider;
  127947. init(scene: Scene): void;
  127948. private _collideWithWorld;
  127949. }
  127950. }
  127951. declare module BABYLON {
  127952. /**
  127953. * Class used to manage all inputs for the scene.
  127954. */
  127955. export class InputManager {
  127956. /** The distance in pixel that you have to move to prevent some events */
  127957. static DragMovementThreshold: number;
  127958. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  127959. static LongPressDelay: number;
  127960. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  127961. static DoubleClickDelay: number;
  127962. /** If you need to check double click without raising a single click at first click, enable this flag */
  127963. static ExclusiveDoubleClickMode: boolean;
  127964. /** 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. */
  127965. private _alreadyAttached;
  127966. private _alreadyAttachedTo;
  127967. private _wheelEventName;
  127968. private _onPointerMove;
  127969. private _onPointerDown;
  127970. private _onPointerUp;
  127971. private _initClickEvent;
  127972. private _initActionManager;
  127973. private _delayedSimpleClick;
  127974. private _delayedSimpleClickTimeout;
  127975. private _previousDelayedSimpleClickTimeout;
  127976. private _meshPickProceed;
  127977. private _previousButtonPressed;
  127978. private _currentPickResult;
  127979. private _previousPickResult;
  127980. private _totalPointersPressed;
  127981. private _doubleClickOccured;
  127982. private _pointerOverMesh;
  127983. private _pickedDownMesh;
  127984. private _pickedUpMesh;
  127985. private _pointerX;
  127986. private _pointerY;
  127987. private _unTranslatedPointerX;
  127988. private _unTranslatedPointerY;
  127989. private _startingPointerPosition;
  127990. private _previousStartingPointerPosition;
  127991. private _startingPointerTime;
  127992. private _previousStartingPointerTime;
  127993. private _pointerCaptures;
  127994. private _meshUnderPointerId;
  127995. private _onKeyDown;
  127996. private _onKeyUp;
  127997. private _keyboardIsAttached;
  127998. private _onCanvasFocusObserver;
  127999. private _onCanvasBlurObserver;
  128000. private _scene;
  128001. /**
  128002. * Creates a new InputManager
  128003. * @param scene defines the hosting scene
  128004. */
  128005. constructor(scene: Scene);
  128006. /**
  128007. * Gets the mesh that is currently under the pointer
  128008. */
  128009. get meshUnderPointer(): Nullable<AbstractMesh>;
  128010. /**
  128011. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  128012. * @param pointerId the pointer id to use
  128013. * @returns The mesh under this pointer id or null if not found
  128014. */
  128015. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  128016. /**
  128017. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  128018. */
  128019. get unTranslatedPointer(): Vector2;
  128020. /**
  128021. * Gets or sets the current on-screen X position of the pointer
  128022. */
  128023. get pointerX(): number;
  128024. set pointerX(value: number);
  128025. /**
  128026. * Gets or sets the current on-screen Y position of the pointer
  128027. */
  128028. get pointerY(): number;
  128029. set pointerY(value: number);
  128030. private _updatePointerPosition;
  128031. private _processPointerMove;
  128032. private _setRayOnPointerInfo;
  128033. private _checkPrePointerObservable;
  128034. /**
  128035. * Use this method to simulate a pointer move on a mesh
  128036. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128037. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128038. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128039. */
  128040. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128041. /**
  128042. * Use this method to simulate a pointer down on a mesh
  128043. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128044. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128045. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128046. */
  128047. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128048. private _processPointerDown;
  128049. /** @hidden */
  128050. _isPointerSwiping(): boolean;
  128051. /**
  128052. * Use this method to simulate a pointer up on a mesh
  128053. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128054. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128055. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128056. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128057. */
  128058. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  128059. private _processPointerUp;
  128060. /**
  128061. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128062. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128063. * @returns true if the pointer was captured
  128064. */
  128065. isPointerCaptured(pointerId?: number): boolean;
  128066. /**
  128067. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128068. * @param attachUp defines if you want to attach events to pointerup
  128069. * @param attachDown defines if you want to attach events to pointerdown
  128070. * @param attachMove defines if you want to attach events to pointermove
  128071. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  128072. */
  128073. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  128074. /**
  128075. * Detaches all event handlers
  128076. */
  128077. detachControl(): void;
  128078. /**
  128079. * Force the value of meshUnderPointer
  128080. * @param mesh defines the mesh to use
  128081. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  128082. */
  128083. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  128084. /**
  128085. * Gets the mesh under the pointer
  128086. * @returns a Mesh or null if no mesh is under the pointer
  128087. */
  128088. getPointerOverMesh(): Nullable<AbstractMesh>;
  128089. }
  128090. }
  128091. declare module BABYLON {
  128092. /**
  128093. * This class defines the direct association between an animation and a target
  128094. */
  128095. export class TargetedAnimation {
  128096. /**
  128097. * Animation to perform
  128098. */
  128099. animation: Animation;
  128100. /**
  128101. * Target to animate
  128102. */
  128103. target: any;
  128104. /**
  128105. * Returns the string "TargetedAnimation"
  128106. * @returns "TargetedAnimation"
  128107. */
  128108. getClassName(): string;
  128109. /**
  128110. * Serialize the object
  128111. * @returns the JSON object representing the current entity
  128112. */
  128113. serialize(): any;
  128114. }
  128115. /**
  128116. * Use this class to create coordinated animations on multiple targets
  128117. */
  128118. export class AnimationGroup implements IDisposable {
  128119. /** The name of the animation group */
  128120. name: string;
  128121. private _scene;
  128122. private _targetedAnimations;
  128123. private _animatables;
  128124. private _from;
  128125. private _to;
  128126. private _isStarted;
  128127. private _isPaused;
  128128. private _speedRatio;
  128129. private _loopAnimation;
  128130. private _isAdditive;
  128131. /**
  128132. * Gets or sets the unique id of the node
  128133. */
  128134. uniqueId: number;
  128135. /**
  128136. * This observable will notify when one animation have ended
  128137. */
  128138. onAnimationEndObservable: Observable<TargetedAnimation>;
  128139. /**
  128140. * Observer raised when one animation loops
  128141. */
  128142. onAnimationLoopObservable: Observable<TargetedAnimation>;
  128143. /**
  128144. * Observer raised when all animations have looped
  128145. */
  128146. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  128147. /**
  128148. * This observable will notify when all animations have ended.
  128149. */
  128150. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  128151. /**
  128152. * This observable will notify when all animations have paused.
  128153. */
  128154. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  128155. /**
  128156. * This observable will notify when all animations are playing.
  128157. */
  128158. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  128159. /**
  128160. * Gets the first frame
  128161. */
  128162. get from(): number;
  128163. /**
  128164. * Gets the last frame
  128165. */
  128166. get to(): number;
  128167. /**
  128168. * Define if the animations are started
  128169. */
  128170. get isStarted(): boolean;
  128171. /**
  128172. * Gets a value indicating that the current group is playing
  128173. */
  128174. get isPlaying(): boolean;
  128175. /**
  128176. * Gets or sets the speed ratio to use for all animations
  128177. */
  128178. get speedRatio(): number;
  128179. /**
  128180. * Gets or sets the speed ratio to use for all animations
  128181. */
  128182. set speedRatio(value: number);
  128183. /**
  128184. * Gets or sets if all animations should loop or not
  128185. */
  128186. get loopAnimation(): boolean;
  128187. set loopAnimation(value: boolean);
  128188. /**
  128189. * Gets or sets if all animations should be evaluated additively
  128190. */
  128191. get isAdditive(): boolean;
  128192. set isAdditive(value: boolean);
  128193. /**
  128194. * Gets the targeted animations for this animation group
  128195. */
  128196. get targetedAnimations(): Array<TargetedAnimation>;
  128197. /**
  128198. * returning the list of animatables controlled by this animation group.
  128199. */
  128200. get animatables(): Array<Animatable>;
  128201. /**
  128202. * Gets the list of target animations
  128203. */
  128204. get children(): TargetedAnimation[];
  128205. /**
  128206. * Instantiates a new Animation Group.
  128207. * This helps managing several animations at once.
  128208. * @see https://doc.babylonjs.com/how_to/group
  128209. * @param name Defines the name of the group
  128210. * @param scene Defines the scene the group belongs to
  128211. */
  128212. constructor(
  128213. /** The name of the animation group */
  128214. name: string, scene?: Nullable<Scene>);
  128215. /**
  128216. * Add an animation (with its target) in the group
  128217. * @param animation defines the animation we want to add
  128218. * @param target defines the target of the animation
  128219. * @returns the TargetedAnimation object
  128220. */
  128221. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  128222. /**
  128223. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  128224. * It can add constant keys at begin or end
  128225. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  128226. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  128227. * @returns the animation group
  128228. */
  128229. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  128230. private _animationLoopCount;
  128231. private _animationLoopFlags;
  128232. private _processLoop;
  128233. /**
  128234. * Start all animations on given targets
  128235. * @param loop defines if animations must loop
  128236. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  128237. * @param from defines the from key (optional)
  128238. * @param to defines the to key (optional)
  128239. * @param isAdditive defines the additive state for the resulting animatables (optional)
  128240. * @returns the current animation group
  128241. */
  128242. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  128243. /**
  128244. * Pause all animations
  128245. * @returns the animation group
  128246. */
  128247. pause(): AnimationGroup;
  128248. /**
  128249. * Play all animations to initial state
  128250. * This function will start() the animations if they were not started or will restart() them if they were paused
  128251. * @param loop defines if animations must loop
  128252. * @returns the animation group
  128253. */
  128254. play(loop?: boolean): AnimationGroup;
  128255. /**
  128256. * Reset all animations to initial state
  128257. * @returns the animation group
  128258. */
  128259. reset(): AnimationGroup;
  128260. /**
  128261. * Restart animations from key 0
  128262. * @returns the animation group
  128263. */
  128264. restart(): AnimationGroup;
  128265. /**
  128266. * Stop all animations
  128267. * @returns the animation group
  128268. */
  128269. stop(): AnimationGroup;
  128270. /**
  128271. * Set animation weight for all animatables
  128272. * @param weight defines the weight to use
  128273. * @return the animationGroup
  128274. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128275. */
  128276. setWeightForAllAnimatables(weight: number): AnimationGroup;
  128277. /**
  128278. * Synchronize and normalize all animatables with a source animatable
  128279. * @param root defines the root animatable to synchronize with
  128280. * @return the animationGroup
  128281. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128282. */
  128283. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  128284. /**
  128285. * Goes to a specific frame in this animation group
  128286. * @param frame the frame number to go to
  128287. * @return the animationGroup
  128288. */
  128289. goToFrame(frame: number): AnimationGroup;
  128290. /**
  128291. * Dispose all associated resources
  128292. */
  128293. dispose(): void;
  128294. private _checkAnimationGroupEnded;
  128295. /**
  128296. * Clone the current animation group and returns a copy
  128297. * @param newName defines the name of the new group
  128298. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  128299. * @returns the new aniamtion group
  128300. */
  128301. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  128302. /**
  128303. * Serializes the animationGroup to an object
  128304. * @returns Serialized object
  128305. */
  128306. serialize(): any;
  128307. /**
  128308. * Returns a new AnimationGroup object parsed from the source provided.
  128309. * @param parsedAnimationGroup defines the source
  128310. * @param scene defines the scene that will receive the animationGroup
  128311. * @returns a new AnimationGroup
  128312. */
  128313. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  128314. /**
  128315. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  128316. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  128317. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  128318. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  128319. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  128320. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  128321. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  128322. */
  128323. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  128324. /**
  128325. * Returns the string "AnimationGroup"
  128326. * @returns "AnimationGroup"
  128327. */
  128328. getClassName(): string;
  128329. /**
  128330. * Creates a detailled string about the object
  128331. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  128332. * @returns a string representing the object
  128333. */
  128334. toString(fullDetails?: boolean): string;
  128335. }
  128336. }
  128337. declare module BABYLON {
  128338. /**
  128339. * @hidden
  128340. **/
  128341. export class _TimeToken {
  128342. _startTimeQuery: Nullable<WebGLQuery>;
  128343. _endTimeQuery: Nullable<WebGLQuery>;
  128344. _timeElapsedQuery: Nullable<WebGLQuery>;
  128345. _timeElapsedQueryEnded: boolean;
  128346. }
  128347. }
  128348. declare module BABYLON {
  128349. /** @hidden */
  128350. export enum ExtensionName {
  128351. DepthClamping = "depth-clamping",
  128352. Depth24UnormStencil8 = "depth24unorm-stencil8",
  128353. Depth32FloatStencil8 = "depth32float-stencil8",
  128354. PipelineStatisticsQuery = "pipeline-statistics-query",
  128355. TextureCompressionBC = "texture-compression-bc",
  128356. TimestampQuery = "timestamp-query"
  128357. }
  128358. /** @hidden */
  128359. export enum AddressMode {
  128360. ClampToEdge = "clamp-to-edge",
  128361. Repeat = "repeat",
  128362. MirrorRepeat = "mirror-repeat"
  128363. }
  128364. /** @hidden */
  128365. export enum BindingType {
  128366. UniformBuffer = "uniform-buffer",
  128367. StorageBuffer = "storage-buffer",
  128368. ReadonlyStorageBuffer = "readonly-storage-buffer",
  128369. Sampler = "sampler",
  128370. ComparisonSampler = "comparison-sampler",
  128371. SampledTexture = "sampled-texture",
  128372. ReadonlyStorageTexture = "readonly-storage-texture",
  128373. WriteonlyStorageTexture = "writeonly-storage-texture"
  128374. }
  128375. /** @hidden */
  128376. export enum BlendFactor {
  128377. Zero = "zero",
  128378. One = "one",
  128379. SrcColor = "src-color",
  128380. OneMinusSrcColor = "one-minus-src-color",
  128381. SrcAlpha = "src-alpha",
  128382. OneMinusSrcAlpha = "one-minus-src-alpha",
  128383. DstColor = "dst-color",
  128384. OneMinusDstColor = "one-minus-dst-color",
  128385. DstAlpha = "dst-alpha",
  128386. OneMinusDstAlpha = "one-minus-dst-alpha",
  128387. SrcAlphaSaturated = "src-alpha-saturated",
  128388. BlendColor = "blend-color",
  128389. OneMinusBlendColor = "one-minus-blend-color"
  128390. }
  128391. /** @hidden */
  128392. export enum BlendOperation {
  128393. Add = "add",
  128394. Subtract = "subtract",
  128395. ReverseSubtract = "reverse-subtract",
  128396. Min = "min",
  128397. Max = "max"
  128398. }
  128399. /** @hidden */
  128400. export enum CompareFunction {
  128401. Never = "never",
  128402. Less = "less",
  128403. Equal = "equal",
  128404. LessEqual = "less-equal",
  128405. Greater = "greater",
  128406. NotEqual = "not-equal",
  128407. GreaterEqual = "greater-equal",
  128408. Always = "always"
  128409. }
  128410. /** @hidden */
  128411. export enum CullMode {
  128412. None = "none",
  128413. Front = "front",
  128414. Back = "back"
  128415. }
  128416. /** @hidden */
  128417. export enum FilterMode {
  128418. Nearest = "nearest",
  128419. Linear = "linear"
  128420. }
  128421. /** @hidden */
  128422. export enum FrontFace {
  128423. CCW = "ccw",
  128424. CW = "cw"
  128425. }
  128426. /** @hidden */
  128427. export enum IndexFormat {
  128428. Uint16 = "uint16",
  128429. Uint32 = "uint32"
  128430. }
  128431. /** @hidden */
  128432. export enum InputStepMode {
  128433. Vertex = "vertex",
  128434. Instance = "instance"
  128435. }
  128436. /** @hidden */
  128437. export enum LoadOp {
  128438. Load = "load"
  128439. }
  128440. /** @hidden */
  128441. export enum PrimitiveTopology {
  128442. PointList = "point-list",
  128443. LineList = "line-list",
  128444. LineStrip = "line-strip",
  128445. TriangleList = "triangle-list",
  128446. TriangleStrip = "triangle-strip"
  128447. }
  128448. /** @hidden */
  128449. export enum StencilOperation {
  128450. Keep = "keep",
  128451. Zero = "zero",
  128452. Replace = "replace",
  128453. Invert = "invert",
  128454. IncrementClamp = "increment-clamp",
  128455. DecrementClamp = "decrement-clamp",
  128456. IncrementWrap = "increment-wrap",
  128457. DecrementWrap = "decrement-wrap"
  128458. }
  128459. /** @hidden */
  128460. export enum StoreOp {
  128461. Store = "store",
  128462. Clear = "clear"
  128463. }
  128464. /** @hidden */
  128465. export enum TextureDimension {
  128466. E1d = "1d",
  128467. E2d = "2d",
  128468. E3d = "3d"
  128469. }
  128470. /** @hidden */
  128471. export enum TextureFormat {
  128472. R8Unorm = "r8unorm",
  128473. R8Snorm = "r8snorm",
  128474. R8Uint = "r8uint",
  128475. R8Sint = "r8sint",
  128476. R16Uint = "r16uint",
  128477. R16Sint = "r16sint",
  128478. R16Float = "r16float",
  128479. RG8Unorm = "rg8unorm",
  128480. RG8Snorm = "rg8snorm",
  128481. RG8Uint = "rg8uint",
  128482. RG8Sint = "rg8sint",
  128483. R32Uint = "r32uint",
  128484. R32Sint = "r32sint",
  128485. R32Float = "r32float",
  128486. RG16Uint = "rg16uint",
  128487. RG16Sint = "rg16sint",
  128488. RG16Float = "rg16float",
  128489. RGBA8Unorm = "rgba8unorm",
  128490. RGBA8UnormSRGB = "rgba8unorm-srgb",
  128491. RGBA8Snorm = "rgba8snorm",
  128492. RGBA8Uint = "rgba8uint",
  128493. RGBA8Sint = "rgba8sint",
  128494. BGRA8Unorm = "bgra8unorm",
  128495. BGRA8UnormSRGB = "bgra8unorm-srgb",
  128496. RGB9E5UFloat = "rgb9e5ufloat",
  128497. RGB10A2Unorm = "rgb10a2unorm",
  128498. RG11B10UFloat = "rg11b10ufloat",
  128499. RG32Uint = "rg32uint",
  128500. RG32Sint = "rg32sint",
  128501. RG32Float = "rg32float",
  128502. RGBA16Uint = "rgba16uint",
  128503. RGBA16Sint = "rgba16sint",
  128504. RGBA16Float = "rgba16float",
  128505. RGBA32Uint = "rgba32uint",
  128506. RGBA32Sint = "rgba32sint",
  128507. RGBA32Float = "rgba32float",
  128508. Stencil8 = "stencil8",
  128509. Depth16Unorm = "depth16unorm",
  128510. Depth24Plus = "depth24plus",
  128511. Depth24PlusStencil8 = "depth24plus-stencil8",
  128512. Depth32Float = "depth32float",
  128513. BC1RGBAUNorm = "bc1-rgba-unorm",
  128514. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  128515. BC2RGBAUnorm = "bc2-rgba-unorm",
  128516. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  128517. BC3RGBAUnorm = "bc3-rgba-unorm",
  128518. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  128519. BC4RUnorm = "bc4-r-unorm",
  128520. BC4RSnorm = "bc4-r-snorm",
  128521. BC5RGUnorm = "bc5-rg-unorm",
  128522. BC5RGSnorm = "bc5-rg-snorm",
  128523. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  128524. BC6HRGBFloat = "bc6h-rgb-float",
  128525. BC7RGBAUnorm = "bc7-rgba-unorm",
  128526. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  128527. Depth24UnormStencil8 = "depth24unorm-stencil8",
  128528. Depth32FloatStencil8 = "depth32float-stencil8"
  128529. }
  128530. /** @hidden */
  128531. export enum TextureComponentType {
  128532. Float = "float",
  128533. Sint = "sint",
  128534. Uint = "uint",
  128535. DepthComparison = "depth-comparison"
  128536. }
  128537. /** @hidden */
  128538. export enum TextureViewDimension {
  128539. E1d = "1d",
  128540. E2d = "2d",
  128541. E2dArray = "2d-array",
  128542. Cube = "cube",
  128543. CubeArray = "cube-array",
  128544. E3d = "3d"
  128545. }
  128546. /** @hidden */
  128547. export enum VertexFormat {
  128548. Uchar2 = "uchar2",
  128549. Uchar4 = "uchar4",
  128550. Char2 = "char2",
  128551. Char4 = "char4",
  128552. Uchar2Norm = "uchar2norm",
  128553. Uchar4Norm = "uchar4norm",
  128554. Char2Norm = "char2norm",
  128555. Char4Norm = "char4norm",
  128556. Ushort2 = "ushort2",
  128557. Ushort4 = "ushort4",
  128558. Short2 = "short2",
  128559. Short4 = "short4",
  128560. Ushort2Norm = "ushort2norm",
  128561. Ushort4Norm = "ushort4norm",
  128562. Short2Norm = "short2norm",
  128563. Short4Norm = "short4norm",
  128564. Half2 = "half2",
  128565. Half4 = "half4",
  128566. Float = "float",
  128567. Float2 = "float2",
  128568. Float3 = "float3",
  128569. Float4 = "float4",
  128570. Uint = "uint",
  128571. Uint2 = "uint2",
  128572. Uint3 = "uint3",
  128573. Uint4 = "uint4",
  128574. Int = "int",
  128575. Int2 = "int2",
  128576. Int3 = "int3",
  128577. Int4 = "int4"
  128578. }
  128579. /** @hidden */
  128580. export enum TextureAspect {
  128581. All = "all",
  128582. StencilOnly = "stencil-only",
  128583. DepthOnly = "depth-only"
  128584. }
  128585. /** @hidden */
  128586. export enum CompilationMessageType {
  128587. Error = "error",
  128588. Warning = "warning",
  128589. Info = "info"
  128590. }
  128591. /** @hidden */
  128592. export enum QueryType {
  128593. Occlusion = "occlusion"
  128594. }
  128595. /** @hidden */
  128596. export enum BufferUsage {
  128597. MapRead = 1,
  128598. MapWrite = 2,
  128599. CopySrc = 4,
  128600. CopyDst = 8,
  128601. Index = 16,
  128602. Vertex = 32,
  128603. Uniform = 64,
  128604. Storage = 128,
  128605. Indirect = 256,
  128606. QueryResolve = 512
  128607. }
  128608. /** @hidden */
  128609. export enum ColorWrite {
  128610. Red = 1,
  128611. Green = 2,
  128612. Blue = 4,
  128613. Alpha = 8,
  128614. All = 15
  128615. }
  128616. /** @hidden */
  128617. export enum ShaderStage {
  128618. Vertex = 1,
  128619. Fragment = 2,
  128620. Compute = 4
  128621. }
  128622. /** @hidden */
  128623. export enum TextureUsage {
  128624. CopySrc = 1,
  128625. CopyDst = 2,
  128626. Sampled = 4,
  128627. Storage = 8,
  128628. OutputAttachment = 16
  128629. }
  128630. /** @hidden */
  128631. export enum MapMode {
  128632. Read = 1,
  128633. Write = 2
  128634. }
  128635. }
  128636. declare module BABYLON {
  128637. /** @hidden */
  128638. export interface WebGPUBindingInfo {
  128639. setIndex: number;
  128640. bindingIndex: number;
  128641. }
  128642. /** @hidden */
  128643. export interface WebGPUTextureSamplerBindingDescription {
  128644. sampler: WebGPUBindingInfo;
  128645. isTextureArray: boolean;
  128646. textures: Array<WebGPUBindingInfo>;
  128647. }
  128648. /** @hidden
  128649. * If the binding is a UBO, isSampler=isTexture=false
  128650. */
  128651. export interface WebGPUBindingDescription {
  128652. name: string;
  128653. usedInVertex: boolean;
  128654. usedInFragment: boolean;
  128655. isSampler: boolean;
  128656. isComparisonSampler?: boolean;
  128657. isTexture: boolean;
  128658. componentType?: GPUTextureComponentType;
  128659. textureDimension?: GPUTextureViewDimension;
  128660. }
  128661. /**
  128662. * @hidden
  128663. */
  128664. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  128665. uboNextBindingIndex: number;
  128666. freeSetIndex: number;
  128667. freeBindingIndex: number;
  128668. availableVaryings: {
  128669. [key: string]: number;
  128670. };
  128671. availableAttributes: {
  128672. [key: string]: number;
  128673. };
  128674. availableUBOs: {
  128675. [key: string]: {
  128676. setIndex: number;
  128677. bindingIndex: number;
  128678. };
  128679. };
  128680. availableSamplers: {
  128681. [key: string]: WebGPUTextureSamplerBindingDescription;
  128682. };
  128683. leftOverUniforms: {
  128684. name: string;
  128685. type: string;
  128686. length: number;
  128687. }[];
  128688. orderedAttributes: string[];
  128689. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  128690. private _attributeNextLocation;
  128691. private _varyingNextLocation;
  128692. constructor();
  128693. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  128694. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  128695. getNextFreeUBOBinding(): {
  128696. setIndex: number;
  128697. bindingIndex: number;
  128698. };
  128699. private _getNextFreeBinding;
  128700. }
  128701. }
  128702. declare module BABYLON {
  128703. /** @hidden */
  128704. export interface IWebGPUPipelineContextSamplerCache {
  128705. samplerBinding: number;
  128706. firstTextureName: string;
  128707. }
  128708. /** @hidden */
  128709. export interface IWebGPUPipelineContextTextureCache {
  128710. textureBinding: number;
  128711. texture: InternalTexture;
  128712. }
  128713. /** @hidden */
  128714. export interface IWebGPUPipelineContextVertexInputsCache {
  128715. indexBuffer: Nullable<GPUBuffer>;
  128716. indexOffset: number;
  128717. vertexStartSlot: number;
  128718. vertexBuffers: GPUBuffer[];
  128719. vertexOffsets: number[];
  128720. }
  128721. /** @hidden */
  128722. export interface IWebGPURenderPipelineStageDescriptor {
  128723. vertexStage: GPUProgrammableStageDescriptor;
  128724. fragmentStage?: GPUProgrammableStageDescriptor;
  128725. }
  128726. /** @hidden */
  128727. export class WebGPUPipelineContext implements IPipelineContext {
  128728. engine: WebGPUEngine;
  128729. shaderProcessingContext: WebGPUShaderProcessingContext;
  128730. leftOverUniformsByName: {
  128731. [name: string]: string;
  128732. };
  128733. sources: {
  128734. vertex: string;
  128735. fragment: string;
  128736. rawVertex: string;
  128737. rawFragment: string;
  128738. };
  128739. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  128740. samplers: {
  128741. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  128742. };
  128743. textures: {
  128744. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  128745. };
  128746. bindGroupLayouts: GPUBindGroupLayout[];
  128747. /**
  128748. * Stores the uniform buffer
  128749. */
  128750. uniformBuffer: Nullable<UniformBuffer>;
  128751. onCompiled?: () => void;
  128752. get isAsync(): boolean;
  128753. get isReady(): boolean;
  128754. /** @hidden */
  128755. _name: string;
  128756. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  128757. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  128758. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  128759. [key: string]: number;
  128760. }, uniformsNames: string[], uniforms: {
  128761. [key: string]: Nullable<WebGLUniformLocation>;
  128762. }, samplerList: string[], samplers: {
  128763. [key: string]: number;
  128764. }, attributesNames: string[], attributes: number[]): void;
  128765. /** @hidden */
  128766. /**
  128767. * Build the uniform buffer used in the material.
  128768. */
  128769. buildUniformLayout(): void;
  128770. /**
  128771. * Release all associated resources.
  128772. **/
  128773. dispose(): void;
  128774. /**
  128775. * Sets an integer value on a uniform variable.
  128776. * @param uniformName Name of the variable.
  128777. * @param value Value to be set.
  128778. */
  128779. setInt(uniformName: string, value: number): void;
  128780. /**
  128781. * Sets an int2 value on a uniform variable.
  128782. * @param uniformName Name of the variable.
  128783. * @param x First int in int2.
  128784. * @param y Second int in int2.
  128785. */
  128786. setInt2(uniformName: string, x: number, y: number): void;
  128787. /**
  128788. * Sets an int3 value on a uniform variable.
  128789. * @param uniformName Name of the variable.
  128790. * @param x First int in int3.
  128791. * @param y Second int in int3.
  128792. * @param z Third int in int3.
  128793. */
  128794. setInt3(uniformName: string, x: number, y: number, z: number): void;
  128795. /**
  128796. * Sets an int4 value on a uniform variable.
  128797. * @param uniformName Name of the variable.
  128798. * @param x First int in int4.
  128799. * @param y Second int in int4.
  128800. * @param z Third int in int4.
  128801. * @param w Fourth int in int4.
  128802. */
  128803. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  128804. /**
  128805. * Sets an int array on a uniform variable.
  128806. * @param uniformName Name of the variable.
  128807. * @param array array to be set.
  128808. */
  128809. setIntArray(uniformName: string, array: Int32Array): void;
  128810. /**
  128811. * 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)
  128812. * @param uniformName Name of the variable.
  128813. * @param array array to be set.
  128814. */
  128815. setIntArray2(uniformName: string, array: Int32Array): void;
  128816. /**
  128817. * 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)
  128818. * @param uniformName Name of the variable.
  128819. * @param array array to be set.
  128820. */
  128821. setIntArray3(uniformName: string, array: Int32Array): void;
  128822. /**
  128823. * 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)
  128824. * @param uniformName Name of the variable.
  128825. * @param array array to be set.
  128826. */
  128827. setIntArray4(uniformName: string, array: Int32Array): void;
  128828. /**
  128829. * Sets an array on a uniform variable.
  128830. * @param uniformName Name of the variable.
  128831. * @param array array to be set.
  128832. */
  128833. setArray(uniformName: string, array: number[]): void;
  128834. /**
  128835. * 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)
  128836. * @param uniformName Name of the variable.
  128837. * @param array array to be set.
  128838. */
  128839. setArray2(uniformName: string, array: number[]): void;
  128840. /**
  128841. * 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)
  128842. * @param uniformName Name of the variable.
  128843. * @param array array to be set.
  128844. * @returns this effect.
  128845. */
  128846. setArray3(uniformName: string, array: number[]): void;
  128847. /**
  128848. * 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)
  128849. * @param uniformName Name of the variable.
  128850. * @param array array to be set.
  128851. */
  128852. setArray4(uniformName: string, array: number[]): void;
  128853. /**
  128854. * Sets matrices on a uniform variable.
  128855. * @param uniformName Name of the variable.
  128856. * @param matrices matrices to be set.
  128857. */
  128858. setMatrices(uniformName: string, matrices: Float32Array): void;
  128859. /**
  128860. * Sets matrix on a uniform variable.
  128861. * @param uniformName Name of the variable.
  128862. * @param matrix matrix to be set.
  128863. */
  128864. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  128865. /**
  128866. * 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)
  128867. * @param uniformName Name of the variable.
  128868. * @param matrix matrix to be set.
  128869. */
  128870. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  128871. /**
  128872. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  128873. * @param uniformName Name of the variable.
  128874. * @param matrix matrix to be set.
  128875. */
  128876. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  128877. /**
  128878. * Sets a float on a uniform variable.
  128879. * @param uniformName Name of the variable.
  128880. * @param value value to be set.
  128881. * @returns this effect.
  128882. */
  128883. setFloat(uniformName: string, value: number): void;
  128884. /**
  128885. * Sets a Vector2 on a uniform variable.
  128886. * @param uniformName Name of the variable.
  128887. * @param vector2 vector2 to be set.
  128888. */
  128889. setVector2(uniformName: string, vector2: IVector2Like): void;
  128890. /**
  128891. * Sets a float2 on a uniform variable.
  128892. * @param uniformName Name of the variable.
  128893. * @param x First float in float2.
  128894. * @param y Second float in float2.
  128895. */
  128896. setFloat2(uniformName: string, x: number, y: number): void;
  128897. /**
  128898. * Sets a Vector3 on a uniform variable.
  128899. * @param uniformName Name of the variable.
  128900. * @param vector3 Value to be set.
  128901. */
  128902. setVector3(uniformName: string, vector3: IVector3Like): void;
  128903. /**
  128904. * Sets a float3 on a uniform variable.
  128905. * @param uniformName Name of the variable.
  128906. * @param x First float in float3.
  128907. * @param y Second float in float3.
  128908. * @param z Third float in float3.
  128909. */
  128910. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  128911. /**
  128912. * Sets a Vector4 on a uniform variable.
  128913. * @param uniformName Name of the variable.
  128914. * @param vector4 Value to be set.
  128915. */
  128916. setVector4(uniformName: string, vector4: IVector4Like): void;
  128917. /**
  128918. * Sets a float4 on a uniform variable.
  128919. * @param uniformName Name of the variable.
  128920. * @param x First float in float4.
  128921. * @param y Second float in float4.
  128922. * @param z Third float in float4.
  128923. * @param w Fourth float in float4.
  128924. * @returns this effect.
  128925. */
  128926. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  128927. /**
  128928. * Sets a Color3 on a uniform variable.
  128929. * @param uniformName Name of the variable.
  128930. * @param color3 Value to be set.
  128931. */
  128932. setColor3(uniformName: string, color3: IColor3Like): void;
  128933. /**
  128934. * Sets a Color4 on a uniform variable.
  128935. * @param uniformName Name of the variable.
  128936. * @param color3 Value to be set.
  128937. * @param alpha Alpha value to be set.
  128938. */
  128939. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  128940. /**
  128941. * Sets a Color4 on a uniform variable
  128942. * @param uniformName defines the name of the variable
  128943. * @param color4 defines the value to be set
  128944. */
  128945. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  128946. _getVertexShaderCode(): string | null;
  128947. _getFragmentShaderCode(): string | null;
  128948. }
  128949. }
  128950. declare module BABYLON {
  128951. /** @hidden */
  128952. export class WebGPUDataBuffer extends DataBuffer {
  128953. private _buffer;
  128954. constructor(resource: GPUBuffer);
  128955. get underlyingResource(): any;
  128956. }
  128957. }
  128958. declare module BABYLON {
  128959. /**
  128960. * Class used to inline functions in shader code
  128961. */
  128962. export class ShaderCodeInliner {
  128963. private static readonly _RegexpFindFunctionNameAndType;
  128964. private _sourceCode;
  128965. private _functionDescr;
  128966. private _numMaxIterations;
  128967. /** Gets or sets the token used to mark the functions to inline */
  128968. inlineToken: string;
  128969. /** Gets or sets the debug mode */
  128970. debug: boolean;
  128971. /** Gets the code after the inlining process */
  128972. get code(): string;
  128973. /**
  128974. * Initializes the inliner
  128975. * @param sourceCode shader code source to inline
  128976. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128977. */
  128978. constructor(sourceCode: string, numMaxIterations?: number);
  128979. /**
  128980. * Start the processing of the shader code
  128981. */
  128982. processCode(): void;
  128983. private _collectFunctions;
  128984. private _processInlining;
  128985. private _extractBetweenMarkers;
  128986. private _skipWhitespaces;
  128987. private _isIdentifierChar;
  128988. private _removeComments;
  128989. private _replaceFunctionCallsByCode;
  128990. private _findBackward;
  128991. private _escapeRegExp;
  128992. private _replaceNames;
  128993. }
  128994. }
  128995. declare module BABYLON {
  128996. /** @hidden */
  128997. export class WebGPUShaderProcessor implements IShaderProcessor {
  128998. protected _missingVaryings: Array<string>;
  128999. protected _textureArrayProcessing: Array<string>;
  129000. protected _preProcessors: {
  129001. [key: string]: string;
  129002. };
  129003. private _getArraySize;
  129004. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  129005. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  129006. [key: string]: string;
  129007. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129008. attributeProcessor(attribute: string, preProcessors: {
  129009. [key: string]: string;
  129010. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129011. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  129012. [key: string]: string;
  129013. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129014. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129015. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129016. private _applyTextureArrayProcessing;
  129017. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  129018. vertexCode: string;
  129019. fragmentCode: string;
  129020. };
  129021. }
  129022. }
  129023. declare module BABYLON {
  129024. /** @hidden */
  129025. export class WebGPUBufferManager {
  129026. private _device;
  129027. private _deferredReleaseBuffers;
  129028. private static _IsGPUBuffer;
  129029. constructor(device: GPUDevice);
  129030. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  129031. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  129032. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  129033. private _FromHalfFloat;
  129034. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  129035. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  129036. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  129037. destroyDeferredBuffers(): void;
  129038. }
  129039. }
  129040. declare module BABYLON {
  129041. /** @hidden */
  129042. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  129043. private _webgpuTexture;
  129044. private _webgpuMSAATexture;
  129045. get underlyingResource(): Nullable<GPUTexture>;
  129046. get msaaTexture(): Nullable<GPUTexture>;
  129047. set msaaTexture(texture: Nullable<GPUTexture>);
  129048. view: Nullable<GPUTextureView>;
  129049. format: GPUTextureFormat;
  129050. textureUsages: number;
  129051. constructor(existingTexture?: Nullable<GPUTexture>);
  129052. set(hardwareTexture: GPUTexture): void;
  129053. setMSAATexture(hardwareTexture: GPUTexture): void;
  129054. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  129055. createView(descriptor?: GPUTextureViewDescriptor): void;
  129056. reset(): void;
  129057. release(): void;
  129058. }
  129059. }
  129060. declare module BABYLON {
  129061. /** @hidden */
  129062. export class WebGPUTextureHelper {
  129063. private _device;
  129064. private _glslang;
  129065. private _bufferManager;
  129066. private _mipmapSampler;
  129067. private _invertYPreMultiplyAlphaSampler;
  129068. private _pipelines;
  129069. private _compiledShaders;
  129070. private _deferredReleaseTextures;
  129071. private _commandEncoderForCreation;
  129072. static ComputeNumMipmapLevels(width: number, height: number): number;
  129073. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  129074. private _getPipeline;
  129075. private static _GetTextureTypeFromFormat;
  129076. private static _GetBlockInformationFromFormat;
  129077. private static _IsHardwareTexture;
  129078. private static _IsInternalTexture;
  129079. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  129080. static IsImageBitmap(imageBitmap: ImageBitmap | {
  129081. width: number;
  129082. height: number;
  129083. }): imageBitmap is ImageBitmap;
  129084. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  129085. width: number;
  129086. height: number;
  129087. }): imageBitmap is ImageBitmap[];
  129088. setCommandEncoder(encoder: GPUCommandEncoder): void;
  129089. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  129090. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  129091. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129092. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  129093. createTexture(imageBitmap: ImageBitmap | {
  129094. width: number;
  129095. height: number;
  129096. layers: number;
  129097. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129098. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  129099. width: number;
  129100. height: number;
  129101. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129102. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  129103. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129104. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  129105. createMSAATexture(texture: InternalTexture, samples: number): void;
  129106. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  129107. 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;
  129108. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  129109. releaseTexture(texture: InternalTexture | GPUTexture): void;
  129110. destroyDeferredTextures(): void;
  129111. }
  129112. }
  129113. declare module BABYLON {
  129114. /** @hidden */
  129115. export class WebGPURenderPassWrapper {
  129116. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  129117. renderPass: Nullable<GPURenderPassEncoder>;
  129118. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129119. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129120. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  129121. depthTextureFormat: GPUTextureFormat | undefined;
  129122. constructor();
  129123. reset(fullReset?: boolean): void;
  129124. }
  129125. }
  129126. declare module BABYLON {
  129127. /** @hidden */
  129128. export class WebGPUCacheSampler {
  129129. private _samplers;
  129130. private _device;
  129131. constructor(device: GPUDevice);
  129132. private static _GetSamplerHashCode;
  129133. private static _GetSamplerFilterDescriptor;
  129134. private static _GetWrappingMode;
  129135. private static _GetSamplerWrappingDescriptor;
  129136. private static _GetSamplerDescriptor;
  129137. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  129138. }
  129139. }
  129140. declare module BABYLON {
  129141. /** @hidden */
  129142. export class WebGPUShaderManager {
  129143. private _shaders;
  129144. private _device;
  129145. constructor(device: GPUDevice);
  129146. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  129147. }
  129148. }
  129149. declare module BABYLON {
  129150. /** @hidden */
  129151. export var clearQuadVertexShader: {
  129152. name: string;
  129153. shader: string;
  129154. };
  129155. }
  129156. declare module BABYLON {
  129157. /** @hidden */
  129158. export var clearQuadPixelShader: {
  129159. name: string;
  129160. shader: string;
  129161. };
  129162. }
  129163. declare module BABYLON {
  129164. /**
  129165. * Options to load the associated Glslang library
  129166. */
  129167. export interface GlslangOptions {
  129168. /**
  129169. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  129170. */
  129171. glslang?: any;
  129172. /**
  129173. * Defines the URL of the glslang JS File.
  129174. */
  129175. jsPath?: string;
  129176. /**
  129177. * Defines the URL of the glslang WASM File.
  129178. */
  129179. wasmPath?: string;
  129180. }
  129181. /**
  129182. * Options to create the WebGPU engine
  129183. */
  129184. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  129185. /**
  129186. * If delta time between frames should be constant
  129187. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129188. */
  129189. deterministicLockstep?: boolean;
  129190. /**
  129191. * Maximum about of steps between frames (Default: 4)
  129192. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129193. */
  129194. lockstepMaxSteps?: number;
  129195. /**
  129196. * Defines the seconds between each deterministic lock step
  129197. */
  129198. timeStep?: number;
  129199. /**
  129200. * Defines that engine should ignore modifying touch action attribute and style
  129201. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  129202. */
  129203. doNotHandleTouchAction?: boolean;
  129204. /**
  129205. * Defines if webaudio should be initialized as well
  129206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  129207. */
  129208. audioEngine?: boolean;
  129209. /**
  129210. * Defines the category of adapter to use.
  129211. * Is it the discrete or integrated device.
  129212. */
  129213. powerPreference?: GPUPowerPreference;
  129214. /**
  129215. * Defines the device descriptor used to create a device.
  129216. */
  129217. deviceDescriptor?: GPUDeviceDescriptor;
  129218. /**
  129219. * Defines the requested Swap Chain Format.
  129220. */
  129221. swapChainFormat?: GPUTextureFormat;
  129222. /**
  129223. * Defines wether MSAA is enabled on the canvas.
  129224. */
  129225. antialiasing?: boolean;
  129226. /**
  129227. * Defines wether the stencil buffer should be enabled.
  129228. */
  129229. stencil?: boolean;
  129230. /**
  129231. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  129232. */
  129233. enableGPUDebugMarkers?: boolean;
  129234. }
  129235. /**
  129236. * The web GPU engine class provides support for WebGPU version of babylon.js.
  129237. */
  129238. export class WebGPUEngine extends Engine {
  129239. private static readonly _glslangDefaultOptions;
  129240. private readonly _uploadEncoderDescriptor;
  129241. private readonly _renderEncoderDescriptor;
  129242. private readonly _renderTargetEncoderDescriptor;
  129243. private readonly _clearDepthValue;
  129244. private readonly _clearReverseDepthValue;
  129245. private readonly _clearStencilValue;
  129246. private readonly _defaultSampleCount;
  129247. private _canvas;
  129248. private _options;
  129249. private _glslang;
  129250. private _adapter;
  129251. private _adapterSupportedExtensions;
  129252. private _device;
  129253. private _deviceEnabledExtensions;
  129254. private _context;
  129255. private _swapChain;
  129256. private _swapChainTexture;
  129257. private _mainPassSampleCount;
  129258. private _textureHelper;
  129259. private _bufferManager;
  129260. private _shaderManager;
  129261. private _cacheSampler;
  129262. private _emptyVertexBuffer;
  129263. private _lastCachedWrapU;
  129264. private _lastCachedWrapV;
  129265. private _lastCachedWrapR;
  129266. private _mrtAttachments;
  129267. private _counters;
  129268. private _mainTexture;
  129269. private _depthTexture;
  129270. private _mainTextureExtends;
  129271. private _depthTextureFormat;
  129272. private _colorFormat;
  129273. private _uploadEncoder;
  129274. private _renderEncoder;
  129275. private _renderTargetEncoder;
  129276. private _commandBuffers;
  129277. private _currentRenderPass;
  129278. private _mainRenderPassWrapper;
  129279. private _rttRenderPassWrapper;
  129280. private _pendingDebugCommands;
  129281. private _currentVertexBuffers;
  129282. private _currentIndexBuffer;
  129283. private __colorWrite;
  129284. private _uniformsBuffers;
  129285. private _forceEnableEffect;
  129286. /** @hidden */
  129287. dbgShowShaderCode: boolean;
  129288. /** @hidden */
  129289. dbgSanityChecks: boolean;
  129290. /** @hidden */
  129291. dbgGenerateLogs: boolean;
  129292. /** @hidden */
  129293. dbgVerboseLogsForFirstFrames: boolean;
  129294. /** @hidden */
  129295. dbgVerboseLogsNumFrames: number;
  129296. /** @hidden */
  129297. dbgShowWarningsNotImplemented: boolean;
  129298. /**
  129299. * Gets a boolean indicating that the engine supports uniform buffers
  129300. */
  129301. get supportsUniformBuffers(): boolean;
  129302. /** Gets the supported extensions by the WebGPU adapter */
  129303. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  129304. /** Gets the currently enabled extensions on the WebGPU device */
  129305. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  129306. /**
  129307. * Returns the name of the engine
  129308. */
  129309. get name(): string;
  129310. /**
  129311. * Returns a string describing the current engine
  129312. */
  129313. get description(): string;
  129314. /**
  129315. * Returns the version of the engine
  129316. */
  129317. get version(): number;
  129318. /**
  129319. * Create a new instance of the gpu engine.
  129320. * @param canvas Defines the canvas to use to display the result
  129321. * @param options Defines the options passed to the engine to create the GPU context dependencies
  129322. */
  129323. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  129324. /**
  129325. * Initializes the WebGPU context and dependencies.
  129326. * @param glslangOptions Defines the GLSLang compiler options if necessary
  129327. * @returns a promise notifying the readiness of the engine.
  129328. */
  129329. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  129330. private _initGlslang;
  129331. private _initializeLimits;
  129332. private _initializeContextAndSwapChain;
  129333. private _initializeMainAttachments;
  129334. /**
  129335. * Force a specific size of the canvas
  129336. * @param width defines the new canvas' width
  129337. * @param height defines the new canvas' height
  129338. * @param forceSetSize true to force setting the sizes of the underlying canvas
  129339. * @returns true if the size was changed
  129340. */
  129341. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  129342. /**
  129343. * Gets a shader processor implementation fitting with the current engine type.
  129344. * @returns The shader processor implementation.
  129345. */
  129346. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  129347. /** @hidden */
  129348. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  129349. /**
  129350. * Force the entire cache to be cleared
  129351. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  129352. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129353. */
  129354. wipeCaches(bruteForce?: boolean): void;
  129355. /**
  129356. * Enable or disable color writing
  129357. * @param enable defines the state to set
  129358. */
  129359. setColorWrite(enable: boolean): void;
  129360. /**
  129361. * Gets a boolean indicating if color writing is enabled
  129362. * @returns the current color writing state
  129363. */
  129364. getColorWrite(): boolean;
  129365. private _viewportsCurrent;
  129366. private _resetCurrentViewport;
  129367. private _applyViewport;
  129368. /** @hidden */
  129369. _viewport(x: number, y: number, width: number, height: number): void;
  129370. private _scissorsCurrent;
  129371. protected _scissorCached: {
  129372. x: number;
  129373. y: number;
  129374. z: number;
  129375. w: number;
  129376. };
  129377. private _resetCurrentScissor;
  129378. private _applyScissor;
  129379. private _scissorIsActive;
  129380. enableScissor(x: number, y: number, width: number, height: number): void;
  129381. disableScissor(): void;
  129382. /**
  129383. * Clear the current render buffer or the current render target (if any is set up)
  129384. * @param color defines the color to use
  129385. * @param backBuffer defines if the back buffer must be cleared
  129386. * @param depth defines if the depth buffer must be cleared
  129387. * @param stencil defines if the stencil buffer must be cleared
  129388. */
  129389. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129390. /**
  129391. * Creates a vertex buffer
  129392. * @param data the data for the vertex buffer
  129393. * @returns the new buffer
  129394. */
  129395. createVertexBuffer(data: DataArray): DataBuffer;
  129396. /**
  129397. * Creates a vertex buffer
  129398. * @param data the data for the dynamic vertex buffer
  129399. * @returns the new buffer
  129400. */
  129401. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129402. /**
  129403. * Updates a vertex buffer.
  129404. * @param vertexBuffer the vertex buffer to update
  129405. * @param data the data used to update the vertex buffer
  129406. * @param byteOffset the byte offset of the data
  129407. * @param byteLength the byte length of the data
  129408. */
  129409. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129410. /**
  129411. * Creates a new index buffer
  129412. * @param indices defines the content of the index buffer
  129413. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  129414. * @returns a new buffer
  129415. */
  129416. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  129417. /**
  129418. * Update an index buffer
  129419. * @param indexBuffer defines the target index buffer
  129420. * @param indices defines the data to update
  129421. * @param offset defines the offset in the target index buffer where update should start
  129422. */
  129423. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129424. /** @hidden */
  129425. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  129426. /** @hidden */
  129427. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  129428. /**
  129429. * Bind a list of vertex buffers with the engine
  129430. * @param vertexBuffers defines the list of vertex buffers to bind
  129431. * @param indexBuffer defines the index buffer to bind
  129432. * @param effect defines the effect associated with the vertex buffers
  129433. */
  129434. bindBuffers(vertexBuffers: {
  129435. [key: string]: Nullable<VertexBuffer>;
  129436. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  129437. /** @hidden */
  129438. _releaseBuffer(buffer: DataBuffer): boolean;
  129439. createUniformBuffer(elements: FloatArray): DataBuffer;
  129440. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  129441. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  129442. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  129443. /**
  129444. * Create a new effect (used to store vertex/fragment shaders)
  129445. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  129446. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  129447. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  129448. * @param samplers defines an array of string used to represent textures
  129449. * @param defines defines the string containing the defines to use to compile the shaders
  129450. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  129451. * @param onCompiled defines a function to call when the effect creation is successful
  129452. * @param onError defines a function to call when the effect creation has failed
  129453. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  129454. * @returns the new Effect
  129455. */
  129456. 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;
  129457. private _compileRawShaderToSpirV;
  129458. private _compileShaderToSpirV;
  129459. private _createPipelineStageDescriptor;
  129460. private _compileRawPipelineStageDescriptor;
  129461. private _compilePipelineStageDescriptor;
  129462. /** @hidden */
  129463. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  129464. /** @hidden */
  129465. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  129466. /**
  129467. * Creates a new pipeline context
  129468. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  129469. * @returns the new pipeline
  129470. */
  129471. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  129472. /** @hidden */
  129473. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  129474. /**
  129475. * Gets the list of active attributes for a given WebGPU program
  129476. * @param pipelineContext defines the pipeline context to use
  129477. * @param attributesNames defines the list of attribute names to get
  129478. * @returns an array of indices indicating the offset of each attribute
  129479. */
  129480. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129481. /**
  129482. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  129483. * @param effect defines the effect to activate
  129484. */
  129485. enableEffect(effect: Nullable<Effect>): void;
  129486. /** @hidden */
  129487. _releaseEffect(effect: Effect): void;
  129488. /**
  129489. * 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
  129490. */
  129491. releaseEffects(): void;
  129492. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129493. /**
  129494. * Gets a boolean indicating that only power of 2 textures are supported
  129495. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  129496. */
  129497. get needPOTTextures(): boolean;
  129498. /** @hidden */
  129499. _createHardwareTexture(): HardwareTextureWrapper;
  129500. /** @hidden */
  129501. _releaseTexture(texture: InternalTexture): void;
  129502. /** @hidden */
  129503. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  129504. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  129505. /**
  129506. * Usually called from Texture.ts.
  129507. * Passed information to create a hardware texture
  129508. * @param url defines a value which contains one of the following:
  129509. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129510. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129511. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129512. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129513. * @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)
  129514. * @param scene needed for loading to the correct scene
  129515. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129516. * @param onLoad optional callback to be called upon successful completion
  129517. * @param onError optional callback to be called upon failure
  129518. * @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
  129519. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129520. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129521. * @param forcedExtension defines the extension to use to pick the right loader
  129522. * @param mimeType defines an optional mime type
  129523. * @param loaderOptions options to be passed to the loader
  129524. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129525. */
  129526. 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;
  129527. /** @hidden */
  129528. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  129529. /**
  129530. * Creates a cube texture
  129531. * @param rootUrl defines the url where the files to load is located
  129532. * @param scene defines the current scene
  129533. * @param files defines the list of files to load (1 per face)
  129534. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129535. * @param onLoad defines an optional callback raised when the texture is loaded
  129536. * @param onError defines an optional callback raised if there is an issue to load the texture
  129537. * @param format defines the format of the data
  129538. * @param forcedExtension defines the extension to use to pick the right loader
  129539. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129540. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129541. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129542. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129543. * @param loaderOptions options to be passed to the loader
  129544. * @returns the cube texture as an InternalTexture
  129545. */
  129546. 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;
  129547. /**
  129548. * Creates a raw texture
  129549. * @param data defines the data to store in the texture
  129550. * @param width defines the width of the texture
  129551. * @param height defines the height of the texture
  129552. * @param format defines the format of the data
  129553. * @param generateMipMaps defines if the engine should generate the mip levels
  129554. * @param invertY defines if data must be stored with Y axis inverted
  129555. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  129556. * @param compression defines the compression used (null by default)
  129557. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129558. * @returns the raw texture inside an InternalTexture
  129559. */
  129560. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  129561. /**
  129562. * Creates a new raw cube texture
  129563. * @param data defines the array of data to use to create each face
  129564. * @param size defines the size of the textures
  129565. * @param format defines the format of the data
  129566. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129567. * @param generateMipMaps defines if the engine should generate the mip levels
  129568. * @param invertY defines if data must be stored with Y axis inverted
  129569. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129570. * @param compression defines the compression used (null by default)
  129571. * @returns the cube texture as an InternalTexture
  129572. */
  129573. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  129574. /**
  129575. * Creates a new raw cube texture from a specified url
  129576. * @param url defines the url where the data is located
  129577. * @param scene defines the current scene
  129578. * @param size defines the size of the textures
  129579. * @param format defines the format of the data
  129580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129581. * @param noMipmap defines if the engine should avoid generating the mip levels
  129582. * @param callback defines a callback used to extract texture data from loaded data
  129583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  129584. * @param onLoad defines a callback called when texture is loaded
  129585. * @param onError defines a callback called if there is an error
  129586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129587. * @param invertY defines if data must be stored with Y axis inverted
  129588. * @returns the cube texture as an InternalTexture
  129589. */
  129590. 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;
  129591. /**
  129592. * Creates a new raw 2D array texture
  129593. * @param data defines the data used to create the texture
  129594. * @param width defines the width of the texture
  129595. * @param height defines the height of the texture
  129596. * @param depth defines the number of layers of the texture
  129597. * @param format defines the format of the texture
  129598. * @param generateMipMaps defines if the engine must generate mip levels
  129599. * @param invertY defines if data must be stored with Y axis inverted
  129600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129601. * @param compression defines the compressed used (can be null)
  129602. * @param textureType defines the compressed used (can be null)
  129603. * @returns a new raw 2D array texture (stored in an InternalTexture)
  129604. */
  129605. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  129606. /**
  129607. * Creates a new raw 3D texture
  129608. * @param data defines the data used to create the texture
  129609. * @param width defines the width of the texture
  129610. * @param height defines the height of the texture
  129611. * @param depth defines the depth of the texture
  129612. * @param format defines the format of the texture
  129613. * @param generateMipMaps defines if the engine must generate mip levels
  129614. * @param invertY defines if data must be stored with Y axis inverted
  129615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129616. * @param compression defines the compressed used (can be null)
  129617. * @param textureType defines the compressed used (can be null)
  129618. * @returns a new raw 3D texture (stored in an InternalTexture)
  129619. */
  129620. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  129621. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  129622. /**
  129623. * Update the sampling mode of a given texture
  129624. * @param samplingMode defines the required sampling mode
  129625. * @param texture defines the texture to update
  129626. * @param generateMipMaps defines whether to generate mipmaps for the texture
  129627. */
  129628. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  129629. /**
  129630. * Update the sampling mode of a given texture
  129631. * @param texture defines the texture to update
  129632. * @param wrapU defines the texture wrap mode of the u coordinates
  129633. * @param wrapV defines the texture wrap mode of the v coordinates
  129634. * @param wrapR defines the texture wrap mode of the r coordinates
  129635. */
  129636. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  129637. /**
  129638. * Update the dimensions of a texture
  129639. * @param texture texture to update
  129640. * @param width new width of the texture
  129641. * @param height new height of the texture
  129642. * @param depth new depth of the texture
  129643. */
  129644. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  129645. private _setInternalTexture;
  129646. /**
  129647. * Sets a texture to the according uniform.
  129648. * @param channel The texture channel
  129649. * @param unused unused parameter
  129650. * @param texture The texture to apply
  129651. * @param name The name of the uniform in the effect
  129652. */
  129653. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  129654. /**
  129655. * Sets an array of texture to the WebGPU context
  129656. * @param channel defines the channel where the texture array must be set
  129657. * @param unused unused parameter
  129658. * @param textures defines the array of textures to bind
  129659. * @param name name of the channel
  129660. */
  129661. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  129662. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  129663. /** @hidden */
  129664. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  129665. /** @hidden */
  129666. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  129667. private _generateMipmaps;
  129668. /**
  129669. * Update the content of a texture
  129670. * @param texture defines the texture to update
  129671. * @param canvas defines the source containing the data
  129672. * @param invertY defines if data must be stored with Y axis inverted
  129673. * @param premulAlpha defines if alpha is stored as premultiplied
  129674. * @param format defines the format of the data
  129675. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129676. */
  129677. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  129678. /**
  129679. * Update a portion of an internal texture
  129680. * @param texture defines the texture to update
  129681. * @param imageData defines the data to store into the texture
  129682. * @param xOffset defines the x coordinates of the update rectangle
  129683. * @param yOffset defines the y coordinates of the update rectangle
  129684. * @param width defines the width of the update rectangle
  129685. * @param height defines the height of the update rectangle
  129686. * @param faceIndex defines the face index if texture is a cube (0 by default)
  129687. * @param lod defines the lod level to update (0 by default)
  129688. */
  129689. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  129690. /**
  129691. * Update a video texture
  129692. * @param texture defines the texture to update
  129693. * @param video defines the video element to use
  129694. * @param invertY defines if data must be stored with Y axis inverted
  129695. */
  129696. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  129697. /** @hidden */
  129698. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129699. /** @hidden */
  129700. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  129701. /** @hidden */
  129702. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129703. /** @hidden */
  129704. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  129705. /**
  129706. * Update a raw texture
  129707. * @param texture defines the texture to update
  129708. * @param bufferView defines the data to store in the texture
  129709. * @param format defines the format of the data
  129710. * @param invertY defines if data must be stored with Y axis inverted
  129711. * @param compression defines the compression used (null by default)
  129712. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129713. */
  129714. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  129715. /**
  129716. * Update a raw cube texture
  129717. * @param texture defines the texture to udpdate
  129718. * @param bufferView defines the data to store
  129719. * @param format defines the data format
  129720. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129721. * @param invertY defines if data must be stored with Y axis inverted
  129722. * @param compression defines the compression used (null by default)
  129723. * @param level defines which level of the texture to update
  129724. */
  129725. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  129726. /**
  129727. * Update a raw 2D array texture
  129728. * @param texture defines the texture to update
  129729. * @param bufferView defines the data to store
  129730. * @param format defines the data format
  129731. * @param invertY defines if data must be stored with Y axis inverted
  129732. * @param compression defines the used compression (can be null)
  129733. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129734. */
  129735. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  129736. /**
  129737. * Update a raw 3D texture
  129738. * @param texture defines the texture to update
  129739. * @param bufferView defines the data to store
  129740. * @param format defines the data format
  129741. * @param invertY defines if data must be stored with Y axis inverted
  129742. * @param compression defines the used compression (can be null)
  129743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129744. */
  129745. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  129746. /**
  129747. * Reads pixels from the current frame buffer. Please note that this function can be slow
  129748. * @param x defines the x coordinate of the rectangle where pixels must be read
  129749. * @param y defines the y coordinate of the rectangle where pixels must be read
  129750. * @param width defines the width of the rectangle where pixels must be read
  129751. * @param height defines the height of the rectangle where pixels must be read
  129752. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  129753. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  129754. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  129755. */
  129756. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  129757. /** @hidden */
  129758. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  129759. /**
  129760. * Creates a new render target texture
  129761. * @param size defines the size of the texture
  129762. * @param options defines the options used to create the texture
  129763. * @returns a new render target texture stored in an InternalTexture
  129764. */
  129765. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129766. /**
  129767. * Create a multi render target texture
  129768. * @param size defines the size of the texture
  129769. * @param options defines the creation options
  129770. * @returns the cube texture as an InternalTexture
  129771. */
  129772. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129773. /**
  129774. * Creates a new render target cube texture
  129775. * @param size defines the size of the texture
  129776. * @param options defines the options used to create the texture
  129777. * @returns a new render target cube texture stored in an InternalTexture
  129778. */
  129779. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  129780. /** @hidden */
  129781. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  129782. width: number;
  129783. height: number;
  129784. layers?: number;
  129785. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  129786. /** @hidden */
  129787. _createDepthStencilTexture(size: number | {
  129788. width: number;
  129789. height: number;
  129790. layers?: number;
  129791. }, options: DepthTextureCreationOptions): InternalTexture;
  129792. /** @hidden */
  129793. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  129794. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  129795. /**
  129796. * Update the sample count for a given multiple render target texture
  129797. * @param textures defines the textures to update
  129798. * @param samples defines the sample count to set
  129799. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129800. */
  129801. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129802. /**
  129803. * Begin a new frame
  129804. */
  129805. beginFrame(): void;
  129806. /**
  129807. * End the current frame
  129808. */
  129809. endFrame(): void;
  129810. /**
  129811. * Force a WebGPU flush (ie. a flush of all waiting commands)
  129812. */
  129813. flushFramebuffer(): void;
  129814. private _startRenderTargetRenderPass;
  129815. private _endRenderTargetRenderPass;
  129816. private _getCurrentRenderPass;
  129817. private _currentRenderPassIsMRT;
  129818. private _startMainRenderPass;
  129819. private _endMainRenderPass;
  129820. /**
  129821. * Restores the WebGPU state to only draw on the main color attachment
  129822. */
  129823. restoreSingleAttachment(): void;
  129824. /**
  129825. * Creates a layout object to draw/clear on specific textures in a MRT
  129826. * @param textureStatus textureStatus[i] indicates if the i-th is active
  129827. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  129828. */
  129829. buildTextureLayout(textureStatus: boolean[]): number[];
  129830. /**
  129831. * Select a subsets of attachments to draw to.
  129832. * @param attachments index of attachments
  129833. */
  129834. bindAttachments(attachments: number[]): void;
  129835. /**
  129836. * Binds the frame buffer to the specified texture.
  129837. * @param texture The texture to render to or null for the default canvas
  129838. * @param faceIndex The face of the texture to render to in case of cube texture
  129839. * @param requiredWidth The width of the target to render to
  129840. * @param requiredHeight The height of the target to render to
  129841. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129842. * @param lodLevel defines the lod level to bind to the frame buffer
  129843. * @param layer defines the 2d array index to bind to frame buffer to
  129844. */
  129845. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  129846. /**
  129847. * Unbind the current render target texture from the WebGPU context
  129848. * @param texture defines the render target texture to unbind
  129849. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129850. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129851. */
  129852. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129853. /**
  129854. * Unbind a list of render target textures from the WebGPU context
  129855. * @param textures defines the render target textures to unbind
  129856. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129857. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129858. */
  129859. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129860. /**
  129861. * Unbind the current render target and bind the default framebuffer
  129862. */
  129863. restoreDefaultFramebuffer(): void;
  129864. setZOffset(value: number): void;
  129865. private _setColorFormat;
  129866. private _setDepthTextureFormat;
  129867. setDepthBuffer(enable: boolean): void;
  129868. setDepthWrite(enable: boolean): void;
  129869. setStencilBuffer(enable: boolean): void;
  129870. setStencilMask(mask: number): void;
  129871. setStencilFunction(stencilFunc: number): void;
  129872. setStencilFunctionReference(reference: number): void;
  129873. setStencilFunctionMask(mask: number): void;
  129874. setStencilOperationFail(operation: number): void;
  129875. setStencilOperationDepthFail(operation: number): void;
  129876. setStencilOperationPass(operation: number): void;
  129877. setDitheringState(value: boolean): void;
  129878. setRasterizerState(value: boolean): void;
  129879. setDepthFunction(depthFunc: number): void;
  129880. setDepthFunctionToGreater(): void;
  129881. setDepthFunctionToGreaterOrEqual(): void;
  129882. setDepthFunctionToLess(): void;
  129883. setDepthFunctionToLessOrEqual(): void;
  129884. private _indexFormatInRenderPass;
  129885. private _getTopology;
  129886. private _getOpFunction;
  129887. private _getDepthStencilStateDescriptor;
  129888. /**
  129889. * Set various states to the context
  129890. * @param culling defines backface culling state
  129891. * @param zOffset defines the value to apply to zOffset (0 by default)
  129892. * @param force defines if states must be applied even if cache is up to date
  129893. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  129894. */
  129895. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129896. private _getFrontFace;
  129897. private _getCullMode;
  129898. private _getRasterizationStateDescriptor;
  129899. private _getWriteMask;
  129900. /**
  129901. * Sets the current alpha mode
  129902. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129903. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129904. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129905. */
  129906. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129907. private _getAphaBlendOperation;
  129908. private _getAphaBlendFactor;
  129909. private _getAphaBlendState;
  129910. private _getColorBlendState;
  129911. private _getColorStateDescriptors;
  129912. private _getStages;
  129913. private _getVertexInputDescriptorFormat;
  129914. private _getVertexInputDescriptor;
  129915. private _getPipelineLayout;
  129916. private _getRenderPipeline;
  129917. private _getVertexInputsToRender;
  129918. private _getBindGroupsToRender;
  129919. private _bindVertexInputs;
  129920. private _setRenderBindGroups;
  129921. private _setRenderPipeline;
  129922. /**
  129923. * Draw a list of indexed primitives
  129924. * @param fillMode defines the primitive to use
  129925. * @param indexStart defines the starting index
  129926. * @param indexCount defines the number of index to draw
  129927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129928. */
  129929. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129930. /**
  129931. * Draw a list of unindexed primitives
  129932. * @param fillMode defines the primitive to use
  129933. * @param verticesStart defines the index of first vertex to draw
  129934. * @param verticesCount defines the count of vertices to draw
  129935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129936. */
  129937. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129938. private _bundleEncoder;
  129939. /**
  129940. * Start recording all the gpu calls into a bundle.
  129941. */
  129942. startRecordBundle(): void;
  129943. /**
  129944. * Stops recording the bundle.
  129945. * @returns the recorded bundle
  129946. */
  129947. stopRecordBundle(): GPURenderBundle;
  129948. /**
  129949. * Execute the previously recorded bundle.
  129950. * @param bundles defines the bundle to replay
  129951. */
  129952. executeBundles(bundles: GPURenderBundle[]): void;
  129953. /**
  129954. * Dispose and release all associated resources
  129955. */
  129956. dispose(): void;
  129957. /**
  129958. * Gets the current render width
  129959. * @param useScreen defines if screen size must be used (or the current render target if any)
  129960. * @returns a number defining the current render width
  129961. */
  129962. getRenderWidth(useScreen?: boolean): number;
  129963. /**
  129964. * Gets the current render height
  129965. * @param useScreen defines if screen size must be used (or the current render target if any)
  129966. * @returns a number defining the current render height
  129967. */
  129968. getRenderHeight(useScreen?: boolean): number;
  129969. /**
  129970. * Gets the HTML canvas attached with the current WebGPU context
  129971. * @returns a HTML canvas
  129972. */
  129973. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  129974. /** @hidden */
  129975. _debugPushGroup(groupName: string, targetObject?: number): void;
  129976. /** @hidden */
  129977. _debugPopGroup(targetObject?: number): void;
  129978. /** @hidden */
  129979. _debugInsertMarker(text: string, targetObject?: number): void;
  129980. private _debugFlushPendingCommands;
  129981. /**
  129982. * Get the current error code of the WebGPU context
  129983. * @returns the error code
  129984. */
  129985. getError(): number;
  129986. /** @hidden */
  129987. bindSamplers(effect: Effect): void;
  129988. /** @hidden */
  129989. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  129990. /** @hidden */
  129991. _releaseFramebufferObjects(texture: InternalTexture): void;
  129992. /** @hidden */
  129993. applyStates(): void;
  129994. /**
  129995. * Gets a boolean indicating if all created effects are ready
  129996. * @returns always true - No parallel shader compilation
  129997. */
  129998. areAllEffectsReady(): boolean;
  129999. /** @hidden */
  130000. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130001. /** @hidden */
  130002. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130003. /** @hidden */
  130004. _getUnpackAlignement(): number;
  130005. /** @hidden */
  130006. _unpackFlipY(value: boolean): void;
  130007. /** @hidden */
  130008. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  130009. min: number;
  130010. mag: number;
  130011. };
  130012. /** @hidden */
  130013. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130014. /** @hidden */
  130015. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130016. /** @hidden */
  130017. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130018. /** @hidden */
  130019. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130020. /** @hidden */
  130021. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130022. /** @hidden */
  130023. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130024. /** @hidden */
  130025. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  130026. /** @hidden */
  130027. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  130028. /** @hidden */
  130029. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  130030. /** @hidden */
  130031. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  130032. /** @hidden */
  130033. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  130034. /** @hidden */
  130035. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130036. /** @hidden */
  130037. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130038. /** @hidden */
  130039. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  130040. /** @hidden */
  130041. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  130042. /** @hidden */
  130043. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  130044. /** @hidden */
  130045. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  130046. }
  130047. }
  130048. declare module BABYLON {
  130049. /**
  130050. * Define an interface for all classes that will hold resources
  130051. */
  130052. export interface IDisposable {
  130053. /**
  130054. * Releases all held resources
  130055. */
  130056. dispose(): void;
  130057. }
  130058. /** Interface defining initialization parameters for Scene class */
  130059. export interface SceneOptions {
  130060. /**
  130061. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  130062. * It will improve performance when the number of geometries becomes important.
  130063. */
  130064. useGeometryUniqueIdsMap?: boolean;
  130065. /**
  130066. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  130067. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130068. */
  130069. useMaterialMeshMap?: boolean;
  130070. /**
  130071. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  130072. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130073. */
  130074. useClonedMeshMap?: boolean;
  130075. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  130076. virtual?: boolean;
  130077. }
  130078. /**
  130079. * Represents a scene to be rendered by the engine.
  130080. * @see https://doc.babylonjs.com/features/scene
  130081. */
  130082. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  130083. /** The fog is deactivated */
  130084. static readonly FOGMODE_NONE: number;
  130085. /** The fog density is following an exponential function */
  130086. static readonly FOGMODE_EXP: number;
  130087. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  130088. static readonly FOGMODE_EXP2: number;
  130089. /** The fog density is following a linear function. */
  130090. static readonly FOGMODE_LINEAR: number;
  130091. /**
  130092. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  130093. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130094. */
  130095. static MinDeltaTime: number;
  130096. /**
  130097. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  130098. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130099. */
  130100. static MaxDeltaTime: number;
  130101. /**
  130102. * Factory used to create the default material.
  130103. * @param name The name of the material to create
  130104. * @param scene The scene to create the material for
  130105. * @returns The default material
  130106. */
  130107. static DefaultMaterialFactory(scene: Scene): Material;
  130108. /**
  130109. * Factory used to create the a collision coordinator.
  130110. * @returns The collision coordinator
  130111. */
  130112. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  130113. /** @hidden */
  130114. _inputManager: InputManager;
  130115. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  130116. cameraToUseForPointers: Nullable<Camera>;
  130117. /** @hidden */
  130118. readonly _isScene: boolean;
  130119. /** @hidden */
  130120. _blockEntityCollection: boolean;
  130121. /**
  130122. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  130123. */
  130124. autoClear: boolean;
  130125. /**
  130126. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  130127. */
  130128. autoClearDepthAndStencil: boolean;
  130129. /**
  130130. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  130131. */
  130132. clearColor: Color4;
  130133. /**
  130134. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  130135. */
  130136. ambientColor: Color3;
  130137. /**
  130138. * This is use to store the default BRDF lookup for PBR materials in your scene.
  130139. * It should only be one of the following (if not the default embedded one):
  130140. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  130141. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  130142. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  130143. * The material properties need to be setup according to the type of texture in use.
  130144. */
  130145. environmentBRDFTexture: BaseTexture;
  130146. /**
  130147. * Texture used in all pbr material as the reflection texture.
  130148. * As in the majority of the scene they are the same (exception for multi room and so on),
  130149. * this is easier to reference from here than from all the materials.
  130150. */
  130151. get environmentTexture(): Nullable<BaseTexture>;
  130152. /**
  130153. * Texture used in all pbr material as the reflection texture.
  130154. * As in the majority of the scene they are the same (exception for multi room and so on),
  130155. * this is easier to set here than in all the materials.
  130156. */
  130157. set environmentTexture(value: Nullable<BaseTexture>);
  130158. /** @hidden */
  130159. protected _environmentIntensity: number;
  130160. /**
  130161. * Intensity of the environment in all pbr material.
  130162. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130163. * As in the majority of the scene they are the same (exception for multi room and so on),
  130164. * this is easier to reference from here than from all the materials.
  130165. */
  130166. get environmentIntensity(): number;
  130167. /**
  130168. * Intensity of the environment in all pbr material.
  130169. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130170. * As in the majority of the scene they are the same (exception for multi room and so on),
  130171. * this is easier to set here than in all the materials.
  130172. */
  130173. set environmentIntensity(value: number);
  130174. /** @hidden */
  130175. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130176. /**
  130177. * Default image processing configuration used either in the rendering
  130178. * Forward main pass or through the imageProcessingPostProcess if present.
  130179. * As in the majority of the scene they are the same (exception for multi camera),
  130180. * this is easier to reference from here than from all the materials and post process.
  130181. *
  130182. * No setter as we it is a shared configuration, you can set the values instead.
  130183. */
  130184. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130185. private _forceWireframe;
  130186. /**
  130187. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  130188. */
  130189. set forceWireframe(value: boolean);
  130190. get forceWireframe(): boolean;
  130191. private _skipFrustumClipping;
  130192. /**
  130193. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  130194. */
  130195. set skipFrustumClipping(value: boolean);
  130196. get skipFrustumClipping(): boolean;
  130197. private _forcePointsCloud;
  130198. /**
  130199. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  130200. */
  130201. set forcePointsCloud(value: boolean);
  130202. get forcePointsCloud(): boolean;
  130203. /**
  130204. * Gets or sets the active clipplane 1
  130205. */
  130206. clipPlane: Nullable<Plane>;
  130207. /**
  130208. * Gets or sets the active clipplane 2
  130209. */
  130210. clipPlane2: Nullable<Plane>;
  130211. /**
  130212. * Gets or sets the active clipplane 3
  130213. */
  130214. clipPlane3: Nullable<Plane>;
  130215. /**
  130216. * Gets or sets the active clipplane 4
  130217. */
  130218. clipPlane4: Nullable<Plane>;
  130219. /**
  130220. * Gets or sets the active clipplane 5
  130221. */
  130222. clipPlane5: Nullable<Plane>;
  130223. /**
  130224. * Gets or sets the active clipplane 6
  130225. */
  130226. clipPlane6: Nullable<Plane>;
  130227. /**
  130228. * Gets or sets a boolean indicating if animations are enabled
  130229. */
  130230. animationsEnabled: boolean;
  130231. private _animationPropertiesOverride;
  130232. /**
  130233. * Gets or sets the animation properties override
  130234. */
  130235. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  130236. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  130237. /**
  130238. * Gets or sets a boolean indicating if a constant deltatime has to be used
  130239. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  130240. */
  130241. useConstantAnimationDeltaTime: boolean;
  130242. /**
  130243. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  130244. * Please note that it requires to run a ray cast through the scene on every frame
  130245. */
  130246. constantlyUpdateMeshUnderPointer: boolean;
  130247. /**
  130248. * Defines the HTML cursor to use when hovering over interactive elements
  130249. */
  130250. hoverCursor: string;
  130251. /**
  130252. * Defines the HTML default cursor to use (empty by default)
  130253. */
  130254. defaultCursor: string;
  130255. /**
  130256. * Defines whether cursors are handled by the scene.
  130257. */
  130258. doNotHandleCursors: boolean;
  130259. /**
  130260. * This is used to call preventDefault() on pointer down
  130261. * in order to block unwanted artifacts like system double clicks
  130262. */
  130263. preventDefaultOnPointerDown: boolean;
  130264. /**
  130265. * This is used to call preventDefault() on pointer up
  130266. * in order to block unwanted artifacts like system double clicks
  130267. */
  130268. preventDefaultOnPointerUp: boolean;
  130269. /**
  130270. * Gets or sets user defined metadata
  130271. */
  130272. metadata: any;
  130273. /**
  130274. * For internal use only. Please do not use.
  130275. */
  130276. reservedDataStore: any;
  130277. /**
  130278. * Gets the name of the plugin used to load this scene (null by default)
  130279. */
  130280. loadingPluginName: string;
  130281. /**
  130282. * Use this array to add regular expressions used to disable offline support for specific urls
  130283. */
  130284. disableOfflineSupportExceptionRules: RegExp[];
  130285. /**
  130286. * An event triggered when the scene is disposed.
  130287. */
  130288. onDisposeObservable: Observable<Scene>;
  130289. private _onDisposeObserver;
  130290. /** Sets a function to be executed when this scene is disposed. */
  130291. set onDispose(callback: () => void);
  130292. /**
  130293. * An event triggered before rendering the scene (right after animations and physics)
  130294. */
  130295. onBeforeRenderObservable: Observable<Scene>;
  130296. private _onBeforeRenderObserver;
  130297. /** Sets a function to be executed before rendering this scene */
  130298. set beforeRender(callback: Nullable<() => void>);
  130299. /**
  130300. * An event triggered after rendering the scene
  130301. */
  130302. onAfterRenderObservable: Observable<Scene>;
  130303. /**
  130304. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  130305. */
  130306. onAfterRenderCameraObservable: Observable<Camera>;
  130307. private _onAfterRenderObserver;
  130308. /** Sets a function to be executed after rendering this scene */
  130309. set afterRender(callback: Nullable<() => void>);
  130310. /**
  130311. * An event triggered before animating the scene
  130312. */
  130313. onBeforeAnimationsObservable: Observable<Scene>;
  130314. /**
  130315. * An event triggered after animations processing
  130316. */
  130317. onAfterAnimationsObservable: Observable<Scene>;
  130318. /**
  130319. * An event triggered before draw calls are ready to be sent
  130320. */
  130321. onBeforeDrawPhaseObservable: Observable<Scene>;
  130322. /**
  130323. * An event triggered after draw calls have been sent
  130324. */
  130325. onAfterDrawPhaseObservable: Observable<Scene>;
  130326. /**
  130327. * An event triggered when the scene is ready
  130328. */
  130329. onReadyObservable: Observable<Scene>;
  130330. /**
  130331. * An event triggered before rendering a camera
  130332. */
  130333. onBeforeCameraRenderObservable: Observable<Camera>;
  130334. private _onBeforeCameraRenderObserver;
  130335. /** Sets a function to be executed before rendering a camera*/
  130336. set beforeCameraRender(callback: () => void);
  130337. /**
  130338. * An event triggered after rendering a camera
  130339. */
  130340. onAfterCameraRenderObservable: Observable<Camera>;
  130341. private _onAfterCameraRenderObserver;
  130342. /** Sets a function to be executed after rendering a camera*/
  130343. set afterCameraRender(callback: () => void);
  130344. /**
  130345. * An event triggered when active meshes evaluation is about to start
  130346. */
  130347. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  130348. /**
  130349. * An event triggered when active meshes evaluation is done
  130350. */
  130351. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  130352. /**
  130353. * An event triggered when particles rendering is about to start
  130354. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130355. */
  130356. onBeforeParticlesRenderingObservable: Observable<Scene>;
  130357. /**
  130358. * An event triggered when particles rendering is done
  130359. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130360. */
  130361. onAfterParticlesRenderingObservable: Observable<Scene>;
  130362. /**
  130363. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  130364. */
  130365. onDataLoadedObservable: Observable<Scene>;
  130366. /**
  130367. * An event triggered when a camera is created
  130368. */
  130369. onNewCameraAddedObservable: Observable<Camera>;
  130370. /**
  130371. * An event triggered when a camera is removed
  130372. */
  130373. onCameraRemovedObservable: Observable<Camera>;
  130374. /**
  130375. * An event triggered when a light is created
  130376. */
  130377. onNewLightAddedObservable: Observable<Light>;
  130378. /**
  130379. * An event triggered when a light is removed
  130380. */
  130381. onLightRemovedObservable: Observable<Light>;
  130382. /**
  130383. * An event triggered when a geometry is created
  130384. */
  130385. onNewGeometryAddedObservable: Observable<Geometry>;
  130386. /**
  130387. * An event triggered when a geometry is removed
  130388. */
  130389. onGeometryRemovedObservable: Observable<Geometry>;
  130390. /**
  130391. * An event triggered when a transform node is created
  130392. */
  130393. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  130394. /**
  130395. * An event triggered when a transform node is removed
  130396. */
  130397. onTransformNodeRemovedObservable: Observable<TransformNode>;
  130398. /**
  130399. * An event triggered when a mesh is created
  130400. */
  130401. onNewMeshAddedObservable: Observable<AbstractMesh>;
  130402. /**
  130403. * An event triggered when a mesh is removed
  130404. */
  130405. onMeshRemovedObservable: Observable<AbstractMesh>;
  130406. /**
  130407. * An event triggered when a skeleton is created
  130408. */
  130409. onNewSkeletonAddedObservable: Observable<Skeleton>;
  130410. /**
  130411. * An event triggered when a skeleton is removed
  130412. */
  130413. onSkeletonRemovedObservable: Observable<Skeleton>;
  130414. /**
  130415. * An event triggered when a material is created
  130416. */
  130417. onNewMaterialAddedObservable: Observable<Material>;
  130418. /**
  130419. * An event triggered when a multi material is created
  130420. */
  130421. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  130422. /**
  130423. * An event triggered when a material is removed
  130424. */
  130425. onMaterialRemovedObservable: Observable<Material>;
  130426. /**
  130427. * An event triggered when a multi material is removed
  130428. */
  130429. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  130430. /**
  130431. * An event triggered when a texture is created
  130432. */
  130433. onNewTextureAddedObservable: Observable<BaseTexture>;
  130434. /**
  130435. * An event triggered when a texture is removed
  130436. */
  130437. onTextureRemovedObservable: Observable<BaseTexture>;
  130438. /**
  130439. * An event triggered when render targets are about to be rendered
  130440. * Can happen multiple times per frame.
  130441. */
  130442. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  130443. /**
  130444. * An event triggered when render targets were rendered.
  130445. * Can happen multiple times per frame.
  130446. */
  130447. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  130448. /**
  130449. * An event triggered before calculating deterministic simulation step
  130450. */
  130451. onBeforeStepObservable: Observable<Scene>;
  130452. /**
  130453. * An event triggered after calculating deterministic simulation step
  130454. */
  130455. onAfterStepObservable: Observable<Scene>;
  130456. /**
  130457. * An event triggered when the activeCamera property is updated
  130458. */
  130459. onActiveCameraChanged: Observable<Scene>;
  130460. /**
  130461. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  130462. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  130463. * 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)
  130464. */
  130465. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  130466. /**
  130467. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  130468. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  130469. * 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)
  130470. */
  130471. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  130472. /**
  130473. * This Observable will when a mesh has been imported into the scene.
  130474. */
  130475. onMeshImportedObservable: Observable<AbstractMesh>;
  130476. /**
  130477. * This Observable will when an animation file has been imported into the scene.
  130478. */
  130479. onAnimationFileImportedObservable: Observable<Scene>;
  130480. /**
  130481. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  130482. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  130483. */
  130484. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  130485. /** @hidden */
  130486. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  130487. /**
  130488. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  130489. */
  130490. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  130491. /**
  130492. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  130493. */
  130494. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  130495. /**
  130496. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  130497. */
  130498. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  130499. /** Callback called when a pointer move is detected */
  130500. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  130501. /** Callback called when a pointer down is detected */
  130502. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  130503. /** Callback called when a pointer up is detected */
  130504. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  130505. /** Callback called when a pointer pick is detected */
  130506. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  130507. /**
  130508. * 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).
  130509. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  130510. */
  130511. onPrePointerObservable: Observable<PointerInfoPre>;
  130512. /**
  130513. * Observable event triggered each time an input event is received from the rendering canvas
  130514. */
  130515. onPointerObservable: Observable<PointerInfo>;
  130516. /**
  130517. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  130518. */
  130519. get unTranslatedPointer(): Vector2;
  130520. /**
  130521. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  130522. */
  130523. static get DragMovementThreshold(): number;
  130524. static set DragMovementThreshold(value: number);
  130525. /**
  130526. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  130527. */
  130528. static get LongPressDelay(): number;
  130529. static set LongPressDelay(value: number);
  130530. /**
  130531. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  130532. */
  130533. static get DoubleClickDelay(): number;
  130534. static set DoubleClickDelay(value: number);
  130535. /** If you need to check double click without raising a single click at first click, enable this flag */
  130536. static get ExclusiveDoubleClickMode(): boolean;
  130537. static set ExclusiveDoubleClickMode(value: boolean);
  130538. /** @hidden */
  130539. _mirroredCameraPosition: Nullable<Vector3>;
  130540. /**
  130541. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  130542. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  130543. */
  130544. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  130545. /**
  130546. * Observable event triggered each time an keyboard event is received from the hosting window
  130547. */
  130548. onKeyboardObservable: Observable<KeyboardInfo>;
  130549. private _useRightHandedSystem;
  130550. /**
  130551. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  130552. */
  130553. set useRightHandedSystem(value: boolean);
  130554. get useRightHandedSystem(): boolean;
  130555. private _timeAccumulator;
  130556. private _currentStepId;
  130557. private _currentInternalStep;
  130558. /**
  130559. * Sets the step Id used by deterministic lock step
  130560. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130561. * @param newStepId defines the step Id
  130562. */
  130563. setStepId(newStepId: number): void;
  130564. /**
  130565. * Gets the step Id used by deterministic lock step
  130566. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130567. * @returns the step Id
  130568. */
  130569. getStepId(): number;
  130570. /**
  130571. * Gets the internal step used by deterministic lock step
  130572. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130573. * @returns the internal step
  130574. */
  130575. getInternalStep(): number;
  130576. private _fogEnabled;
  130577. /**
  130578. * Gets or sets a boolean indicating if fog is enabled on this scene
  130579. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130580. * (Default is true)
  130581. */
  130582. set fogEnabled(value: boolean);
  130583. get fogEnabled(): boolean;
  130584. private _fogMode;
  130585. /**
  130586. * Gets or sets the fog mode to use
  130587. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130588. * | mode | value |
  130589. * | --- | --- |
  130590. * | FOGMODE_NONE | 0 |
  130591. * | FOGMODE_EXP | 1 |
  130592. * | FOGMODE_EXP2 | 2 |
  130593. * | FOGMODE_LINEAR | 3 |
  130594. */
  130595. set fogMode(value: number);
  130596. get fogMode(): number;
  130597. /**
  130598. * Gets or sets the fog color to use
  130599. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130600. * (Default is Color3(0.2, 0.2, 0.3))
  130601. */
  130602. fogColor: Color3;
  130603. /**
  130604. * Gets or sets the fog density to use
  130605. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130606. * (Default is 0.1)
  130607. */
  130608. fogDensity: number;
  130609. /**
  130610. * Gets or sets the fog start distance to use
  130611. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130612. * (Default is 0)
  130613. */
  130614. fogStart: number;
  130615. /**
  130616. * Gets or sets the fog end distance to use
  130617. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130618. * (Default is 1000)
  130619. */
  130620. fogEnd: number;
  130621. /**
  130622. * Flag indicating that the frame buffer binding is handled by another component
  130623. */
  130624. prePass: boolean;
  130625. private _shadowsEnabled;
  130626. /**
  130627. * Gets or sets a boolean indicating if shadows are enabled on this scene
  130628. */
  130629. set shadowsEnabled(value: boolean);
  130630. get shadowsEnabled(): boolean;
  130631. private _lightsEnabled;
  130632. /**
  130633. * Gets or sets a boolean indicating if lights are enabled on this scene
  130634. */
  130635. set lightsEnabled(value: boolean);
  130636. get lightsEnabled(): boolean;
  130637. /** All of the active cameras added to this scene. */
  130638. activeCameras: Nullable<Camera[]>;
  130639. /** @hidden */
  130640. _activeCamera: Nullable<Camera>;
  130641. /** Gets or sets the current active camera */
  130642. get activeCamera(): Nullable<Camera>;
  130643. set activeCamera(value: Nullable<Camera>);
  130644. private _defaultMaterial;
  130645. /** The default material used on meshes when no material is affected */
  130646. get defaultMaterial(): Material;
  130647. /** The default material used on meshes when no material is affected */
  130648. set defaultMaterial(value: Material);
  130649. private _texturesEnabled;
  130650. /**
  130651. * Gets or sets a boolean indicating if textures are enabled on this scene
  130652. */
  130653. set texturesEnabled(value: boolean);
  130654. get texturesEnabled(): boolean;
  130655. /**
  130656. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  130657. */
  130658. physicsEnabled: boolean;
  130659. /**
  130660. * Gets or sets a boolean indicating if particles are enabled on this scene
  130661. */
  130662. particlesEnabled: boolean;
  130663. /**
  130664. * Gets or sets a boolean indicating if sprites are enabled on this scene
  130665. */
  130666. spritesEnabled: boolean;
  130667. private _skeletonsEnabled;
  130668. /**
  130669. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  130670. */
  130671. set skeletonsEnabled(value: boolean);
  130672. get skeletonsEnabled(): boolean;
  130673. /**
  130674. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  130675. */
  130676. lensFlaresEnabled: boolean;
  130677. /**
  130678. * Gets or sets a boolean indicating if collisions are enabled on this scene
  130679. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  130680. */
  130681. collisionsEnabled: boolean;
  130682. private _collisionCoordinator;
  130683. /** @hidden */
  130684. get collisionCoordinator(): ICollisionCoordinator;
  130685. /**
  130686. * Defines the gravity applied to this scene (used only for collisions)
  130687. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  130688. */
  130689. gravity: Vector3;
  130690. /**
  130691. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  130692. */
  130693. postProcessesEnabled: boolean;
  130694. /**
  130695. * Gets the current postprocess manager
  130696. */
  130697. postProcessManager: PostProcessManager;
  130698. /**
  130699. * Gets or sets a boolean indicating if render targets are enabled on this scene
  130700. */
  130701. renderTargetsEnabled: boolean;
  130702. /**
  130703. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  130704. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  130705. */
  130706. dumpNextRenderTargets: boolean;
  130707. /**
  130708. * The list of user defined render targets added to the scene
  130709. */
  130710. customRenderTargets: RenderTargetTexture[];
  130711. /**
  130712. * Defines if texture loading must be delayed
  130713. * If true, textures will only be loaded when they need to be rendered
  130714. */
  130715. useDelayedTextureLoading: boolean;
  130716. /**
  130717. * Gets the list of meshes imported to the scene through SceneLoader
  130718. */
  130719. importedMeshesFiles: String[];
  130720. /**
  130721. * Gets or sets a boolean indicating if probes are enabled on this scene
  130722. */
  130723. probesEnabled: boolean;
  130724. /**
  130725. * Gets or sets the current offline provider to use to store scene data
  130726. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  130727. */
  130728. offlineProvider: IOfflineProvider;
  130729. /**
  130730. * Gets or sets the action manager associated with the scene
  130731. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  130732. */
  130733. actionManager: AbstractActionManager;
  130734. private _meshesForIntersections;
  130735. /**
  130736. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  130737. */
  130738. proceduralTexturesEnabled: boolean;
  130739. private _engine;
  130740. private _totalVertices;
  130741. /** @hidden */
  130742. _activeIndices: PerfCounter;
  130743. /** @hidden */
  130744. _activeParticles: PerfCounter;
  130745. /** @hidden */
  130746. _activeBones: PerfCounter;
  130747. private _animationRatio;
  130748. /** @hidden */
  130749. _animationTimeLast: number;
  130750. /** @hidden */
  130751. _animationTime: number;
  130752. /**
  130753. * Gets or sets a general scale for animation speed
  130754. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  130755. */
  130756. animationTimeScale: number;
  130757. /** @hidden */
  130758. _cachedMaterial: Nullable<Material>;
  130759. /** @hidden */
  130760. _cachedEffect: Nullable<Effect>;
  130761. /** @hidden */
  130762. _cachedVisibility: Nullable<number>;
  130763. private _renderId;
  130764. private _frameId;
  130765. private _executeWhenReadyTimeoutId;
  130766. private _intermediateRendering;
  130767. private _viewUpdateFlag;
  130768. private _projectionUpdateFlag;
  130769. /** @hidden */
  130770. _toBeDisposed: Nullable<IDisposable>[];
  130771. private _activeRequests;
  130772. /** @hidden */
  130773. _pendingData: any[];
  130774. private _isDisposed;
  130775. /**
  130776. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  130777. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  130778. */
  130779. dispatchAllSubMeshesOfActiveMeshes: boolean;
  130780. private _activeMeshes;
  130781. private _processedMaterials;
  130782. private _renderTargets;
  130783. /** @hidden */
  130784. _activeParticleSystems: SmartArray<IParticleSystem>;
  130785. private _activeSkeletons;
  130786. private _softwareSkinnedMeshes;
  130787. private _renderingManager;
  130788. /** @hidden */
  130789. _activeAnimatables: Animatable[];
  130790. private _transformMatrix;
  130791. private _sceneUbo;
  130792. /** @hidden */
  130793. _viewMatrix: Matrix;
  130794. /** @hidden */
  130795. _projectionMatrix: Matrix;
  130796. /** @hidden */
  130797. _forcedViewPosition: Nullable<Vector3>;
  130798. /** @hidden */
  130799. _frustumPlanes: Plane[];
  130800. /**
  130801. * Gets the list of frustum planes (built from the active camera)
  130802. */
  130803. get frustumPlanes(): Plane[];
  130804. /**
  130805. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  130806. * This is useful if there are more lights that the maximum simulteanous authorized
  130807. */
  130808. requireLightSorting: boolean;
  130809. /** @hidden */
  130810. readonly useMaterialMeshMap: boolean;
  130811. /** @hidden */
  130812. readonly useClonedMeshMap: boolean;
  130813. private _externalData;
  130814. private _uid;
  130815. /**
  130816. * @hidden
  130817. * Backing store of defined scene components.
  130818. */
  130819. _components: ISceneComponent[];
  130820. /**
  130821. * @hidden
  130822. * Backing store of defined scene components.
  130823. */
  130824. _serializableComponents: ISceneSerializableComponent[];
  130825. /**
  130826. * List of components to register on the next registration step.
  130827. */
  130828. private _transientComponents;
  130829. /**
  130830. * Registers the transient components if needed.
  130831. */
  130832. private _registerTransientComponents;
  130833. /**
  130834. * @hidden
  130835. * Add a component to the scene.
  130836. * Note that the ccomponent could be registered on th next frame if this is called after
  130837. * the register component stage.
  130838. * @param component Defines the component to add to the scene
  130839. */
  130840. _addComponent(component: ISceneComponent): void;
  130841. /**
  130842. * @hidden
  130843. * Gets a component from the scene.
  130844. * @param name defines the name of the component to retrieve
  130845. * @returns the component or null if not present
  130846. */
  130847. _getComponent(name: string): Nullable<ISceneComponent>;
  130848. /**
  130849. * @hidden
  130850. * Defines the actions happening before camera updates.
  130851. */
  130852. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  130853. /**
  130854. * @hidden
  130855. * Defines the actions happening before clear the canvas.
  130856. */
  130857. _beforeClearStage: Stage<SimpleStageAction>;
  130858. /**
  130859. * @hidden
  130860. * Defines the actions when collecting render targets for the frame.
  130861. */
  130862. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  130863. /**
  130864. * @hidden
  130865. * Defines the actions happening for one camera in the frame.
  130866. */
  130867. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  130868. /**
  130869. * @hidden
  130870. * Defines the actions happening during the per mesh ready checks.
  130871. */
  130872. _isReadyForMeshStage: Stage<MeshStageAction>;
  130873. /**
  130874. * @hidden
  130875. * Defines the actions happening before evaluate active mesh checks.
  130876. */
  130877. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  130878. /**
  130879. * @hidden
  130880. * Defines the actions happening during the evaluate sub mesh checks.
  130881. */
  130882. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  130883. /**
  130884. * @hidden
  130885. * Defines the actions happening during the active mesh stage.
  130886. */
  130887. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  130888. /**
  130889. * @hidden
  130890. * Defines the actions happening during the per camera render target step.
  130891. */
  130892. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  130893. /**
  130894. * @hidden
  130895. * Defines the actions happening just before the active camera is drawing.
  130896. */
  130897. _beforeCameraDrawStage: Stage<CameraStageAction>;
  130898. /**
  130899. * @hidden
  130900. * Defines the actions happening just before a render target is drawing.
  130901. */
  130902. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  130903. /**
  130904. * @hidden
  130905. * Defines the actions happening just before a rendering group is drawing.
  130906. */
  130907. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  130908. /**
  130909. * @hidden
  130910. * Defines the actions happening just before a mesh is drawing.
  130911. */
  130912. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  130913. /**
  130914. * @hidden
  130915. * Defines the actions happening just after a mesh has been drawn.
  130916. */
  130917. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  130918. /**
  130919. * @hidden
  130920. * Defines the actions happening just after a rendering group has been drawn.
  130921. */
  130922. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  130923. /**
  130924. * @hidden
  130925. * Defines the actions happening just after the active camera has been drawn.
  130926. */
  130927. _afterCameraDrawStage: Stage<CameraStageAction>;
  130928. /**
  130929. * @hidden
  130930. * Defines the actions happening just after a render target has been drawn.
  130931. */
  130932. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  130933. /**
  130934. * @hidden
  130935. * Defines the actions happening just after rendering all cameras and computing intersections.
  130936. */
  130937. _afterRenderStage: Stage<SimpleStageAction>;
  130938. /**
  130939. * @hidden
  130940. * Defines the actions happening when a pointer move event happens.
  130941. */
  130942. _pointerMoveStage: Stage<PointerMoveStageAction>;
  130943. /**
  130944. * @hidden
  130945. * Defines the actions happening when a pointer down event happens.
  130946. */
  130947. _pointerDownStage: Stage<PointerUpDownStageAction>;
  130948. /**
  130949. * @hidden
  130950. * Defines the actions happening when a pointer up event happens.
  130951. */
  130952. _pointerUpStage: Stage<PointerUpDownStageAction>;
  130953. /**
  130954. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  130955. */
  130956. private geometriesByUniqueId;
  130957. private _renderBundles;
  130958. /**
  130959. * Creates a new Scene
  130960. * @param engine defines the engine to use to render this scene
  130961. * @param options defines the scene options
  130962. */
  130963. constructor(engine: Engine, options?: SceneOptions);
  130964. /**
  130965. * Gets a string identifying the name of the class
  130966. * @returns "Scene" string
  130967. */
  130968. getClassName(): string;
  130969. private _defaultMeshCandidates;
  130970. /**
  130971. * @hidden
  130972. */
  130973. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130974. private _defaultSubMeshCandidates;
  130975. /**
  130976. * @hidden
  130977. */
  130978. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130979. /**
  130980. * Sets the default candidate providers for the scene.
  130981. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  130982. * and getCollidingSubMeshCandidates to their default function
  130983. */
  130984. setDefaultCandidateProviders(): void;
  130985. /**
  130986. * Gets the mesh that is currently under the pointer
  130987. */
  130988. get meshUnderPointer(): Nullable<AbstractMesh>;
  130989. /**
  130990. * Gets or sets the current on-screen X position of the pointer
  130991. */
  130992. get pointerX(): number;
  130993. set pointerX(value: number);
  130994. /**
  130995. * Gets or sets the current on-screen Y position of the pointer
  130996. */
  130997. get pointerY(): number;
  130998. set pointerY(value: number);
  130999. /**
  131000. * Gets the cached material (ie. the latest rendered one)
  131001. * @returns the cached material
  131002. */
  131003. getCachedMaterial(): Nullable<Material>;
  131004. /**
  131005. * Gets the cached effect (ie. the latest rendered one)
  131006. * @returns the cached effect
  131007. */
  131008. getCachedEffect(): Nullable<Effect>;
  131009. /**
  131010. * Gets the cached visibility state (ie. the latest rendered one)
  131011. * @returns the cached visibility state
  131012. */
  131013. getCachedVisibility(): Nullable<number>;
  131014. /**
  131015. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  131016. * @param material defines the current material
  131017. * @param effect defines the current effect
  131018. * @param visibility defines the current visibility state
  131019. * @returns true if one parameter is not cached
  131020. */
  131021. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  131022. /**
  131023. * Gets the engine associated with the scene
  131024. * @returns an Engine
  131025. */
  131026. getEngine(): Engine;
  131027. /**
  131028. * Gets the total number of vertices rendered per frame
  131029. * @returns the total number of vertices rendered per frame
  131030. */
  131031. getTotalVertices(): number;
  131032. /**
  131033. * Gets the performance counter for total vertices
  131034. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131035. */
  131036. get totalVerticesPerfCounter(): PerfCounter;
  131037. /**
  131038. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  131039. * @returns the total number of active indices rendered per frame
  131040. */
  131041. getActiveIndices(): number;
  131042. /**
  131043. * Gets the performance counter for active indices
  131044. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131045. */
  131046. get totalActiveIndicesPerfCounter(): PerfCounter;
  131047. /**
  131048. * Gets the total number of active particles rendered per frame
  131049. * @returns the total number of active particles rendered per frame
  131050. */
  131051. getActiveParticles(): number;
  131052. /**
  131053. * Gets the performance counter for active particles
  131054. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131055. */
  131056. get activeParticlesPerfCounter(): PerfCounter;
  131057. /**
  131058. * Gets the total number of active bones rendered per frame
  131059. * @returns the total number of active bones rendered per frame
  131060. */
  131061. getActiveBones(): number;
  131062. /**
  131063. * Gets the performance counter for active bones
  131064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131065. */
  131066. get activeBonesPerfCounter(): PerfCounter;
  131067. /**
  131068. * Gets the array of active meshes
  131069. * @returns an array of AbstractMesh
  131070. */
  131071. getActiveMeshes(): SmartArray<AbstractMesh>;
  131072. /**
  131073. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  131074. * @returns a number
  131075. */
  131076. getAnimationRatio(): number;
  131077. /**
  131078. * Gets an unique Id for the current render phase
  131079. * @returns a number
  131080. */
  131081. getRenderId(): number;
  131082. /**
  131083. * Gets an unique Id for the current frame
  131084. * @returns a number
  131085. */
  131086. getFrameId(): number;
  131087. /** Call this function if you want to manually increment the render Id*/
  131088. incrementRenderId(): void;
  131089. private _createUbo;
  131090. /**
  131091. * Use this method to simulate a pointer move on a mesh
  131092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131095. * @returns the current scene
  131096. */
  131097. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131098. /**
  131099. * Use this method to simulate a pointer down on a mesh
  131100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131103. * @returns the current scene
  131104. */
  131105. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131106. /**
  131107. * Use this method to simulate a pointer up on a mesh
  131108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131111. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  131112. * @returns the current scene
  131113. */
  131114. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  131115. /**
  131116. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  131117. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  131118. * @returns true if the pointer was captured
  131119. */
  131120. isPointerCaptured(pointerId?: number): boolean;
  131121. /**
  131122. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  131123. * @param attachUp defines if you want to attach events to pointerup
  131124. * @param attachDown defines if you want to attach events to pointerdown
  131125. * @param attachMove defines if you want to attach events to pointermove
  131126. */
  131127. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  131128. /** Detaches all event handlers*/
  131129. detachControl(): void;
  131130. /**
  131131. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  131132. * Delay loaded resources are not taking in account
  131133. * @return true if all required resources are ready
  131134. */
  131135. isReady(): boolean;
  131136. /** Resets all cached information relative to material (including effect and visibility) */
  131137. resetCachedMaterial(): void;
  131138. /**
  131139. * Registers a function to be called before every frame render
  131140. * @param func defines the function to register
  131141. */
  131142. registerBeforeRender(func: () => void): void;
  131143. /**
  131144. * Unregisters a function called before every frame render
  131145. * @param func defines the function to unregister
  131146. */
  131147. unregisterBeforeRender(func: () => void): void;
  131148. /**
  131149. * Registers a function to be called after every frame render
  131150. * @param func defines the function to register
  131151. */
  131152. registerAfterRender(func: () => void): void;
  131153. /**
  131154. * Unregisters a function called after every frame render
  131155. * @param func defines the function to unregister
  131156. */
  131157. unregisterAfterRender(func: () => void): void;
  131158. private _executeOnceBeforeRender;
  131159. /**
  131160. * The provided function will run before render once and will be disposed afterwards.
  131161. * A timeout delay can be provided so that the function will be executed in N ms.
  131162. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  131163. * @param func The function to be executed.
  131164. * @param timeout optional delay in ms
  131165. */
  131166. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  131167. /** @hidden */
  131168. _addPendingData(data: any): void;
  131169. /** @hidden */
  131170. _removePendingData(data: any): void;
  131171. /**
  131172. * Returns the number of items waiting to be loaded
  131173. * @returns the number of items waiting to be loaded
  131174. */
  131175. getWaitingItemsCount(): number;
  131176. /**
  131177. * Returns a boolean indicating if the scene is still loading data
  131178. */
  131179. get isLoading(): boolean;
  131180. /**
  131181. * Registers a function to be executed when the scene is ready
  131182. * @param {Function} func - the function to be executed
  131183. */
  131184. executeWhenReady(func: () => void): void;
  131185. /**
  131186. * Returns a promise that resolves when the scene is ready
  131187. * @returns A promise that resolves when the scene is ready
  131188. */
  131189. whenReadyAsync(): Promise<void>;
  131190. /** @hidden */
  131191. _checkIsReady(): void;
  131192. /**
  131193. * Gets all animatable attached to the scene
  131194. */
  131195. get animatables(): Animatable[];
  131196. /**
  131197. * Resets the last animation time frame.
  131198. * Useful to override when animations start running when loading a scene for the first time.
  131199. */
  131200. resetLastAnimationTimeFrame(): void;
  131201. /**
  131202. * Gets the current view matrix
  131203. * @returns a Matrix
  131204. */
  131205. getViewMatrix(): Matrix;
  131206. /**
  131207. * Gets the current projection matrix
  131208. * @returns a Matrix
  131209. */
  131210. getProjectionMatrix(): Matrix;
  131211. /**
  131212. * Gets the current transform matrix
  131213. * @returns a Matrix made of View * Projection
  131214. */
  131215. getTransformMatrix(): Matrix;
  131216. /**
  131217. * Sets the current transform matrix
  131218. * @param viewL defines the View matrix to use
  131219. * @param projectionL defines the Projection matrix to use
  131220. * @param viewR defines the right View matrix to use (if provided)
  131221. * @param projectionR defines the right Projection matrix to use (if provided)
  131222. */
  131223. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  131224. /**
  131225. * Gets the uniform buffer used to store scene data
  131226. * @returns a UniformBuffer
  131227. */
  131228. getSceneUniformBuffer(): UniformBuffer;
  131229. /**
  131230. * Gets an unique (relatively to the current scene) Id
  131231. * @returns an unique number for the scene
  131232. */
  131233. getUniqueId(): number;
  131234. /**
  131235. * Add a mesh to the list of scene's meshes
  131236. * @param newMesh defines the mesh to add
  131237. * @param recursive if all child meshes should also be added to the scene
  131238. */
  131239. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  131240. /**
  131241. * Remove a mesh for the list of scene's meshes
  131242. * @param toRemove defines the mesh to remove
  131243. * @param recursive if all child meshes should also be removed from the scene
  131244. * @returns the index where the mesh was in the mesh list
  131245. */
  131246. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  131247. /**
  131248. * Add a transform node to the list of scene's transform nodes
  131249. * @param newTransformNode defines the transform node to add
  131250. */
  131251. addTransformNode(newTransformNode: TransformNode): void;
  131252. /**
  131253. * Remove a transform node for the list of scene's transform nodes
  131254. * @param toRemove defines the transform node to remove
  131255. * @returns the index where the transform node was in the transform node list
  131256. */
  131257. removeTransformNode(toRemove: TransformNode): number;
  131258. /**
  131259. * Remove a skeleton for the list of scene's skeletons
  131260. * @param toRemove defines the skeleton to remove
  131261. * @returns the index where the skeleton was in the skeleton list
  131262. */
  131263. removeSkeleton(toRemove: Skeleton): number;
  131264. /**
  131265. * Remove a morph target for the list of scene's morph targets
  131266. * @param toRemove defines the morph target to remove
  131267. * @returns the index where the morph target was in the morph target list
  131268. */
  131269. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  131270. /**
  131271. * Remove a light for the list of scene's lights
  131272. * @param toRemove defines the light to remove
  131273. * @returns the index where the light was in the light list
  131274. */
  131275. removeLight(toRemove: Light): number;
  131276. /**
  131277. * Remove a camera for the list of scene's cameras
  131278. * @param toRemove defines the camera to remove
  131279. * @returns the index where the camera was in the camera list
  131280. */
  131281. removeCamera(toRemove: Camera): number;
  131282. /**
  131283. * Remove a particle system for the list of scene's particle systems
  131284. * @param toRemove defines the particle system to remove
  131285. * @returns the index where the particle system was in the particle system list
  131286. */
  131287. removeParticleSystem(toRemove: IParticleSystem): number;
  131288. /**
  131289. * Remove a animation for the list of scene's animations
  131290. * @param toRemove defines the animation to remove
  131291. * @returns the index where the animation was in the animation list
  131292. */
  131293. removeAnimation(toRemove: Animation): number;
  131294. /**
  131295. * Will stop the animation of the given target
  131296. * @param target - the target
  131297. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  131298. * @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)
  131299. */
  131300. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  131301. /**
  131302. * Removes the given animation group from this scene.
  131303. * @param toRemove The animation group to remove
  131304. * @returns The index of the removed animation group
  131305. */
  131306. removeAnimationGroup(toRemove: AnimationGroup): number;
  131307. /**
  131308. * Removes the given multi-material from this scene.
  131309. * @param toRemove The multi-material to remove
  131310. * @returns The index of the removed multi-material
  131311. */
  131312. removeMultiMaterial(toRemove: MultiMaterial): number;
  131313. /**
  131314. * Removes the given material from this scene.
  131315. * @param toRemove The material to remove
  131316. * @returns The index of the removed material
  131317. */
  131318. removeMaterial(toRemove: Material): number;
  131319. /**
  131320. * Removes the given action manager from this scene.
  131321. * @param toRemove The action manager to remove
  131322. * @returns The index of the removed action manager
  131323. */
  131324. removeActionManager(toRemove: AbstractActionManager): number;
  131325. /**
  131326. * Removes the given texture from this scene.
  131327. * @param toRemove The texture to remove
  131328. * @returns The index of the removed texture
  131329. */
  131330. removeTexture(toRemove: BaseTexture): number;
  131331. /**
  131332. * Adds the given light to this scene
  131333. * @param newLight The light to add
  131334. */
  131335. addLight(newLight: Light): void;
  131336. /**
  131337. * Sorts the list list based on light priorities
  131338. */
  131339. sortLightsByPriority(): void;
  131340. /**
  131341. * Adds the given camera to this scene
  131342. * @param newCamera The camera to add
  131343. */
  131344. addCamera(newCamera: Camera): void;
  131345. /**
  131346. * Adds the given skeleton to this scene
  131347. * @param newSkeleton The skeleton to add
  131348. */
  131349. addSkeleton(newSkeleton: Skeleton): void;
  131350. /**
  131351. * Adds the given particle system to this scene
  131352. * @param newParticleSystem The particle system to add
  131353. */
  131354. addParticleSystem(newParticleSystem: IParticleSystem): void;
  131355. /**
  131356. * Adds the given animation to this scene
  131357. * @param newAnimation The animation to add
  131358. */
  131359. addAnimation(newAnimation: Animation): void;
  131360. /**
  131361. * Adds the given animation group to this scene.
  131362. * @param newAnimationGroup The animation group to add
  131363. */
  131364. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  131365. /**
  131366. * Adds the given multi-material to this scene
  131367. * @param newMultiMaterial The multi-material to add
  131368. */
  131369. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  131370. /**
  131371. * Adds the given material to this scene
  131372. * @param newMaterial The material to add
  131373. */
  131374. addMaterial(newMaterial: Material): void;
  131375. /**
  131376. * Adds the given morph target to this scene
  131377. * @param newMorphTargetManager The morph target to add
  131378. */
  131379. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  131380. /**
  131381. * Adds the given geometry to this scene
  131382. * @param newGeometry The geometry to add
  131383. */
  131384. addGeometry(newGeometry: Geometry): void;
  131385. /**
  131386. * Adds the given action manager to this scene
  131387. * @param newActionManager The action manager to add
  131388. */
  131389. addActionManager(newActionManager: AbstractActionManager): void;
  131390. /**
  131391. * Adds the given texture to this scene.
  131392. * @param newTexture The texture to add
  131393. */
  131394. addTexture(newTexture: BaseTexture): void;
  131395. /**
  131396. * Switch active camera
  131397. * @param newCamera defines the new active camera
  131398. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  131399. */
  131400. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  131401. /**
  131402. * sets the active camera of the scene using its ID
  131403. * @param id defines the camera's ID
  131404. * @return the new active camera or null if none found.
  131405. */
  131406. setActiveCameraByID(id: string): Nullable<Camera>;
  131407. /**
  131408. * sets the active camera of the scene using its name
  131409. * @param name defines the camera's name
  131410. * @returns the new active camera or null if none found.
  131411. */
  131412. setActiveCameraByName(name: string): Nullable<Camera>;
  131413. /**
  131414. * get an animation group using its name
  131415. * @param name defines the material's name
  131416. * @return the animation group or null if none found.
  131417. */
  131418. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  131419. /**
  131420. * Get a material using its unique id
  131421. * @param uniqueId defines the material's unique id
  131422. * @return the material or null if none found.
  131423. */
  131424. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  131425. /**
  131426. * get a material using its id
  131427. * @param id defines the material's ID
  131428. * @return the material or null if none found.
  131429. */
  131430. getMaterialByID(id: string): Nullable<Material>;
  131431. /**
  131432. * Gets a the last added material using a given id
  131433. * @param id defines the material's ID
  131434. * @return the last material with the given id or null if none found.
  131435. */
  131436. getLastMaterialByID(id: string): Nullable<Material>;
  131437. /**
  131438. * Gets a material using its name
  131439. * @param name defines the material's name
  131440. * @return the material or null if none found.
  131441. */
  131442. getMaterialByName(name: string): Nullable<Material>;
  131443. /**
  131444. * Get a texture using its unique id
  131445. * @param uniqueId defines the texture's unique id
  131446. * @return the texture or null if none found.
  131447. */
  131448. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  131449. /**
  131450. * Gets a camera using its id
  131451. * @param id defines the id to look for
  131452. * @returns the camera or null if not found
  131453. */
  131454. getCameraByID(id: string): Nullable<Camera>;
  131455. /**
  131456. * Gets a camera using its unique id
  131457. * @param uniqueId defines the unique id to look for
  131458. * @returns the camera or null if not found
  131459. */
  131460. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  131461. /**
  131462. * Gets a camera using its name
  131463. * @param name defines the camera's name
  131464. * @return the camera or null if none found.
  131465. */
  131466. getCameraByName(name: string): Nullable<Camera>;
  131467. /**
  131468. * Gets a bone using its id
  131469. * @param id defines the bone's id
  131470. * @return the bone or null if not found
  131471. */
  131472. getBoneByID(id: string): Nullable<Bone>;
  131473. /**
  131474. * Gets a bone using its id
  131475. * @param name defines the bone's name
  131476. * @return the bone or null if not found
  131477. */
  131478. getBoneByName(name: string): Nullable<Bone>;
  131479. /**
  131480. * Gets a light node using its name
  131481. * @param name defines the the light's name
  131482. * @return the light or null if none found.
  131483. */
  131484. getLightByName(name: string): Nullable<Light>;
  131485. /**
  131486. * Gets a light node using its id
  131487. * @param id defines the light's id
  131488. * @return the light or null if none found.
  131489. */
  131490. getLightByID(id: string): Nullable<Light>;
  131491. /**
  131492. * Gets a light node using its scene-generated unique ID
  131493. * @param uniqueId defines the light's unique id
  131494. * @return the light or null if none found.
  131495. */
  131496. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  131497. /**
  131498. * Gets a particle system by id
  131499. * @param id defines the particle system id
  131500. * @return the corresponding system or null if none found
  131501. */
  131502. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  131503. /**
  131504. * Gets a geometry using its ID
  131505. * @param id defines the geometry's id
  131506. * @return the geometry or null if none found.
  131507. */
  131508. getGeometryByID(id: string): Nullable<Geometry>;
  131509. private _getGeometryByUniqueID;
  131510. /**
  131511. * Add a new geometry to this scene
  131512. * @param geometry defines the geometry to be added to the scene.
  131513. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  131514. * @return a boolean defining if the geometry was added or not
  131515. */
  131516. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  131517. /**
  131518. * Removes an existing geometry
  131519. * @param geometry defines the geometry to be removed from the scene
  131520. * @return a boolean defining if the geometry was removed or not
  131521. */
  131522. removeGeometry(geometry: Geometry): boolean;
  131523. /**
  131524. * Gets the list of geometries attached to the scene
  131525. * @returns an array of Geometry
  131526. */
  131527. getGeometries(): Geometry[];
  131528. /**
  131529. * Gets the first added mesh found of a given ID
  131530. * @param id defines the id to search for
  131531. * @return the mesh found or null if not found at all
  131532. */
  131533. getMeshByID(id: string): Nullable<AbstractMesh>;
  131534. /**
  131535. * Gets a list of meshes using their id
  131536. * @param id defines the id to search for
  131537. * @returns a list of meshes
  131538. */
  131539. getMeshesByID(id: string): Array<AbstractMesh>;
  131540. /**
  131541. * Gets the first added transform node found of a given ID
  131542. * @param id defines the id to search for
  131543. * @return the found transform node or null if not found at all.
  131544. */
  131545. getTransformNodeByID(id: string): Nullable<TransformNode>;
  131546. /**
  131547. * Gets a transform node with its auto-generated unique id
  131548. * @param uniqueId efines the unique id to search for
  131549. * @return the found transform node or null if not found at all.
  131550. */
  131551. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  131552. /**
  131553. * Gets a list of transform nodes using their id
  131554. * @param id defines the id to search for
  131555. * @returns a list of transform nodes
  131556. */
  131557. getTransformNodesByID(id: string): Array<TransformNode>;
  131558. /**
  131559. * Gets a mesh with its auto-generated unique id
  131560. * @param uniqueId defines the unique id to search for
  131561. * @return the found mesh or null if not found at all.
  131562. */
  131563. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  131564. /**
  131565. * Gets a the last added mesh using a given id
  131566. * @param id defines the id to search for
  131567. * @return the found mesh or null if not found at all.
  131568. */
  131569. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  131570. /**
  131571. * Gets a the last added node (Mesh, Camera, Light) using a given id
  131572. * @param id defines the id to search for
  131573. * @return the found node or null if not found at all
  131574. */
  131575. getLastEntryByID(id: string): Nullable<Node>;
  131576. /**
  131577. * Gets a node (Mesh, Camera, Light) using a given id
  131578. * @param id defines the id to search for
  131579. * @return the found node or null if not found at all
  131580. */
  131581. getNodeByID(id: string): Nullable<Node>;
  131582. /**
  131583. * Gets a node (Mesh, Camera, Light) using a given name
  131584. * @param name defines the name to search for
  131585. * @return the found node or null if not found at all.
  131586. */
  131587. getNodeByName(name: string): Nullable<Node>;
  131588. /**
  131589. * Gets a mesh using a given name
  131590. * @param name defines the name to search for
  131591. * @return the found mesh or null if not found at all.
  131592. */
  131593. getMeshByName(name: string): Nullable<AbstractMesh>;
  131594. /**
  131595. * Gets a transform node using a given name
  131596. * @param name defines the name to search for
  131597. * @return the found transform node or null if not found at all.
  131598. */
  131599. getTransformNodeByName(name: string): Nullable<TransformNode>;
  131600. /**
  131601. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  131602. * @param id defines the id to search for
  131603. * @return the found skeleton or null if not found at all.
  131604. */
  131605. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  131606. /**
  131607. * Gets a skeleton using a given auto generated unique id
  131608. * @param uniqueId defines the unique id to search for
  131609. * @return the found skeleton or null if not found at all.
  131610. */
  131611. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  131612. /**
  131613. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  131614. * @param id defines the id to search for
  131615. * @return the found skeleton or null if not found at all.
  131616. */
  131617. getSkeletonById(id: string): Nullable<Skeleton>;
  131618. /**
  131619. * Gets a skeleton using a given name
  131620. * @param name defines the name to search for
  131621. * @return the found skeleton or null if not found at all.
  131622. */
  131623. getSkeletonByName(name: string): Nullable<Skeleton>;
  131624. /**
  131625. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  131626. * @param id defines the id to search for
  131627. * @return the found morph target manager or null if not found at all.
  131628. */
  131629. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  131630. /**
  131631. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  131632. * @param id defines the id to search for
  131633. * @return the found morph target or null if not found at all.
  131634. */
  131635. getMorphTargetById(id: string): Nullable<MorphTarget>;
  131636. /**
  131637. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  131638. * @param name defines the name to search for
  131639. * @return the found morph target or null if not found at all.
  131640. */
  131641. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  131642. /**
  131643. * Gets a post process using a given name (if many are found, this function will pick the first one)
  131644. * @param name defines the name to search for
  131645. * @return the found post process or null if not found at all.
  131646. */
  131647. getPostProcessByName(name: string): Nullable<PostProcess>;
  131648. /**
  131649. * Gets a boolean indicating if the given mesh is active
  131650. * @param mesh defines the mesh to look for
  131651. * @returns true if the mesh is in the active list
  131652. */
  131653. isActiveMesh(mesh: AbstractMesh): boolean;
  131654. /**
  131655. * Return a unique id as a string which can serve as an identifier for the scene
  131656. */
  131657. get uid(): string;
  131658. /**
  131659. * Add an externaly attached data from its key.
  131660. * This method call will fail and return false, if such key already exists.
  131661. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  131662. * @param key the unique key that identifies the data
  131663. * @param data the data object to associate to the key for this Engine instance
  131664. * @return true if no such key were already present and the data was added successfully, false otherwise
  131665. */
  131666. addExternalData<T>(key: string, data: T): boolean;
  131667. /**
  131668. * Get an externaly attached data from its key
  131669. * @param key the unique key that identifies the data
  131670. * @return the associated data, if present (can be null), or undefined if not present
  131671. */
  131672. getExternalData<T>(key: string): Nullable<T>;
  131673. /**
  131674. * Get an externaly attached data from its key, create it using a factory if it's not already present
  131675. * @param key the unique key that identifies the data
  131676. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  131677. * @return the associated data, can be null if the factory returned null.
  131678. */
  131679. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  131680. /**
  131681. * Remove an externaly attached data from the Engine instance
  131682. * @param key the unique key that identifies the data
  131683. * @return true if the data was successfully removed, false if it doesn't exist
  131684. */
  131685. removeExternalData(key: string): boolean;
  131686. private _evaluateSubMesh;
  131687. /**
  131688. * Clear the processed materials smart array preventing retention point in material dispose.
  131689. */
  131690. freeProcessedMaterials(): void;
  131691. private _preventFreeActiveMeshesAndRenderingGroups;
  131692. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  131693. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  131694. * when disposing several meshes in a row or a hierarchy of meshes.
  131695. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  131696. */
  131697. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  131698. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  131699. /**
  131700. * Clear the active meshes smart array preventing retention point in mesh dispose.
  131701. */
  131702. freeActiveMeshes(): void;
  131703. /**
  131704. * Clear the info related to rendering groups preventing retention points during dispose.
  131705. */
  131706. freeRenderingGroups(): void;
  131707. /** @hidden */
  131708. _isInIntermediateRendering(): boolean;
  131709. /**
  131710. * Lambda returning the list of potentially active meshes.
  131711. */
  131712. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  131713. /**
  131714. * Lambda returning the list of potentially active sub meshes.
  131715. */
  131716. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  131717. /**
  131718. * Lambda returning the list of potentially intersecting sub meshes.
  131719. */
  131720. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  131721. /**
  131722. * Lambda returning the list of potentially colliding sub meshes.
  131723. */
  131724. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  131725. /** @hidden */
  131726. _activeMeshesFrozen: boolean;
  131727. private _skipEvaluateActiveMeshesCompletely;
  131728. /**
  131729. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  131730. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  131731. * @param onSuccess optional success callback
  131732. * @param onError optional error callback
  131733. * @returns the current scene
  131734. */
  131735. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  131736. /**
  131737. * Use this function to restart evaluating active meshes on every frame
  131738. * @returns the current scene
  131739. */
  131740. unfreezeActiveMeshes(): Scene;
  131741. private _evaluateActiveMeshes;
  131742. private _activeMesh;
  131743. /**
  131744. * Update the transform matrix to update from the current active camera
  131745. * @param force defines a boolean used to force the update even if cache is up to date
  131746. */
  131747. updateTransformMatrix(force?: boolean): void;
  131748. private _bindFrameBuffer;
  131749. /** @hidden */
  131750. _allowPostProcessClearColor: boolean;
  131751. /** @hidden */
  131752. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  131753. private _processSubCameras;
  131754. private _checkIntersections;
  131755. /** @hidden */
  131756. _advancePhysicsEngineStep(step: number): void;
  131757. /**
  131758. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  131759. */
  131760. getDeterministicFrameTime: () => number;
  131761. /** @hidden */
  131762. _animate(): void;
  131763. /** Execute all animations (for a frame) */
  131764. animate(): void;
  131765. /**
  131766. * Render the scene
  131767. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  131768. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  131769. */
  131770. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  131771. /**
  131772. * Freeze all materials
  131773. * A frozen material will not be updatable but should be faster to render
  131774. */
  131775. freezeMaterials(): void;
  131776. /**
  131777. * Unfreeze all materials
  131778. * A frozen material will not be updatable but should be faster to render
  131779. */
  131780. unfreezeMaterials(): void;
  131781. /**
  131782. * Releases all held ressources
  131783. */
  131784. dispose(): void;
  131785. /**
  131786. * Gets if the scene is already disposed
  131787. */
  131788. get isDisposed(): boolean;
  131789. /**
  131790. * Call this function to reduce memory footprint of the scene.
  131791. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131792. */
  131793. clearCachedVertexData(): void;
  131794. /**
  131795. * This function will remove the local cached buffer data from texture.
  131796. * It will save memory but will prevent the texture from being rebuilt
  131797. */
  131798. cleanCachedTextureBuffer(): void;
  131799. /**
  131800. * Get the world extend vectors with an optional filter
  131801. *
  131802. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131803. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131804. */
  131805. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  131806. min: Vector3;
  131807. max: Vector3;
  131808. };
  131809. /**
  131810. * Creates a ray that can be used to pick in the scene
  131811. * @param x defines the x coordinate of the origin (on-screen)
  131812. * @param y defines the y coordinate of the origin (on-screen)
  131813. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131814. * @param camera defines the camera to use for the picking
  131815. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131816. * @returns a Ray
  131817. */
  131818. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  131819. /**
  131820. * Creates a ray that can be used to pick in the scene
  131821. * @param x defines the x coordinate of the origin (on-screen)
  131822. * @param y defines the y coordinate of the origin (on-screen)
  131823. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131824. * @param result defines the ray where to store the picking ray
  131825. * @param camera defines the camera to use for the picking
  131826. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131827. * @returns the current scene
  131828. */
  131829. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  131830. /**
  131831. * Creates a ray that can be used to pick in the scene
  131832. * @param x defines the x coordinate of the origin (on-screen)
  131833. * @param y defines the y coordinate of the origin (on-screen)
  131834. * @param camera defines the camera to use for the picking
  131835. * @returns a Ray
  131836. */
  131837. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  131838. /**
  131839. * Creates a ray that can be used to pick in the scene
  131840. * @param x defines the x coordinate of the origin (on-screen)
  131841. * @param y defines the y coordinate of the origin (on-screen)
  131842. * @param result defines the ray where to store the picking ray
  131843. * @param camera defines the camera to use for the picking
  131844. * @returns the current scene
  131845. */
  131846. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  131847. /** Launch a ray to try to pick a mesh in the scene
  131848. * @param x position on screen
  131849. * @param y position on screen
  131850. * @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
  131851. * @param fastCheck defines if the first intersection will be used (and not the closest)
  131852. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131854. * @returns a PickingInfo
  131855. */
  131856. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  131857. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  131858. * @param x position on screen
  131859. * @param y position on screen
  131860. * @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
  131861. * @param fastCheck defines if the first intersection will be used (and not the closest)
  131862. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131863. * @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)
  131864. */
  131865. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  131866. /** Use the given ray to pick a mesh in the scene
  131867. * @param ray The ray to use to pick meshes
  131868. * @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
  131869. * @param fastCheck defines if the first intersection will be used (and not the closest)
  131870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131871. * @returns a PickingInfo
  131872. */
  131873. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  131874. /**
  131875. * Launch a ray to try to pick a mesh in the scene
  131876. * @param x X position on screen
  131877. * @param y Y position on screen
  131878. * @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
  131879. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131880. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131881. * @returns an array of PickingInfo
  131882. */
  131883. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  131884. /**
  131885. * Launch a ray to try to pick a mesh in the scene
  131886. * @param ray Ray to use
  131887. * @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
  131888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131889. * @returns an array of PickingInfo
  131890. */
  131891. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  131892. /**
  131893. * Force the value of meshUnderPointer
  131894. * @param mesh defines the mesh to use
  131895. * @param pointerId optional pointer id when using more than one pointer
  131896. */
  131897. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  131898. /**
  131899. * Gets the mesh under the pointer
  131900. * @returns a Mesh or null if no mesh is under the pointer
  131901. */
  131902. getPointerOverMesh(): Nullable<AbstractMesh>;
  131903. /** @hidden */
  131904. _rebuildGeometries(): void;
  131905. /** @hidden */
  131906. _rebuildTextures(): void;
  131907. private _getByTags;
  131908. /**
  131909. * Get a list of meshes by tags
  131910. * @param tagsQuery defines the tags query to use
  131911. * @param forEach defines a predicate used to filter results
  131912. * @returns an array of Mesh
  131913. */
  131914. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  131915. /**
  131916. * Get a list of cameras by tags
  131917. * @param tagsQuery defines the tags query to use
  131918. * @param forEach defines a predicate used to filter results
  131919. * @returns an array of Camera
  131920. */
  131921. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  131922. /**
  131923. * Get a list of lights by tags
  131924. * @param tagsQuery defines the tags query to use
  131925. * @param forEach defines a predicate used to filter results
  131926. * @returns an array of Light
  131927. */
  131928. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  131929. /**
  131930. * Get a list of materials by tags
  131931. * @param tagsQuery defines the tags query to use
  131932. * @param forEach defines a predicate used to filter results
  131933. * @returns an array of Material
  131934. */
  131935. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  131936. /**
  131937. * Get a list of transform nodes by tags
  131938. * @param tagsQuery defines the tags query to use
  131939. * @param forEach defines a predicate used to filter results
  131940. * @returns an array of TransformNode
  131941. */
  131942. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  131943. /**
  131944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131945. * This allowed control for front to back rendering or reversly depending of the special needs.
  131946. *
  131947. * @param renderingGroupId The rendering group id corresponding to its index
  131948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131951. */
  131952. 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;
  131953. /**
  131954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131955. *
  131956. * @param renderingGroupId The rendering group id corresponding to its index
  131957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131960. */
  131961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  131962. /**
  131963. * Gets the current auto clear configuration for one rendering group of the rendering
  131964. * manager.
  131965. * @param index the rendering group index to get the information for
  131966. * @returns The auto clear setup for the requested rendering group
  131967. */
  131968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  131969. private _blockMaterialDirtyMechanism;
  131970. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131971. get blockMaterialDirtyMechanism(): boolean;
  131972. set blockMaterialDirtyMechanism(value: boolean);
  131973. /**
  131974. * Will flag all materials as dirty to trigger new shader compilation
  131975. * @param flag defines the flag used to specify which material part must be marked as dirty
  131976. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131977. */
  131978. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  131979. /** @hidden */
  131980. _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;
  131981. /** @hidden */
  131982. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  131983. /** @hidden */
  131984. _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;
  131985. /** @hidden */
  131986. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  131987. /** @hidden */
  131988. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  131989. /** @hidden */
  131990. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  131991. }
  131992. }
  131993. declare module BABYLON {
  131994. /**
  131995. * Set of assets to keep when moving a scene into an asset container.
  131996. */
  131997. export class KeepAssets extends AbstractScene {
  131998. }
  131999. /**
  132000. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  132001. */
  132002. export class InstantiatedEntries {
  132003. /**
  132004. * List of new root nodes (eg. nodes with no parent)
  132005. */
  132006. rootNodes: TransformNode[];
  132007. /**
  132008. * List of new skeletons
  132009. */
  132010. skeletons: Skeleton[];
  132011. /**
  132012. * List of new animation groups
  132013. */
  132014. animationGroups: AnimationGroup[];
  132015. }
  132016. /**
  132017. * Container with a set of assets that can be added or removed from a scene.
  132018. */
  132019. export class AssetContainer extends AbstractScene {
  132020. private _wasAddedToScene;
  132021. /**
  132022. * The scene the AssetContainer belongs to.
  132023. */
  132024. scene: Scene;
  132025. /**
  132026. * Instantiates an AssetContainer.
  132027. * @param scene The scene the AssetContainer belongs to.
  132028. */
  132029. constructor(scene: Scene);
  132030. /**
  132031. * Instantiate or clone all meshes and add the new ones to the scene.
  132032. * Skeletons and animation groups will all be cloned
  132033. * @param nameFunction defines an optional function used to get new names for clones
  132034. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  132035. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  132036. */
  132037. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  132038. /**
  132039. * Adds all the assets from the container to the scene.
  132040. */
  132041. addAllToScene(): void;
  132042. /**
  132043. * Removes all the assets in the container from the scene
  132044. */
  132045. removeAllFromScene(): void;
  132046. /**
  132047. * Disposes all the assets in the container
  132048. */
  132049. dispose(): void;
  132050. private _moveAssets;
  132051. /**
  132052. * Removes all the assets contained in the scene and adds them to the container.
  132053. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  132054. */
  132055. moveAllFromScene(keepAssets?: KeepAssets): void;
  132056. /**
  132057. * 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.
  132058. * @returns the root mesh
  132059. */
  132060. createRootMesh(): Mesh;
  132061. /**
  132062. * Merge animations (direct and animation groups) from this asset container into a scene
  132063. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132064. * @param animatables set of animatables to retarget to a node from the scene
  132065. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  132066. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  132067. */
  132068. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  132069. }
  132070. }
  132071. declare module BABYLON {
  132072. /**
  132073. * Defines how the parser contract is defined.
  132074. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  132075. */
  132076. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  132077. /**
  132078. * Defines how the individual parser contract is defined.
  132079. * These parser can parse an individual asset
  132080. */
  132081. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  132082. /**
  132083. * Base class of the scene acting as a container for the different elements composing a scene.
  132084. * This class is dynamically extended by the different components of the scene increasing
  132085. * flexibility and reducing coupling
  132086. */
  132087. export abstract class AbstractScene {
  132088. /**
  132089. * Stores the list of available parsers in the application.
  132090. */
  132091. private static _BabylonFileParsers;
  132092. /**
  132093. * Stores the list of available individual parsers in the application.
  132094. */
  132095. private static _IndividualBabylonFileParsers;
  132096. /**
  132097. * Adds a parser in the list of available ones
  132098. * @param name Defines the name of the parser
  132099. * @param parser Defines the parser to add
  132100. */
  132101. static AddParser(name: string, parser: BabylonFileParser): void;
  132102. /**
  132103. * Gets a general parser from the list of avaialble ones
  132104. * @param name Defines the name of the parser
  132105. * @returns the requested parser or null
  132106. */
  132107. static GetParser(name: string): Nullable<BabylonFileParser>;
  132108. /**
  132109. * Adds n individual parser in the list of available ones
  132110. * @param name Defines the name of the parser
  132111. * @param parser Defines the parser to add
  132112. */
  132113. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  132114. /**
  132115. * Gets an individual parser from the list of avaialble ones
  132116. * @param name Defines the name of the parser
  132117. * @returns the requested parser or null
  132118. */
  132119. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  132120. /**
  132121. * Parser json data and populate both a scene and its associated container object
  132122. * @param jsonData Defines the data to parse
  132123. * @param scene Defines the scene to parse the data for
  132124. * @param container Defines the container attached to the parsing sequence
  132125. * @param rootUrl Defines the root url of the data
  132126. */
  132127. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  132128. /**
  132129. * Gets the list of root nodes (ie. nodes with no parent)
  132130. */
  132131. rootNodes: Node[];
  132132. /** All of the cameras added to this scene
  132133. * @see https://doc.babylonjs.com/babylon101/cameras
  132134. */
  132135. cameras: Camera[];
  132136. /**
  132137. * All of the lights added to this scene
  132138. * @see https://doc.babylonjs.com/babylon101/lights
  132139. */
  132140. lights: Light[];
  132141. /**
  132142. * All of the (abstract) meshes added to this scene
  132143. */
  132144. meshes: AbstractMesh[];
  132145. /**
  132146. * The list of skeletons added to the scene
  132147. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132148. */
  132149. skeletons: Skeleton[];
  132150. /**
  132151. * All of the particle systems added to this scene
  132152. * @see https://doc.babylonjs.com/babylon101/particles
  132153. */
  132154. particleSystems: IParticleSystem[];
  132155. /**
  132156. * Gets a list of Animations associated with the scene
  132157. */
  132158. animations: Animation[];
  132159. /**
  132160. * All of the animation groups added to this scene
  132161. * @see https://doc.babylonjs.com/how_to/group
  132162. */
  132163. animationGroups: AnimationGroup[];
  132164. /**
  132165. * All of the multi-materials added to this scene
  132166. * @see https://doc.babylonjs.com/how_to/multi_materials
  132167. */
  132168. multiMaterials: MultiMaterial[];
  132169. /**
  132170. * All of the materials added to this scene
  132171. * In the context of a Scene, it is not supposed to be modified manually.
  132172. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  132173. * Note also that the order of the Material within the array is not significant and might change.
  132174. * @see https://doc.babylonjs.com/babylon101/materials
  132175. */
  132176. materials: Material[];
  132177. /**
  132178. * The list of morph target managers added to the scene
  132179. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132180. */
  132181. morphTargetManagers: MorphTargetManager[];
  132182. /**
  132183. * The list of geometries used in the scene.
  132184. */
  132185. geometries: Geometry[];
  132186. /**
  132187. * All of the tranform nodes added to this scene
  132188. * In the context of a Scene, it is not supposed to be modified manually.
  132189. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132190. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132191. * @see https://doc.babylonjs.com/how_to/transformnode
  132192. */
  132193. transformNodes: TransformNode[];
  132194. /**
  132195. * ActionManagers available on the scene.
  132196. */
  132197. actionManagers: AbstractActionManager[];
  132198. /**
  132199. * Textures to keep.
  132200. */
  132201. textures: BaseTexture[];
  132202. /** @hidden */
  132203. protected _environmentTexture: Nullable<BaseTexture>;
  132204. /**
  132205. * Texture used in all pbr material as the reflection texture.
  132206. * As in the majority of the scene they are the same (exception for multi room and so on),
  132207. * this is easier to reference from here than from all the materials.
  132208. */
  132209. get environmentTexture(): Nullable<BaseTexture>;
  132210. set environmentTexture(value: Nullable<BaseTexture>);
  132211. /**
  132212. * The list of postprocesses added to the scene
  132213. */
  132214. postProcesses: PostProcess[];
  132215. /**
  132216. * @returns all meshes, lights, cameras, transformNodes and bones
  132217. */
  132218. getNodes(): Array<Node>;
  132219. }
  132220. }
  132221. declare module BABYLON {
  132222. /**
  132223. * Interface used to define options for Sound class
  132224. */
  132225. export interface ISoundOptions {
  132226. /**
  132227. * Does the sound autoplay once loaded.
  132228. */
  132229. autoplay?: boolean;
  132230. /**
  132231. * Does the sound loop after it finishes playing once.
  132232. */
  132233. loop?: boolean;
  132234. /**
  132235. * Sound's volume
  132236. */
  132237. volume?: number;
  132238. /**
  132239. * Is it a spatial sound?
  132240. */
  132241. spatialSound?: boolean;
  132242. /**
  132243. * Maximum distance to hear that sound
  132244. */
  132245. maxDistance?: number;
  132246. /**
  132247. * Uses user defined attenuation function
  132248. */
  132249. useCustomAttenuation?: boolean;
  132250. /**
  132251. * Define the roll off factor of spatial sounds.
  132252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132253. */
  132254. rolloffFactor?: number;
  132255. /**
  132256. * Define the reference distance the sound should be heard perfectly.
  132257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132258. */
  132259. refDistance?: number;
  132260. /**
  132261. * Define the distance attenuation model the sound will follow.
  132262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132263. */
  132264. distanceModel?: string;
  132265. /**
  132266. * Defines the playback speed (1 by default)
  132267. */
  132268. playbackRate?: number;
  132269. /**
  132270. * Defines if the sound is from a streaming source
  132271. */
  132272. streaming?: boolean;
  132273. /**
  132274. * Defines an optional length (in seconds) inside the sound file
  132275. */
  132276. length?: number;
  132277. /**
  132278. * Defines an optional offset (in seconds) inside the sound file
  132279. */
  132280. offset?: number;
  132281. /**
  132282. * If true, URLs will not be required to state the audio file codec to use.
  132283. */
  132284. skipCodecCheck?: boolean;
  132285. }
  132286. }
  132287. declare module BABYLON {
  132288. /**
  132289. * Defines a sound that can be played in the application.
  132290. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  132291. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132292. */
  132293. export class Sound {
  132294. /**
  132295. * The name of the sound in the scene.
  132296. */
  132297. name: string;
  132298. /**
  132299. * Does the sound autoplay once loaded.
  132300. */
  132301. autoplay: boolean;
  132302. private _loop;
  132303. /**
  132304. * Does the sound loop after it finishes playing once.
  132305. */
  132306. get loop(): boolean;
  132307. set loop(value: boolean);
  132308. /**
  132309. * Does the sound use a custom attenuation curve to simulate the falloff
  132310. * happening when the source gets further away from the camera.
  132311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  132312. */
  132313. useCustomAttenuation: boolean;
  132314. /**
  132315. * The sound track id this sound belongs to.
  132316. */
  132317. soundTrackId: number;
  132318. /**
  132319. * Is this sound currently played.
  132320. */
  132321. isPlaying: boolean;
  132322. /**
  132323. * Is this sound currently paused.
  132324. */
  132325. isPaused: boolean;
  132326. /**
  132327. * Does this sound enables spatial sound.
  132328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132329. */
  132330. spatialSound: boolean;
  132331. /**
  132332. * Define the reference distance the sound should be heard perfectly.
  132333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132334. */
  132335. refDistance: number;
  132336. /**
  132337. * Define the roll off factor of spatial sounds.
  132338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132339. */
  132340. rolloffFactor: number;
  132341. /**
  132342. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  132343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132344. */
  132345. maxDistance: number;
  132346. /**
  132347. * Define the distance attenuation model the sound will follow.
  132348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132349. */
  132350. distanceModel: string;
  132351. /**
  132352. * @hidden
  132353. * Back Compat
  132354. **/
  132355. onended: () => any;
  132356. /**
  132357. * Gets or sets an object used to store user defined information for the sound.
  132358. */
  132359. metadata: any;
  132360. /**
  132361. * Observable event when the current playing sound finishes.
  132362. */
  132363. onEndedObservable: Observable<Sound>;
  132364. /**
  132365. * Gets the current time for the sound.
  132366. */
  132367. get currentTime(): number;
  132368. private _panningModel;
  132369. private _playbackRate;
  132370. private _streaming;
  132371. private _startTime;
  132372. private _startOffset;
  132373. private _position;
  132374. /** @hidden */
  132375. _positionInEmitterSpace: boolean;
  132376. private _localDirection;
  132377. private _volume;
  132378. private _isReadyToPlay;
  132379. private _isDirectional;
  132380. private _readyToPlayCallback;
  132381. private _audioBuffer;
  132382. private _soundSource;
  132383. private _streamingSource;
  132384. private _soundPanner;
  132385. private _soundGain;
  132386. private _inputAudioNode;
  132387. private _outputAudioNode;
  132388. private _coneInnerAngle;
  132389. private _coneOuterAngle;
  132390. private _coneOuterGain;
  132391. private _scene;
  132392. private _connectedTransformNode;
  132393. private _customAttenuationFunction;
  132394. private _registerFunc;
  132395. private _isOutputConnected;
  132396. private _htmlAudioElement;
  132397. private _urlType;
  132398. private _length?;
  132399. private _offset?;
  132400. /** @hidden */
  132401. static _SceneComponentInitialization: (scene: Scene) => void;
  132402. /**
  132403. * Create a sound and attach it to a scene
  132404. * @param name Name of your sound
  132405. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  132406. * @param scene defines the scene the sound belongs to
  132407. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  132408. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  132409. */
  132410. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  132411. /**
  132412. * Release the sound and its associated resources
  132413. */
  132414. dispose(): void;
  132415. /**
  132416. * Gets if the sounds is ready to be played or not.
  132417. * @returns true if ready, otherwise false
  132418. */
  132419. isReady(): boolean;
  132420. /**
  132421. * Get the current class name.
  132422. * @returns current class name
  132423. */
  132424. getClassName(): string;
  132425. private _soundLoaded;
  132426. /**
  132427. * Sets the data of the sound from an audiobuffer
  132428. * @param audioBuffer The audioBuffer containing the data
  132429. */
  132430. setAudioBuffer(audioBuffer: AudioBuffer): void;
  132431. /**
  132432. * Updates the current sounds options such as maxdistance, loop...
  132433. * @param options A JSON object containing values named as the object properties
  132434. */
  132435. updateOptions(options: ISoundOptions): void;
  132436. private _createSpatialParameters;
  132437. private _updateSpatialParameters;
  132438. /**
  132439. * Switch the panning model to HRTF:
  132440. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  132441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132442. */
  132443. switchPanningModelToHRTF(): void;
  132444. /**
  132445. * Switch the panning model to Equal Power:
  132446. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  132447. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132448. */
  132449. switchPanningModelToEqualPower(): void;
  132450. private _switchPanningModel;
  132451. /**
  132452. * Connect this sound to a sound track audio node like gain...
  132453. * @param soundTrackAudioNode the sound track audio node to connect to
  132454. */
  132455. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  132456. /**
  132457. * Transform this sound into a directional source
  132458. * @param coneInnerAngle Size of the inner cone in degree
  132459. * @param coneOuterAngle Size of the outer cone in degree
  132460. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  132461. */
  132462. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  132463. /**
  132464. * Gets or sets the inner angle for the directional cone.
  132465. */
  132466. get directionalConeInnerAngle(): number;
  132467. /**
  132468. * Gets or sets the inner angle for the directional cone.
  132469. */
  132470. set directionalConeInnerAngle(value: number);
  132471. /**
  132472. * Gets or sets the outer angle for the directional cone.
  132473. */
  132474. get directionalConeOuterAngle(): number;
  132475. /**
  132476. * Gets or sets the outer angle for the directional cone.
  132477. */
  132478. set directionalConeOuterAngle(value: number);
  132479. /**
  132480. * Sets the position of the emitter if spatial sound is enabled
  132481. * @param newPosition Defines the new posisiton
  132482. */
  132483. setPosition(newPosition: Vector3): void;
  132484. /**
  132485. * Sets the local direction of the emitter if spatial sound is enabled
  132486. * @param newLocalDirection Defines the new local direction
  132487. */
  132488. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  132489. private _updateDirection;
  132490. /** @hidden */
  132491. updateDistanceFromListener(): void;
  132492. /**
  132493. * Sets a new custom attenuation function for the sound.
  132494. * @param callback Defines the function used for the attenuation
  132495. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  132496. */
  132497. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  132498. /**
  132499. * Play the sound
  132500. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  132501. * @param offset (optional) Start the sound at a specific time in seconds
  132502. * @param length (optional) Sound duration (in seconds)
  132503. */
  132504. play(time?: number, offset?: number, length?: number): void;
  132505. private _onended;
  132506. /**
  132507. * Stop the sound
  132508. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  132509. */
  132510. stop(time?: number): void;
  132511. /**
  132512. * Put the sound in pause
  132513. */
  132514. pause(): void;
  132515. /**
  132516. * Sets a dedicated volume for this sounds
  132517. * @param newVolume Define the new volume of the sound
  132518. * @param time Define time for gradual change to new volume
  132519. */
  132520. setVolume(newVolume: number, time?: number): void;
  132521. /**
  132522. * Set the sound play back rate
  132523. * @param newPlaybackRate Define the playback rate the sound should be played at
  132524. */
  132525. setPlaybackRate(newPlaybackRate: number): void;
  132526. /**
  132527. * Gets the volume of the sound.
  132528. * @returns the volume of the sound
  132529. */
  132530. getVolume(): number;
  132531. /**
  132532. * Attach the sound to a dedicated mesh
  132533. * @param transformNode The transform node to connect the sound with
  132534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  132535. */
  132536. attachToMesh(transformNode: TransformNode): void;
  132537. /**
  132538. * Detach the sound from the previously attached mesh
  132539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  132540. */
  132541. detachFromMesh(): void;
  132542. private _onRegisterAfterWorldMatrixUpdate;
  132543. /**
  132544. * Clone the current sound in the scene.
  132545. * @returns the new sound clone
  132546. */
  132547. clone(): Nullable<Sound>;
  132548. /**
  132549. * Gets the current underlying audio buffer containing the data
  132550. * @returns the audio buffer
  132551. */
  132552. getAudioBuffer(): Nullable<AudioBuffer>;
  132553. /**
  132554. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  132555. * @returns the source node
  132556. */
  132557. getSoundSource(): Nullable<AudioBufferSourceNode>;
  132558. /**
  132559. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  132560. * @returns the gain node
  132561. */
  132562. getSoundGain(): Nullable<GainNode>;
  132563. /**
  132564. * Serializes the Sound in a JSON representation
  132565. * @returns the JSON representation of the sound
  132566. */
  132567. serialize(): any;
  132568. /**
  132569. * Parse a JSON representation of a sound to innstantiate in a given scene
  132570. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  132571. * @param scene Define the scene the new parsed sound should be created in
  132572. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  132573. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  132574. * @returns the newly parsed sound
  132575. */
  132576. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  132577. }
  132578. }
  132579. declare module BABYLON {
  132580. /**
  132581. * This defines an action helpful to play a defined sound on a triggered action.
  132582. */
  132583. export class PlaySoundAction extends Action {
  132584. private _sound;
  132585. /**
  132586. * Instantiate the action
  132587. * @param triggerOptions defines the trigger options
  132588. * @param sound defines the sound to play
  132589. * @param condition defines the trigger related conditions
  132590. */
  132591. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  132592. /** @hidden */
  132593. _prepare(): void;
  132594. /**
  132595. * Execute the action and play the sound.
  132596. */
  132597. execute(): void;
  132598. /**
  132599. * Serializes the actions and its related information.
  132600. * @param parent defines the object to serialize in
  132601. * @returns the serialized object
  132602. */
  132603. serialize(parent: any): any;
  132604. }
  132605. /**
  132606. * This defines an action helpful to stop a defined sound on a triggered action.
  132607. */
  132608. export class StopSoundAction extends Action {
  132609. private _sound;
  132610. /**
  132611. * Instantiate the action
  132612. * @param triggerOptions defines the trigger options
  132613. * @param sound defines the sound to stop
  132614. * @param condition defines the trigger related conditions
  132615. */
  132616. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  132617. /** @hidden */
  132618. _prepare(): void;
  132619. /**
  132620. * Execute the action and stop the sound.
  132621. */
  132622. execute(): void;
  132623. /**
  132624. * Serializes the actions and its related information.
  132625. * @param parent defines the object to serialize in
  132626. * @returns the serialized object
  132627. */
  132628. serialize(parent: any): any;
  132629. }
  132630. }
  132631. declare module BABYLON {
  132632. /**
  132633. * This defines an action responsible to change the value of a property
  132634. * by interpolating between its current value and the newly set one once triggered.
  132635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  132636. */
  132637. export class InterpolateValueAction extends Action {
  132638. /**
  132639. * Defines the path of the property where the value should be interpolated
  132640. */
  132641. propertyPath: string;
  132642. /**
  132643. * Defines the target value at the end of the interpolation.
  132644. */
  132645. value: any;
  132646. /**
  132647. * Defines the time it will take for the property to interpolate to the value.
  132648. */
  132649. duration: number;
  132650. /**
  132651. * Defines if the other scene animations should be stopped when the action has been triggered
  132652. */
  132653. stopOtherAnimations?: boolean;
  132654. /**
  132655. * Defines a callback raised once the interpolation animation has been done.
  132656. */
  132657. onInterpolationDone?: () => void;
  132658. /**
  132659. * Observable triggered once the interpolation animation has been done.
  132660. */
  132661. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  132662. private _target;
  132663. private _effectiveTarget;
  132664. private _property;
  132665. /**
  132666. * Instantiate the action
  132667. * @param triggerOptions defines the trigger options
  132668. * @param target defines the object containing the value to interpolate
  132669. * @param propertyPath defines the path to the property in the target object
  132670. * @param value defines the target value at the end of the interpolation
  132671. * @param duration deines the time it will take for the property to interpolate to the value.
  132672. * @param condition defines the trigger related conditions
  132673. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  132674. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  132675. */
  132676. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  132677. /** @hidden */
  132678. _prepare(): void;
  132679. /**
  132680. * Execute the action starts the value interpolation.
  132681. */
  132682. execute(): void;
  132683. /**
  132684. * Serializes the actions and its related information.
  132685. * @param parent defines the object to serialize in
  132686. * @returns the serialized object
  132687. */
  132688. serialize(parent: any): any;
  132689. }
  132690. }
  132691. declare module BABYLON {
  132692. /**
  132693. * This represents the default audio engine used in babylon.
  132694. * It is responsible to play, synchronize and analyse sounds throughout the application.
  132695. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132696. */
  132697. export class AudioEngine implements IAudioEngine {
  132698. private _audioContext;
  132699. private _audioContextInitialized;
  132700. private _muteButton;
  132701. private _hostElement;
  132702. /**
  132703. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  132704. */
  132705. canUseWebAudio: boolean;
  132706. /**
  132707. * The master gain node defines the global audio volume of your audio engine.
  132708. */
  132709. masterGain: GainNode;
  132710. /**
  132711. * Defines if Babylon should emit a warning if WebAudio is not supported.
  132712. * @ignoreNaming
  132713. */
  132714. WarnedWebAudioUnsupported: boolean;
  132715. /**
  132716. * Gets whether or not mp3 are supported by your browser.
  132717. */
  132718. isMP3supported: boolean;
  132719. /**
  132720. * Gets whether or not ogg are supported by your browser.
  132721. */
  132722. isOGGsupported: boolean;
  132723. /**
  132724. * Gets whether audio has been unlocked on the device.
  132725. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  132726. * a user interaction has happened.
  132727. */
  132728. unlocked: boolean;
  132729. /**
  132730. * Defines if the audio engine relies on a custom unlocked button.
  132731. * In this case, the embedded button will not be displayed.
  132732. */
  132733. useCustomUnlockedButton: boolean;
  132734. /**
  132735. * Event raised when audio has been unlocked on the browser.
  132736. */
  132737. onAudioUnlockedObservable: Observable<IAudioEngine>;
  132738. /**
  132739. * Event raised when audio has been locked on the browser.
  132740. */
  132741. onAudioLockedObservable: Observable<IAudioEngine>;
  132742. /**
  132743. * Gets the current AudioContext if available.
  132744. */
  132745. get audioContext(): Nullable<AudioContext>;
  132746. private _connectedAnalyser;
  132747. /**
  132748. * Instantiates a new audio engine.
  132749. *
  132750. * There should be only one per page as some browsers restrict the number
  132751. * of audio contexts you can create.
  132752. * @param hostElement defines the host element where to display the mute icon if necessary
  132753. */
  132754. constructor(hostElement?: Nullable<HTMLElement>);
  132755. /**
  132756. * Flags the audio engine in Locked state.
  132757. * This happens due to new browser policies preventing audio to autoplay.
  132758. */
  132759. lock(): void;
  132760. /**
  132761. * Unlocks the audio engine once a user action has been done on the dom.
  132762. * This is helpful to resume play once browser policies have been satisfied.
  132763. */
  132764. unlock(): void;
  132765. private _resumeAudioContext;
  132766. private _initializeAudioContext;
  132767. private _tryToRun;
  132768. private _triggerRunningState;
  132769. private _triggerSuspendedState;
  132770. private _displayMuteButton;
  132771. private _moveButtonToTopLeft;
  132772. private _onResize;
  132773. private _hideMuteButton;
  132774. /**
  132775. * Destroy and release the resources associated with the audio ccontext.
  132776. */
  132777. dispose(): void;
  132778. /**
  132779. * Gets the global volume sets on the master gain.
  132780. * @returns the global volume if set or -1 otherwise
  132781. */
  132782. getGlobalVolume(): number;
  132783. /**
  132784. * Sets the global volume of your experience (sets on the master gain).
  132785. * @param newVolume Defines the new global volume of the application
  132786. */
  132787. setGlobalVolume(newVolume: number): void;
  132788. /**
  132789. * Connect the audio engine to an audio analyser allowing some amazing
  132790. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  132791. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  132792. * @param analyser The analyser to connect to the engine
  132793. */
  132794. connectToAnalyser(analyser: Analyser): void;
  132795. }
  132796. }
  132797. declare module BABYLON {
  132798. /**
  132799. * Options allowed during the creation of a sound track.
  132800. */
  132801. export interface ISoundTrackOptions {
  132802. /**
  132803. * The volume the sound track should take during creation
  132804. */
  132805. volume?: number;
  132806. /**
  132807. * Define if the sound track is the main sound track of the scene
  132808. */
  132809. mainTrack?: boolean;
  132810. }
  132811. /**
  132812. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  132813. * It will be also used in a future release to apply effects on a specific track.
  132814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  132815. */
  132816. export class SoundTrack {
  132817. /**
  132818. * The unique identifier of the sound track in the scene.
  132819. */
  132820. id: number;
  132821. /**
  132822. * The list of sounds included in the sound track.
  132823. */
  132824. soundCollection: Array<Sound>;
  132825. private _outputAudioNode;
  132826. private _scene;
  132827. private _connectedAnalyser;
  132828. private _options;
  132829. private _isInitialized;
  132830. /**
  132831. * Creates a new sound track.
  132832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  132833. * @param scene Define the scene the sound track belongs to
  132834. * @param options
  132835. */
  132836. constructor(scene: Scene, options?: ISoundTrackOptions);
  132837. private _initializeSoundTrackAudioGraph;
  132838. /**
  132839. * Release the sound track and its associated resources
  132840. */
  132841. dispose(): void;
  132842. /**
  132843. * Adds a sound to this sound track
  132844. * @param sound define the cound to add
  132845. * @ignoreNaming
  132846. */
  132847. addSound(sound: Sound): void;
  132848. /**
  132849. * Removes a sound to this sound track
  132850. * @param sound define the cound to remove
  132851. * @ignoreNaming
  132852. */
  132853. removeSound(sound: Sound): void;
  132854. /**
  132855. * Set a global volume for the full sound track.
  132856. * @param newVolume Define the new volume of the sound track
  132857. */
  132858. setVolume(newVolume: number): void;
  132859. /**
  132860. * Switch the panning model to HRTF:
  132861. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  132862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132863. */
  132864. switchPanningModelToHRTF(): void;
  132865. /**
  132866. * Switch the panning model to Equal Power:
  132867. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  132868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132869. */
  132870. switchPanningModelToEqualPower(): void;
  132871. /**
  132872. * Connect the sound track to an audio analyser allowing some amazing
  132873. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  132874. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  132875. * @param analyser The analyser to connect to the engine
  132876. */
  132877. connectToAnalyser(analyser: Analyser): void;
  132878. }
  132879. }
  132880. declare module BABYLON {
  132881. interface AbstractScene {
  132882. /**
  132883. * The list of sounds used in the scene.
  132884. */
  132885. sounds: Nullable<Array<Sound>>;
  132886. }
  132887. interface Scene {
  132888. /**
  132889. * @hidden
  132890. * Backing field
  132891. */
  132892. _mainSoundTrack: SoundTrack;
  132893. /**
  132894. * The main sound track played by the scene.
  132895. * It cotains your primary collection of sounds.
  132896. */
  132897. mainSoundTrack: SoundTrack;
  132898. /**
  132899. * The list of sound tracks added to the scene
  132900. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132901. */
  132902. soundTracks: Nullable<Array<SoundTrack>>;
  132903. /**
  132904. * Gets a sound using a given name
  132905. * @param name defines the name to search for
  132906. * @return the found sound or null if not found at all.
  132907. */
  132908. getSoundByName(name: string): Nullable<Sound>;
  132909. /**
  132910. * Gets or sets if audio support is enabled
  132911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132912. */
  132913. audioEnabled: boolean;
  132914. /**
  132915. * Gets or sets if audio will be output to headphones
  132916. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132917. */
  132918. headphone: boolean;
  132919. /**
  132920. * Gets or sets custom audio listener position provider
  132921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132922. */
  132923. audioListenerPositionProvider: Nullable<() => Vector3>;
  132924. /**
  132925. * Gets or sets a refresh rate when using 3D audio positioning
  132926. */
  132927. audioPositioningRefreshRate: number;
  132928. }
  132929. /**
  132930. * Defines the sound scene component responsible to manage any sounds
  132931. * in a given scene.
  132932. */
  132933. export class AudioSceneComponent implements ISceneSerializableComponent {
  132934. private static _CameraDirectionLH;
  132935. private static _CameraDirectionRH;
  132936. /**
  132937. * The component name helpfull to identify the component in the list of scene components.
  132938. */
  132939. readonly name: string;
  132940. /**
  132941. * The scene the component belongs to.
  132942. */
  132943. scene: Scene;
  132944. private _audioEnabled;
  132945. /**
  132946. * Gets whether audio is enabled or not.
  132947. * Please use related enable/disable method to switch state.
  132948. */
  132949. get audioEnabled(): boolean;
  132950. private _headphone;
  132951. /**
  132952. * Gets whether audio is outputing to headphone or not.
  132953. * Please use the according Switch methods to change output.
  132954. */
  132955. get headphone(): boolean;
  132956. /**
  132957. * Gets or sets a refresh rate when using 3D audio positioning
  132958. */
  132959. audioPositioningRefreshRate: number;
  132960. private _audioListenerPositionProvider;
  132961. /**
  132962. * Gets the current audio listener position provider
  132963. */
  132964. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  132965. /**
  132966. * Sets a custom listener position for all sounds in the scene
  132967. * By default, this is the position of the first active camera
  132968. */
  132969. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  132970. /**
  132971. * Creates a new instance of the component for the given scene
  132972. * @param scene Defines the scene to register the component in
  132973. */
  132974. constructor(scene: Scene);
  132975. /**
  132976. * Registers the component in a given scene
  132977. */
  132978. register(): void;
  132979. /**
  132980. * Rebuilds the elements related to this component in case of
  132981. * context lost for instance.
  132982. */
  132983. rebuild(): void;
  132984. /**
  132985. * Serializes the component data to the specified json object
  132986. * @param serializationObject The object to serialize to
  132987. */
  132988. serialize(serializationObject: any): void;
  132989. /**
  132990. * Adds all the elements from the container to the scene
  132991. * @param container the container holding the elements
  132992. */
  132993. addFromContainer(container: AbstractScene): void;
  132994. /**
  132995. * Removes all the elements in the container from the scene
  132996. * @param container contains the elements to remove
  132997. * @param dispose if the removed element should be disposed (default: false)
  132998. */
  132999. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133000. /**
  133001. * Disposes the component and the associated ressources.
  133002. */
  133003. dispose(): void;
  133004. /**
  133005. * Disables audio in the associated scene.
  133006. */
  133007. disableAudio(): void;
  133008. /**
  133009. * Enables audio in the associated scene.
  133010. */
  133011. enableAudio(): void;
  133012. /**
  133013. * Switch audio to headphone output.
  133014. */
  133015. switchAudioModeForHeadphones(): void;
  133016. /**
  133017. * Switch audio to normal speakers.
  133018. */
  133019. switchAudioModeForNormalSpeakers(): void;
  133020. private _cachedCameraDirection;
  133021. private _cachedCameraPosition;
  133022. private _lastCheck;
  133023. private _afterRender;
  133024. }
  133025. }
  133026. declare module BABYLON {
  133027. /**
  133028. * Wraps one or more Sound objects and selects one with random weight for playback.
  133029. */
  133030. export class WeightedSound {
  133031. /** When true a Sound will be selected and played when the current playing Sound completes. */
  133032. loop: boolean;
  133033. private _coneInnerAngle;
  133034. private _coneOuterAngle;
  133035. private _volume;
  133036. /** A Sound is currently playing. */
  133037. isPlaying: boolean;
  133038. /** A Sound is currently paused. */
  133039. isPaused: boolean;
  133040. private _sounds;
  133041. private _weights;
  133042. private _currentIndex?;
  133043. /**
  133044. * Creates a new WeightedSound from the list of sounds given.
  133045. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  133046. * @param sounds Array of Sounds that will be selected from.
  133047. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  133048. */
  133049. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  133050. /**
  133051. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  133052. */
  133053. get directionalConeInnerAngle(): number;
  133054. /**
  133055. * The size of cone in degress for a directional sound in which there will be no attenuation.
  133056. */
  133057. set directionalConeInnerAngle(value: number);
  133058. /**
  133059. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133060. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133061. */
  133062. get directionalConeOuterAngle(): number;
  133063. /**
  133064. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133065. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133066. */
  133067. set directionalConeOuterAngle(value: number);
  133068. /**
  133069. * Playback volume.
  133070. */
  133071. get volume(): number;
  133072. /**
  133073. * Playback volume.
  133074. */
  133075. set volume(value: number);
  133076. private _onended;
  133077. /**
  133078. * Suspend playback
  133079. */
  133080. pause(): void;
  133081. /**
  133082. * Stop playback
  133083. */
  133084. stop(): void;
  133085. /**
  133086. * Start playback.
  133087. * @param startOffset Position the clip head at a specific time in seconds.
  133088. */
  133089. play(startOffset?: number): void;
  133090. }
  133091. }
  133092. declare module BABYLON {
  133093. /**
  133094. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  133095. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133096. */
  133097. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  133098. /**
  133099. * Gets the name of the behavior.
  133100. */
  133101. get name(): string;
  133102. /**
  133103. * The easing function used by animations
  133104. */
  133105. static EasingFunction: BackEase;
  133106. /**
  133107. * The easing mode used by animations
  133108. */
  133109. static EasingMode: number;
  133110. /**
  133111. * The duration of the animation, in milliseconds
  133112. */
  133113. transitionDuration: number;
  133114. /**
  133115. * Length of the distance animated by the transition when lower radius is reached
  133116. */
  133117. lowerRadiusTransitionRange: number;
  133118. /**
  133119. * Length of the distance animated by the transition when upper radius is reached
  133120. */
  133121. upperRadiusTransitionRange: number;
  133122. private _autoTransitionRange;
  133123. /**
  133124. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133125. */
  133126. get autoTransitionRange(): boolean;
  133127. /**
  133128. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133129. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  133130. */
  133131. set autoTransitionRange(value: boolean);
  133132. private _attachedCamera;
  133133. private _onAfterCheckInputsObserver;
  133134. private _onMeshTargetChangedObserver;
  133135. /**
  133136. * Initializes the behavior.
  133137. */
  133138. init(): void;
  133139. /**
  133140. * Attaches the behavior to its arc rotate camera.
  133141. * @param camera Defines the camera to attach the behavior to
  133142. */
  133143. attach(camera: ArcRotateCamera): void;
  133144. /**
  133145. * Detaches the behavior from its current arc rotate camera.
  133146. */
  133147. detach(): void;
  133148. private _radiusIsAnimating;
  133149. private _radiusBounceTransition;
  133150. private _animatables;
  133151. private _cachedWheelPrecision;
  133152. /**
  133153. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  133154. * @param radiusLimit The limit to check against.
  133155. * @return Bool to indicate if at limit.
  133156. */
  133157. private _isRadiusAtLimit;
  133158. /**
  133159. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  133160. * @param radiusDelta The delta by which to animate to. Can be negative.
  133161. */
  133162. private _applyBoundRadiusAnimation;
  133163. /**
  133164. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  133165. */
  133166. protected _clearAnimationLocks(): void;
  133167. /**
  133168. * Stops and removes all animations that have been applied to the camera
  133169. */
  133170. stopAllAnimations(): void;
  133171. }
  133172. }
  133173. declare module BABYLON {
  133174. /**
  133175. * 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.
  133176. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133177. */
  133178. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  133179. /**
  133180. * Gets the name of the behavior.
  133181. */
  133182. get name(): string;
  133183. private _mode;
  133184. private _radiusScale;
  133185. private _positionScale;
  133186. private _defaultElevation;
  133187. private _elevationReturnTime;
  133188. private _elevationReturnWaitTime;
  133189. private _zoomStopsAnimation;
  133190. private _framingTime;
  133191. /**
  133192. * The easing function used by animations
  133193. */
  133194. static EasingFunction: ExponentialEase;
  133195. /**
  133196. * The easing mode used by animations
  133197. */
  133198. static EasingMode: number;
  133199. /**
  133200. * Sets the current mode used by the behavior
  133201. */
  133202. set mode(mode: number);
  133203. /**
  133204. * Gets current mode used by the behavior.
  133205. */
  133206. get mode(): number;
  133207. /**
  133208. * Sets the scale applied to the radius (1 by default)
  133209. */
  133210. set radiusScale(radius: number);
  133211. /**
  133212. * Gets the scale applied to the radius
  133213. */
  133214. get radiusScale(): number;
  133215. /**
  133216. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  133217. */
  133218. set positionScale(scale: number);
  133219. /**
  133220. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  133221. */
  133222. get positionScale(): number;
  133223. /**
  133224. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  133225. * behaviour is triggered, in radians.
  133226. */
  133227. set defaultElevation(elevation: number);
  133228. /**
  133229. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  133230. * behaviour is triggered, in radians.
  133231. */
  133232. get defaultElevation(): number;
  133233. /**
  133234. * Sets the time (in milliseconds) taken to return to the default beta position.
  133235. * Negative value indicates camera should not return to default.
  133236. */
  133237. set elevationReturnTime(speed: number);
  133238. /**
  133239. * Gets the time (in milliseconds) taken to return to the default beta position.
  133240. * Negative value indicates camera should not return to default.
  133241. */
  133242. get elevationReturnTime(): number;
  133243. /**
  133244. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  133245. */
  133246. set elevationReturnWaitTime(time: number);
  133247. /**
  133248. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  133249. */
  133250. get elevationReturnWaitTime(): number;
  133251. /**
  133252. * Sets the flag that indicates if user zooming should stop animation.
  133253. */
  133254. set zoomStopsAnimation(flag: boolean);
  133255. /**
  133256. * Gets the flag that indicates if user zooming should stop animation.
  133257. */
  133258. get zoomStopsAnimation(): boolean;
  133259. /**
  133260. * Sets the transition time when framing the mesh, in milliseconds
  133261. */
  133262. set framingTime(time: number);
  133263. /**
  133264. * Gets the transition time when framing the mesh, in milliseconds
  133265. */
  133266. get framingTime(): number;
  133267. /**
  133268. * Define if the behavior should automatically change the configured
  133269. * camera limits and sensibilities.
  133270. */
  133271. autoCorrectCameraLimitsAndSensibility: boolean;
  133272. private _onPrePointerObservableObserver;
  133273. private _onAfterCheckInputsObserver;
  133274. private _onMeshTargetChangedObserver;
  133275. private _attachedCamera;
  133276. private _isPointerDown;
  133277. private _lastInteractionTime;
  133278. /**
  133279. * Initializes the behavior.
  133280. */
  133281. init(): void;
  133282. /**
  133283. * Attaches the behavior to its arc rotate camera.
  133284. * @param camera Defines the camera to attach the behavior to
  133285. */
  133286. attach(camera: ArcRotateCamera): void;
  133287. /**
  133288. * Detaches the behavior from its current arc rotate camera.
  133289. */
  133290. detach(): void;
  133291. private _animatables;
  133292. private _betaIsAnimating;
  133293. private _betaTransition;
  133294. private _radiusTransition;
  133295. private _vectorTransition;
  133296. /**
  133297. * Targets the given mesh and updates zoom level accordingly.
  133298. * @param mesh The mesh to target.
  133299. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133300. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133301. */
  133302. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133303. /**
  133304. * Targets the given mesh with its children and updates zoom level accordingly.
  133305. * @param mesh The mesh to target.
  133306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133308. */
  133309. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133310. /**
  133311. * Targets the given meshes with their children and updates zoom level accordingly.
  133312. * @param meshes The mesh to target.
  133313. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133314. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133315. */
  133316. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133317. /**
  133318. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  133319. * @param minimumWorld Determines the smaller position of the bounding box extend
  133320. * @param maximumWorld Determines the bigger position of the bounding box extend
  133321. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133322. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133323. */
  133324. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133325. /**
  133326. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  133327. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  133328. * frustum width.
  133329. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  133330. * to fully enclose the mesh in the viewing frustum.
  133331. */
  133332. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  133333. /**
  133334. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  133335. * is automatically returned to its default position (expected to be above ground plane).
  133336. */
  133337. private _maintainCameraAboveGround;
  133338. /**
  133339. * Returns the frustum slope based on the canvas ratio and camera FOV
  133340. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  133341. */
  133342. private _getFrustumSlope;
  133343. /**
  133344. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  133345. */
  133346. private _clearAnimationLocks;
  133347. /**
  133348. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  133349. */
  133350. private _applyUserInteraction;
  133351. /**
  133352. * Stops and removes all animations that have been applied to the camera
  133353. */
  133354. stopAllAnimations(): void;
  133355. /**
  133356. * Gets a value indicating if the user is moving the camera
  133357. */
  133358. get isUserIsMoving(): boolean;
  133359. /**
  133360. * The camera can move all the way towards the mesh.
  133361. */
  133362. static IgnoreBoundsSizeMode: number;
  133363. /**
  133364. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  133365. */
  133366. static FitFrustumSidesMode: number;
  133367. }
  133368. }
  133369. declare module BABYLON {
  133370. /**
  133371. * Base class for Camera Pointer Inputs.
  133372. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  133373. * for example usage.
  133374. */
  133375. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  133376. /**
  133377. * Defines the camera the input is attached to.
  133378. */
  133379. abstract camera: Camera;
  133380. /**
  133381. * Whether keyboard modifier keys are pressed at time of last mouse event.
  133382. */
  133383. protected _altKey: boolean;
  133384. protected _ctrlKey: boolean;
  133385. protected _metaKey: boolean;
  133386. protected _shiftKey: boolean;
  133387. /**
  133388. * Which mouse buttons were pressed at time of last mouse event.
  133389. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  133390. */
  133391. protected _buttonsPressed: number;
  133392. /**
  133393. * Defines the buttons associated with the input to handle camera move.
  133394. */
  133395. buttons: number[];
  133396. /**
  133397. * Attach the input controls to a specific dom element to get the input from.
  133398. * @param element Defines the element the controls should be listened from
  133399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133400. */
  133401. attachControl(noPreventDefault?: boolean): void;
  133402. /**
  133403. * Detach the current controls from the specified dom element.
  133404. */
  133405. detachControl(): void;
  133406. /**
  133407. * Gets the class name of the current input.
  133408. * @returns the class name
  133409. */
  133410. getClassName(): string;
  133411. /**
  133412. * Get the friendly name associated with the input class.
  133413. * @returns the input friendly name
  133414. */
  133415. getSimpleName(): string;
  133416. /**
  133417. * Called on pointer POINTERDOUBLETAP event.
  133418. * Override this method to provide functionality on POINTERDOUBLETAP event.
  133419. */
  133420. protected onDoubleTap(type: string): void;
  133421. /**
  133422. * Called on pointer POINTERMOVE event if only a single touch is active.
  133423. * Override this method to provide functionality.
  133424. */
  133425. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  133426. /**
  133427. * Called on pointer POINTERMOVE event if multiple touches are active.
  133428. * Override this method to provide functionality.
  133429. */
  133430. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  133431. /**
  133432. * Called on JS contextmenu event.
  133433. * Override this method to provide functionality.
  133434. */
  133435. protected onContextMenu(evt: PointerEvent): void;
  133436. /**
  133437. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  133438. * press.
  133439. * Override this method to provide functionality.
  133440. */
  133441. protected onButtonDown(evt: PointerEvent): void;
  133442. /**
  133443. * Called each time a new POINTERUP event occurs. Ie, for each button
  133444. * release.
  133445. * Override this method to provide functionality.
  133446. */
  133447. protected onButtonUp(evt: PointerEvent): void;
  133448. /**
  133449. * Called when window becomes inactive.
  133450. * Override this method to provide functionality.
  133451. */
  133452. protected onLostFocus(): void;
  133453. private _pointerInput;
  133454. private _observer;
  133455. private _onLostFocus;
  133456. private pointA;
  133457. private pointB;
  133458. }
  133459. }
  133460. declare module BABYLON {
  133461. /**
  133462. * Manage the pointers inputs to control an arc rotate camera.
  133463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133464. */
  133465. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  133466. /**
  133467. * Defines the camera the input is attached to.
  133468. */
  133469. camera: ArcRotateCamera;
  133470. /**
  133471. * Gets the class name of the current input.
  133472. * @returns the class name
  133473. */
  133474. getClassName(): string;
  133475. /**
  133476. * Defines the buttons associated with the input to handle camera move.
  133477. */
  133478. buttons: number[];
  133479. /**
  133480. * Defines the pointer angular sensibility along the X axis or how fast is
  133481. * the camera rotating.
  133482. */
  133483. angularSensibilityX: number;
  133484. /**
  133485. * Defines the pointer angular sensibility along the Y axis or how fast is
  133486. * the camera rotating.
  133487. */
  133488. angularSensibilityY: number;
  133489. /**
  133490. * Defines the pointer pinch precision or how fast is the camera zooming.
  133491. */
  133492. pinchPrecision: number;
  133493. /**
  133494. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  133495. * from 0.
  133496. * It defines the percentage of current camera.radius to use as delta when
  133497. * pinch zoom is used.
  133498. */
  133499. pinchDeltaPercentage: number;
  133500. /**
  133501. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  133502. * that any object in the plane at the camera's target point will scale
  133503. * perfectly with finger motion.
  133504. * Overrides pinchDeltaPercentage and pinchPrecision.
  133505. */
  133506. useNaturalPinchZoom: boolean;
  133507. /**
  133508. * Defines the pointer panning sensibility or how fast is the camera moving.
  133509. */
  133510. panningSensibility: number;
  133511. /**
  133512. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  133513. */
  133514. multiTouchPanning: boolean;
  133515. /**
  133516. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  133517. * zoom (pinch) through multitouch.
  133518. */
  133519. multiTouchPanAndZoom: boolean;
  133520. /**
  133521. * Revers pinch action direction.
  133522. */
  133523. pinchInwards: boolean;
  133524. private _isPanClick;
  133525. private _twoFingerActivityCount;
  133526. private _isPinching;
  133527. /**
  133528. * Called on pointer POINTERMOVE event if only a single touch is active.
  133529. */
  133530. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  133531. /**
  133532. * Called on pointer POINTERDOUBLETAP event.
  133533. */
  133534. protected onDoubleTap(type: string): void;
  133535. /**
  133536. * Called on pointer POINTERMOVE event if multiple touches are active.
  133537. */
  133538. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  133539. /**
  133540. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  133541. * press.
  133542. */
  133543. protected onButtonDown(evt: PointerEvent): void;
  133544. /**
  133545. * Called each time a new POINTERUP event occurs. Ie, for each button
  133546. * release.
  133547. */
  133548. protected onButtonUp(evt: PointerEvent): void;
  133549. /**
  133550. * Called when window becomes inactive.
  133551. */
  133552. protected onLostFocus(): void;
  133553. }
  133554. }
  133555. declare module BABYLON {
  133556. /**
  133557. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  133558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133559. */
  133560. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  133561. /**
  133562. * Defines the camera the input is attached to.
  133563. */
  133564. camera: ArcRotateCamera;
  133565. /**
  133566. * Defines the list of key codes associated with the up action (increase alpha)
  133567. */
  133568. keysUp: number[];
  133569. /**
  133570. * Defines the list of key codes associated with the down action (decrease alpha)
  133571. */
  133572. keysDown: number[];
  133573. /**
  133574. * Defines the list of key codes associated with the left action (increase beta)
  133575. */
  133576. keysLeft: number[];
  133577. /**
  133578. * Defines the list of key codes associated with the right action (decrease beta)
  133579. */
  133580. keysRight: number[];
  133581. /**
  133582. * Defines the list of key codes associated with the reset action.
  133583. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  133584. */
  133585. keysReset: number[];
  133586. /**
  133587. * Defines the panning sensibility of the inputs.
  133588. * (How fast is the camera panning)
  133589. */
  133590. panningSensibility: number;
  133591. /**
  133592. * Defines the zooming sensibility of the inputs.
  133593. * (How fast is the camera zooming)
  133594. */
  133595. zoomingSensibility: number;
  133596. /**
  133597. * Defines whether maintaining the alt key down switch the movement mode from
  133598. * orientation to zoom.
  133599. */
  133600. useAltToZoom: boolean;
  133601. /**
  133602. * Rotation speed of the camera
  133603. */
  133604. angularSpeed: number;
  133605. private _keys;
  133606. private _ctrlPressed;
  133607. private _altPressed;
  133608. private _onCanvasBlurObserver;
  133609. private _onKeyboardObserver;
  133610. private _engine;
  133611. private _scene;
  133612. /**
  133613. * Attach the input controls to a specific dom element to get the input from.
  133614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133615. */
  133616. attachControl(noPreventDefault?: boolean): void;
  133617. /**
  133618. * Detach the current controls from the specified dom element.
  133619. */
  133620. detachControl(): void;
  133621. /**
  133622. * Update the current camera state depending on the inputs that have been used this frame.
  133623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  133624. */
  133625. checkInputs(): void;
  133626. /**
  133627. * Gets the class name of the current intput.
  133628. * @returns the class name
  133629. */
  133630. getClassName(): string;
  133631. /**
  133632. * Get the friendly name associated with the input class.
  133633. * @returns the input friendly name
  133634. */
  133635. getSimpleName(): string;
  133636. }
  133637. }
  133638. declare module BABYLON {
  133639. /**
  133640. * Manage the mouse wheel inputs to control an arc rotate camera.
  133641. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133642. */
  133643. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  133644. /**
  133645. * Defines the camera the input is attached to.
  133646. */
  133647. camera: ArcRotateCamera;
  133648. /**
  133649. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  133650. */
  133651. wheelPrecision: number;
  133652. /**
  133653. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  133654. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  133655. */
  133656. wheelDeltaPercentage: number;
  133657. private _wheel;
  133658. private _observer;
  133659. private computeDeltaFromMouseWheelLegacyEvent;
  133660. /**
  133661. * Attach the input controls to a specific dom element to get the input from.
  133662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133663. */
  133664. attachControl(noPreventDefault?: boolean): void;
  133665. /**
  133666. * Detach the current controls from the specified dom element.
  133667. */
  133668. detachControl(): void;
  133669. /**
  133670. * Gets the class name of the current intput.
  133671. * @returns the class name
  133672. */
  133673. getClassName(): string;
  133674. /**
  133675. * Get the friendly name associated with the input class.
  133676. * @returns the input friendly name
  133677. */
  133678. getSimpleName(): string;
  133679. }
  133680. }
  133681. declare module BABYLON {
  133682. /**
  133683. * Default Inputs manager for the ArcRotateCamera.
  133684. * It groups all the default supported inputs for ease of use.
  133685. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133686. */
  133687. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  133688. /**
  133689. * Instantiates a new ArcRotateCameraInputsManager.
  133690. * @param camera Defines the camera the inputs belong to
  133691. */
  133692. constructor(camera: ArcRotateCamera);
  133693. /**
  133694. * Add mouse wheel input support to the input manager.
  133695. * @returns the current input manager
  133696. */
  133697. addMouseWheel(): ArcRotateCameraInputsManager;
  133698. /**
  133699. * Add pointers input support to the input manager.
  133700. * @returns the current input manager
  133701. */
  133702. addPointers(): ArcRotateCameraInputsManager;
  133703. /**
  133704. * Add keyboard input support to the input manager.
  133705. * @returns the current input manager
  133706. */
  133707. addKeyboard(): ArcRotateCameraInputsManager;
  133708. }
  133709. }
  133710. declare module BABYLON {
  133711. /**
  133712. * This represents an orbital type of camera.
  133713. *
  133714. * 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.
  133715. * 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.
  133716. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  133717. */
  133718. export class ArcRotateCamera extends TargetCamera {
  133719. /**
  133720. * Defines the rotation angle of the camera along the longitudinal axis.
  133721. */
  133722. alpha: number;
  133723. /**
  133724. * Defines the rotation angle of the camera along the latitudinal axis.
  133725. */
  133726. beta: number;
  133727. /**
  133728. * Defines the radius of the camera from it s target point.
  133729. */
  133730. radius: number;
  133731. protected _target: Vector3;
  133732. protected _targetHost: Nullable<AbstractMesh>;
  133733. /**
  133734. * Defines the target point of the camera.
  133735. * The camera looks towards it form the radius distance.
  133736. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  133737. */
  133738. get target(): Vector3;
  133739. set target(value: Vector3);
  133740. /**
  133741. * Define the current local position of the camera in the scene
  133742. */
  133743. get position(): Vector3;
  133744. set position(newPosition: Vector3);
  133745. protected _upToYMatrix: Matrix;
  133746. protected _YToUpMatrix: Matrix;
  133747. /**
  133748. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  133749. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  133750. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  133751. */
  133752. set upVector(vec: Vector3);
  133753. get upVector(): Vector3;
  133754. /**
  133755. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  133756. */
  133757. setMatUp(): void;
  133758. /**
  133759. * Current inertia value on the longitudinal axis.
  133760. * The bigger this number the longer it will take for the camera to stop.
  133761. */
  133762. inertialAlphaOffset: number;
  133763. /**
  133764. * Current inertia value on the latitudinal axis.
  133765. * The bigger this number the longer it will take for the camera to stop.
  133766. */
  133767. inertialBetaOffset: number;
  133768. /**
  133769. * Current inertia value on the radius axis.
  133770. * The bigger this number the longer it will take for the camera to stop.
  133771. */
  133772. inertialRadiusOffset: number;
  133773. /**
  133774. * Minimum allowed angle on the longitudinal axis.
  133775. * This can help limiting how the Camera is able to move in the scene.
  133776. */
  133777. lowerAlphaLimit: Nullable<number>;
  133778. /**
  133779. * Maximum allowed angle on the longitudinal axis.
  133780. * This can help limiting how the Camera is able to move in the scene.
  133781. */
  133782. upperAlphaLimit: Nullable<number>;
  133783. /**
  133784. * Minimum allowed angle on the latitudinal axis.
  133785. * This can help limiting how the Camera is able to move in the scene.
  133786. */
  133787. lowerBetaLimit: number;
  133788. /**
  133789. * Maximum allowed angle on the latitudinal axis.
  133790. * This can help limiting how the Camera is able to move in the scene.
  133791. */
  133792. upperBetaLimit: number;
  133793. /**
  133794. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  133795. * This can help limiting how the Camera is able to move in the scene.
  133796. */
  133797. lowerRadiusLimit: Nullable<number>;
  133798. /**
  133799. * Maximum allowed distance of the camera to the target (The camera can not get further).
  133800. * This can help limiting how the Camera is able to move in the scene.
  133801. */
  133802. upperRadiusLimit: Nullable<number>;
  133803. /**
  133804. * Defines the current inertia value used during panning of the camera along the X axis.
  133805. */
  133806. inertialPanningX: number;
  133807. /**
  133808. * Defines the current inertia value used during panning of the camera along the Y axis.
  133809. */
  133810. inertialPanningY: number;
  133811. /**
  133812. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  133813. * Basically if your fingers moves away from more than this distance you will be considered
  133814. * in pinch mode.
  133815. */
  133816. pinchToPanMaxDistance: number;
  133817. /**
  133818. * Defines the maximum distance the camera can pan.
  133819. * This could help keeping the cammera always in your scene.
  133820. */
  133821. panningDistanceLimit: Nullable<number>;
  133822. /**
  133823. * Defines the target of the camera before paning.
  133824. */
  133825. panningOriginTarget: Vector3;
  133826. /**
  133827. * Defines the value of the inertia used during panning.
  133828. * 0 would mean stop inertia and one would mean no decelleration at all.
  133829. */
  133830. panningInertia: number;
  133831. /**
  133832. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  133833. */
  133834. get angularSensibilityX(): number;
  133835. set angularSensibilityX(value: number);
  133836. /**
  133837. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  133838. */
  133839. get angularSensibilityY(): number;
  133840. set angularSensibilityY(value: number);
  133841. /**
  133842. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  133843. */
  133844. get pinchPrecision(): number;
  133845. set pinchPrecision(value: number);
  133846. /**
  133847. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  133848. * It will be used instead of pinchDeltaPrecision if different from 0.
  133849. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  133850. */
  133851. get pinchDeltaPercentage(): number;
  133852. set pinchDeltaPercentage(value: number);
  133853. /**
  133854. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  133855. * and pinch delta percentage.
  133856. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  133857. * that any object in the plane at the camera's target point will scale
  133858. * perfectly with finger motion.
  133859. */
  133860. get useNaturalPinchZoom(): boolean;
  133861. set useNaturalPinchZoom(value: boolean);
  133862. /**
  133863. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  133864. */
  133865. get panningSensibility(): number;
  133866. set panningSensibility(value: number);
  133867. /**
  133868. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  133869. */
  133870. get keysUp(): number[];
  133871. set keysUp(value: number[]);
  133872. /**
  133873. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  133874. */
  133875. get keysDown(): number[];
  133876. set keysDown(value: number[]);
  133877. /**
  133878. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  133879. */
  133880. get keysLeft(): number[];
  133881. set keysLeft(value: number[]);
  133882. /**
  133883. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  133884. */
  133885. get keysRight(): number[];
  133886. set keysRight(value: number[]);
  133887. /**
  133888. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  133889. */
  133890. get wheelPrecision(): number;
  133891. set wheelPrecision(value: number);
  133892. /**
  133893. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  133894. * It will be used instead of pinchDeltaPrecision if different from 0.
  133895. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  133896. */
  133897. get wheelDeltaPercentage(): number;
  133898. set wheelDeltaPercentage(value: number);
  133899. /**
  133900. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  133901. */
  133902. zoomOnFactor: number;
  133903. /**
  133904. * Defines a screen offset for the camera position.
  133905. */
  133906. targetScreenOffset: Vector2;
  133907. /**
  133908. * Allows the camera to be completely reversed.
  133909. * If false the camera can not arrive upside down.
  133910. */
  133911. allowUpsideDown: boolean;
  133912. /**
  133913. * Define if double tap/click is used to restore the previously saved state of the camera.
  133914. */
  133915. useInputToRestoreState: boolean;
  133916. /** @hidden */
  133917. _viewMatrix: Matrix;
  133918. /** @hidden */
  133919. _useCtrlForPanning: boolean;
  133920. /** @hidden */
  133921. _panningMouseButton: number;
  133922. /**
  133923. * Defines the input associated to the camera.
  133924. */
  133925. inputs: ArcRotateCameraInputsManager;
  133926. /** @hidden */
  133927. _reset: () => void;
  133928. /**
  133929. * Defines the allowed panning axis.
  133930. */
  133931. panningAxis: Vector3;
  133932. protected _transformedDirection: Vector3;
  133933. private _bouncingBehavior;
  133934. /**
  133935. * Gets the bouncing behavior of the camera if it has been enabled.
  133936. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133937. */
  133938. get bouncingBehavior(): Nullable<BouncingBehavior>;
  133939. /**
  133940. * Defines if the bouncing behavior of the camera is enabled on the camera.
  133941. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133942. */
  133943. get useBouncingBehavior(): boolean;
  133944. set useBouncingBehavior(value: boolean);
  133945. private _framingBehavior;
  133946. /**
  133947. * Gets the framing behavior of the camera if it has been enabled.
  133948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133949. */
  133950. get framingBehavior(): Nullable<FramingBehavior>;
  133951. /**
  133952. * Defines if the framing behavior of the camera is enabled on the camera.
  133953. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133954. */
  133955. get useFramingBehavior(): boolean;
  133956. set useFramingBehavior(value: boolean);
  133957. private _autoRotationBehavior;
  133958. /**
  133959. * Gets the auto rotation behavior of the camera if it has been enabled.
  133960. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  133961. */
  133962. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  133963. /**
  133964. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  133965. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  133966. */
  133967. get useAutoRotationBehavior(): boolean;
  133968. set useAutoRotationBehavior(value: boolean);
  133969. /**
  133970. * Observable triggered when the mesh target has been changed on the camera.
  133971. */
  133972. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  133973. /**
  133974. * Event raised when the camera is colliding with a mesh.
  133975. */
  133976. onCollide: (collidedMesh: AbstractMesh) => void;
  133977. /**
  133978. * Defines whether the camera should check collision with the objects oh the scene.
  133979. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  133980. */
  133981. checkCollisions: boolean;
  133982. /**
  133983. * Defines the collision radius of the camera.
  133984. * This simulates a sphere around the camera.
  133985. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  133986. */
  133987. collisionRadius: Vector3;
  133988. protected _collider: Collider;
  133989. protected _previousPosition: Vector3;
  133990. protected _collisionVelocity: Vector3;
  133991. protected _newPosition: Vector3;
  133992. protected _previousAlpha: number;
  133993. protected _previousBeta: number;
  133994. protected _previousRadius: number;
  133995. protected _collisionTriggered: boolean;
  133996. protected _targetBoundingCenter: Nullable<Vector3>;
  133997. private _computationVector;
  133998. /**
  133999. * Instantiates a new ArcRotateCamera in a given scene
  134000. * @param name Defines the name of the camera
  134001. * @param alpha Defines the camera rotation along the logitudinal axis
  134002. * @param beta Defines the camera rotation along the latitudinal axis
  134003. * @param radius Defines the camera distance from its target
  134004. * @param target Defines the camera target
  134005. * @param scene Defines the scene the camera belongs to
  134006. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  134007. */
  134008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  134009. /** @hidden */
  134010. _initCache(): void;
  134011. /** @hidden */
  134012. _updateCache(ignoreParentClass?: boolean): void;
  134013. protected _getTargetPosition(): Vector3;
  134014. private _storedAlpha;
  134015. private _storedBeta;
  134016. private _storedRadius;
  134017. private _storedTarget;
  134018. private _storedTargetScreenOffset;
  134019. /**
  134020. * Stores the current state of the camera (alpha, beta, radius and target)
  134021. * @returns the camera itself
  134022. */
  134023. storeState(): Camera;
  134024. /**
  134025. * @hidden
  134026. * Restored camera state. You must call storeState() first
  134027. */
  134028. _restoreStateValues(): boolean;
  134029. /** @hidden */
  134030. _isSynchronizedViewMatrix(): boolean;
  134031. /**
  134032. * Attach the input controls to a specific dom element to get the input from.
  134033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134034. */
  134035. attachControl(noPreventDefault?: boolean): void;
  134036. /**
  134037. * Attach the input controls to a specific dom element to get the input from.
  134038. * @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
  134039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134040. */
  134041. attachControl(ignored: any, noPreventDefault?: boolean): void;
  134042. /**
  134043. * Attached controls to the current camera.
  134044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134045. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134046. */
  134047. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134048. /**
  134049. * Attached controls to the current camera.
  134050. * @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
  134051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134052. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134053. */
  134054. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134055. /**
  134056. * Attached controls to the current camera.
  134057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134058. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134059. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  134060. */
  134061. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  134062. /**
  134063. * Detach the current controls from the specified dom element.
  134064. */
  134065. detachControl(): void;
  134066. /**
  134067. * Detach the current controls from the specified dom element.
  134068. * @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
  134069. */
  134070. detachControl(ignored: any): void;
  134071. /** @hidden */
  134072. _checkInputs(): void;
  134073. protected _checkLimits(): void;
  134074. /**
  134075. * Rebuilds angles (alpha, beta) and radius from the give position and target
  134076. */
  134077. rebuildAnglesAndRadius(): void;
  134078. /**
  134079. * Use a position to define the current camera related information like alpha, beta and radius
  134080. * @param position Defines the position to set the camera at
  134081. */
  134082. setPosition(position: Vector3): void;
  134083. /**
  134084. * Defines the target the camera should look at.
  134085. * This will automatically adapt alpha beta and radius to fit within the new target.
  134086. * @param target Defines the new target as a Vector or a mesh
  134087. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  134088. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  134089. */
  134090. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  134091. /** @hidden */
  134092. _getViewMatrix(): Matrix;
  134093. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  134094. /**
  134095. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  134096. * @param meshes Defines the mesh to zoom on
  134097. * @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)
  134098. */
  134099. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  134100. /**
  134101. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  134102. * The target will be changed but the radius
  134103. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  134104. * @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)
  134105. */
  134106. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  134107. min: Vector3;
  134108. max: Vector3;
  134109. distance: number;
  134110. }, doNotUpdateMaxZ?: boolean): void;
  134111. /**
  134112. * @override
  134113. * Override Camera.createRigCamera
  134114. */
  134115. createRigCamera(name: string, cameraIndex: number): Camera;
  134116. /**
  134117. * @hidden
  134118. * @override
  134119. * Override Camera._updateRigCameras
  134120. */
  134121. _updateRigCameras(): void;
  134122. /**
  134123. * Destroy the camera and release the current resources hold by it.
  134124. */
  134125. dispose(): void;
  134126. /**
  134127. * Gets the current object class name.
  134128. * @return the class name
  134129. */
  134130. getClassName(): string;
  134131. }
  134132. }
  134133. declare module BABYLON {
  134134. /**
  134135. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  134136. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134137. */
  134138. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  134139. /**
  134140. * Gets the name of the behavior.
  134141. */
  134142. get name(): string;
  134143. private _zoomStopsAnimation;
  134144. private _idleRotationSpeed;
  134145. private _idleRotationWaitTime;
  134146. private _idleRotationSpinupTime;
  134147. /**
  134148. * Sets the flag that indicates if user zooming should stop animation.
  134149. */
  134150. set zoomStopsAnimation(flag: boolean);
  134151. /**
  134152. * Gets the flag that indicates if user zooming should stop animation.
  134153. */
  134154. get zoomStopsAnimation(): boolean;
  134155. /**
  134156. * Sets the default speed at which the camera rotates around the model.
  134157. */
  134158. set idleRotationSpeed(speed: number);
  134159. /**
  134160. * Gets the default speed at which the camera rotates around the model.
  134161. */
  134162. get idleRotationSpeed(): number;
  134163. /**
  134164. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  134165. */
  134166. set idleRotationWaitTime(time: number);
  134167. /**
  134168. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  134169. */
  134170. get idleRotationWaitTime(): number;
  134171. /**
  134172. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134173. */
  134174. set idleRotationSpinupTime(time: number);
  134175. /**
  134176. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134177. */
  134178. get idleRotationSpinupTime(): number;
  134179. /**
  134180. * Gets a value indicating if the camera is currently rotating because of this behavior
  134181. */
  134182. get rotationInProgress(): boolean;
  134183. private _onPrePointerObservableObserver;
  134184. private _onAfterCheckInputsObserver;
  134185. private _attachedCamera;
  134186. private _isPointerDown;
  134187. private _lastFrameTime;
  134188. private _lastInteractionTime;
  134189. private _cameraRotationSpeed;
  134190. /**
  134191. * Initializes the behavior.
  134192. */
  134193. init(): void;
  134194. /**
  134195. * Attaches the behavior to its arc rotate camera.
  134196. * @param camera Defines the camera to attach the behavior to
  134197. */
  134198. attach(camera: ArcRotateCamera): void;
  134199. /**
  134200. * Detaches the behavior from its current arc rotate camera.
  134201. */
  134202. detach(): void;
  134203. /**
  134204. * Returns true if user is scrolling.
  134205. * @return true if user is scrolling.
  134206. */
  134207. private _userIsZooming;
  134208. private _lastFrameRadius;
  134209. private _shouldAnimationStopForInteraction;
  134210. /**
  134211. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  134212. */
  134213. private _applyUserInteraction;
  134214. private _userIsMoving;
  134215. }
  134216. }
  134217. declare module BABYLON {
  134218. /**
  134219. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  134220. */
  134221. export class AttachToBoxBehavior implements Behavior<Mesh> {
  134222. private ui;
  134223. /**
  134224. * The name of the behavior
  134225. */
  134226. name: string;
  134227. /**
  134228. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  134229. */
  134230. distanceAwayFromFace: number;
  134231. /**
  134232. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  134233. */
  134234. distanceAwayFromBottomOfFace: number;
  134235. private _faceVectors;
  134236. private _target;
  134237. private _scene;
  134238. private _onRenderObserver;
  134239. private _tmpMatrix;
  134240. private _tmpVector;
  134241. /**
  134242. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  134243. * @param ui The transform node that should be attched to the mesh
  134244. */
  134245. constructor(ui: TransformNode);
  134246. /**
  134247. * Initializes the behavior
  134248. */
  134249. init(): void;
  134250. private _closestFace;
  134251. private _zeroVector;
  134252. private _lookAtTmpMatrix;
  134253. private _lookAtToRef;
  134254. /**
  134255. * Attaches the AttachToBoxBehavior to the passed in mesh
  134256. * @param target The mesh that the specified node will be attached to
  134257. */
  134258. attach(target: Mesh): void;
  134259. /**
  134260. * Detaches the behavior from the mesh
  134261. */
  134262. detach(): void;
  134263. }
  134264. }
  134265. declare module BABYLON {
  134266. /**
  134267. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  134268. */
  134269. export class FadeInOutBehavior implements Behavior<Mesh> {
  134270. /**
  134271. * Time in milliseconds to delay before fading in (Default: 0)
  134272. */
  134273. delay: number;
  134274. /**
  134275. * Time in milliseconds for the mesh to fade in (Default: 300)
  134276. */
  134277. fadeInTime: number;
  134278. private _millisecondsPerFrame;
  134279. private _hovered;
  134280. private _hoverValue;
  134281. private _ownerNode;
  134282. /**
  134283. * Instatiates the FadeInOutBehavior
  134284. */
  134285. constructor();
  134286. /**
  134287. * The name of the behavior
  134288. */
  134289. get name(): string;
  134290. /**
  134291. * Initializes the behavior
  134292. */
  134293. init(): void;
  134294. /**
  134295. * Attaches the fade behavior on the passed in mesh
  134296. * @param ownerNode The mesh that will be faded in/out once attached
  134297. */
  134298. attach(ownerNode: Mesh): void;
  134299. /**
  134300. * Detaches the behavior from the mesh
  134301. */
  134302. detach(): void;
  134303. /**
  134304. * Triggers the mesh to begin fading in or out
  134305. * @param value if the object should fade in or out (true to fade in)
  134306. */
  134307. fadeIn(value: boolean): void;
  134308. private _update;
  134309. private _setAllVisibility;
  134310. }
  134311. }
  134312. declare module BABYLON {
  134313. /**
  134314. * Class containing a set of static utilities functions for managing Pivots
  134315. * @hidden
  134316. */
  134317. export class PivotTools {
  134318. private static _PivotCached;
  134319. private static _OldPivotPoint;
  134320. private static _PivotTranslation;
  134321. private static _PivotTmpVector;
  134322. private static _PivotPostMultiplyPivotMatrix;
  134323. /** @hidden */
  134324. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  134325. /** @hidden */
  134326. static _RestorePivotPoint(mesh: AbstractMesh): void;
  134327. }
  134328. }
  134329. declare module BABYLON {
  134330. /**
  134331. * Class containing static functions to help procedurally build meshes
  134332. */
  134333. export class PlaneBuilder {
  134334. /**
  134335. * Creates a plane mesh
  134336. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134337. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134338. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134340. * * 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
  134341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134342. * @param name defines the name of the mesh
  134343. * @param options defines the options used to create the mesh
  134344. * @param scene defines the hosting scene
  134345. * @returns the plane mesh
  134346. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134347. */
  134348. static CreatePlane(name: string, options: {
  134349. size?: number;
  134350. width?: number;
  134351. height?: number;
  134352. sideOrientation?: number;
  134353. frontUVs?: Vector4;
  134354. backUVs?: Vector4;
  134355. updatable?: boolean;
  134356. sourcePlane?: Plane;
  134357. }, scene?: Nullable<Scene>): Mesh;
  134358. }
  134359. }
  134360. declare module BABYLON {
  134361. /**
  134362. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  134363. */
  134364. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  134365. private static _AnyMouseID;
  134366. /**
  134367. * Abstract mesh the behavior is set on
  134368. */
  134369. attachedNode: AbstractMesh;
  134370. private _dragPlane;
  134371. private _scene;
  134372. private _pointerObserver;
  134373. private _beforeRenderObserver;
  134374. private static _planeScene;
  134375. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  134376. /**
  134377. * 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)
  134378. */
  134379. maxDragAngle: number;
  134380. /**
  134381. * @hidden
  134382. */
  134383. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  134384. /**
  134385. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  134386. */
  134387. currentDraggingPointerID: number;
  134388. /**
  134389. * The last position where the pointer hit the drag plane in world space
  134390. */
  134391. lastDragPosition: Vector3;
  134392. /**
  134393. * If the behavior is currently in a dragging state
  134394. */
  134395. dragging: boolean;
  134396. /**
  134397. * 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)
  134398. */
  134399. dragDeltaRatio: number;
  134400. /**
  134401. * If the drag plane orientation should be updated during the dragging (Default: true)
  134402. */
  134403. updateDragPlane: boolean;
  134404. private _debugMode;
  134405. private _moving;
  134406. /**
  134407. * Fires each time the attached mesh is dragged with the pointer
  134408. * * delta between last drag position and current drag position in world space
  134409. * * dragDistance along the drag axis
  134410. * * dragPlaneNormal normal of the current drag plane used during the drag
  134411. * * dragPlanePoint in world space where the drag intersects the drag plane
  134412. */
  134413. onDragObservable: Observable<{
  134414. delta: Vector3;
  134415. dragPlanePoint: Vector3;
  134416. dragPlaneNormal: Vector3;
  134417. dragDistance: number;
  134418. pointerId: number;
  134419. }>;
  134420. /**
  134421. * Fires each time a drag begins (eg. mouse down on mesh)
  134422. */
  134423. onDragStartObservable: Observable<{
  134424. dragPlanePoint: Vector3;
  134425. pointerId: number;
  134426. }>;
  134427. /**
  134428. * Fires each time a drag ends (eg. mouse release after drag)
  134429. */
  134430. onDragEndObservable: Observable<{
  134431. dragPlanePoint: Vector3;
  134432. pointerId: number;
  134433. }>;
  134434. /**
  134435. * If the attached mesh should be moved when dragged
  134436. */
  134437. moveAttached: boolean;
  134438. /**
  134439. * If the drag behavior will react to drag events (Default: true)
  134440. */
  134441. enabled: boolean;
  134442. /**
  134443. * If pointer events should start and release the drag (Default: true)
  134444. */
  134445. startAndReleaseDragOnPointerEvents: boolean;
  134446. /**
  134447. * If camera controls should be detached during the drag
  134448. */
  134449. detachCameraControls: boolean;
  134450. /**
  134451. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  134452. */
  134453. useObjectOrientationForDragging: boolean;
  134454. private _options;
  134455. /**
  134456. * Gets the options used by the behavior
  134457. */
  134458. get options(): {
  134459. dragAxis?: Vector3;
  134460. dragPlaneNormal?: Vector3;
  134461. };
  134462. /**
  134463. * Sets the options used by the behavior
  134464. */
  134465. set options(options: {
  134466. dragAxis?: Vector3;
  134467. dragPlaneNormal?: Vector3;
  134468. });
  134469. /**
  134470. * Creates a pointer drag behavior that can be attached to a mesh
  134471. * @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)
  134472. */
  134473. constructor(options?: {
  134474. dragAxis?: Vector3;
  134475. dragPlaneNormal?: Vector3;
  134476. });
  134477. /**
  134478. * Predicate to determine if it is valid to move the object to a new position when it is moved
  134479. */
  134480. validateDrag: (targetPosition: Vector3) => boolean;
  134481. /**
  134482. * The name of the behavior
  134483. */
  134484. get name(): string;
  134485. /**
  134486. * Initializes the behavior
  134487. */
  134488. init(): void;
  134489. private _tmpVector;
  134490. private _alternatePickedPoint;
  134491. private _worldDragAxis;
  134492. private _targetPosition;
  134493. private _attachedToElement;
  134494. /**
  134495. * Attaches the drag behavior the passed in mesh
  134496. * @param ownerNode The mesh that will be dragged around once attached
  134497. * @param predicate Predicate to use for pick filtering
  134498. */
  134499. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  134500. /**
  134501. * Force relase the drag action by code.
  134502. */
  134503. releaseDrag(): void;
  134504. private _startDragRay;
  134505. private _lastPointerRay;
  134506. /**
  134507. * Simulates the start of a pointer drag event on the behavior
  134508. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  134509. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  134510. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  134511. */
  134512. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  134513. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  134514. private _dragDelta;
  134515. protected _moveDrag(ray: Ray): void;
  134516. private _pickWithRayOnDragPlane;
  134517. private _pointA;
  134518. private _pointC;
  134519. private _localAxis;
  134520. private _lookAt;
  134521. private _updateDragPlanePosition;
  134522. /**
  134523. * Detaches the behavior from the mesh
  134524. */
  134525. detach(): void;
  134526. }
  134527. }
  134528. declare module BABYLON {
  134529. /**
  134530. * A behavior that when attached to a mesh will allow the mesh to be scaled
  134531. */
  134532. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  134533. private _dragBehaviorA;
  134534. private _dragBehaviorB;
  134535. private _startDistance;
  134536. private _initialScale;
  134537. private _targetScale;
  134538. private _ownerNode;
  134539. private _sceneRenderObserver;
  134540. /**
  134541. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  134542. */
  134543. constructor();
  134544. /**
  134545. * The name of the behavior
  134546. */
  134547. get name(): string;
  134548. /**
  134549. * Initializes the behavior
  134550. */
  134551. init(): void;
  134552. private _getCurrentDistance;
  134553. /**
  134554. * Attaches the scale behavior the passed in mesh
  134555. * @param ownerNode The mesh that will be scaled around once attached
  134556. */
  134557. attach(ownerNode: Mesh): void;
  134558. /**
  134559. * Detaches the behavior from the mesh
  134560. */
  134561. detach(): void;
  134562. }
  134563. }
  134564. declare module BABYLON {
  134565. /**
  134566. * 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
  134567. */
  134568. export class SixDofDragBehavior implements Behavior<Mesh> {
  134569. private static _virtualScene;
  134570. private _ownerNode;
  134571. private _sceneRenderObserver;
  134572. private _scene;
  134573. private _targetPosition;
  134574. private _virtualOriginMesh;
  134575. private _virtualDragMesh;
  134576. private _pointerObserver;
  134577. private _moving;
  134578. private _startingOrientation;
  134579. private _attachedToElement;
  134580. /**
  134581. * 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)
  134582. */
  134583. private zDragFactor;
  134584. /**
  134585. * If the object should rotate to face the drag origin
  134586. */
  134587. rotateDraggedObject: boolean;
  134588. /**
  134589. * If the behavior is currently in a dragging state
  134590. */
  134591. dragging: boolean;
  134592. /**
  134593. * 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)
  134594. */
  134595. dragDeltaRatio: number;
  134596. /**
  134597. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  134598. */
  134599. currentDraggingPointerID: number;
  134600. /**
  134601. * If camera controls should be detached during the drag
  134602. */
  134603. detachCameraControls: boolean;
  134604. /**
  134605. * Fires each time a drag starts
  134606. */
  134607. onDragStartObservable: Observable<{}>;
  134608. /**
  134609. * Fires each time a drag happens
  134610. */
  134611. onDragObservable: Observable<void>;
  134612. /**
  134613. * Fires each time a drag ends (eg. mouse release after drag)
  134614. */
  134615. onDragEndObservable: Observable<{}>;
  134616. /**
  134617. * 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
  134618. */
  134619. constructor();
  134620. /**
  134621. * The name of the behavior
  134622. */
  134623. get name(): string;
  134624. /**
  134625. * Initializes the behavior
  134626. */
  134627. init(): void;
  134628. /**
  134629. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  134630. */
  134631. private get _pointerCamera();
  134632. /**
  134633. * Attaches the scale behavior the passed in mesh
  134634. * @param ownerNode The mesh that will be scaled around once attached
  134635. */
  134636. attach(ownerNode: Mesh): void;
  134637. /**
  134638. * Detaches the behavior from the mesh
  134639. */
  134640. detach(): void;
  134641. }
  134642. }
  134643. declare module BABYLON {
  134644. /**
  134645. * Class used to apply inverse kinematics to bones
  134646. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  134647. */
  134648. export class BoneIKController {
  134649. private static _tmpVecs;
  134650. private static _tmpQuat;
  134651. private static _tmpMats;
  134652. /**
  134653. * Gets or sets the target mesh
  134654. */
  134655. targetMesh: AbstractMesh;
  134656. /** Gets or sets the mesh used as pole */
  134657. poleTargetMesh: AbstractMesh;
  134658. /**
  134659. * Gets or sets the bone used as pole
  134660. */
  134661. poleTargetBone: Nullable<Bone>;
  134662. /**
  134663. * Gets or sets the target position
  134664. */
  134665. targetPosition: Vector3;
  134666. /**
  134667. * Gets or sets the pole target position
  134668. */
  134669. poleTargetPosition: Vector3;
  134670. /**
  134671. * Gets or sets the pole target local offset
  134672. */
  134673. poleTargetLocalOffset: Vector3;
  134674. /**
  134675. * Gets or sets the pole angle
  134676. */
  134677. poleAngle: number;
  134678. /**
  134679. * Gets or sets the mesh associated with the controller
  134680. */
  134681. mesh: AbstractMesh;
  134682. /**
  134683. * 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)
  134684. */
  134685. slerpAmount: number;
  134686. private _bone1Quat;
  134687. private _bone1Mat;
  134688. private _bone2Ang;
  134689. private _bone1;
  134690. private _bone2;
  134691. private _bone1Length;
  134692. private _bone2Length;
  134693. private _maxAngle;
  134694. private _maxReach;
  134695. private _rightHandedSystem;
  134696. private _bendAxis;
  134697. private _slerping;
  134698. private _adjustRoll;
  134699. /**
  134700. * Gets or sets maximum allowed angle
  134701. */
  134702. get maxAngle(): number;
  134703. set maxAngle(value: number);
  134704. /**
  134705. * Creates a new BoneIKController
  134706. * @param mesh defines the mesh to control
  134707. * @param bone defines the bone to control
  134708. * @param options defines options to set up the controller
  134709. */
  134710. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  134711. targetMesh?: AbstractMesh;
  134712. poleTargetMesh?: AbstractMesh;
  134713. poleTargetBone?: Bone;
  134714. poleTargetLocalOffset?: Vector3;
  134715. poleAngle?: number;
  134716. bendAxis?: Vector3;
  134717. maxAngle?: number;
  134718. slerpAmount?: number;
  134719. });
  134720. private _setMaxAngle;
  134721. /**
  134722. * Force the controller to update the bones
  134723. */
  134724. update(): void;
  134725. }
  134726. }
  134727. declare module BABYLON {
  134728. /**
  134729. * Class used to make a bone look toward a point in space
  134730. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  134731. */
  134732. export class BoneLookController {
  134733. private static _tmpVecs;
  134734. private static _tmpQuat;
  134735. private static _tmpMats;
  134736. /**
  134737. * The target Vector3 that the bone will look at
  134738. */
  134739. target: Vector3;
  134740. /**
  134741. * The mesh that the bone is attached to
  134742. */
  134743. mesh: AbstractMesh;
  134744. /**
  134745. * The bone that will be looking to the target
  134746. */
  134747. bone: Bone;
  134748. /**
  134749. * The up axis of the coordinate system that is used when the bone is rotated
  134750. */
  134751. upAxis: Vector3;
  134752. /**
  134753. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  134754. */
  134755. upAxisSpace: Space;
  134756. /**
  134757. * Used to make an adjustment to the yaw of the bone
  134758. */
  134759. adjustYaw: number;
  134760. /**
  134761. * Used to make an adjustment to the pitch of the bone
  134762. */
  134763. adjustPitch: number;
  134764. /**
  134765. * Used to make an adjustment to the roll of the bone
  134766. */
  134767. adjustRoll: number;
  134768. /**
  134769. * 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)
  134770. */
  134771. slerpAmount: number;
  134772. private _minYaw;
  134773. private _maxYaw;
  134774. private _minPitch;
  134775. private _maxPitch;
  134776. private _minYawSin;
  134777. private _minYawCos;
  134778. private _maxYawSin;
  134779. private _maxYawCos;
  134780. private _midYawConstraint;
  134781. private _minPitchTan;
  134782. private _maxPitchTan;
  134783. private _boneQuat;
  134784. private _slerping;
  134785. private _transformYawPitch;
  134786. private _transformYawPitchInv;
  134787. private _firstFrameSkipped;
  134788. private _yawRange;
  134789. private _fowardAxis;
  134790. /**
  134791. * Gets or sets the minimum yaw angle that the bone can look to
  134792. */
  134793. get minYaw(): number;
  134794. set minYaw(value: number);
  134795. /**
  134796. * Gets or sets the maximum yaw angle that the bone can look to
  134797. */
  134798. get maxYaw(): number;
  134799. set maxYaw(value: number);
  134800. /**
  134801. * Gets or sets the minimum pitch angle that the bone can look to
  134802. */
  134803. get minPitch(): number;
  134804. set minPitch(value: number);
  134805. /**
  134806. * Gets or sets the maximum pitch angle that the bone can look to
  134807. */
  134808. get maxPitch(): number;
  134809. set maxPitch(value: number);
  134810. /**
  134811. * Create a BoneLookController
  134812. * @param mesh the mesh that the bone belongs to
  134813. * @param bone the bone that will be looking to the target
  134814. * @param target the target Vector3 to look at
  134815. * @param options optional settings:
  134816. * * maxYaw: the maximum angle the bone will yaw to
  134817. * * minYaw: the minimum angle the bone will yaw to
  134818. * * maxPitch: the maximum angle the bone will pitch to
  134819. * * minPitch: the minimum angle the bone will yaw to
  134820. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  134821. * * upAxis: the up axis of the coordinate system
  134822. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  134823. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  134824. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  134825. * * adjustYaw: used to make an adjustment to the yaw of the bone
  134826. * * adjustPitch: used to make an adjustment to the pitch of the bone
  134827. * * adjustRoll: used to make an adjustment to the roll of the bone
  134828. **/
  134829. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  134830. maxYaw?: number;
  134831. minYaw?: number;
  134832. maxPitch?: number;
  134833. minPitch?: number;
  134834. slerpAmount?: number;
  134835. upAxis?: Vector3;
  134836. upAxisSpace?: Space;
  134837. yawAxis?: Vector3;
  134838. pitchAxis?: Vector3;
  134839. adjustYaw?: number;
  134840. adjustPitch?: number;
  134841. adjustRoll?: number;
  134842. });
  134843. /**
  134844. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  134845. */
  134846. update(): void;
  134847. private _getAngleDiff;
  134848. private _getAngleBetween;
  134849. private _isAngleBetween;
  134850. }
  134851. }
  134852. declare module BABYLON {
  134853. /**
  134854. * Manage the gamepad inputs to control an arc rotate camera.
  134855. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134856. */
  134857. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  134858. /**
  134859. * Defines the camera the input is attached to.
  134860. */
  134861. camera: ArcRotateCamera;
  134862. /**
  134863. * Defines the gamepad the input is gathering event from.
  134864. */
  134865. gamepad: Nullable<Gamepad>;
  134866. /**
  134867. * Defines the gamepad rotation sensiblity.
  134868. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  134869. */
  134870. gamepadRotationSensibility: number;
  134871. /**
  134872. * Defines the gamepad move sensiblity.
  134873. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  134874. */
  134875. gamepadMoveSensibility: number;
  134876. private _yAxisScale;
  134877. /**
  134878. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  134879. */
  134880. get invertYAxis(): boolean;
  134881. set invertYAxis(value: boolean);
  134882. private _onGamepadConnectedObserver;
  134883. private _onGamepadDisconnectedObserver;
  134884. /**
  134885. * Attach the input controls to a specific dom element to get the input from.
  134886. */
  134887. attachControl(): void;
  134888. /**
  134889. * Detach the current controls from the specified dom element.
  134890. */
  134891. detachControl(): void;
  134892. /**
  134893. * Update the current camera state depending on the inputs that have been used this frame.
  134894. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  134895. */
  134896. checkInputs(): void;
  134897. /**
  134898. * Gets the class name of the current intput.
  134899. * @returns the class name
  134900. */
  134901. getClassName(): string;
  134902. /**
  134903. * Get the friendly name associated with the input class.
  134904. * @returns the input friendly name
  134905. */
  134906. getSimpleName(): string;
  134907. }
  134908. }
  134909. declare module BABYLON {
  134910. interface ArcRotateCameraInputsManager {
  134911. /**
  134912. * Add orientation input support to the input manager.
  134913. * @returns the current input manager
  134914. */
  134915. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  134916. }
  134917. /**
  134918. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  134919. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134920. */
  134921. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  134922. /**
  134923. * Defines the camera the input is attached to.
  134924. */
  134925. camera: ArcRotateCamera;
  134926. /**
  134927. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  134928. */
  134929. alphaCorrection: number;
  134930. /**
  134931. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  134932. */
  134933. gammaCorrection: number;
  134934. private _alpha;
  134935. private _gamma;
  134936. private _dirty;
  134937. private _deviceOrientationHandler;
  134938. /**
  134939. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  134940. */
  134941. constructor();
  134942. /**
  134943. * Attach the input controls to a specific dom element to get the input from.
  134944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134945. */
  134946. attachControl(noPreventDefault?: boolean): void;
  134947. /** @hidden */
  134948. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  134949. /**
  134950. * Update the current camera state depending on the inputs that have been used this frame.
  134951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  134952. */
  134953. checkInputs(): void;
  134954. /**
  134955. * Detach the current controls from the specified dom element.
  134956. */
  134957. detachControl(): void;
  134958. /**
  134959. * Gets the class name of the current intput.
  134960. * @returns the class name
  134961. */
  134962. getClassName(): string;
  134963. /**
  134964. * Get the friendly name associated with the input class.
  134965. * @returns the input friendly name
  134966. */
  134967. getSimpleName(): string;
  134968. }
  134969. }
  134970. declare module BABYLON {
  134971. /**
  134972. * Listen to mouse events to control the camera.
  134973. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134974. */
  134975. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  134976. /**
  134977. * Defines the camera the input is attached to.
  134978. */
  134979. camera: FlyCamera;
  134980. /**
  134981. * Defines if touch is enabled. (Default is true.)
  134982. */
  134983. touchEnabled: boolean;
  134984. /**
  134985. * Defines the buttons associated with the input to handle camera rotation.
  134986. */
  134987. buttons: number[];
  134988. /**
  134989. * Assign buttons for Yaw control.
  134990. */
  134991. buttonsYaw: number[];
  134992. /**
  134993. * Assign buttons for Pitch control.
  134994. */
  134995. buttonsPitch: number[];
  134996. /**
  134997. * Assign buttons for Roll control.
  134998. */
  134999. buttonsRoll: number[];
  135000. /**
  135001. * Detect if any button is being pressed while mouse is moved.
  135002. * -1 = Mouse locked.
  135003. * 0 = Left button.
  135004. * 1 = Middle Button.
  135005. * 2 = Right Button.
  135006. */
  135007. activeButton: number;
  135008. /**
  135009. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  135010. * Higher values reduce its sensitivity.
  135011. */
  135012. angularSensibility: number;
  135013. private _observer;
  135014. private _rollObserver;
  135015. private previousPosition;
  135016. private noPreventDefault;
  135017. private element;
  135018. /**
  135019. * Listen to mouse events to control the camera.
  135020. * @param touchEnabled Define if touch is enabled. (Default is true.)
  135021. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135022. */
  135023. constructor(touchEnabled?: boolean);
  135024. /**
  135025. * Attach the mouse control to the HTML DOM element.
  135026. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  135027. */
  135028. attachControl(noPreventDefault?: boolean): void;
  135029. /**
  135030. * Detach the current controls from the specified dom element.
  135031. */
  135032. detachControl(): void;
  135033. /**
  135034. * Gets the class name of the current input.
  135035. * @returns the class name.
  135036. */
  135037. getClassName(): string;
  135038. /**
  135039. * Get the friendly name associated with the input class.
  135040. * @returns the input's friendly name.
  135041. */
  135042. getSimpleName(): string;
  135043. private _pointerInput;
  135044. private _onMouseMove;
  135045. /**
  135046. * Rotate camera by mouse offset.
  135047. */
  135048. private rotateCamera;
  135049. }
  135050. }
  135051. declare module BABYLON {
  135052. /**
  135053. * Default Inputs manager for the FlyCamera.
  135054. * It groups all the default supported inputs for ease of use.
  135055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135056. */
  135057. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  135058. /**
  135059. * Instantiates a new FlyCameraInputsManager.
  135060. * @param camera Defines the camera the inputs belong to.
  135061. */
  135062. constructor(camera: FlyCamera);
  135063. /**
  135064. * Add keyboard input support to the input manager.
  135065. * @returns the new FlyCameraKeyboardMoveInput().
  135066. */
  135067. addKeyboard(): FlyCameraInputsManager;
  135068. /**
  135069. * Add mouse input support to the input manager.
  135070. * @param touchEnabled Enable touch screen support.
  135071. * @returns the new FlyCameraMouseInput().
  135072. */
  135073. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  135074. }
  135075. }
  135076. declare module BABYLON {
  135077. /**
  135078. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135079. * such as in a 3D Space Shooter or a Flight Simulator.
  135080. */
  135081. export class FlyCamera extends TargetCamera {
  135082. /**
  135083. * Define the collision ellipsoid of the camera.
  135084. * This is helpful for simulating a camera body, like a player's body.
  135085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  135086. */
  135087. ellipsoid: Vector3;
  135088. /**
  135089. * Define an offset for the position of the ellipsoid around the camera.
  135090. * This can be helpful if the camera is attached away from the player's body center,
  135091. * such as at its head.
  135092. */
  135093. ellipsoidOffset: Vector3;
  135094. /**
  135095. * Enable or disable collisions of the camera with the rest of the scene objects.
  135096. */
  135097. checkCollisions: boolean;
  135098. /**
  135099. * Enable or disable gravity on the camera.
  135100. */
  135101. applyGravity: boolean;
  135102. /**
  135103. * Define the current direction the camera is moving to.
  135104. */
  135105. cameraDirection: Vector3;
  135106. /**
  135107. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  135108. * This overrides and empties cameraRotation.
  135109. */
  135110. rotationQuaternion: Quaternion;
  135111. /**
  135112. * Track Roll to maintain the wanted Rolling when looking around.
  135113. */
  135114. _trackRoll: number;
  135115. /**
  135116. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  135117. */
  135118. rollCorrect: number;
  135119. /**
  135120. * Mimic a banked turn, Rolling the camera when Yawing.
  135121. * It's recommended to use rollCorrect = 10 for faster banking correction.
  135122. */
  135123. bankedTurn: boolean;
  135124. /**
  135125. * Limit in radians for how much Roll banking will add. (Default: 90°)
  135126. */
  135127. bankedTurnLimit: number;
  135128. /**
  135129. * Value of 0 disables the banked Roll.
  135130. * Value of 1 is equal to the Yaw angle in radians.
  135131. */
  135132. bankedTurnMultiplier: number;
  135133. /**
  135134. * The inputs manager loads all the input sources, such as keyboard and mouse.
  135135. */
  135136. inputs: FlyCameraInputsManager;
  135137. /**
  135138. * Gets the input sensibility for mouse input.
  135139. * Higher values reduce sensitivity.
  135140. */
  135141. get angularSensibility(): number;
  135142. /**
  135143. * Sets the input sensibility for a mouse input.
  135144. * Higher values reduce sensitivity.
  135145. */
  135146. set angularSensibility(value: number);
  135147. /**
  135148. * Get the keys for camera movement forward.
  135149. */
  135150. get keysForward(): number[];
  135151. /**
  135152. * Set the keys for camera movement forward.
  135153. */
  135154. set keysForward(value: number[]);
  135155. /**
  135156. * Get the keys for camera movement backward.
  135157. */
  135158. get keysBackward(): number[];
  135159. set keysBackward(value: number[]);
  135160. /**
  135161. * Get the keys for camera movement up.
  135162. */
  135163. get keysUp(): number[];
  135164. /**
  135165. * Set the keys for camera movement up.
  135166. */
  135167. set keysUp(value: number[]);
  135168. /**
  135169. * Get the keys for camera movement down.
  135170. */
  135171. get keysDown(): number[];
  135172. /**
  135173. * Set the keys for camera movement down.
  135174. */
  135175. set keysDown(value: number[]);
  135176. /**
  135177. * Get the keys for camera movement left.
  135178. */
  135179. get keysLeft(): number[];
  135180. /**
  135181. * Set the keys for camera movement left.
  135182. */
  135183. set keysLeft(value: number[]);
  135184. /**
  135185. * Set the keys for camera movement right.
  135186. */
  135187. get keysRight(): number[];
  135188. /**
  135189. * Set the keys for camera movement right.
  135190. */
  135191. set keysRight(value: number[]);
  135192. /**
  135193. * Event raised when the camera collides with a mesh in the scene.
  135194. */
  135195. onCollide: (collidedMesh: AbstractMesh) => void;
  135196. private _collider;
  135197. private _needMoveForGravity;
  135198. private _oldPosition;
  135199. private _diffPosition;
  135200. private _newPosition;
  135201. /** @hidden */
  135202. _localDirection: Vector3;
  135203. /** @hidden */
  135204. _transformedDirection: Vector3;
  135205. /**
  135206. * Instantiates a FlyCamera.
  135207. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135208. * such as in a 3D Space Shooter or a Flight Simulator.
  135209. * @param name Define the name of the camera in the scene.
  135210. * @param position Define the starting position of the camera in the scene.
  135211. * @param scene Define the scene the camera belongs to.
  135212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  135213. */
  135214. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  135215. /**
  135216. * Attach the input controls to a specific dom element to get the input from.
  135217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135218. */
  135219. attachControl(noPreventDefault?: boolean): void;
  135220. /**
  135221. * Detach a control from the HTML DOM element.
  135222. * The camera will stop reacting to that input.
  135223. */
  135224. detachControl(): void;
  135225. private _collisionMask;
  135226. /**
  135227. * Get the mask that the camera ignores in collision events.
  135228. */
  135229. get collisionMask(): number;
  135230. /**
  135231. * Set the mask that the camera ignores in collision events.
  135232. */
  135233. set collisionMask(mask: number);
  135234. /** @hidden */
  135235. _collideWithWorld(displacement: Vector3): void;
  135236. /** @hidden */
  135237. private _onCollisionPositionChange;
  135238. /** @hidden */
  135239. _checkInputs(): void;
  135240. /** @hidden */
  135241. _decideIfNeedsToMove(): boolean;
  135242. /** @hidden */
  135243. _updatePosition(): void;
  135244. /**
  135245. * Restore the Roll to its target value at the rate specified.
  135246. * @param rate - Higher means slower restoring.
  135247. * @hidden
  135248. */
  135249. restoreRoll(rate: number): void;
  135250. /**
  135251. * Destroy the camera and release the current resources held by it.
  135252. */
  135253. dispose(): void;
  135254. /**
  135255. * Get the current object class name.
  135256. * @returns the class name.
  135257. */
  135258. getClassName(): string;
  135259. }
  135260. }
  135261. declare module BABYLON {
  135262. /**
  135263. * Listen to keyboard events to control the camera.
  135264. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135265. */
  135266. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  135267. /**
  135268. * Defines the camera the input is attached to.
  135269. */
  135270. camera: FlyCamera;
  135271. /**
  135272. * The list of keyboard keys used to control the forward move of the camera.
  135273. */
  135274. keysForward: number[];
  135275. /**
  135276. * The list of keyboard keys used to control the backward move of the camera.
  135277. */
  135278. keysBackward: number[];
  135279. /**
  135280. * The list of keyboard keys used to control the forward move of the camera.
  135281. */
  135282. keysUp: number[];
  135283. /**
  135284. * The list of keyboard keys used to control the backward move of the camera.
  135285. */
  135286. keysDown: number[];
  135287. /**
  135288. * The list of keyboard keys used to control the right strafe move of the camera.
  135289. */
  135290. keysRight: number[];
  135291. /**
  135292. * The list of keyboard keys used to control the left strafe move of the camera.
  135293. */
  135294. keysLeft: number[];
  135295. private _keys;
  135296. private _onCanvasBlurObserver;
  135297. private _onKeyboardObserver;
  135298. private _engine;
  135299. private _scene;
  135300. /**
  135301. * Attach the input controls to a specific dom element to get the input from.
  135302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135303. */
  135304. attachControl(noPreventDefault?: boolean): void;
  135305. /**
  135306. * Detach the current controls from the specified dom element.
  135307. */
  135308. detachControl(): void;
  135309. /**
  135310. * Gets the class name of the current intput.
  135311. * @returns the class name
  135312. */
  135313. getClassName(): string;
  135314. /** @hidden */
  135315. _onLostFocus(e: FocusEvent): void;
  135316. /**
  135317. * Get the friendly name associated with the input class.
  135318. * @returns the input friendly name
  135319. */
  135320. getSimpleName(): string;
  135321. /**
  135322. * Update the current camera state depending on the inputs that have been used this frame.
  135323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135324. */
  135325. checkInputs(): void;
  135326. }
  135327. }
  135328. declare module BABYLON {
  135329. /**
  135330. * Manage the mouse wheel inputs to control a follow camera.
  135331. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135332. */
  135333. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  135334. /**
  135335. * Defines the camera the input is attached to.
  135336. */
  135337. camera: FollowCamera;
  135338. /**
  135339. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  135340. */
  135341. axisControlRadius: boolean;
  135342. /**
  135343. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  135344. */
  135345. axisControlHeight: boolean;
  135346. /**
  135347. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  135348. */
  135349. axisControlRotation: boolean;
  135350. /**
  135351. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  135352. * relation to mouseWheel events.
  135353. */
  135354. wheelPrecision: number;
  135355. /**
  135356. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  135357. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  135358. */
  135359. wheelDeltaPercentage: number;
  135360. private _wheel;
  135361. private _observer;
  135362. /**
  135363. * Attach the input controls to a specific dom element to get the input from.
  135364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135365. */
  135366. attachControl(noPreventDefault?: boolean): void;
  135367. /**
  135368. * Detach the current controls from the specified dom element.
  135369. */
  135370. detachControl(): void;
  135371. /**
  135372. * Gets the class name of the current intput.
  135373. * @returns the class name
  135374. */
  135375. getClassName(): string;
  135376. /**
  135377. * Get the friendly name associated with the input class.
  135378. * @returns the input friendly name
  135379. */
  135380. getSimpleName(): string;
  135381. }
  135382. }
  135383. declare module BABYLON {
  135384. /**
  135385. * Manage the pointers inputs to control an follow camera.
  135386. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135387. */
  135388. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  135389. /**
  135390. * Defines the camera the input is attached to.
  135391. */
  135392. camera: FollowCamera;
  135393. /**
  135394. * Gets the class name of the current input.
  135395. * @returns the class name
  135396. */
  135397. getClassName(): string;
  135398. /**
  135399. * Defines the pointer angular sensibility along the X axis or how fast is
  135400. * the camera rotating.
  135401. * A negative number will reverse the axis direction.
  135402. */
  135403. angularSensibilityX: number;
  135404. /**
  135405. * Defines the pointer angular sensibility along the Y axis or how fast is
  135406. * the camera rotating.
  135407. * A negative number will reverse the axis direction.
  135408. */
  135409. angularSensibilityY: number;
  135410. /**
  135411. * Defines the pointer pinch precision or how fast is the camera zooming.
  135412. * A negative number will reverse the axis direction.
  135413. */
  135414. pinchPrecision: number;
  135415. /**
  135416. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  135417. * from 0.
  135418. * It defines the percentage of current camera.radius to use as delta when
  135419. * pinch zoom is used.
  135420. */
  135421. pinchDeltaPercentage: number;
  135422. /**
  135423. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  135424. */
  135425. axisXControlRadius: boolean;
  135426. /**
  135427. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  135428. */
  135429. axisXControlHeight: boolean;
  135430. /**
  135431. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  135432. */
  135433. axisXControlRotation: boolean;
  135434. /**
  135435. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  135436. */
  135437. axisYControlRadius: boolean;
  135438. /**
  135439. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  135440. */
  135441. axisYControlHeight: boolean;
  135442. /**
  135443. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  135444. */
  135445. axisYControlRotation: boolean;
  135446. /**
  135447. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  135448. */
  135449. axisPinchControlRadius: boolean;
  135450. /**
  135451. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  135452. */
  135453. axisPinchControlHeight: boolean;
  135454. /**
  135455. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  135456. */
  135457. axisPinchControlRotation: boolean;
  135458. /**
  135459. * Log error messages if basic misconfiguration has occurred.
  135460. */
  135461. warningEnable: boolean;
  135462. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  135463. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  135464. private _warningCounter;
  135465. private _warning;
  135466. }
  135467. }
  135468. declare module BABYLON {
  135469. /**
  135470. * Default Inputs manager for the FollowCamera.
  135471. * It groups all the default supported inputs for ease of use.
  135472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135473. */
  135474. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  135475. /**
  135476. * Instantiates a new FollowCameraInputsManager.
  135477. * @param camera Defines the camera the inputs belong to
  135478. */
  135479. constructor(camera: FollowCamera);
  135480. /**
  135481. * Add keyboard input support to the input manager.
  135482. * @returns the current input manager
  135483. */
  135484. addKeyboard(): FollowCameraInputsManager;
  135485. /**
  135486. * Add mouse wheel input support to the input manager.
  135487. * @returns the current input manager
  135488. */
  135489. addMouseWheel(): FollowCameraInputsManager;
  135490. /**
  135491. * Add pointers input support to the input manager.
  135492. * @returns the current input manager
  135493. */
  135494. addPointers(): FollowCameraInputsManager;
  135495. /**
  135496. * Add orientation input support to the input manager.
  135497. * @returns the current input manager
  135498. */
  135499. addVRDeviceOrientation(): FollowCameraInputsManager;
  135500. }
  135501. }
  135502. declare module BABYLON {
  135503. /**
  135504. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  135505. * an arc rotate version arcFollowCamera are available.
  135506. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135507. */
  135508. export class FollowCamera extends TargetCamera {
  135509. /**
  135510. * Distance the follow camera should follow an object at
  135511. */
  135512. radius: number;
  135513. /**
  135514. * Minimum allowed distance of the camera to the axis of rotation
  135515. * (The camera can not get closer).
  135516. * This can help limiting how the Camera is able to move in the scene.
  135517. */
  135518. lowerRadiusLimit: Nullable<number>;
  135519. /**
  135520. * Maximum allowed distance of the camera to the axis of rotation
  135521. * (The camera can not get further).
  135522. * This can help limiting how the Camera is able to move in the scene.
  135523. */
  135524. upperRadiusLimit: Nullable<number>;
  135525. /**
  135526. * Define a rotation offset between the camera and the object it follows
  135527. */
  135528. rotationOffset: number;
  135529. /**
  135530. * Minimum allowed angle to camera position relative to target object.
  135531. * This can help limiting how the Camera is able to move in the scene.
  135532. */
  135533. lowerRotationOffsetLimit: Nullable<number>;
  135534. /**
  135535. * Maximum allowed angle to camera position relative to target object.
  135536. * This can help limiting how the Camera is able to move in the scene.
  135537. */
  135538. upperRotationOffsetLimit: Nullable<number>;
  135539. /**
  135540. * Define a height offset between the camera and the object it follows.
  135541. * It can help following an object from the top (like a car chaing a plane)
  135542. */
  135543. heightOffset: number;
  135544. /**
  135545. * Minimum allowed height of camera position relative to target object.
  135546. * This can help limiting how the Camera is able to move in the scene.
  135547. */
  135548. lowerHeightOffsetLimit: Nullable<number>;
  135549. /**
  135550. * Maximum allowed height of camera position relative to target object.
  135551. * This can help limiting how the Camera is able to move in the scene.
  135552. */
  135553. upperHeightOffsetLimit: Nullable<number>;
  135554. /**
  135555. * Define how fast the camera can accelerate to follow it s target.
  135556. */
  135557. cameraAcceleration: number;
  135558. /**
  135559. * Define the speed limit of the camera following an object.
  135560. */
  135561. maxCameraSpeed: number;
  135562. /**
  135563. * Define the target of the camera.
  135564. */
  135565. lockedTarget: Nullable<AbstractMesh>;
  135566. /**
  135567. * Defines the input associated with the camera.
  135568. */
  135569. inputs: FollowCameraInputsManager;
  135570. /**
  135571. * Instantiates the follow camera.
  135572. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135573. * @param name Define the name of the camera in the scene
  135574. * @param position Define the position of the camera
  135575. * @param scene Define the scene the camera belong to
  135576. * @param lockedTarget Define the target of the camera
  135577. */
  135578. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  135579. private _follow;
  135580. /**
  135581. * Attach the input controls to a specific dom element to get the input from.
  135582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135583. */
  135584. attachControl(noPreventDefault?: boolean): void;
  135585. /**
  135586. * Detach the current controls from the specified dom element.
  135587. */
  135588. detachControl(): void;
  135589. /** @hidden */
  135590. _checkInputs(): void;
  135591. private _checkLimits;
  135592. /**
  135593. * Gets the camera class name.
  135594. * @returns the class name
  135595. */
  135596. getClassName(): string;
  135597. }
  135598. /**
  135599. * Arc Rotate version of the follow camera.
  135600. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  135601. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135602. */
  135603. export class ArcFollowCamera extends TargetCamera {
  135604. /** The longitudinal angle of the camera */
  135605. alpha: number;
  135606. /** The latitudinal angle of the camera */
  135607. beta: number;
  135608. /** The radius of the camera from its target */
  135609. radius: number;
  135610. private _cartesianCoordinates;
  135611. /** Define the camera target (the mesh it should follow) */
  135612. private _meshTarget;
  135613. /**
  135614. * Instantiates a new ArcFollowCamera
  135615. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135616. * @param name Define the name of the camera
  135617. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  135618. * @param beta Define the rotation angle of the camera around the elevation axis
  135619. * @param radius Define the radius of the camera from its target point
  135620. * @param target Define the target of the camera
  135621. * @param scene Define the scene the camera belongs to
  135622. */
  135623. constructor(name: string,
  135624. /** The longitudinal angle of the camera */
  135625. alpha: number,
  135626. /** The latitudinal angle of the camera */
  135627. beta: number,
  135628. /** The radius of the camera from its target */
  135629. radius: number,
  135630. /** Define the camera target (the mesh it should follow) */
  135631. target: Nullable<AbstractMesh>, scene: Scene);
  135632. private _follow;
  135633. /** @hidden */
  135634. _checkInputs(): void;
  135635. /**
  135636. * Returns the class name of the object.
  135637. * It is mostly used internally for serialization purposes.
  135638. */
  135639. getClassName(): string;
  135640. }
  135641. }
  135642. declare module BABYLON {
  135643. /**
  135644. * Manage the keyboard inputs to control the movement of a follow camera.
  135645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135646. */
  135647. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  135648. /**
  135649. * Defines the camera the input is attached to.
  135650. */
  135651. camera: FollowCamera;
  135652. /**
  135653. * Defines the list of key codes associated with the up action (increase heightOffset)
  135654. */
  135655. keysHeightOffsetIncr: number[];
  135656. /**
  135657. * Defines the list of key codes associated with the down action (decrease heightOffset)
  135658. */
  135659. keysHeightOffsetDecr: number[];
  135660. /**
  135661. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  135662. */
  135663. keysHeightOffsetModifierAlt: boolean;
  135664. /**
  135665. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  135666. */
  135667. keysHeightOffsetModifierCtrl: boolean;
  135668. /**
  135669. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  135670. */
  135671. keysHeightOffsetModifierShift: boolean;
  135672. /**
  135673. * Defines the list of key codes associated with the left action (increase rotationOffset)
  135674. */
  135675. keysRotationOffsetIncr: number[];
  135676. /**
  135677. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  135678. */
  135679. keysRotationOffsetDecr: number[];
  135680. /**
  135681. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  135682. */
  135683. keysRotationOffsetModifierAlt: boolean;
  135684. /**
  135685. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  135686. */
  135687. keysRotationOffsetModifierCtrl: boolean;
  135688. /**
  135689. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  135690. */
  135691. keysRotationOffsetModifierShift: boolean;
  135692. /**
  135693. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  135694. */
  135695. keysRadiusIncr: number[];
  135696. /**
  135697. * Defines the list of key codes associated with the zoom-out action (increase radius)
  135698. */
  135699. keysRadiusDecr: number[];
  135700. /**
  135701. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  135702. */
  135703. keysRadiusModifierAlt: boolean;
  135704. /**
  135705. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  135706. */
  135707. keysRadiusModifierCtrl: boolean;
  135708. /**
  135709. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  135710. */
  135711. keysRadiusModifierShift: boolean;
  135712. /**
  135713. * Defines the rate of change of heightOffset.
  135714. */
  135715. heightSensibility: number;
  135716. /**
  135717. * Defines the rate of change of rotationOffset.
  135718. */
  135719. rotationSensibility: number;
  135720. /**
  135721. * Defines the rate of change of radius.
  135722. */
  135723. radiusSensibility: number;
  135724. private _keys;
  135725. private _ctrlPressed;
  135726. private _altPressed;
  135727. private _shiftPressed;
  135728. private _onCanvasBlurObserver;
  135729. private _onKeyboardObserver;
  135730. private _engine;
  135731. private _scene;
  135732. /**
  135733. * Attach the input controls to a specific dom element to get the input from.
  135734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135735. */
  135736. attachControl(noPreventDefault?: boolean): void;
  135737. /**
  135738. * Detach the current controls from the specified dom element.
  135739. */
  135740. detachControl(): void;
  135741. /**
  135742. * Update the current camera state depending on the inputs that have been used this frame.
  135743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135744. */
  135745. checkInputs(): void;
  135746. /**
  135747. * Gets the class name of the current input.
  135748. * @returns the class name
  135749. */
  135750. getClassName(): string;
  135751. /**
  135752. * Get the friendly name associated with the input class.
  135753. * @returns the input friendly name
  135754. */
  135755. getSimpleName(): string;
  135756. /**
  135757. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  135758. * allow modification of the heightOffset value.
  135759. */
  135760. private _modifierHeightOffset;
  135761. /**
  135762. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  135763. * allow modification of the rotationOffset value.
  135764. */
  135765. private _modifierRotationOffset;
  135766. /**
  135767. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  135768. * allow modification of the radius value.
  135769. */
  135770. private _modifierRadius;
  135771. }
  135772. }
  135773. declare module BABYLON {
  135774. interface FreeCameraInputsManager {
  135775. /**
  135776. * @hidden
  135777. */
  135778. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  135779. /**
  135780. * Add orientation input support to the input manager.
  135781. * @returns the current input manager
  135782. */
  135783. addDeviceOrientation(): FreeCameraInputsManager;
  135784. }
  135785. /**
  135786. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  135787. * Screen rotation is taken into account.
  135788. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135789. */
  135790. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  135791. private _camera;
  135792. private _screenOrientationAngle;
  135793. private _constantTranform;
  135794. private _screenQuaternion;
  135795. private _alpha;
  135796. private _beta;
  135797. private _gamma;
  135798. /**
  135799. * Can be used to detect if a device orientation sensor is available on a device
  135800. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  135801. * @returns a promise that will resolve on orientation change
  135802. */
  135803. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  135804. /**
  135805. * @hidden
  135806. */
  135807. _onDeviceOrientationChangedObservable: Observable<void>;
  135808. /**
  135809. * Instantiates a new input
  135810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135811. */
  135812. constructor();
  135813. /**
  135814. * Define the camera controlled by the input.
  135815. */
  135816. get camera(): FreeCamera;
  135817. set camera(camera: FreeCamera);
  135818. /**
  135819. * Attach the input controls to a specific dom element to get the input from.
  135820. */
  135821. attachControl(): void;
  135822. private _orientationChanged;
  135823. private _deviceOrientation;
  135824. /**
  135825. * Detach the current controls from the specified dom element.
  135826. */
  135827. detachControl(): void;
  135828. /**
  135829. * Update the current camera state depending on the inputs that have been used this frame.
  135830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135831. */
  135832. checkInputs(): void;
  135833. /**
  135834. * Gets the class name of the current intput.
  135835. * @returns the class name
  135836. */
  135837. getClassName(): string;
  135838. /**
  135839. * Get the friendly name associated with the input class.
  135840. * @returns the input friendly name
  135841. */
  135842. getSimpleName(): string;
  135843. }
  135844. }
  135845. declare module BABYLON {
  135846. /**
  135847. * Manage the gamepad inputs to control a free camera.
  135848. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135849. */
  135850. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  135851. /**
  135852. * Define the camera the input is attached to.
  135853. */
  135854. camera: FreeCamera;
  135855. /**
  135856. * Define the Gamepad controlling the input
  135857. */
  135858. gamepad: Nullable<Gamepad>;
  135859. /**
  135860. * Defines the gamepad rotation sensiblity.
  135861. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  135862. */
  135863. gamepadAngularSensibility: number;
  135864. /**
  135865. * Defines the gamepad move sensiblity.
  135866. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  135867. */
  135868. gamepadMoveSensibility: number;
  135869. private _yAxisScale;
  135870. /**
  135871. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  135872. */
  135873. get invertYAxis(): boolean;
  135874. set invertYAxis(value: boolean);
  135875. private _onGamepadConnectedObserver;
  135876. private _onGamepadDisconnectedObserver;
  135877. private _cameraTransform;
  135878. private _deltaTransform;
  135879. private _vector3;
  135880. private _vector2;
  135881. /**
  135882. * Attach the input controls to a specific dom element to get the input from.
  135883. */
  135884. attachControl(): void;
  135885. /**
  135886. * Detach the current controls from the specified dom element.
  135887. */
  135888. detachControl(): void;
  135889. /**
  135890. * Update the current camera state depending on the inputs that have been used this frame.
  135891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135892. */
  135893. checkInputs(): void;
  135894. /**
  135895. * Gets the class name of the current intput.
  135896. * @returns the class name
  135897. */
  135898. getClassName(): string;
  135899. /**
  135900. * Get the friendly name associated with the input class.
  135901. * @returns the input friendly name
  135902. */
  135903. getSimpleName(): string;
  135904. }
  135905. }
  135906. declare module BABYLON {
  135907. /**
  135908. * Defines the potential axis of a Joystick
  135909. */
  135910. export enum JoystickAxis {
  135911. /** X axis */
  135912. X = 0,
  135913. /** Y axis */
  135914. Y = 1,
  135915. /** Z axis */
  135916. Z = 2
  135917. }
  135918. /**
  135919. * Represents the different customization options available
  135920. * for VirtualJoystick
  135921. */
  135922. interface VirtualJoystickCustomizations {
  135923. /**
  135924. * Size of the joystick's puck
  135925. */
  135926. puckSize: number;
  135927. /**
  135928. * Size of the joystick's container
  135929. */
  135930. containerSize: number;
  135931. /**
  135932. * Color of the joystick && puck
  135933. */
  135934. color: string;
  135935. /**
  135936. * Image URL for the joystick's puck
  135937. */
  135938. puckImage?: string;
  135939. /**
  135940. * Image URL for the joystick's container
  135941. */
  135942. containerImage?: string;
  135943. /**
  135944. * Defines the unmoving position of the joystick container
  135945. */
  135946. position?: {
  135947. x: number;
  135948. y: number;
  135949. };
  135950. /**
  135951. * Defines whether or not the joystick container is always visible
  135952. */
  135953. alwaysVisible: boolean;
  135954. /**
  135955. * Defines whether or not to limit the movement of the puck to the joystick's container
  135956. */
  135957. limitToContainer: boolean;
  135958. }
  135959. /**
  135960. * Class used to define virtual joystick (used in touch mode)
  135961. */
  135962. export class VirtualJoystick {
  135963. /**
  135964. * Gets or sets a boolean indicating that left and right values must be inverted
  135965. */
  135966. reverseLeftRight: boolean;
  135967. /**
  135968. * Gets or sets a boolean indicating that up and down values must be inverted
  135969. */
  135970. reverseUpDown: boolean;
  135971. /**
  135972. * Gets the offset value for the position (ie. the change of the position value)
  135973. */
  135974. deltaPosition: Vector3;
  135975. /**
  135976. * Gets a boolean indicating if the virtual joystick was pressed
  135977. */
  135978. pressed: boolean;
  135979. /**
  135980. * Canvas the virtual joystick will render onto, default z-index of this is 5
  135981. */
  135982. static Canvas: Nullable<HTMLCanvasElement>;
  135983. /**
  135984. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  135985. */
  135986. limitToContainer: boolean;
  135987. private static _globalJoystickIndex;
  135988. private static _alwaysVisibleSticks;
  135989. private static vjCanvasContext;
  135990. private static vjCanvasWidth;
  135991. private static vjCanvasHeight;
  135992. private static halfWidth;
  135993. private static _GetDefaultOptions;
  135994. private _action;
  135995. private _axisTargetedByLeftAndRight;
  135996. private _axisTargetedByUpAndDown;
  135997. private _joystickSensibility;
  135998. private _inversedSensibility;
  135999. private _joystickPointerID;
  136000. private _joystickColor;
  136001. private _joystickPointerPos;
  136002. private _joystickPreviousPointerPos;
  136003. private _joystickPointerStartPos;
  136004. private _deltaJoystickVector;
  136005. private _leftJoystick;
  136006. private _touches;
  136007. private _joystickPosition;
  136008. private _alwaysVisible;
  136009. private _puckImage;
  136010. private _containerImage;
  136011. private _joystickPuckSize;
  136012. private _joystickContainerSize;
  136013. private _clearPuckSize;
  136014. private _clearContainerSize;
  136015. private _clearPuckSizeOffset;
  136016. private _clearContainerSizeOffset;
  136017. private _onPointerDownHandlerRef;
  136018. private _onPointerMoveHandlerRef;
  136019. private _onPointerUpHandlerRef;
  136020. private _onResize;
  136021. /**
  136022. * Creates a new virtual joystick
  136023. * @param leftJoystick defines that the joystick is for left hand (false by default)
  136024. * @param customizations Defines the options we want to customize the VirtualJoystick
  136025. */
  136026. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  136027. /**
  136028. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  136029. * @param newJoystickSensibility defines the new sensibility
  136030. */
  136031. setJoystickSensibility(newJoystickSensibility: number): void;
  136032. private _onPointerDown;
  136033. private _onPointerMove;
  136034. private _onPointerUp;
  136035. /**
  136036. * Change the color of the virtual joystick
  136037. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  136038. */
  136039. setJoystickColor(newColor: string): void;
  136040. /**
  136041. * Size of the joystick's container
  136042. */
  136043. set containerSize(newSize: number);
  136044. get containerSize(): number;
  136045. /**
  136046. * Size of the joystick's puck
  136047. */
  136048. set puckSize(newSize: number);
  136049. get puckSize(): number;
  136050. /**
  136051. * Clears the set position of the joystick
  136052. */
  136053. clearPosition(): void;
  136054. /**
  136055. * Defines whether or not the joystick container is always visible
  136056. */
  136057. set alwaysVisible(value: boolean);
  136058. get alwaysVisible(): boolean;
  136059. /**
  136060. * Sets the constant position of the Joystick container
  136061. * @param x X axis coordinate
  136062. * @param y Y axis coordinate
  136063. */
  136064. setPosition(x: number, y: number): void;
  136065. /**
  136066. * Defines a callback to call when the joystick is touched
  136067. * @param action defines the callback
  136068. */
  136069. setActionOnTouch(action: () => any): void;
  136070. /**
  136071. * Defines which axis you'd like to control for left & right
  136072. * @param axis defines the axis to use
  136073. */
  136074. setAxisForLeftRight(axis: JoystickAxis): void;
  136075. /**
  136076. * Defines which axis you'd like to control for up & down
  136077. * @param axis defines the axis to use
  136078. */
  136079. setAxisForUpDown(axis: JoystickAxis): void;
  136080. /**
  136081. * Clears the canvas from the previous puck / container draw
  136082. */
  136083. private _clearPreviousDraw;
  136084. /**
  136085. * Loads `urlPath` to be used for the container's image
  136086. * @param urlPath defines the urlPath of an image to use
  136087. */
  136088. setContainerImage(urlPath: string): void;
  136089. /**
  136090. * Loads `urlPath` to be used for the puck's image
  136091. * @param urlPath defines the urlPath of an image to use
  136092. */
  136093. setPuckImage(urlPath: string): void;
  136094. /**
  136095. * Draws the Virtual Joystick's container
  136096. */
  136097. private _drawContainer;
  136098. /**
  136099. * Draws the Virtual Joystick's puck
  136100. */
  136101. private _drawPuck;
  136102. private _drawVirtualJoystick;
  136103. /**
  136104. * Release internal HTML canvas
  136105. */
  136106. releaseCanvas(): void;
  136107. }
  136108. }
  136109. declare module BABYLON {
  136110. interface FreeCameraInputsManager {
  136111. /**
  136112. * Add virtual joystick input support to the input manager.
  136113. * @returns the current input manager
  136114. */
  136115. addVirtualJoystick(): FreeCameraInputsManager;
  136116. }
  136117. /**
  136118. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  136119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136120. */
  136121. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  136122. /**
  136123. * Defines the camera the input is attached to.
  136124. */
  136125. camera: FreeCamera;
  136126. private _leftjoystick;
  136127. private _rightjoystick;
  136128. /**
  136129. * Gets the left stick of the virtual joystick.
  136130. * @returns The virtual Joystick
  136131. */
  136132. getLeftJoystick(): VirtualJoystick;
  136133. /**
  136134. * Gets the right stick of the virtual joystick.
  136135. * @returns The virtual Joystick
  136136. */
  136137. getRightJoystick(): VirtualJoystick;
  136138. /**
  136139. * Update the current camera state depending on the inputs that have been used this frame.
  136140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136141. */
  136142. checkInputs(): void;
  136143. /**
  136144. * Attach the input controls to a specific dom element to get the input from.
  136145. */
  136146. attachControl(): void;
  136147. /**
  136148. * Detach the current controls from the specified dom element.
  136149. */
  136150. detachControl(): void;
  136151. /**
  136152. * Gets the class name of the current intput.
  136153. * @returns the class name
  136154. */
  136155. getClassName(): string;
  136156. /**
  136157. * Get the friendly name associated with the input class.
  136158. * @returns the input friendly name
  136159. */
  136160. getSimpleName(): string;
  136161. }
  136162. }
  136163. declare module BABYLON {
  136164. /**
  136165. * This represents a FPS type of camera controlled by touch.
  136166. * This is like a universal camera minus the Gamepad controls.
  136167. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136168. */
  136169. export class TouchCamera extends FreeCamera {
  136170. /**
  136171. * Defines the touch sensibility for rotation.
  136172. * The higher the faster.
  136173. */
  136174. get touchAngularSensibility(): number;
  136175. set touchAngularSensibility(value: number);
  136176. /**
  136177. * Defines the touch sensibility for move.
  136178. * The higher the faster.
  136179. */
  136180. get touchMoveSensibility(): number;
  136181. set touchMoveSensibility(value: number);
  136182. /**
  136183. * Instantiates a new touch camera.
  136184. * This represents a FPS type of camera controlled by touch.
  136185. * This is like a universal camera minus the Gamepad controls.
  136186. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136187. * @param name Define the name of the camera in the scene
  136188. * @param position Define the start position of the camera in the scene
  136189. * @param scene Define the scene the camera belongs to
  136190. */
  136191. constructor(name: string, position: Vector3, scene: Scene);
  136192. /**
  136193. * Gets the current object class name.
  136194. * @return the class name
  136195. */
  136196. getClassName(): string;
  136197. /** @hidden */
  136198. _setupInputs(): void;
  136199. }
  136200. }
  136201. declare module BABYLON {
  136202. /**
  136203. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  136204. * being tilted forward or back and left or right.
  136205. */
  136206. export class DeviceOrientationCamera extends FreeCamera {
  136207. private _initialQuaternion;
  136208. private _quaternionCache;
  136209. private _tmpDragQuaternion;
  136210. private _disablePointerInputWhenUsingDeviceOrientation;
  136211. /**
  136212. * Creates a new device orientation camera
  136213. * @param name The name of the camera
  136214. * @param position The start position camera
  136215. * @param scene The scene the camera belongs to
  136216. */
  136217. constructor(name: string, position: Vector3, scene: Scene);
  136218. /**
  136219. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  136220. */
  136221. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  136222. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  136223. private _dragFactor;
  136224. /**
  136225. * Enabled turning on the y axis when the orientation sensor is active
  136226. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  136227. */
  136228. enableHorizontalDragging(dragFactor?: number): void;
  136229. /**
  136230. * Gets the current instance class name ("DeviceOrientationCamera").
  136231. * This helps avoiding instanceof at run time.
  136232. * @returns the class name
  136233. */
  136234. getClassName(): string;
  136235. /**
  136236. * @hidden
  136237. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  136238. */
  136239. _checkInputs(): void;
  136240. /**
  136241. * Reset the camera to its default orientation on the specified axis only.
  136242. * @param axis The axis to reset
  136243. */
  136244. resetToCurrentRotation(axis?: Axis): void;
  136245. }
  136246. }
  136247. declare module BABYLON {
  136248. /**
  136249. * Defines supported buttons for XBox360 compatible gamepads
  136250. */
  136251. export enum Xbox360Button {
  136252. /** A */
  136253. A = 0,
  136254. /** B */
  136255. B = 1,
  136256. /** X */
  136257. X = 2,
  136258. /** Y */
  136259. Y = 3,
  136260. /** Left button */
  136261. LB = 4,
  136262. /** Right button */
  136263. RB = 5,
  136264. /** Back */
  136265. Back = 8,
  136266. /** Start */
  136267. Start = 9,
  136268. /** Left stick */
  136269. LeftStick = 10,
  136270. /** Right stick */
  136271. RightStick = 11
  136272. }
  136273. /** Defines values for XBox360 DPad */
  136274. export enum Xbox360Dpad {
  136275. /** Up */
  136276. Up = 12,
  136277. /** Down */
  136278. Down = 13,
  136279. /** Left */
  136280. Left = 14,
  136281. /** Right */
  136282. Right = 15
  136283. }
  136284. /**
  136285. * Defines a XBox360 gamepad
  136286. */
  136287. export class Xbox360Pad extends Gamepad {
  136288. private _leftTrigger;
  136289. private _rightTrigger;
  136290. private _onlefttriggerchanged;
  136291. private _onrighttriggerchanged;
  136292. private _onbuttondown;
  136293. private _onbuttonup;
  136294. private _ondpaddown;
  136295. private _ondpadup;
  136296. /** Observable raised when a button is pressed */
  136297. onButtonDownObservable: Observable<Xbox360Button>;
  136298. /** Observable raised when a button is released */
  136299. onButtonUpObservable: Observable<Xbox360Button>;
  136300. /** Observable raised when a pad is pressed */
  136301. onPadDownObservable: Observable<Xbox360Dpad>;
  136302. /** Observable raised when a pad is released */
  136303. onPadUpObservable: Observable<Xbox360Dpad>;
  136304. private _buttonA;
  136305. private _buttonB;
  136306. private _buttonX;
  136307. private _buttonY;
  136308. private _buttonBack;
  136309. private _buttonStart;
  136310. private _buttonLB;
  136311. private _buttonRB;
  136312. private _buttonLeftStick;
  136313. private _buttonRightStick;
  136314. private _dPadUp;
  136315. private _dPadDown;
  136316. private _dPadLeft;
  136317. private _dPadRight;
  136318. private _isXboxOnePad;
  136319. /**
  136320. * Creates a new XBox360 gamepad object
  136321. * @param id defines the id of this gamepad
  136322. * @param index defines its index
  136323. * @param gamepad defines the internal HTML gamepad object
  136324. * @param xboxOne defines if it is a XBox One gamepad
  136325. */
  136326. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  136327. /**
  136328. * Defines the callback to call when left trigger is pressed
  136329. * @param callback defines the callback to use
  136330. */
  136331. onlefttriggerchanged(callback: (value: number) => void): void;
  136332. /**
  136333. * Defines the callback to call when right trigger is pressed
  136334. * @param callback defines the callback to use
  136335. */
  136336. onrighttriggerchanged(callback: (value: number) => void): void;
  136337. /**
  136338. * Gets the left trigger value
  136339. */
  136340. get leftTrigger(): number;
  136341. /**
  136342. * Sets the left trigger value
  136343. */
  136344. set leftTrigger(newValue: number);
  136345. /**
  136346. * Gets the right trigger value
  136347. */
  136348. get rightTrigger(): number;
  136349. /**
  136350. * Sets the right trigger value
  136351. */
  136352. set rightTrigger(newValue: number);
  136353. /**
  136354. * Defines the callback to call when a button is pressed
  136355. * @param callback defines the callback to use
  136356. */
  136357. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  136358. /**
  136359. * Defines the callback to call when a button is released
  136360. * @param callback defines the callback to use
  136361. */
  136362. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  136363. /**
  136364. * Defines the callback to call when a pad is pressed
  136365. * @param callback defines the callback to use
  136366. */
  136367. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  136368. /**
  136369. * Defines the callback to call when a pad is released
  136370. * @param callback defines the callback to use
  136371. */
  136372. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  136373. private _setButtonValue;
  136374. private _setDPadValue;
  136375. /**
  136376. * Gets the value of the `A` button
  136377. */
  136378. get buttonA(): number;
  136379. /**
  136380. * Sets the value of the `A` button
  136381. */
  136382. set buttonA(value: number);
  136383. /**
  136384. * Gets the value of the `B` button
  136385. */
  136386. get buttonB(): number;
  136387. /**
  136388. * Sets the value of the `B` button
  136389. */
  136390. set buttonB(value: number);
  136391. /**
  136392. * Gets the value of the `X` button
  136393. */
  136394. get buttonX(): number;
  136395. /**
  136396. * Sets the value of the `X` button
  136397. */
  136398. set buttonX(value: number);
  136399. /**
  136400. * Gets the value of the `Y` button
  136401. */
  136402. get buttonY(): number;
  136403. /**
  136404. * Sets the value of the `Y` button
  136405. */
  136406. set buttonY(value: number);
  136407. /**
  136408. * Gets the value of the `Start` button
  136409. */
  136410. get buttonStart(): number;
  136411. /**
  136412. * Sets the value of the `Start` button
  136413. */
  136414. set buttonStart(value: number);
  136415. /**
  136416. * Gets the value of the `Back` button
  136417. */
  136418. get buttonBack(): number;
  136419. /**
  136420. * Sets the value of the `Back` button
  136421. */
  136422. set buttonBack(value: number);
  136423. /**
  136424. * Gets the value of the `Left` button
  136425. */
  136426. get buttonLB(): number;
  136427. /**
  136428. * Sets the value of the `Left` button
  136429. */
  136430. set buttonLB(value: number);
  136431. /**
  136432. * Gets the value of the `Right` button
  136433. */
  136434. get buttonRB(): number;
  136435. /**
  136436. * Sets the value of the `Right` button
  136437. */
  136438. set buttonRB(value: number);
  136439. /**
  136440. * Gets the value of the Left joystick
  136441. */
  136442. get buttonLeftStick(): number;
  136443. /**
  136444. * Sets the value of the Left joystick
  136445. */
  136446. set buttonLeftStick(value: number);
  136447. /**
  136448. * Gets the value of the Right joystick
  136449. */
  136450. get buttonRightStick(): number;
  136451. /**
  136452. * Sets the value of the Right joystick
  136453. */
  136454. set buttonRightStick(value: number);
  136455. /**
  136456. * Gets the value of D-pad up
  136457. */
  136458. get dPadUp(): number;
  136459. /**
  136460. * Sets the value of D-pad up
  136461. */
  136462. set dPadUp(value: number);
  136463. /**
  136464. * Gets the value of D-pad down
  136465. */
  136466. get dPadDown(): number;
  136467. /**
  136468. * Sets the value of D-pad down
  136469. */
  136470. set dPadDown(value: number);
  136471. /**
  136472. * Gets the value of D-pad left
  136473. */
  136474. get dPadLeft(): number;
  136475. /**
  136476. * Sets the value of D-pad left
  136477. */
  136478. set dPadLeft(value: number);
  136479. /**
  136480. * Gets the value of D-pad right
  136481. */
  136482. get dPadRight(): number;
  136483. /**
  136484. * Sets the value of D-pad right
  136485. */
  136486. set dPadRight(value: number);
  136487. /**
  136488. * Force the gamepad to synchronize with device values
  136489. */
  136490. update(): void;
  136491. /**
  136492. * Disposes the gamepad
  136493. */
  136494. dispose(): void;
  136495. }
  136496. }
  136497. declare module BABYLON {
  136498. /**
  136499. * Defines supported buttons for DualShock compatible gamepads
  136500. */
  136501. export enum DualShockButton {
  136502. /** Cross */
  136503. Cross = 0,
  136504. /** Circle */
  136505. Circle = 1,
  136506. /** Square */
  136507. Square = 2,
  136508. /** Triangle */
  136509. Triangle = 3,
  136510. /** L1 */
  136511. L1 = 4,
  136512. /** R1 */
  136513. R1 = 5,
  136514. /** Share */
  136515. Share = 8,
  136516. /** Options */
  136517. Options = 9,
  136518. /** Left stick */
  136519. LeftStick = 10,
  136520. /** Right stick */
  136521. RightStick = 11
  136522. }
  136523. /** Defines values for DualShock DPad */
  136524. export enum DualShockDpad {
  136525. /** Up */
  136526. Up = 12,
  136527. /** Down */
  136528. Down = 13,
  136529. /** Left */
  136530. Left = 14,
  136531. /** Right */
  136532. Right = 15
  136533. }
  136534. /**
  136535. * Defines a DualShock gamepad
  136536. */
  136537. export class DualShockPad extends Gamepad {
  136538. private _leftTrigger;
  136539. private _rightTrigger;
  136540. private _onlefttriggerchanged;
  136541. private _onrighttriggerchanged;
  136542. private _onbuttondown;
  136543. private _onbuttonup;
  136544. private _ondpaddown;
  136545. private _ondpadup;
  136546. /** Observable raised when a button is pressed */
  136547. onButtonDownObservable: Observable<DualShockButton>;
  136548. /** Observable raised when a button is released */
  136549. onButtonUpObservable: Observable<DualShockButton>;
  136550. /** Observable raised when a pad is pressed */
  136551. onPadDownObservable: Observable<DualShockDpad>;
  136552. /** Observable raised when a pad is released */
  136553. onPadUpObservable: Observable<DualShockDpad>;
  136554. private _buttonCross;
  136555. private _buttonCircle;
  136556. private _buttonSquare;
  136557. private _buttonTriangle;
  136558. private _buttonShare;
  136559. private _buttonOptions;
  136560. private _buttonL1;
  136561. private _buttonR1;
  136562. private _buttonLeftStick;
  136563. private _buttonRightStick;
  136564. private _dPadUp;
  136565. private _dPadDown;
  136566. private _dPadLeft;
  136567. private _dPadRight;
  136568. /**
  136569. * Creates a new DualShock gamepad object
  136570. * @param id defines the id of this gamepad
  136571. * @param index defines its index
  136572. * @param gamepad defines the internal HTML gamepad object
  136573. */
  136574. constructor(id: string, index: number, gamepad: any);
  136575. /**
  136576. * Defines the callback to call when left trigger is pressed
  136577. * @param callback defines the callback to use
  136578. */
  136579. onlefttriggerchanged(callback: (value: number) => void): void;
  136580. /**
  136581. * Defines the callback to call when right trigger is pressed
  136582. * @param callback defines the callback to use
  136583. */
  136584. onrighttriggerchanged(callback: (value: number) => void): void;
  136585. /**
  136586. * Gets the left trigger value
  136587. */
  136588. get leftTrigger(): number;
  136589. /**
  136590. * Sets the left trigger value
  136591. */
  136592. set leftTrigger(newValue: number);
  136593. /**
  136594. * Gets the right trigger value
  136595. */
  136596. get rightTrigger(): number;
  136597. /**
  136598. * Sets the right trigger value
  136599. */
  136600. set rightTrigger(newValue: number);
  136601. /**
  136602. * Defines the callback to call when a button is pressed
  136603. * @param callback defines the callback to use
  136604. */
  136605. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  136606. /**
  136607. * Defines the callback to call when a button is released
  136608. * @param callback defines the callback to use
  136609. */
  136610. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  136611. /**
  136612. * Defines the callback to call when a pad is pressed
  136613. * @param callback defines the callback to use
  136614. */
  136615. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  136616. /**
  136617. * Defines the callback to call when a pad is released
  136618. * @param callback defines the callback to use
  136619. */
  136620. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  136621. private _setButtonValue;
  136622. private _setDPadValue;
  136623. /**
  136624. * Gets the value of the `Cross` button
  136625. */
  136626. get buttonCross(): number;
  136627. /**
  136628. * Sets the value of the `Cross` button
  136629. */
  136630. set buttonCross(value: number);
  136631. /**
  136632. * Gets the value of the `Circle` button
  136633. */
  136634. get buttonCircle(): number;
  136635. /**
  136636. * Sets the value of the `Circle` button
  136637. */
  136638. set buttonCircle(value: number);
  136639. /**
  136640. * Gets the value of the `Square` button
  136641. */
  136642. get buttonSquare(): number;
  136643. /**
  136644. * Sets the value of the `Square` button
  136645. */
  136646. set buttonSquare(value: number);
  136647. /**
  136648. * Gets the value of the `Triangle` button
  136649. */
  136650. get buttonTriangle(): number;
  136651. /**
  136652. * Sets the value of the `Triangle` button
  136653. */
  136654. set buttonTriangle(value: number);
  136655. /**
  136656. * Gets the value of the `Options` button
  136657. */
  136658. get buttonOptions(): number;
  136659. /**
  136660. * Sets the value of the `Options` button
  136661. */
  136662. set buttonOptions(value: number);
  136663. /**
  136664. * Gets the value of the `Share` button
  136665. */
  136666. get buttonShare(): number;
  136667. /**
  136668. * Sets the value of the `Share` button
  136669. */
  136670. set buttonShare(value: number);
  136671. /**
  136672. * Gets the value of the `L1` button
  136673. */
  136674. get buttonL1(): number;
  136675. /**
  136676. * Sets the value of the `L1` button
  136677. */
  136678. set buttonL1(value: number);
  136679. /**
  136680. * Gets the value of the `R1` button
  136681. */
  136682. get buttonR1(): number;
  136683. /**
  136684. * Sets the value of the `R1` button
  136685. */
  136686. set buttonR1(value: number);
  136687. /**
  136688. * Gets the value of the Left joystick
  136689. */
  136690. get buttonLeftStick(): number;
  136691. /**
  136692. * Sets the value of the Left joystick
  136693. */
  136694. set buttonLeftStick(value: number);
  136695. /**
  136696. * Gets the value of the Right joystick
  136697. */
  136698. get buttonRightStick(): number;
  136699. /**
  136700. * Sets the value of the Right joystick
  136701. */
  136702. set buttonRightStick(value: number);
  136703. /**
  136704. * Gets the value of D-pad up
  136705. */
  136706. get dPadUp(): number;
  136707. /**
  136708. * Sets the value of D-pad up
  136709. */
  136710. set dPadUp(value: number);
  136711. /**
  136712. * Gets the value of D-pad down
  136713. */
  136714. get dPadDown(): number;
  136715. /**
  136716. * Sets the value of D-pad down
  136717. */
  136718. set dPadDown(value: number);
  136719. /**
  136720. * Gets the value of D-pad left
  136721. */
  136722. get dPadLeft(): number;
  136723. /**
  136724. * Sets the value of D-pad left
  136725. */
  136726. set dPadLeft(value: number);
  136727. /**
  136728. * Gets the value of D-pad right
  136729. */
  136730. get dPadRight(): number;
  136731. /**
  136732. * Sets the value of D-pad right
  136733. */
  136734. set dPadRight(value: number);
  136735. /**
  136736. * Force the gamepad to synchronize with device values
  136737. */
  136738. update(): void;
  136739. /**
  136740. * Disposes the gamepad
  136741. */
  136742. dispose(): void;
  136743. }
  136744. }
  136745. declare module BABYLON {
  136746. /**
  136747. * Manager for handling gamepads
  136748. */
  136749. export class GamepadManager {
  136750. private _scene?;
  136751. private _babylonGamepads;
  136752. private _oneGamepadConnected;
  136753. /** @hidden */
  136754. _isMonitoring: boolean;
  136755. private _gamepadEventSupported;
  136756. private _gamepadSupport?;
  136757. /**
  136758. * observable to be triggered when the gamepad controller has been connected
  136759. */
  136760. onGamepadConnectedObservable: Observable<Gamepad>;
  136761. /**
  136762. * observable to be triggered when the gamepad controller has been disconnected
  136763. */
  136764. onGamepadDisconnectedObservable: Observable<Gamepad>;
  136765. private _onGamepadConnectedEvent;
  136766. private _onGamepadDisconnectedEvent;
  136767. /**
  136768. * Initializes the gamepad manager
  136769. * @param _scene BabylonJS scene
  136770. */
  136771. constructor(_scene?: Scene | undefined);
  136772. /**
  136773. * The gamepads in the game pad manager
  136774. */
  136775. get gamepads(): Gamepad[];
  136776. /**
  136777. * Get the gamepad controllers based on type
  136778. * @param type The type of gamepad controller
  136779. * @returns Nullable gamepad
  136780. */
  136781. getGamepadByType(type?: number): Nullable<Gamepad>;
  136782. /**
  136783. * Disposes the gamepad manager
  136784. */
  136785. dispose(): void;
  136786. private _addNewGamepad;
  136787. private _startMonitoringGamepads;
  136788. private _stopMonitoringGamepads;
  136789. /** @hidden */
  136790. _checkGamepadsStatus(): void;
  136791. private _updateGamepadObjects;
  136792. }
  136793. }
  136794. declare module BABYLON {
  136795. interface Scene {
  136796. /** @hidden */
  136797. _gamepadManager: Nullable<GamepadManager>;
  136798. /**
  136799. * Gets the gamepad manager associated with the scene
  136800. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  136801. */
  136802. gamepadManager: GamepadManager;
  136803. }
  136804. /**
  136805. * Interface representing a free camera inputs manager
  136806. */
  136807. interface FreeCameraInputsManager {
  136808. /**
  136809. * Adds gamepad input support to the FreeCameraInputsManager.
  136810. * @returns the FreeCameraInputsManager
  136811. */
  136812. addGamepad(): FreeCameraInputsManager;
  136813. }
  136814. /**
  136815. * Interface representing an arc rotate camera inputs manager
  136816. */
  136817. interface ArcRotateCameraInputsManager {
  136818. /**
  136819. * Adds gamepad input support to the ArcRotateCamera InputManager.
  136820. * @returns the camera inputs manager
  136821. */
  136822. addGamepad(): ArcRotateCameraInputsManager;
  136823. }
  136824. /**
  136825. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  136826. */
  136827. export class GamepadSystemSceneComponent implements ISceneComponent {
  136828. /**
  136829. * The component name helpfull to identify the component in the list of scene components.
  136830. */
  136831. readonly name: string;
  136832. /**
  136833. * The scene the component belongs to.
  136834. */
  136835. scene: Scene;
  136836. /**
  136837. * Creates a new instance of the component for the given scene
  136838. * @param scene Defines the scene to register the component in
  136839. */
  136840. constructor(scene: Scene);
  136841. /**
  136842. * Registers the component in a given scene
  136843. */
  136844. register(): void;
  136845. /**
  136846. * Rebuilds the elements related to this component in case of
  136847. * context lost for instance.
  136848. */
  136849. rebuild(): void;
  136850. /**
  136851. * Disposes the component and the associated ressources
  136852. */
  136853. dispose(): void;
  136854. private _beforeCameraUpdate;
  136855. }
  136856. }
  136857. declare module BABYLON {
  136858. /**
  136859. * 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,
  136860. * which still works and will still be found in many Playgrounds.
  136861. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136862. */
  136863. export class UniversalCamera extends TouchCamera {
  136864. /**
  136865. * Defines the gamepad rotation sensiblity.
  136866. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  136867. */
  136868. get gamepadAngularSensibility(): number;
  136869. set gamepadAngularSensibility(value: number);
  136870. /**
  136871. * Defines the gamepad move sensiblity.
  136872. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  136873. */
  136874. get gamepadMoveSensibility(): number;
  136875. set gamepadMoveSensibility(value: number);
  136876. /**
  136877. * 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,
  136878. * which still works and will still be found in many Playgrounds.
  136879. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136880. * @param name Define the name of the camera in the scene
  136881. * @param position Define the start position of the camera in the scene
  136882. * @param scene Define the scene the camera belongs to
  136883. */
  136884. constructor(name: string, position: Vector3, scene: Scene);
  136885. /**
  136886. * Gets the current object class name.
  136887. * @return the class name
  136888. */
  136889. getClassName(): string;
  136890. }
  136891. }
  136892. declare module BABYLON {
  136893. /**
  136894. * This represents a FPS type of camera. This is only here for back compat purpose.
  136895. * Please use the UniversalCamera instead as both are identical.
  136896. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136897. */
  136898. export class GamepadCamera extends UniversalCamera {
  136899. /**
  136900. * Instantiates a new Gamepad Camera
  136901. * This represents a FPS type of camera. This is only here for back compat purpose.
  136902. * Please use the UniversalCamera instead as both are identical.
  136903. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136904. * @param name Define the name of the camera in the scene
  136905. * @param position Define the start position of the camera in the scene
  136906. * @param scene Define the scene the camera belongs to
  136907. */
  136908. constructor(name: string, position: Vector3, scene: Scene);
  136909. /**
  136910. * Gets the current object class name.
  136911. * @return the class name
  136912. */
  136913. getClassName(): string;
  136914. }
  136915. }
  136916. declare module BABYLON {
  136917. /** @hidden */
  136918. export var anaglyphPixelShader: {
  136919. name: string;
  136920. shader: string;
  136921. };
  136922. }
  136923. declare module BABYLON {
  136924. /**
  136925. * Postprocess used to generate anaglyphic rendering
  136926. */
  136927. export class AnaglyphPostProcess extends PostProcess {
  136928. private _passedProcess;
  136929. /**
  136930. * Gets a string identifying the name of the class
  136931. * @returns "AnaglyphPostProcess" string
  136932. */
  136933. getClassName(): string;
  136934. /**
  136935. * Creates a new AnaglyphPostProcess
  136936. * @param name defines postprocess name
  136937. * @param options defines creation options or target ratio scale
  136938. * @param rigCameras defines cameras using this postprocess
  136939. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  136940. * @param engine defines hosting engine
  136941. * @param reusable defines if the postprocess will be reused multiple times per frame
  136942. */
  136943. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  136944. }
  136945. }
  136946. declare module BABYLON {
  136947. /**
  136948. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  136949. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  136950. */
  136951. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  136952. /**
  136953. * Creates a new AnaglyphArcRotateCamera
  136954. * @param name defines camera name
  136955. * @param alpha defines alpha angle (in radians)
  136956. * @param beta defines beta angle (in radians)
  136957. * @param radius defines radius
  136958. * @param target defines camera target
  136959. * @param interaxialDistance defines distance between each color axis
  136960. * @param scene defines the hosting scene
  136961. */
  136962. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  136963. /**
  136964. * Gets camera class name
  136965. * @returns AnaglyphArcRotateCamera
  136966. */
  136967. getClassName(): string;
  136968. }
  136969. }
  136970. declare module BABYLON {
  136971. /**
  136972. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  136973. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  136974. */
  136975. export class AnaglyphFreeCamera extends FreeCamera {
  136976. /**
  136977. * Creates a new AnaglyphFreeCamera
  136978. * @param name defines camera name
  136979. * @param position defines initial position
  136980. * @param interaxialDistance defines distance between each color axis
  136981. * @param scene defines the hosting scene
  136982. */
  136983. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  136984. /**
  136985. * Gets camera class name
  136986. * @returns AnaglyphFreeCamera
  136987. */
  136988. getClassName(): string;
  136989. }
  136990. }
  136991. declare module BABYLON {
  136992. /**
  136993. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  136994. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  136995. */
  136996. export class AnaglyphGamepadCamera extends GamepadCamera {
  136997. /**
  136998. * Creates a new AnaglyphGamepadCamera
  136999. * @param name defines camera name
  137000. * @param position defines initial position
  137001. * @param interaxialDistance defines distance between each color axis
  137002. * @param scene defines the hosting scene
  137003. */
  137004. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137005. /**
  137006. * Gets camera class name
  137007. * @returns AnaglyphGamepadCamera
  137008. */
  137009. getClassName(): string;
  137010. }
  137011. }
  137012. declare module BABYLON {
  137013. /**
  137014. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  137015. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137016. */
  137017. export class AnaglyphUniversalCamera extends UniversalCamera {
  137018. /**
  137019. * Creates a new AnaglyphUniversalCamera
  137020. * @param name defines camera name
  137021. * @param position defines initial position
  137022. * @param interaxialDistance defines distance between each color axis
  137023. * @param scene defines the hosting scene
  137024. */
  137025. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137026. /**
  137027. * Gets camera class name
  137028. * @returns AnaglyphUniversalCamera
  137029. */
  137030. getClassName(): string;
  137031. }
  137032. }
  137033. declare module BABYLON {
  137034. /**
  137035. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  137036. * @see https://doc.babylonjs.com/features/cameras
  137037. */
  137038. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  137039. /**
  137040. * Creates a new StereoscopicArcRotateCamera
  137041. * @param name defines camera name
  137042. * @param alpha defines alpha angle (in radians)
  137043. * @param beta defines beta angle (in radians)
  137044. * @param radius defines radius
  137045. * @param target defines camera target
  137046. * @param interaxialDistance defines distance between each color axis
  137047. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137048. * @param scene defines the hosting scene
  137049. */
  137050. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137051. /**
  137052. * Gets camera class name
  137053. * @returns StereoscopicArcRotateCamera
  137054. */
  137055. getClassName(): string;
  137056. }
  137057. }
  137058. declare module BABYLON {
  137059. /**
  137060. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  137061. * @see https://doc.babylonjs.com/features/cameras
  137062. */
  137063. export class StereoscopicFreeCamera extends FreeCamera {
  137064. /**
  137065. * Creates a new StereoscopicFreeCamera
  137066. * @param name defines camera name
  137067. * @param position defines initial position
  137068. * @param interaxialDistance defines distance between each color axis
  137069. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137070. * @param scene defines the hosting scene
  137071. */
  137072. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137073. /**
  137074. * Gets camera class name
  137075. * @returns StereoscopicFreeCamera
  137076. */
  137077. getClassName(): string;
  137078. }
  137079. }
  137080. declare module BABYLON {
  137081. /**
  137082. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  137083. * @see https://doc.babylonjs.com/features/cameras
  137084. */
  137085. export class StereoscopicGamepadCamera extends GamepadCamera {
  137086. /**
  137087. * Creates a new StereoscopicGamepadCamera
  137088. * @param name defines camera name
  137089. * @param position defines initial position
  137090. * @param interaxialDistance defines distance between each color axis
  137091. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137092. * @param scene defines the hosting scene
  137093. */
  137094. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137095. /**
  137096. * Gets camera class name
  137097. * @returns StereoscopicGamepadCamera
  137098. */
  137099. getClassName(): string;
  137100. }
  137101. }
  137102. declare module BABYLON {
  137103. /**
  137104. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  137105. * @see https://doc.babylonjs.com/features/cameras
  137106. */
  137107. export class StereoscopicUniversalCamera extends UniversalCamera {
  137108. /**
  137109. * Creates a new StereoscopicUniversalCamera
  137110. * @param name defines camera name
  137111. * @param position defines initial position
  137112. * @param interaxialDistance defines distance between each color axis
  137113. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137114. * @param scene defines the hosting scene
  137115. */
  137116. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137117. /**
  137118. * Gets camera class name
  137119. * @returns StereoscopicUniversalCamera
  137120. */
  137121. getClassName(): string;
  137122. }
  137123. }
  137124. declare module BABYLON {
  137125. /**
  137126. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  137127. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137128. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137129. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137130. */
  137131. export class VirtualJoysticksCamera extends FreeCamera {
  137132. /**
  137133. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  137134. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137135. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137136. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137137. * @param name Define the name of the camera in the scene
  137138. * @param position Define the start position of the camera in the scene
  137139. * @param scene Define the scene the camera belongs to
  137140. */
  137141. constructor(name: string, position: Vector3, scene: Scene);
  137142. /**
  137143. * Gets the current object class name.
  137144. * @return the class name
  137145. */
  137146. getClassName(): string;
  137147. }
  137148. }
  137149. declare module BABYLON {
  137150. /**
  137151. * This represents all the required metrics to create a VR camera.
  137152. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  137153. */
  137154. export class VRCameraMetrics {
  137155. /**
  137156. * Define the horizontal resolution off the screen.
  137157. */
  137158. hResolution: number;
  137159. /**
  137160. * Define the vertical resolution off the screen.
  137161. */
  137162. vResolution: number;
  137163. /**
  137164. * Define the horizontal screen size.
  137165. */
  137166. hScreenSize: number;
  137167. /**
  137168. * Define the vertical screen size.
  137169. */
  137170. vScreenSize: number;
  137171. /**
  137172. * Define the vertical screen center position.
  137173. */
  137174. vScreenCenter: number;
  137175. /**
  137176. * Define the distance of the eyes to the screen.
  137177. */
  137178. eyeToScreenDistance: number;
  137179. /**
  137180. * Define the distance between both lenses
  137181. */
  137182. lensSeparationDistance: number;
  137183. /**
  137184. * Define the distance between both viewer's eyes.
  137185. */
  137186. interpupillaryDistance: number;
  137187. /**
  137188. * Define the distortion factor of the VR postprocess.
  137189. * Please, touch with care.
  137190. */
  137191. distortionK: number[];
  137192. /**
  137193. * Define the chromatic aberration correction factors for the VR post process.
  137194. */
  137195. chromaAbCorrection: number[];
  137196. /**
  137197. * Define the scale factor of the post process.
  137198. * The smaller the better but the slower.
  137199. */
  137200. postProcessScaleFactor: number;
  137201. /**
  137202. * Define an offset for the lens center.
  137203. */
  137204. lensCenterOffset: number;
  137205. /**
  137206. * Define if the current vr camera should compensate the distortion of the lense or not.
  137207. */
  137208. compensateDistortion: boolean;
  137209. /**
  137210. * Defines if multiview should be enabled when rendering (Default: false)
  137211. */
  137212. multiviewEnabled: boolean;
  137213. /**
  137214. * Gets the rendering aspect ratio based on the provided resolutions.
  137215. */
  137216. get aspectRatio(): number;
  137217. /**
  137218. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  137219. */
  137220. get aspectRatioFov(): number;
  137221. /**
  137222. * @hidden
  137223. */
  137224. get leftHMatrix(): Matrix;
  137225. /**
  137226. * @hidden
  137227. */
  137228. get rightHMatrix(): Matrix;
  137229. /**
  137230. * @hidden
  137231. */
  137232. get leftPreViewMatrix(): Matrix;
  137233. /**
  137234. * @hidden
  137235. */
  137236. get rightPreViewMatrix(): Matrix;
  137237. /**
  137238. * Get the default VRMetrics based on the most generic setup.
  137239. * @returns the default vr metrics
  137240. */
  137241. static GetDefault(): VRCameraMetrics;
  137242. }
  137243. }
  137244. declare module BABYLON {
  137245. /** @hidden */
  137246. export var vrDistortionCorrectionPixelShader: {
  137247. name: string;
  137248. shader: string;
  137249. };
  137250. }
  137251. declare module BABYLON {
  137252. /**
  137253. * VRDistortionCorrectionPostProcess used for mobile VR
  137254. */
  137255. export class VRDistortionCorrectionPostProcess extends PostProcess {
  137256. private _isRightEye;
  137257. private _distortionFactors;
  137258. private _postProcessScaleFactor;
  137259. private _lensCenterOffset;
  137260. private _scaleIn;
  137261. private _scaleFactor;
  137262. private _lensCenter;
  137263. /**
  137264. * Gets a string identifying the name of the class
  137265. * @returns "VRDistortionCorrectionPostProcess" string
  137266. */
  137267. getClassName(): string;
  137268. /**
  137269. * Initializes the VRDistortionCorrectionPostProcess
  137270. * @param name The name of the effect.
  137271. * @param camera The camera to apply the render pass to.
  137272. * @param isRightEye If this is for the right eye distortion
  137273. * @param vrMetrics All the required metrics for the VR camera
  137274. */
  137275. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  137276. }
  137277. }
  137278. declare module BABYLON {
  137279. /**
  137280. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  137281. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137282. */
  137283. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  137284. /**
  137285. * Creates a new VRDeviceOrientationArcRotateCamera
  137286. * @param name defines camera name
  137287. * @param alpha defines the camera rotation along the logitudinal axis
  137288. * @param beta defines the camera rotation along the latitudinal axis
  137289. * @param radius defines the camera distance from its target
  137290. * @param target defines the camera target
  137291. * @param scene defines the scene the camera belongs to
  137292. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137293. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137294. */
  137295. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137296. /**
  137297. * Gets camera class name
  137298. * @returns VRDeviceOrientationArcRotateCamera
  137299. */
  137300. getClassName(): string;
  137301. }
  137302. }
  137303. declare module BABYLON {
  137304. /**
  137305. * Camera used to simulate VR rendering (based on FreeCamera)
  137306. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137307. */
  137308. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  137309. /**
  137310. * Creates a new VRDeviceOrientationFreeCamera
  137311. * @param name defines camera name
  137312. * @param position defines the start position of the camera
  137313. * @param scene defines the scene the camera belongs to
  137314. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137315. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137316. */
  137317. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137318. /**
  137319. * Gets camera class name
  137320. * @returns VRDeviceOrientationFreeCamera
  137321. */
  137322. getClassName(): string;
  137323. }
  137324. }
  137325. declare module BABYLON {
  137326. /**
  137327. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  137328. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137329. */
  137330. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  137331. /**
  137332. * Creates a new VRDeviceOrientationGamepadCamera
  137333. * @param name defines camera name
  137334. * @param position defines the start position of the camera
  137335. * @param scene defines the scene the camera belongs to
  137336. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137337. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137338. */
  137339. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137340. /**
  137341. * Gets camera class name
  137342. * @returns VRDeviceOrientationGamepadCamera
  137343. */
  137344. getClassName(): string;
  137345. }
  137346. }
  137347. declare module BABYLON {
  137348. /**
  137349. * A class extending Texture allowing drawing on a texture
  137350. * @see https://doc.babylonjs.com/how_to/dynamictexture
  137351. */
  137352. export class DynamicTexture extends Texture {
  137353. private _generateMipMaps;
  137354. private _canvas;
  137355. private _context;
  137356. /**
  137357. * Creates a DynamicTexture
  137358. * @param name defines the name of the texture
  137359. * @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
  137360. * @param scene defines the scene where you want the texture
  137361. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  137362. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137363. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  137364. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  137365. */
  137366. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  137367. /**
  137368. * Get the current class name of the texture useful for serialization or dynamic coding.
  137369. * @returns "DynamicTexture"
  137370. */
  137371. getClassName(): string;
  137372. /**
  137373. * Gets the current state of canRescale
  137374. */
  137375. get canRescale(): boolean;
  137376. private _recreate;
  137377. /**
  137378. * Scales the texture
  137379. * @param ratio the scale factor to apply to both width and height
  137380. */
  137381. scale(ratio: number): void;
  137382. /**
  137383. * Resizes the texture
  137384. * @param width the new width
  137385. * @param height the new height
  137386. */
  137387. scaleTo(width: number, height: number): void;
  137388. /**
  137389. * Gets the context of the canvas used by the texture
  137390. * @returns the canvas context of the dynamic texture
  137391. */
  137392. getContext(): CanvasRenderingContext2D;
  137393. /**
  137394. * Clears the texture
  137395. */
  137396. clear(): void;
  137397. /**
  137398. * Updates the texture
  137399. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  137400. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  137401. */
  137402. update(invertY?: boolean, premulAlpha?: boolean): void;
  137403. /**
  137404. * Draws text onto the texture
  137405. * @param text defines the text to be drawn
  137406. * @param x defines the placement of the text from the left
  137407. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  137408. * @param font defines the font to be used with font-style, font-size, font-name
  137409. * @param color defines the color used for the text
  137410. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  137411. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  137412. * @param update defines whether texture is immediately update (default is true)
  137413. */
  137414. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  137415. /**
  137416. * Clones the texture
  137417. * @returns the clone of the texture.
  137418. */
  137419. clone(): DynamicTexture;
  137420. /**
  137421. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  137422. * @returns a serialized dynamic texture object
  137423. */
  137424. serialize(): any;
  137425. private _IsCanvasElement;
  137426. /** @hidden */
  137427. _rebuild(): void;
  137428. }
  137429. }
  137430. declare module BABYLON {
  137431. /**
  137432. * Class containing static functions to help procedurally build meshes
  137433. */
  137434. export class GroundBuilder {
  137435. /**
  137436. * Creates a ground mesh
  137437. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  137438. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  137439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137440. * @param name defines the name of the mesh
  137441. * @param options defines the options used to create the mesh
  137442. * @param scene defines the hosting scene
  137443. * @returns the ground mesh
  137444. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  137445. */
  137446. static CreateGround(name: string, options: {
  137447. width?: number;
  137448. height?: number;
  137449. subdivisions?: number;
  137450. subdivisionsX?: number;
  137451. subdivisionsY?: number;
  137452. updatable?: boolean;
  137453. }, scene: any): Mesh;
  137454. /**
  137455. * Creates a tiled ground mesh
  137456. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  137457. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  137458. * * 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
  137459. * * 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
  137460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137461. * @param name defines the name of the mesh
  137462. * @param options defines the options used to create the mesh
  137463. * @param scene defines the hosting scene
  137464. * @returns the tiled ground mesh
  137465. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  137466. */
  137467. static CreateTiledGround(name: string, options: {
  137468. xmin: number;
  137469. zmin: number;
  137470. xmax: number;
  137471. zmax: number;
  137472. subdivisions?: {
  137473. w: number;
  137474. h: number;
  137475. };
  137476. precision?: {
  137477. w: number;
  137478. h: number;
  137479. };
  137480. updatable?: boolean;
  137481. }, scene?: Nullable<Scene>): Mesh;
  137482. /**
  137483. * Creates a ground mesh from a height map
  137484. * * The parameter `url` sets the URL of the height map image resource.
  137485. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  137486. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  137487. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  137488. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  137489. * * 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.
  137490. * * 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).
  137491. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  137492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137493. * @param name defines the name of the mesh
  137494. * @param url defines the url to the height map
  137495. * @param options defines the options used to create the mesh
  137496. * @param scene defines the hosting scene
  137497. * @returns the ground mesh
  137498. * @see https://doc.babylonjs.com/babylon101/height_map
  137499. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  137500. */
  137501. static CreateGroundFromHeightMap(name: string, url: string, options: {
  137502. width?: number;
  137503. height?: number;
  137504. subdivisions?: number;
  137505. minHeight?: number;
  137506. maxHeight?: number;
  137507. colorFilter?: Color3;
  137508. alphaFilter?: number;
  137509. updatable?: boolean;
  137510. onReady?: (mesh: GroundMesh) => void;
  137511. }, scene?: Nullable<Scene>): GroundMesh;
  137512. }
  137513. }
  137514. declare module BABYLON {
  137515. /**
  137516. * Class containing static functions to help procedurally build meshes
  137517. */
  137518. export class TorusBuilder {
  137519. /**
  137520. * Creates a torus mesh
  137521. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  137522. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  137523. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  137524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137525. * * 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
  137526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137527. * @param name defines the name of the mesh
  137528. * @param options defines the options used to create the mesh
  137529. * @param scene defines the hosting scene
  137530. * @returns the torus mesh
  137531. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  137532. */
  137533. static CreateTorus(name: string, options: {
  137534. diameter?: number;
  137535. thickness?: number;
  137536. tessellation?: number;
  137537. updatable?: boolean;
  137538. sideOrientation?: number;
  137539. frontUVs?: Vector4;
  137540. backUVs?: Vector4;
  137541. }, scene: any): Mesh;
  137542. }
  137543. }
  137544. declare module BABYLON {
  137545. /**
  137546. * Class containing static functions to help procedurally build meshes
  137547. */
  137548. export class CylinderBuilder {
  137549. /**
  137550. * Creates a cylinder or a cone mesh
  137551. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  137552. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  137553. * * 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.
  137554. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  137555. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  137556. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  137557. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  137558. * * 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).
  137559. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  137560. * * 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).
  137561. * * 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
  137562. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  137563. * * 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
  137564. * * 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.
  137565. * * If `enclose` is false, a ring surface is one element.
  137566. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  137567. * * 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
  137568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137569. * * 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
  137570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137571. * @param name defines the name of the mesh
  137572. * @param options defines the options used to create the mesh
  137573. * @param scene defines the hosting scene
  137574. * @returns the cylinder mesh
  137575. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  137576. */
  137577. static CreateCylinder(name: string, options: {
  137578. height?: number;
  137579. diameterTop?: number;
  137580. diameterBottom?: number;
  137581. diameter?: number;
  137582. tessellation?: number;
  137583. subdivisions?: number;
  137584. arc?: number;
  137585. faceColors?: Color4[];
  137586. faceUV?: Vector4[];
  137587. updatable?: boolean;
  137588. hasRings?: boolean;
  137589. enclose?: boolean;
  137590. cap?: number;
  137591. sideOrientation?: number;
  137592. frontUVs?: Vector4;
  137593. backUVs?: Vector4;
  137594. }, scene: any): Mesh;
  137595. }
  137596. }
  137597. declare module BABYLON {
  137598. /**
  137599. * States of the webXR experience
  137600. */
  137601. export enum WebXRState {
  137602. /**
  137603. * Transitioning to being in XR mode
  137604. */
  137605. ENTERING_XR = 0,
  137606. /**
  137607. * Transitioning to non XR mode
  137608. */
  137609. EXITING_XR = 1,
  137610. /**
  137611. * In XR mode and presenting
  137612. */
  137613. IN_XR = 2,
  137614. /**
  137615. * Not entered XR mode
  137616. */
  137617. NOT_IN_XR = 3
  137618. }
  137619. /**
  137620. * The state of the XR camera's tracking
  137621. */
  137622. export enum WebXRTrackingState {
  137623. /**
  137624. * No transformation received, device is not being tracked
  137625. */
  137626. NOT_TRACKING = 0,
  137627. /**
  137628. * Tracking lost - using emulated position
  137629. */
  137630. TRACKING_LOST = 1,
  137631. /**
  137632. * Transformation tracking works normally
  137633. */
  137634. TRACKING = 2
  137635. }
  137636. /**
  137637. * Abstraction of the XR render target
  137638. */
  137639. export interface WebXRRenderTarget extends IDisposable {
  137640. /**
  137641. * xrpresent context of the canvas which can be used to display/mirror xr content
  137642. */
  137643. canvasContext: WebGLRenderingContext;
  137644. /**
  137645. * xr layer for the canvas
  137646. */
  137647. xrLayer: Nullable<XRWebGLLayer>;
  137648. /**
  137649. * Initializes the xr layer for the session
  137650. * @param xrSession xr session
  137651. * @returns a promise that will resolve once the XR Layer has been created
  137652. */
  137653. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  137654. }
  137655. }
  137656. declare module BABYLON {
  137657. /**
  137658. * COnfiguration object for WebXR output canvas
  137659. */
  137660. export class WebXRManagedOutputCanvasOptions {
  137661. /**
  137662. * An optional canvas in case you wish to create it yourself and provide it here.
  137663. * If not provided, a new canvas will be created
  137664. */
  137665. canvasElement?: HTMLCanvasElement;
  137666. /**
  137667. * Options for this XR Layer output
  137668. */
  137669. canvasOptions?: XRWebGLLayerInit;
  137670. /**
  137671. * CSS styling for a newly created canvas (if not provided)
  137672. */
  137673. newCanvasCssStyle?: string;
  137674. /**
  137675. * Get the default values of the configuration object
  137676. * @param engine defines the engine to use (can be null)
  137677. * @returns default values of this configuration object
  137678. */
  137679. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  137680. }
  137681. /**
  137682. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  137683. */
  137684. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  137685. private _options;
  137686. private _canvas;
  137687. private _engine;
  137688. private _originalCanvasSize;
  137689. /**
  137690. * Rendering context of the canvas which can be used to display/mirror xr content
  137691. */
  137692. canvasContext: WebGLRenderingContext;
  137693. /**
  137694. * xr layer for the canvas
  137695. */
  137696. xrLayer: Nullable<XRWebGLLayer>;
  137697. /**
  137698. * Obseervers registered here will be triggered when the xr layer was initialized
  137699. */
  137700. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  137701. /**
  137702. * Initializes the canvas to be added/removed upon entering/exiting xr
  137703. * @param _xrSessionManager The XR Session manager
  137704. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  137705. */
  137706. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  137707. /**
  137708. * Disposes of the object
  137709. */
  137710. dispose(): void;
  137711. /**
  137712. * Initializes the xr layer for the session
  137713. * @param xrSession xr session
  137714. * @returns a promise that will resolve once the XR Layer has been created
  137715. */
  137716. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  137717. private _addCanvas;
  137718. private _removeCanvas;
  137719. private _setCanvasSize;
  137720. private _setManagedOutputCanvas;
  137721. }
  137722. }
  137723. declare module BABYLON {
  137724. /**
  137725. * Manages an XRSession to work with Babylon's engine
  137726. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  137727. */
  137728. export class WebXRSessionManager implements IDisposable {
  137729. /** The scene which the session should be created for */
  137730. scene: Scene;
  137731. private _referenceSpace;
  137732. private _rttProvider;
  137733. private _sessionEnded;
  137734. private _xrNavigator;
  137735. private baseLayer;
  137736. /**
  137737. * The base reference space from which the session started. good if you want to reset your
  137738. * reference space
  137739. */
  137740. baseReferenceSpace: XRReferenceSpace;
  137741. /**
  137742. * Current XR frame
  137743. */
  137744. currentFrame: Nullable<XRFrame>;
  137745. /** WebXR timestamp updated every frame */
  137746. currentTimestamp: number;
  137747. /**
  137748. * Used just in case of a failure to initialize an immersive session.
  137749. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  137750. */
  137751. defaultHeightCompensation: number;
  137752. /**
  137753. * Fires every time a new xrFrame arrives which can be used to update the camera
  137754. */
  137755. onXRFrameObservable: Observable<XRFrame>;
  137756. /**
  137757. * Fires when the reference space changed
  137758. */
  137759. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  137760. /**
  137761. * Fires when the xr session is ended either by the device or manually done
  137762. */
  137763. onXRSessionEnded: Observable<any>;
  137764. /**
  137765. * Fires when the xr session is ended either by the device or manually done
  137766. */
  137767. onXRSessionInit: Observable<XRSession>;
  137768. /**
  137769. * Underlying xr session
  137770. */
  137771. session: XRSession;
  137772. /**
  137773. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  137774. * or get the offset the player is currently at.
  137775. */
  137776. viewerReferenceSpace: XRReferenceSpace;
  137777. /**
  137778. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  137779. * @param scene The scene which the session should be created for
  137780. */
  137781. constructor(
  137782. /** The scene which the session should be created for */
  137783. scene: Scene);
  137784. /**
  137785. * The current reference space used in this session. This reference space can constantly change!
  137786. * It is mainly used to offset the camera's position.
  137787. */
  137788. get referenceSpace(): XRReferenceSpace;
  137789. /**
  137790. * Set a new reference space and triggers the observable
  137791. */
  137792. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  137793. /**
  137794. * Disposes of the session manager
  137795. */
  137796. dispose(): void;
  137797. /**
  137798. * Stops the xrSession and restores the render loop
  137799. * @returns Promise which resolves after it exits XR
  137800. */
  137801. exitXRAsync(): Promise<void>;
  137802. /**
  137803. * Gets the correct render target texture to be rendered this frame for this eye
  137804. * @param eye the eye for which to get the render target
  137805. * @returns the render target for the specified eye
  137806. */
  137807. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  137808. /**
  137809. * Creates a WebXRRenderTarget object for the XR session
  137810. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  137811. * @param options optional options to provide when creating a new render target
  137812. * @returns a WebXR render target to which the session can render
  137813. */
  137814. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  137815. /**
  137816. * Initializes the manager
  137817. * After initialization enterXR can be called to start an XR session
  137818. * @returns Promise which resolves after it is initialized
  137819. */
  137820. initializeAsync(): Promise<void>;
  137821. /**
  137822. * Initializes an xr session
  137823. * @param xrSessionMode mode to initialize
  137824. * @param xrSessionInit defines optional and required values to pass to the session builder
  137825. * @returns a promise which will resolve once the session has been initialized
  137826. */
  137827. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  137828. /**
  137829. * Checks if a session would be supported for the creation options specified
  137830. * @param sessionMode session mode to check if supported eg. immersive-vr
  137831. * @returns A Promise that resolves to true if supported and false if not
  137832. */
  137833. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  137834. /**
  137835. * Resets the reference space to the one started the session
  137836. */
  137837. resetReferenceSpace(): void;
  137838. /**
  137839. * Starts rendering to the xr layer
  137840. */
  137841. runXRRenderLoop(): void;
  137842. /**
  137843. * Sets the reference space on the xr session
  137844. * @param referenceSpaceType space to set
  137845. * @returns a promise that will resolve once the reference space has been set
  137846. */
  137847. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  137848. /**
  137849. * Updates the render state of the session
  137850. * @param state state to set
  137851. * @returns a promise that resolves once the render state has been updated
  137852. */
  137853. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  137854. /**
  137855. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  137856. * @param sessionMode defines the session to test
  137857. * @returns a promise with boolean as final value
  137858. */
  137859. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  137860. /**
  137861. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  137862. */
  137863. get isNative(): boolean;
  137864. private _createRenderTargetTexture;
  137865. }
  137866. }
  137867. declare module BABYLON {
  137868. /**
  137869. * WebXR Camera which holds the views for the xrSession
  137870. * @see https://doc.babylonjs.com/how_to/webxr_camera
  137871. */
  137872. export class WebXRCamera extends FreeCamera {
  137873. private _xrSessionManager;
  137874. private _firstFrame;
  137875. private _referenceQuaternion;
  137876. private _referencedPosition;
  137877. private _xrInvPositionCache;
  137878. private _xrInvQuaternionCache;
  137879. private _trackingState;
  137880. /**
  137881. * Observable raised before camera teleportation
  137882. */
  137883. onBeforeCameraTeleport: Observable<Vector3>;
  137884. /**
  137885. * Observable raised after camera teleportation
  137886. */
  137887. onAfterCameraTeleport: Observable<Vector3>;
  137888. /**
  137889. * Notifies when the camera's tracking state has changed.
  137890. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  137891. */
  137892. onTrackingStateChanged: Observable<WebXRTrackingState>;
  137893. /**
  137894. * Should position compensation execute on first frame.
  137895. * This is used when copying the position from a native (non XR) camera
  137896. */
  137897. compensateOnFirstFrame: boolean;
  137898. /**
  137899. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  137900. * @param name the name of the camera
  137901. * @param scene the scene to add the camera to
  137902. * @param _xrSessionManager a constructed xr session manager
  137903. */
  137904. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  137905. /**
  137906. * Get the current XR tracking state of the camera
  137907. */
  137908. get trackingState(): WebXRTrackingState;
  137909. private _setTrackingState;
  137910. /**
  137911. * Return the user's height, unrelated to the current ground.
  137912. * This will be the y position of this camera, when ground level is 0.
  137913. */
  137914. get realWorldHeight(): number;
  137915. /** @hidden */
  137916. _updateForDualEyeDebugging(): void;
  137917. /**
  137918. * Sets this camera's transformation based on a non-vr camera
  137919. * @param otherCamera the non-vr camera to copy the transformation from
  137920. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  137921. */
  137922. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  137923. /**
  137924. * Gets the current instance class name ("WebXRCamera").
  137925. * @returns the class name
  137926. */
  137927. getClassName(): string;
  137928. private _rotate180;
  137929. private _updateFromXRSession;
  137930. private _updateNumberOfRigCameras;
  137931. private _updateReferenceSpace;
  137932. private _updateReferenceSpaceOffset;
  137933. }
  137934. }
  137935. declare module BABYLON {
  137936. /**
  137937. * Defining the interface required for a (webxr) feature
  137938. */
  137939. export interface IWebXRFeature extends IDisposable {
  137940. /**
  137941. * Is this feature attached
  137942. */
  137943. attached: boolean;
  137944. /**
  137945. * Should auto-attach be disabled?
  137946. */
  137947. disableAutoAttach: boolean;
  137948. /**
  137949. * Attach the feature to the session
  137950. * Will usually be called by the features manager
  137951. *
  137952. * @param force should attachment be forced (even when already attached)
  137953. * @returns true if successful.
  137954. */
  137955. attach(force?: boolean): boolean;
  137956. /**
  137957. * Detach the feature from the session
  137958. * Will usually be called by the features manager
  137959. *
  137960. * @returns true if successful.
  137961. */
  137962. detach(): boolean;
  137963. /**
  137964. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  137965. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  137966. *
  137967. * @returns whether or not the feature is compatible in this environment
  137968. */
  137969. isCompatible(): boolean;
  137970. /**
  137971. * Was this feature disposed;
  137972. */
  137973. isDisposed: boolean;
  137974. /**
  137975. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  137976. */
  137977. xrNativeFeatureName?: string;
  137978. /**
  137979. * A list of (Babylon WebXR) features this feature depends on
  137980. */
  137981. dependsOn?: string[];
  137982. }
  137983. /**
  137984. * A list of the currently available features without referencing them
  137985. */
  137986. export class WebXRFeatureName {
  137987. /**
  137988. * The name of the anchor system feature
  137989. */
  137990. static readonly ANCHOR_SYSTEM: string;
  137991. /**
  137992. * The name of the background remover feature
  137993. */
  137994. static readonly BACKGROUND_REMOVER: string;
  137995. /**
  137996. * The name of the hit test feature
  137997. */
  137998. static readonly HIT_TEST: string;
  137999. /**
  138000. * The name of the mesh detection feature
  138001. */
  138002. static readonly MESH_DETECTION: string;
  138003. /**
  138004. * physics impostors for xr controllers feature
  138005. */
  138006. static readonly PHYSICS_CONTROLLERS: string;
  138007. /**
  138008. * The name of the plane detection feature
  138009. */
  138010. static readonly PLANE_DETECTION: string;
  138011. /**
  138012. * The name of the pointer selection feature
  138013. */
  138014. static readonly POINTER_SELECTION: string;
  138015. /**
  138016. * The name of the teleportation feature
  138017. */
  138018. static readonly TELEPORTATION: string;
  138019. /**
  138020. * The name of the feature points feature.
  138021. */
  138022. static readonly FEATURE_POINTS: string;
  138023. /**
  138024. * The name of the hand tracking feature.
  138025. */
  138026. static readonly HAND_TRACKING: string;
  138027. }
  138028. /**
  138029. * Defining the constructor of a feature. Used to register the modules.
  138030. */
  138031. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  138032. /**
  138033. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  138034. * It is mainly used in AR sessions.
  138035. *
  138036. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  138037. */
  138038. export class WebXRFeaturesManager implements IDisposable {
  138039. private _xrSessionManager;
  138040. private static readonly _AvailableFeatures;
  138041. private _features;
  138042. /**
  138043. * constructs a new features manages.
  138044. *
  138045. * @param _xrSessionManager an instance of WebXRSessionManager
  138046. */
  138047. constructor(_xrSessionManager: WebXRSessionManager);
  138048. /**
  138049. * Used to register a module. After calling this function a developer can use this feature in the scene.
  138050. * Mainly used internally.
  138051. *
  138052. * @param featureName the name of the feature to register
  138053. * @param constructorFunction the function used to construct the module
  138054. * @param version the (babylon) version of the module
  138055. * @param stable is that a stable version of this module
  138056. */
  138057. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  138058. /**
  138059. * Returns a constructor of a specific feature.
  138060. *
  138061. * @param featureName the name of the feature to construct
  138062. * @param version the version of the feature to load
  138063. * @param xrSessionManager the xrSessionManager. Used to construct the module
  138064. * @param options optional options provided to the module.
  138065. * @returns a function that, when called, will return a new instance of this feature
  138066. */
  138067. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  138068. /**
  138069. * Can be used to return the list of features currently registered
  138070. *
  138071. * @returns an Array of available features
  138072. */
  138073. static GetAvailableFeatures(): string[];
  138074. /**
  138075. * Gets the versions available for a specific feature
  138076. * @param featureName the name of the feature
  138077. * @returns an array with the available versions
  138078. */
  138079. static GetAvailableVersions(featureName: string): string[];
  138080. /**
  138081. * Return the latest unstable version of this feature
  138082. * @param featureName the name of the feature to search
  138083. * @returns the version number. if not found will return -1
  138084. */
  138085. static GetLatestVersionOfFeature(featureName: string): number;
  138086. /**
  138087. * Return the latest stable version of this feature
  138088. * @param featureName the name of the feature to search
  138089. * @returns the version number. if not found will return -1
  138090. */
  138091. static GetStableVersionOfFeature(featureName: string): number;
  138092. /**
  138093. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  138094. * Can be used during a session to start a feature
  138095. * @param featureName the name of feature to attach
  138096. */
  138097. attachFeature(featureName: string): void;
  138098. /**
  138099. * Can be used inside a session or when the session ends to detach a specific feature
  138100. * @param featureName the name of the feature to detach
  138101. */
  138102. detachFeature(featureName: string): void;
  138103. /**
  138104. * Used to disable an already-enabled feature
  138105. * The feature will be disposed and will be recreated once enabled.
  138106. * @param featureName the feature to disable
  138107. * @returns true if disable was successful
  138108. */
  138109. disableFeature(featureName: string | {
  138110. Name: string;
  138111. }): boolean;
  138112. /**
  138113. * dispose this features manager
  138114. */
  138115. dispose(): void;
  138116. /**
  138117. * 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.
  138118. * 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.
  138119. *
  138120. * @param featureName the name of the feature to load or the class of the feature
  138121. * @param version optional version to load. if not provided the latest version will be enabled
  138122. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  138123. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  138124. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  138125. * @returns a new constructed feature or throws an error if feature not found.
  138126. */
  138127. enableFeature(featureName: string | {
  138128. Name: string;
  138129. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  138130. /**
  138131. * get the implementation of an enabled feature.
  138132. * @param featureName the name of the feature to load
  138133. * @returns the feature class, if found
  138134. */
  138135. getEnabledFeature(featureName: string): IWebXRFeature;
  138136. /**
  138137. * Get the list of enabled features
  138138. * @returns an array of enabled features
  138139. */
  138140. getEnabledFeatures(): string[];
  138141. /**
  138142. * This function will exten the session creation configuration object with enabled features.
  138143. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  138144. * according to the defined "required" variable, provided during enableFeature call
  138145. * @param xrSessionInit the xr Session init object to extend
  138146. *
  138147. * @returns an extended XRSessionInit object
  138148. */
  138149. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  138150. }
  138151. }
  138152. declare module BABYLON {
  138153. /**
  138154. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  138155. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  138156. */
  138157. export class WebXRExperienceHelper implements IDisposable {
  138158. private scene;
  138159. private _nonVRCamera;
  138160. private _originalSceneAutoClear;
  138161. private _supported;
  138162. /**
  138163. * Camera used to render xr content
  138164. */
  138165. camera: WebXRCamera;
  138166. /** A features manager for this xr session */
  138167. featuresManager: WebXRFeaturesManager;
  138168. /**
  138169. * Observers registered here will be triggered after the camera's initial transformation is set
  138170. * This can be used to set a different ground level or an extra rotation.
  138171. *
  138172. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  138173. * to the position set after this observable is done executing.
  138174. */
  138175. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  138176. /**
  138177. * Fires when the state of the experience helper has changed
  138178. */
  138179. onStateChangedObservable: Observable<WebXRState>;
  138180. /** Session manager used to keep track of xr session */
  138181. sessionManager: WebXRSessionManager;
  138182. /**
  138183. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  138184. */
  138185. state: WebXRState;
  138186. /**
  138187. * Creates a WebXRExperienceHelper
  138188. * @param scene The scene the helper should be created in
  138189. */
  138190. private constructor();
  138191. /**
  138192. * Creates the experience helper
  138193. * @param scene the scene to attach the experience helper to
  138194. * @returns a promise for the experience helper
  138195. */
  138196. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  138197. /**
  138198. * Disposes of the experience helper
  138199. */
  138200. dispose(): void;
  138201. /**
  138202. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  138203. * @param sessionMode options for the XR session
  138204. * @param referenceSpaceType frame of reference of the XR session
  138205. * @param renderTarget the output canvas that will be used to enter XR mode
  138206. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  138207. * @returns promise that resolves after xr mode has entered
  138208. */
  138209. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  138210. /**
  138211. * Exits XR mode and returns the scene to its original state
  138212. * @returns promise that resolves after xr mode has exited
  138213. */
  138214. exitXRAsync(): Promise<void>;
  138215. private _nonXRToXRCamera;
  138216. private _setState;
  138217. }
  138218. }
  138219. declare module BABYLON {
  138220. /**
  138221. * X-Y values for axes in WebXR
  138222. */
  138223. export interface IWebXRMotionControllerAxesValue {
  138224. /**
  138225. * The value of the x axis
  138226. */
  138227. x: number;
  138228. /**
  138229. * The value of the y-axis
  138230. */
  138231. y: number;
  138232. }
  138233. /**
  138234. * changed / previous values for the values of this component
  138235. */
  138236. export interface IWebXRMotionControllerComponentChangesValues<T> {
  138237. /**
  138238. * current (this frame) value
  138239. */
  138240. current: T;
  138241. /**
  138242. * previous (last change) value
  138243. */
  138244. previous: T;
  138245. }
  138246. /**
  138247. * Represents changes in the component between current frame and last values recorded
  138248. */
  138249. export interface IWebXRMotionControllerComponentChanges {
  138250. /**
  138251. * will be populated with previous and current values if axes changed
  138252. */
  138253. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  138254. /**
  138255. * will be populated with previous and current values if pressed changed
  138256. */
  138257. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  138258. /**
  138259. * will be populated with previous and current values if touched changed
  138260. */
  138261. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  138262. /**
  138263. * will be populated with previous and current values if value changed
  138264. */
  138265. value?: IWebXRMotionControllerComponentChangesValues<number>;
  138266. }
  138267. /**
  138268. * This class represents a single component (for example button or thumbstick) of a motion controller
  138269. */
  138270. export class WebXRControllerComponent implements IDisposable {
  138271. /**
  138272. * the id of this component
  138273. */
  138274. id: string;
  138275. /**
  138276. * the type of the component
  138277. */
  138278. type: MotionControllerComponentType;
  138279. private _buttonIndex;
  138280. private _axesIndices;
  138281. private _axes;
  138282. private _changes;
  138283. private _currentValue;
  138284. private _hasChanges;
  138285. private _pressed;
  138286. private _touched;
  138287. /**
  138288. * button component type
  138289. */
  138290. static BUTTON_TYPE: MotionControllerComponentType;
  138291. /**
  138292. * squeeze component type
  138293. */
  138294. static SQUEEZE_TYPE: MotionControllerComponentType;
  138295. /**
  138296. * Thumbstick component type
  138297. */
  138298. static THUMBSTICK_TYPE: MotionControllerComponentType;
  138299. /**
  138300. * Touchpad component type
  138301. */
  138302. static TOUCHPAD_TYPE: MotionControllerComponentType;
  138303. /**
  138304. * trigger component type
  138305. */
  138306. static TRIGGER_TYPE: MotionControllerComponentType;
  138307. /**
  138308. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  138309. * the axes data changes
  138310. */
  138311. onAxisValueChangedObservable: Observable<{
  138312. x: number;
  138313. y: number;
  138314. }>;
  138315. /**
  138316. * Observers registered here will be triggered when the state of a button changes
  138317. * State change is either pressed / touched / value
  138318. */
  138319. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  138320. /**
  138321. * Creates a new component for a motion controller.
  138322. * It is created by the motion controller itself
  138323. *
  138324. * @param id the id of this component
  138325. * @param type the type of the component
  138326. * @param _buttonIndex index in the buttons array of the gamepad
  138327. * @param _axesIndices indices of the values in the axes array of the gamepad
  138328. */
  138329. constructor(
  138330. /**
  138331. * the id of this component
  138332. */
  138333. id: string,
  138334. /**
  138335. * the type of the component
  138336. */
  138337. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  138338. /**
  138339. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  138340. */
  138341. get axes(): IWebXRMotionControllerAxesValue;
  138342. /**
  138343. * Get the changes. Elements will be populated only if they changed with their previous and current value
  138344. */
  138345. get changes(): IWebXRMotionControllerComponentChanges;
  138346. /**
  138347. * Return whether or not the component changed the last frame
  138348. */
  138349. get hasChanges(): boolean;
  138350. /**
  138351. * is the button currently pressed
  138352. */
  138353. get pressed(): boolean;
  138354. /**
  138355. * is the button currently touched
  138356. */
  138357. get touched(): boolean;
  138358. /**
  138359. * Get the current value of this component
  138360. */
  138361. get value(): number;
  138362. /**
  138363. * Dispose this component
  138364. */
  138365. dispose(): void;
  138366. /**
  138367. * Are there axes correlating to this component
  138368. * @return true is axes data is available
  138369. */
  138370. isAxes(): boolean;
  138371. /**
  138372. * Is this component a button (hence - pressable)
  138373. * @returns true if can be pressed
  138374. */
  138375. isButton(): boolean;
  138376. /**
  138377. * update this component using the gamepad object it is in. Called on every frame
  138378. * @param nativeController the native gamepad controller object
  138379. */
  138380. update(nativeController: IMinimalMotionControllerObject): void;
  138381. }
  138382. }
  138383. declare module BABYLON {
  138384. /**
  138385. * Type used for the success callback of ImportMesh
  138386. */
  138387. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  138388. /**
  138389. * Interface used for the result of ImportMeshAsync
  138390. */
  138391. export interface ISceneLoaderAsyncResult {
  138392. /**
  138393. * The array of loaded meshes
  138394. */
  138395. readonly meshes: AbstractMesh[];
  138396. /**
  138397. * The array of loaded particle systems
  138398. */
  138399. readonly particleSystems: IParticleSystem[];
  138400. /**
  138401. * The array of loaded skeletons
  138402. */
  138403. readonly skeletons: Skeleton[];
  138404. /**
  138405. * The array of loaded animation groups
  138406. */
  138407. readonly animationGroups: AnimationGroup[];
  138408. /**
  138409. * The array of loaded transform nodes
  138410. */
  138411. readonly transformNodes: TransformNode[];
  138412. /**
  138413. * The array of loaded geometries
  138414. */
  138415. readonly geometries: Geometry[];
  138416. /**
  138417. * The array of loaded lights
  138418. */
  138419. readonly lights: Light[];
  138420. }
  138421. /**
  138422. * Interface used to represent data loading progression
  138423. */
  138424. export interface ISceneLoaderProgressEvent {
  138425. /**
  138426. * Defines if data length to load can be evaluated
  138427. */
  138428. readonly lengthComputable: boolean;
  138429. /**
  138430. * Defines the loaded data length
  138431. */
  138432. readonly loaded: number;
  138433. /**
  138434. * Defines the data length to load
  138435. */
  138436. readonly total: number;
  138437. }
  138438. /**
  138439. * Interface used by SceneLoader plugins to define supported file extensions
  138440. */
  138441. export interface ISceneLoaderPluginExtensions {
  138442. /**
  138443. * Defines the list of supported extensions
  138444. */
  138445. [extension: string]: {
  138446. isBinary: boolean;
  138447. };
  138448. }
  138449. /**
  138450. * Interface used by SceneLoader plugin factory
  138451. */
  138452. export interface ISceneLoaderPluginFactory {
  138453. /**
  138454. * Defines the name of the factory
  138455. */
  138456. name: string;
  138457. /**
  138458. * Function called to create a new plugin
  138459. * @return the new plugin
  138460. */
  138461. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  138462. /**
  138463. * The callback that returns true if the data can be directly loaded.
  138464. * @param data string containing the file data
  138465. * @returns if the data can be loaded directly
  138466. */
  138467. canDirectLoad?(data: string): boolean;
  138468. }
  138469. /**
  138470. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  138471. */
  138472. export interface ISceneLoaderPluginBase {
  138473. /**
  138474. * The friendly name of this plugin.
  138475. */
  138476. name: string;
  138477. /**
  138478. * The file extensions supported by this plugin.
  138479. */
  138480. extensions: string | ISceneLoaderPluginExtensions;
  138481. /**
  138482. * The callback called when loading from a url.
  138483. * @param scene scene loading this url
  138484. * @param url url to load
  138485. * @param onSuccess callback called when the file successfully loads
  138486. * @param onProgress callback called while file is loading (if the server supports this mode)
  138487. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  138488. * @param onError callback called when the file fails to load
  138489. * @returns a file request object
  138490. */
  138491. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  138492. /**
  138493. * The callback called when loading from a file object.
  138494. * @param scene scene loading this file
  138495. * @param file defines the file to load
  138496. * @param onSuccess defines the callback to call when data is loaded
  138497. * @param onProgress defines the callback to call during loading process
  138498. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  138499. * @param onError defines the callback to call when an error occurs
  138500. * @returns a file request object
  138501. */
  138502. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  138503. /**
  138504. * The callback that returns true if the data can be directly loaded.
  138505. * @param data string containing the file data
  138506. * @returns if the data can be loaded directly
  138507. */
  138508. canDirectLoad?(data: string): boolean;
  138509. /**
  138510. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  138511. * @param scene scene loading this data
  138512. * @param data string containing the data
  138513. * @returns data to pass to the plugin
  138514. */
  138515. directLoad?(scene: Scene, data: string): any;
  138516. /**
  138517. * The callback that allows custom handling of the root url based on the response url.
  138518. * @param rootUrl the original root url
  138519. * @param responseURL the response url if available
  138520. * @returns the new root url
  138521. */
  138522. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  138523. }
  138524. /**
  138525. * Interface used to define a SceneLoader plugin
  138526. */
  138527. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  138528. /**
  138529. * Import meshes into a scene.
  138530. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138531. * @param scene The scene to import into
  138532. * @param data The data to import
  138533. * @param rootUrl The root url for scene and resources
  138534. * @param meshes The meshes array to import into
  138535. * @param particleSystems The particle systems array to import into
  138536. * @param skeletons The skeletons array to import into
  138537. * @param onError The callback when import fails
  138538. * @returns True if successful or false otherwise
  138539. */
  138540. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  138541. /**
  138542. * Load into a scene.
  138543. * @param scene The scene to load into
  138544. * @param data The data to import
  138545. * @param rootUrl The root url for scene and resources
  138546. * @param onError The callback when import fails
  138547. * @returns True if successful or false otherwise
  138548. */
  138549. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  138550. /**
  138551. * Load into an asset container.
  138552. * @param scene The scene to load into
  138553. * @param data The data to import
  138554. * @param rootUrl The root url for scene and resources
  138555. * @param onError The callback when import fails
  138556. * @returns The loaded asset container
  138557. */
  138558. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  138559. }
  138560. /**
  138561. * Interface used to define an async SceneLoader plugin
  138562. */
  138563. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  138564. /**
  138565. * Import meshes into a scene.
  138566. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138567. * @param scene The scene to import into
  138568. * @param data The data to import
  138569. * @param rootUrl The root url for scene and resources
  138570. * @param onProgress The callback when the load progresses
  138571. * @param fileName Defines the name of the file to load
  138572. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  138573. */
  138574. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  138575. /**
  138576. * Load into a scene.
  138577. * @param scene The scene to load into
  138578. * @param data The data to import
  138579. * @param rootUrl The root url for scene and resources
  138580. * @param onProgress The callback when the load progresses
  138581. * @param fileName Defines the name of the file to load
  138582. * @returns Nothing
  138583. */
  138584. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  138585. /**
  138586. * Load into an asset container.
  138587. * @param scene The scene to load into
  138588. * @param data The data to import
  138589. * @param rootUrl The root url for scene and resources
  138590. * @param onProgress The callback when the load progresses
  138591. * @param fileName Defines the name of the file to load
  138592. * @returns The loaded asset container
  138593. */
  138594. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  138595. }
  138596. /**
  138597. * Mode that determines how to handle old animation groups before loading new ones.
  138598. */
  138599. export enum SceneLoaderAnimationGroupLoadingMode {
  138600. /**
  138601. * Reset all old animations to initial state then dispose them.
  138602. */
  138603. Clean = 0,
  138604. /**
  138605. * Stop all old animations.
  138606. */
  138607. Stop = 1,
  138608. /**
  138609. * Restart old animations from first frame.
  138610. */
  138611. Sync = 2,
  138612. /**
  138613. * Old animations remains untouched.
  138614. */
  138615. NoSync = 3
  138616. }
  138617. /**
  138618. * Defines a plugin registered by the SceneLoader
  138619. */
  138620. interface IRegisteredPlugin {
  138621. /**
  138622. * Defines the plugin to use
  138623. */
  138624. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  138625. /**
  138626. * Defines if the plugin supports binary data
  138627. */
  138628. isBinary: boolean;
  138629. }
  138630. /**
  138631. * Class used to load scene from various file formats using registered plugins
  138632. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  138633. */
  138634. export class SceneLoader {
  138635. /**
  138636. * No logging while loading
  138637. */
  138638. static readonly NO_LOGGING: number;
  138639. /**
  138640. * Minimal logging while loading
  138641. */
  138642. static readonly MINIMAL_LOGGING: number;
  138643. /**
  138644. * Summary logging while loading
  138645. */
  138646. static readonly SUMMARY_LOGGING: number;
  138647. /**
  138648. * Detailled logging while loading
  138649. */
  138650. static readonly DETAILED_LOGGING: number;
  138651. /**
  138652. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  138653. */
  138654. static get ForceFullSceneLoadingForIncremental(): boolean;
  138655. static set ForceFullSceneLoadingForIncremental(value: boolean);
  138656. /**
  138657. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  138658. */
  138659. static get ShowLoadingScreen(): boolean;
  138660. static set ShowLoadingScreen(value: boolean);
  138661. /**
  138662. * Defines the current logging level (while loading the scene)
  138663. * @ignorenaming
  138664. */
  138665. static get loggingLevel(): number;
  138666. static set loggingLevel(value: number);
  138667. /**
  138668. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  138669. */
  138670. static get CleanBoneMatrixWeights(): boolean;
  138671. static set CleanBoneMatrixWeights(value: boolean);
  138672. /**
  138673. * Event raised when a plugin is used to load a scene
  138674. */
  138675. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  138676. private static _registeredPlugins;
  138677. private static _showingLoadingScreen;
  138678. /**
  138679. * Gets the default plugin (used to load Babylon files)
  138680. * @returns the .babylon plugin
  138681. */
  138682. static GetDefaultPlugin(): IRegisteredPlugin;
  138683. private static _GetPluginForExtension;
  138684. private static _GetPluginForDirectLoad;
  138685. private static _GetPluginForFilename;
  138686. private static _GetDirectLoad;
  138687. private static _LoadData;
  138688. private static _GetFileInfo;
  138689. /**
  138690. * Gets a plugin that can load the given extension
  138691. * @param extension defines the extension to load
  138692. * @returns a plugin or null if none works
  138693. */
  138694. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  138695. /**
  138696. * Gets a boolean indicating that the given extension can be loaded
  138697. * @param extension defines the extension to load
  138698. * @returns true if the extension is supported
  138699. */
  138700. static IsPluginForExtensionAvailable(extension: string): boolean;
  138701. /**
  138702. * Adds a new plugin to the list of registered plugins
  138703. * @param plugin defines the plugin to add
  138704. */
  138705. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  138706. /**
  138707. * Import meshes into a scene
  138708. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138709. * @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)
  138710. * @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)
  138711. * @param scene the instance of BABYLON.Scene to append to
  138712. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  138713. * @param onProgress a callback with a progress event for each file being loaded
  138714. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138715. * @param pluginExtension the extension used to determine the plugin
  138716. * @returns The loaded plugin
  138717. */
  138718. 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>;
  138719. /**
  138720. * Import meshes into a scene
  138721. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138722. * @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)
  138723. * @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)
  138724. * @param scene the instance of BABYLON.Scene to append to
  138725. * @param onProgress a callback with a progress event for each file being loaded
  138726. * @param pluginExtension the extension used to determine the plugin
  138727. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  138728. */
  138729. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  138730. /**
  138731. * Load a scene
  138732. * @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)
  138733. * @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)
  138734. * @param engine is the instance of BABYLON.Engine to use to create the scene
  138735. * @param onSuccess a callback with the scene when import succeeds
  138736. * @param onProgress a callback with a progress event for each file being loaded
  138737. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138738. * @param pluginExtension the extension used to determine the plugin
  138739. * @returns The loaded plugin
  138740. */
  138741. 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>;
  138742. /**
  138743. * Load a scene
  138744. * @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)
  138745. * @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)
  138746. * @param engine is the instance of BABYLON.Engine to use to create the scene
  138747. * @param onProgress a callback with a progress event for each file being loaded
  138748. * @param pluginExtension the extension used to determine the plugin
  138749. * @returns The loaded scene
  138750. */
  138751. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  138752. /**
  138753. * Append a scene
  138754. * @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)
  138755. * @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)
  138756. * @param scene is the instance of BABYLON.Scene to append to
  138757. * @param onSuccess a callback with the scene when import succeeds
  138758. * @param onProgress a callback with a progress event for each file being loaded
  138759. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138760. * @param pluginExtension the extension used to determine the plugin
  138761. * @returns The loaded plugin
  138762. */
  138763. 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>;
  138764. /**
  138765. * Append a scene
  138766. * @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)
  138767. * @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)
  138768. * @param scene is the instance of BABYLON.Scene to append to
  138769. * @param onProgress a callback with a progress event for each file being loaded
  138770. * @param pluginExtension the extension used to determine the plugin
  138771. * @returns The given scene
  138772. */
  138773. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  138774. /**
  138775. * Load a scene into an asset container
  138776. * @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)
  138777. * @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)
  138778. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  138779. * @param onSuccess a callback with the scene when import succeeds
  138780. * @param onProgress a callback with a progress event for each file being loaded
  138781. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138782. * @param pluginExtension the extension used to determine the plugin
  138783. * @returns The loaded plugin
  138784. */
  138785. 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>;
  138786. /**
  138787. * Load a scene into an asset container
  138788. * @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)
  138789. * @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)
  138790. * @param scene is the instance of Scene to append to
  138791. * @param onProgress a callback with a progress event for each file being loaded
  138792. * @param pluginExtension the extension used to determine the plugin
  138793. * @returns The loaded asset container
  138794. */
  138795. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  138796. /**
  138797. * Import animations from a file into a scene
  138798. * @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)
  138799. * @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)
  138800. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  138801. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  138802. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  138803. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  138804. * @param onSuccess a callback with the scene when import succeeds
  138805. * @param onProgress a callback with a progress event for each file being loaded
  138806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138807. * @param pluginExtension the extension used to determine the plugin
  138808. */
  138809. 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;
  138810. /**
  138811. * Import animations from a file into a scene
  138812. * @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)
  138813. * @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)
  138814. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  138815. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  138816. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  138817. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  138818. * @param onSuccess a callback with the scene when import succeeds
  138819. * @param onProgress a callback with a progress event for each file being loaded
  138820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138821. * @param pluginExtension the extension used to determine the plugin
  138822. * @returns the updated scene with imported animations
  138823. */
  138824. 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>;
  138825. }
  138826. }
  138827. declare module BABYLON {
  138828. /**
  138829. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  138830. */
  138831. export type MotionControllerHandedness = "none" | "left" | "right";
  138832. /**
  138833. * The type of components available in motion controllers.
  138834. * This is not the name of the component.
  138835. */
  138836. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  138837. /**
  138838. * The state of a controller component
  138839. */
  138840. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  138841. /**
  138842. * The schema of motion controller layout.
  138843. * No object will be initialized using this interface
  138844. * This is used just to define the profile.
  138845. */
  138846. export interface IMotionControllerLayout {
  138847. /**
  138848. * Path to load the assets. Usually relative to the base path
  138849. */
  138850. assetPath: string;
  138851. /**
  138852. * Available components (unsorted)
  138853. */
  138854. components: {
  138855. /**
  138856. * A map of component Ids
  138857. */
  138858. [componentId: string]: {
  138859. /**
  138860. * The type of input the component outputs
  138861. */
  138862. type: MotionControllerComponentType;
  138863. /**
  138864. * The indices of this component in the gamepad object
  138865. */
  138866. gamepadIndices: {
  138867. /**
  138868. * Index of button
  138869. */
  138870. button?: number;
  138871. /**
  138872. * If available, index of x-axis
  138873. */
  138874. xAxis?: number;
  138875. /**
  138876. * If available, index of y-axis
  138877. */
  138878. yAxis?: number;
  138879. };
  138880. /**
  138881. * The mesh's root node name
  138882. */
  138883. rootNodeName: string;
  138884. /**
  138885. * Animation definitions for this model
  138886. */
  138887. visualResponses: {
  138888. [stateKey: string]: {
  138889. /**
  138890. * What property will be animated
  138891. */
  138892. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  138893. /**
  138894. * What states influence this visual response
  138895. */
  138896. states: MotionControllerComponentStateType[];
  138897. /**
  138898. * Type of animation - movement or visibility
  138899. */
  138900. valueNodeProperty: "transform" | "visibility";
  138901. /**
  138902. * Base node name to move. Its position will be calculated according to the min and max nodes
  138903. */
  138904. valueNodeName?: string;
  138905. /**
  138906. * Minimum movement node
  138907. */
  138908. minNodeName?: string;
  138909. /**
  138910. * Max movement node
  138911. */
  138912. maxNodeName?: string;
  138913. };
  138914. };
  138915. /**
  138916. * If touch enabled, what is the name of node to display user feedback
  138917. */
  138918. touchPointNodeName?: string;
  138919. };
  138920. };
  138921. /**
  138922. * Is it xr standard mapping or not
  138923. */
  138924. gamepadMapping: "" | "xr-standard";
  138925. /**
  138926. * Base root node of this entire model
  138927. */
  138928. rootNodeName: string;
  138929. /**
  138930. * Defines the main button component id
  138931. */
  138932. selectComponentId: string;
  138933. }
  138934. /**
  138935. * A definition for the layout map in the input profile
  138936. */
  138937. export interface IMotionControllerLayoutMap {
  138938. /**
  138939. * Layouts with handedness type as a key
  138940. */
  138941. [handedness: string]: IMotionControllerLayout;
  138942. }
  138943. /**
  138944. * The XR Input profile schema
  138945. * Profiles can be found here:
  138946. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  138947. */
  138948. export interface IMotionControllerProfile {
  138949. /**
  138950. * fallback profiles for this profileId
  138951. */
  138952. fallbackProfileIds: string[];
  138953. /**
  138954. * The layout map, with handedness as key
  138955. */
  138956. layouts: IMotionControllerLayoutMap;
  138957. /**
  138958. * The id of this profile
  138959. * correlates to the profile(s) in the xrInput.profiles array
  138960. */
  138961. profileId: string;
  138962. }
  138963. /**
  138964. * A helper-interface for the 3 meshes needed for controller button animation
  138965. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  138966. */
  138967. export interface IMotionControllerButtonMeshMap {
  138968. /**
  138969. * the mesh that defines the pressed value mesh position.
  138970. * This is used to find the max-position of this button
  138971. */
  138972. pressedMesh: AbstractMesh;
  138973. /**
  138974. * the mesh that defines the unpressed value mesh position.
  138975. * This is used to find the min (or initial) position of this button
  138976. */
  138977. unpressedMesh: AbstractMesh;
  138978. /**
  138979. * The mesh that will be changed when value changes
  138980. */
  138981. valueMesh: AbstractMesh;
  138982. }
  138983. /**
  138984. * A helper-interface for the 3 meshes needed for controller axis animation.
  138985. * This will be expanded when touchpad animations are fully supported
  138986. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  138987. */
  138988. export interface IMotionControllerMeshMap {
  138989. /**
  138990. * the mesh that defines the maximum value mesh position.
  138991. */
  138992. maxMesh?: AbstractMesh;
  138993. /**
  138994. * the mesh that defines the minimum value mesh position.
  138995. */
  138996. minMesh?: AbstractMesh;
  138997. /**
  138998. * The mesh that will be changed when axis value changes
  138999. */
  139000. valueMesh?: AbstractMesh;
  139001. }
  139002. /**
  139003. * The elements needed for change-detection of the gamepad objects in motion controllers
  139004. */
  139005. export interface IMinimalMotionControllerObject {
  139006. /**
  139007. * Available axes of this controller
  139008. */
  139009. axes: number[];
  139010. /**
  139011. * An array of available buttons
  139012. */
  139013. buttons: Array<{
  139014. /**
  139015. * Value of the button/trigger
  139016. */
  139017. value: number;
  139018. /**
  139019. * If the button/trigger is currently touched
  139020. */
  139021. touched: boolean;
  139022. /**
  139023. * If the button/trigger is currently pressed
  139024. */
  139025. pressed: boolean;
  139026. }>;
  139027. /**
  139028. * EXPERIMENTAL haptic support.
  139029. */
  139030. hapticActuators?: Array<{
  139031. pulse: (value: number, duration: number) => Promise<boolean>;
  139032. }>;
  139033. }
  139034. /**
  139035. * An Abstract Motion controller
  139036. * This class receives an xrInput and a profile layout and uses those to initialize the components
  139037. * Each component has an observable to check for changes in value and state
  139038. */
  139039. export abstract class WebXRAbstractMotionController implements IDisposable {
  139040. protected scene: Scene;
  139041. protected layout: IMotionControllerLayout;
  139042. /**
  139043. * The gamepad object correlating to this controller
  139044. */
  139045. gamepadObject: IMinimalMotionControllerObject;
  139046. /**
  139047. * handedness (left/right/none) of this controller
  139048. */
  139049. handedness: MotionControllerHandedness;
  139050. private _initComponent;
  139051. private _modelReady;
  139052. /**
  139053. * A map of components (WebXRControllerComponent) in this motion controller
  139054. * Components have a ComponentType and can also have both button and axis definitions
  139055. */
  139056. readonly components: {
  139057. [id: string]: WebXRControllerComponent;
  139058. };
  139059. /**
  139060. * Disable the model's animation. Can be set at any time.
  139061. */
  139062. disableAnimation: boolean;
  139063. /**
  139064. * Observers registered here will be triggered when the model of this controller is done loading
  139065. */
  139066. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  139067. /**
  139068. * The profile id of this motion controller
  139069. */
  139070. abstract profileId: string;
  139071. /**
  139072. * The root mesh of the model. It is null if the model was not yet initialized
  139073. */
  139074. rootMesh: Nullable<AbstractMesh>;
  139075. /**
  139076. * constructs a new abstract motion controller
  139077. * @param scene the scene to which the model of the controller will be added
  139078. * @param layout The profile layout to load
  139079. * @param gamepadObject The gamepad object correlating to this controller
  139080. * @param handedness handedness (left/right/none) of this controller
  139081. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  139082. */
  139083. constructor(scene: Scene, layout: IMotionControllerLayout,
  139084. /**
  139085. * The gamepad object correlating to this controller
  139086. */
  139087. gamepadObject: IMinimalMotionControllerObject,
  139088. /**
  139089. * handedness (left/right/none) of this controller
  139090. */
  139091. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  139092. /**
  139093. * Dispose this controller, the model mesh and all its components
  139094. */
  139095. dispose(): void;
  139096. /**
  139097. * Returns all components of specific type
  139098. * @param type the type to search for
  139099. * @return an array of components with this type
  139100. */
  139101. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  139102. /**
  139103. * get a component based an its component id as defined in layout.components
  139104. * @param id the id of the component
  139105. * @returns the component correlates to the id or undefined if not found
  139106. */
  139107. getComponent(id: string): WebXRControllerComponent;
  139108. /**
  139109. * Get the list of components available in this motion controller
  139110. * @returns an array of strings correlating to available components
  139111. */
  139112. getComponentIds(): string[];
  139113. /**
  139114. * Get the first component of specific type
  139115. * @param type type of component to find
  139116. * @return a controller component or null if not found
  139117. */
  139118. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  139119. /**
  139120. * Get the main (Select) component of this controller as defined in the layout
  139121. * @returns the main component of this controller
  139122. */
  139123. getMainComponent(): WebXRControllerComponent;
  139124. /**
  139125. * Loads the model correlating to this controller
  139126. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  139127. * @returns A promise fulfilled with the result of the model loading
  139128. */
  139129. loadModel(): Promise<boolean>;
  139130. /**
  139131. * Update this model using the current XRFrame
  139132. * @param xrFrame the current xr frame to use and update the model
  139133. */
  139134. updateFromXRFrame(xrFrame: XRFrame): void;
  139135. /**
  139136. * Backwards compatibility due to a deeply-integrated typo
  139137. */
  139138. get handness(): XREye;
  139139. /**
  139140. * Pulse (vibrate) this controller
  139141. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  139142. * Consecutive calls to this function will cancel the last pulse call
  139143. *
  139144. * @param value the strength of the pulse in 0.0...1.0 range
  139145. * @param duration Duration of the pulse in milliseconds
  139146. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  139147. * @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
  139148. */
  139149. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  139150. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  139151. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  139152. /**
  139153. * Moves the axis on the controller mesh based on its current state
  139154. * @param axis the index of the axis
  139155. * @param axisValue the value of the axis which determines the meshes new position
  139156. * @hidden
  139157. */
  139158. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  139159. /**
  139160. * Update the model itself with the current frame data
  139161. * @param xrFrame the frame to use for updating the model mesh
  139162. */
  139163. protected updateModel(xrFrame: XRFrame): void;
  139164. /**
  139165. * Get the filename and path for this controller's model
  139166. * @returns a map of filename and path
  139167. */
  139168. protected abstract _getFilenameAndPath(): {
  139169. filename: string;
  139170. path: string;
  139171. };
  139172. /**
  139173. * This function is called before the mesh is loaded. It checks for loading constraints.
  139174. * For example, this function can check if the GLB loader is available
  139175. * If this function returns false, the generic controller will be loaded instead
  139176. * @returns Is the client ready to load the mesh
  139177. */
  139178. protected abstract _getModelLoadingConstraints(): boolean;
  139179. /**
  139180. * This function will be called after the model was successfully loaded and can be used
  139181. * for mesh transformations before it is available for the user
  139182. * @param meshes the loaded meshes
  139183. */
  139184. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  139185. /**
  139186. * Set the root mesh for this controller. Important for the WebXR controller class
  139187. * @param meshes the loaded meshes
  139188. */
  139189. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  139190. /**
  139191. * A function executed each frame that updates the mesh (if needed)
  139192. * @param xrFrame the current xrFrame
  139193. */
  139194. protected abstract _updateModel(xrFrame: XRFrame): void;
  139195. private _getGenericFilenameAndPath;
  139196. private _getGenericParentMesh;
  139197. }
  139198. }
  139199. declare module BABYLON {
  139200. /**
  139201. * A generic trigger-only motion controller for WebXR
  139202. */
  139203. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  139204. /**
  139205. * Static version of the profile id of this controller
  139206. */
  139207. static ProfileId: string;
  139208. profileId: string;
  139209. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  139210. protected _getFilenameAndPath(): {
  139211. filename: string;
  139212. path: string;
  139213. };
  139214. protected _getModelLoadingConstraints(): boolean;
  139215. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  139216. protected _setRootMesh(meshes: AbstractMesh[]): void;
  139217. protected _updateModel(): void;
  139218. }
  139219. }
  139220. declare module BABYLON {
  139221. /**
  139222. * Class containing static functions to help procedurally build meshes
  139223. */
  139224. export class SphereBuilder {
  139225. /**
  139226. * Creates a sphere mesh
  139227. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139228. * * 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`)
  139229. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139230. * * 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
  139231. * * 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)
  139232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139233. * * 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
  139234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139235. * @param name defines the name of the mesh
  139236. * @param options defines the options used to create the mesh
  139237. * @param scene defines the hosting scene
  139238. * @returns the sphere mesh
  139239. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139240. */
  139241. static CreateSphere(name: string, options: {
  139242. segments?: number;
  139243. diameter?: number;
  139244. diameterX?: number;
  139245. diameterY?: number;
  139246. diameterZ?: number;
  139247. arc?: number;
  139248. slice?: number;
  139249. sideOrientation?: number;
  139250. frontUVs?: Vector4;
  139251. backUVs?: Vector4;
  139252. updatable?: boolean;
  139253. }, scene?: Nullable<Scene>): Mesh;
  139254. }
  139255. }
  139256. declare module BABYLON {
  139257. /**
  139258. * A profiled motion controller has its profile loaded from an online repository.
  139259. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  139260. */
  139261. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  139262. private _repositoryUrl;
  139263. private _buttonMeshMapping;
  139264. private _touchDots;
  139265. /**
  139266. * The profile ID of this controller. Will be populated when the controller initializes.
  139267. */
  139268. profileId: string;
  139269. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  139270. dispose(): void;
  139271. protected _getFilenameAndPath(): {
  139272. filename: string;
  139273. path: string;
  139274. };
  139275. protected _getModelLoadingConstraints(): boolean;
  139276. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  139277. protected _setRootMesh(meshes: AbstractMesh[]): void;
  139278. protected _updateModel(_xrFrame: XRFrame): void;
  139279. }
  139280. }
  139281. declare module BABYLON {
  139282. /**
  139283. * A construction function type to create a new controller based on an xrInput object
  139284. */
  139285. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  139286. /**
  139287. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  139288. *
  139289. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  139290. * it should be replaced with auto-loaded controllers.
  139291. *
  139292. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  139293. */
  139294. export class WebXRMotionControllerManager {
  139295. private static _AvailableControllers;
  139296. private static _Fallbacks;
  139297. private static _ProfileLoadingPromises;
  139298. private static _ProfilesList;
  139299. /**
  139300. * The base URL of the online controller repository. Can be changed at any time.
  139301. */
  139302. static BaseRepositoryUrl: string;
  139303. /**
  139304. * Which repository gets priority - local or online
  139305. */
  139306. static PrioritizeOnlineRepository: boolean;
  139307. /**
  139308. * Use the online repository, or use only locally-defined controllers
  139309. */
  139310. static UseOnlineRepository: boolean;
  139311. /**
  139312. * Clear the cache used for profile loading and reload when requested again
  139313. */
  139314. static ClearProfilesCache(): void;
  139315. /**
  139316. * Register the default fallbacks.
  139317. * This function is called automatically when this file is imported.
  139318. */
  139319. static DefaultFallbacks(): void;
  139320. /**
  139321. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  139322. * @param profileId the profile to which a fallback needs to be found
  139323. * @return an array with corresponding fallback profiles
  139324. */
  139325. static FindFallbackWithProfileId(profileId: string): string[];
  139326. /**
  139327. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  139328. * The order of search:
  139329. *
  139330. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  139331. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  139332. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  139333. * 4) return the generic trigger controller if none were found
  139334. *
  139335. * @param xrInput the xrInput to which a new controller is initialized
  139336. * @param scene the scene to which the model will be added
  139337. * @param forceProfile force a certain profile for this controller
  139338. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  139339. */
  139340. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  139341. /**
  139342. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  139343. *
  139344. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  139345. *
  139346. * @param type the profile type to register
  139347. * @param constructFunction the function to be called when loading this profile
  139348. */
  139349. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  139350. /**
  139351. * Register a fallback to a specific profile.
  139352. * @param profileId the profileId that will receive the fallbacks
  139353. * @param fallbacks A list of fallback profiles
  139354. */
  139355. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  139356. /**
  139357. * Will update the list of profiles available in the repository
  139358. * @return a promise that resolves to a map of profiles available online
  139359. */
  139360. static UpdateProfilesList(): Promise<{
  139361. [profile: string]: string;
  139362. }>;
  139363. private static _LoadProfileFromRepository;
  139364. private static _LoadProfilesFromAvailableControllers;
  139365. }
  139366. }
  139367. declare module BABYLON {
  139368. /**
  139369. * Configuration options for the WebXR controller creation
  139370. */
  139371. export interface IWebXRControllerOptions {
  139372. /**
  139373. * Should the controller mesh be animated when a user interacts with it
  139374. * The pressed buttons / thumbstick and touchpad animations will be disabled
  139375. */
  139376. disableMotionControllerAnimation?: boolean;
  139377. /**
  139378. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  139379. */
  139380. doNotLoadControllerMesh?: boolean;
  139381. /**
  139382. * Force a specific controller type for this controller.
  139383. * This can be used when creating your own profile or when testing different controllers
  139384. */
  139385. forceControllerProfile?: string;
  139386. /**
  139387. * Defines a rendering group ID for meshes that will be loaded.
  139388. * This is for the default controllers only.
  139389. */
  139390. renderingGroupId?: number;
  139391. }
  139392. /**
  139393. * Represents an XR controller
  139394. */
  139395. export class WebXRInputSource {
  139396. private _scene;
  139397. /** The underlying input source for the controller */
  139398. inputSource: XRInputSource;
  139399. private _options;
  139400. private _tmpVector;
  139401. private _uniqueId;
  139402. private _disposed;
  139403. /**
  139404. * 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
  139405. */
  139406. grip?: AbstractMesh;
  139407. /**
  139408. * If available, this is the gamepad object related to this controller.
  139409. * Using this object it is possible to get click events and trackpad changes of the
  139410. * webxr controller that is currently being used.
  139411. */
  139412. motionController?: WebXRAbstractMotionController;
  139413. /**
  139414. * Event that fires when the controller is removed/disposed.
  139415. * The object provided as event data is this controller, after associated assets were disposed.
  139416. * uniqueId is still available.
  139417. */
  139418. onDisposeObservable: Observable<WebXRInputSource>;
  139419. /**
  139420. * Will be triggered when the mesh associated with the motion controller is done loading.
  139421. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  139422. * A shortened version of controller -> motion controller -> on mesh loaded.
  139423. */
  139424. onMeshLoadedObservable: Observable<AbstractMesh>;
  139425. /**
  139426. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  139427. */
  139428. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  139429. /**
  139430. * Pointer which can be used to select objects or attach a visible laser to
  139431. */
  139432. pointer: AbstractMesh;
  139433. /**
  139434. * Creates the input source object
  139435. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  139436. * @param _scene the scene which the controller should be associated to
  139437. * @param inputSource the underlying input source for the controller
  139438. * @param _options options for this controller creation
  139439. */
  139440. constructor(_scene: Scene,
  139441. /** The underlying input source for the controller */
  139442. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  139443. /**
  139444. * Get this controllers unique id
  139445. */
  139446. get uniqueId(): string;
  139447. /**
  139448. * Disposes of the object
  139449. */
  139450. dispose(): void;
  139451. /**
  139452. * Gets a world space ray coming from the pointer or grip
  139453. * @param result the resulting ray
  139454. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  139455. */
  139456. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  139457. /**
  139458. * Updates the controller pose based on the given XRFrame
  139459. * @param xrFrame xr frame to update the pose with
  139460. * @param referenceSpace reference space to use
  139461. */
  139462. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  139463. }
  139464. }
  139465. declare module BABYLON {
  139466. /**
  139467. * The schema for initialization options of the XR Input class
  139468. */
  139469. export interface IWebXRInputOptions {
  139470. /**
  139471. * If set to true no model will be automatically loaded
  139472. */
  139473. doNotLoadControllerMeshes?: boolean;
  139474. /**
  139475. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  139476. * If not found, the xr input profile data will be used.
  139477. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  139478. */
  139479. forceInputProfile?: string;
  139480. /**
  139481. * Do not send a request to the controller repository to load the profile.
  139482. *
  139483. * Instead, use the controllers available in babylon itself.
  139484. */
  139485. disableOnlineControllerRepository?: boolean;
  139486. /**
  139487. * A custom URL for the controllers repository
  139488. */
  139489. customControllersRepositoryURL?: string;
  139490. /**
  139491. * Should the controller model's components not move according to the user input
  139492. */
  139493. disableControllerAnimation?: boolean;
  139494. /**
  139495. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  139496. */
  139497. controllerOptions?: IWebXRControllerOptions;
  139498. }
  139499. /**
  139500. * XR input used to track XR inputs such as controllers/rays
  139501. */
  139502. export class WebXRInput implements IDisposable {
  139503. /**
  139504. * the xr session manager for this session
  139505. */
  139506. xrSessionManager: WebXRSessionManager;
  139507. /**
  139508. * the WebXR camera for this session. Mainly used for teleportation
  139509. */
  139510. xrCamera: WebXRCamera;
  139511. private readonly options;
  139512. /**
  139513. * XR controllers being tracked
  139514. */
  139515. controllers: Array<WebXRInputSource>;
  139516. private _frameObserver;
  139517. private _sessionEndedObserver;
  139518. private _sessionInitObserver;
  139519. /**
  139520. * Event when a controller has been connected/added
  139521. */
  139522. onControllerAddedObservable: Observable<WebXRInputSource>;
  139523. /**
  139524. * Event when a controller has been removed/disconnected
  139525. */
  139526. onControllerRemovedObservable: Observable<WebXRInputSource>;
  139527. /**
  139528. * Initializes the WebXRInput
  139529. * @param xrSessionManager the xr session manager for this session
  139530. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  139531. * @param options = initialization options for this xr input
  139532. */
  139533. constructor(
  139534. /**
  139535. * the xr session manager for this session
  139536. */
  139537. xrSessionManager: WebXRSessionManager,
  139538. /**
  139539. * the WebXR camera for this session. Mainly used for teleportation
  139540. */
  139541. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  139542. private _onInputSourcesChange;
  139543. private _addAndRemoveControllers;
  139544. /**
  139545. * Disposes of the object
  139546. */
  139547. dispose(): void;
  139548. }
  139549. }
  139550. declare module BABYLON {
  139551. /**
  139552. * This is the base class for all WebXR features.
  139553. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  139554. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  139555. */
  139556. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  139557. protected _xrSessionManager: WebXRSessionManager;
  139558. private _attached;
  139559. private _removeOnDetach;
  139560. /**
  139561. * Is this feature disposed?
  139562. */
  139563. isDisposed: boolean;
  139564. /**
  139565. * Should auto-attach be disabled?
  139566. */
  139567. disableAutoAttach: boolean;
  139568. /**
  139569. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  139570. */
  139571. xrNativeFeatureName: string;
  139572. /**
  139573. * Construct a new (abstract) WebXR feature
  139574. * @param _xrSessionManager the xr session manager for this feature
  139575. */
  139576. constructor(_xrSessionManager: WebXRSessionManager);
  139577. /**
  139578. * Is this feature attached
  139579. */
  139580. get attached(): boolean;
  139581. /**
  139582. * attach this feature
  139583. *
  139584. * @param force should attachment be forced (even when already attached)
  139585. * @returns true if successful, false is failed or already attached
  139586. */
  139587. attach(force?: boolean): boolean;
  139588. /**
  139589. * detach this feature.
  139590. *
  139591. * @returns true if successful, false if failed or already detached
  139592. */
  139593. detach(): boolean;
  139594. /**
  139595. * Dispose this feature and all of the resources attached
  139596. */
  139597. dispose(): void;
  139598. /**
  139599. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  139600. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  139601. *
  139602. * @returns whether or not the feature is compatible in this environment
  139603. */
  139604. isCompatible(): boolean;
  139605. /**
  139606. * This is used to register callbacks that will automatically be removed when detach is called.
  139607. * @param observable the observable to which the observer will be attached
  139608. * @param callback the callback to register
  139609. */
  139610. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  139611. /**
  139612. * Code in this function will be executed on each xrFrame received from the browser.
  139613. * This function will not execute after the feature is detached.
  139614. * @param _xrFrame the current frame
  139615. */
  139616. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  139617. }
  139618. }
  139619. declare module BABYLON {
  139620. /**
  139621. * Renders a layer on top of an existing scene
  139622. */
  139623. export class UtilityLayerRenderer implements IDisposable {
  139624. /** the original scene that will be rendered on top of */
  139625. originalScene: Scene;
  139626. private _pointerCaptures;
  139627. private _lastPointerEvents;
  139628. private static _DefaultUtilityLayer;
  139629. private static _DefaultKeepDepthUtilityLayer;
  139630. private _sharedGizmoLight;
  139631. private _renderCamera;
  139632. /**
  139633. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  139634. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  139635. * @returns the camera that is used when rendering the utility layer
  139636. */
  139637. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  139638. /**
  139639. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  139640. * @param cam the camera that should be used when rendering the utility layer
  139641. */
  139642. setRenderCamera(cam: Nullable<Camera>): void;
  139643. /**
  139644. * @hidden
  139645. * Light which used by gizmos to get light shading
  139646. */
  139647. _getSharedGizmoLight(): HemisphericLight;
  139648. /**
  139649. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  139650. */
  139651. pickUtilitySceneFirst: boolean;
  139652. /**
  139653. * 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)
  139654. */
  139655. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  139656. /**
  139657. * 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)
  139658. */
  139659. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  139660. /**
  139661. * The scene that is rendered on top of the original scene
  139662. */
  139663. utilityLayerScene: Scene;
  139664. /**
  139665. * If the utility layer should automatically be rendered on top of existing scene
  139666. */
  139667. shouldRender: boolean;
  139668. /**
  139669. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  139670. */
  139671. onlyCheckPointerDownEvents: boolean;
  139672. /**
  139673. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  139674. */
  139675. processAllEvents: boolean;
  139676. /**
  139677. * Observable raised when the pointer move from the utility layer scene to the main scene
  139678. */
  139679. onPointerOutObservable: Observable<number>;
  139680. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  139681. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  139682. private _afterRenderObserver;
  139683. private _sceneDisposeObserver;
  139684. private _originalPointerObserver;
  139685. /**
  139686. * Instantiates a UtilityLayerRenderer
  139687. * @param originalScene the original scene that will be rendered on top of
  139688. * @param handleEvents boolean indicating if the utility layer should handle events
  139689. */
  139690. constructor(
  139691. /** the original scene that will be rendered on top of */
  139692. originalScene: Scene, handleEvents?: boolean);
  139693. private _notifyObservers;
  139694. /**
  139695. * Renders the utility layers scene on top of the original scene
  139696. */
  139697. render(): void;
  139698. /**
  139699. * Disposes of the renderer
  139700. */
  139701. dispose(): void;
  139702. private _updateCamera;
  139703. }
  139704. }
  139705. declare module BABYLON {
  139706. /**
  139707. * Options interface for the pointer selection module
  139708. */
  139709. export interface IWebXRControllerPointerSelectionOptions {
  139710. /**
  139711. * if provided, this scene will be used to render meshes.
  139712. */
  139713. customUtilityLayerScene?: Scene;
  139714. /**
  139715. * 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)
  139716. * If not disabled, the last picked point will be used to execute a pointer up event
  139717. * If disabled, pointer up event will be triggered right after the pointer down event.
  139718. * Used in screen and gaze target ray mode only
  139719. */
  139720. disablePointerUpOnTouchOut: boolean;
  139721. /**
  139722. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  139723. */
  139724. forceGazeMode: boolean;
  139725. /**
  139726. * 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
  139727. * to start a new countdown to the pointer down event.
  139728. * Defaults to 1.
  139729. */
  139730. gazeModePointerMovedFactor?: number;
  139731. /**
  139732. * Different button type to use instead of the main component
  139733. */
  139734. overrideButtonId?: string;
  139735. /**
  139736. * use this rendering group id for the meshes (optional)
  139737. */
  139738. renderingGroupId?: number;
  139739. /**
  139740. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  139741. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  139742. * 3000 means 3 seconds between pointing at something and selecting it
  139743. */
  139744. timeToSelect?: number;
  139745. /**
  139746. * Should meshes created here be added to a utility layer or the main scene
  139747. */
  139748. useUtilityLayer?: boolean;
  139749. /**
  139750. * Optional WebXR camera to be used for gaze selection
  139751. */
  139752. gazeCamera?: WebXRCamera;
  139753. /**
  139754. * the xr input to use with this pointer selection
  139755. */
  139756. xrInput: WebXRInput;
  139757. /**
  139758. * Should the scene pointerX and pointerY update be disabled
  139759. * This is required for fullscreen AR GUI, but might slow down other experiences.
  139760. * Disable in VR, if not needed.
  139761. * The first rig camera (left eye) will be used to calculate the projection
  139762. */
  139763. disableScenePointerVectorUpdate: boolean;
  139764. /**
  139765. * Enable pointer selection on all controllers instead of switching between them
  139766. */
  139767. enablePointerSelectionOnAllControllers?: boolean;
  139768. /**
  139769. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  139770. * If switch is enabled, it will still allow the user to switch between the different controllers
  139771. */
  139772. preferredHandedness?: XRHandedness;
  139773. /**
  139774. * Disable switching the pointer selection from one controller to the other.
  139775. * 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
  139776. */
  139777. disableSwitchOnClick?: boolean;
  139778. /**
  139779. * The maximum distance of the pointer selection feature. Defaults to 100.
  139780. */
  139781. maxPointerDistance?: number;
  139782. }
  139783. /**
  139784. * A module that will enable pointer selection for motion controllers of XR Input Sources
  139785. */
  139786. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  139787. private readonly _options;
  139788. private static _idCounter;
  139789. private _attachController;
  139790. private _controllers;
  139791. private _scene;
  139792. private _tmpVectorForPickCompare;
  139793. private _attachedController;
  139794. /**
  139795. * The module's name
  139796. */
  139797. static readonly Name: string;
  139798. /**
  139799. * The (Babylon) version of this module.
  139800. * This is an integer representing the implementation version.
  139801. * This number does not correspond to the WebXR specs version
  139802. */
  139803. static readonly Version: number;
  139804. /**
  139805. * Disable lighting on the laser pointer (so it will always be visible)
  139806. */
  139807. disablePointerLighting: boolean;
  139808. /**
  139809. * Disable lighting on the selection mesh (so it will always be visible)
  139810. */
  139811. disableSelectionMeshLighting: boolean;
  139812. /**
  139813. * Should the laser pointer be displayed
  139814. */
  139815. displayLaserPointer: boolean;
  139816. /**
  139817. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  139818. */
  139819. displaySelectionMesh: boolean;
  139820. /**
  139821. * This color will be set to the laser pointer when selection is triggered
  139822. */
  139823. laserPointerPickedColor: Color3;
  139824. /**
  139825. * Default color of the laser pointer
  139826. */
  139827. laserPointerDefaultColor: Color3;
  139828. /**
  139829. * default color of the selection ring
  139830. */
  139831. selectionMeshDefaultColor: Color3;
  139832. /**
  139833. * This color will be applied to the selection ring when selection is triggered
  139834. */
  139835. selectionMeshPickedColor: Color3;
  139836. /**
  139837. * Optional filter to be used for ray selection. This predicate shares behavior with
  139838. * scene.pointerMovePredicate which takes priority if it is also assigned.
  139839. */
  139840. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  139841. /**
  139842. * constructs a new background remover module
  139843. * @param _xrSessionManager the session manager for this module
  139844. * @param _options read-only options to be used in this module
  139845. */
  139846. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  139847. /**
  139848. * attach this feature
  139849. * Will usually be called by the features manager
  139850. *
  139851. * @returns true if successful.
  139852. */
  139853. attach(): boolean;
  139854. /**
  139855. * detach this feature.
  139856. * Will usually be called by the features manager
  139857. *
  139858. * @returns true if successful.
  139859. */
  139860. detach(): boolean;
  139861. /**
  139862. * Will get the mesh under a specific pointer.
  139863. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  139864. * @param controllerId the controllerId to check
  139865. * @returns The mesh under pointer or null if no mesh is under the pointer
  139866. */
  139867. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  139868. /**
  139869. * Get the xr controller that correlates to the pointer id in the pointer event
  139870. *
  139871. * @param id the pointer id to search for
  139872. * @returns the controller that correlates to this id or null if not found
  139873. */
  139874. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  139875. private _identityMatrix;
  139876. private _screenCoordinatesRef;
  139877. private _viewportRef;
  139878. protected _onXRFrame(_xrFrame: XRFrame): void;
  139879. private _attachGazeMode;
  139880. private _attachScreenRayMode;
  139881. private _attachTrackedPointerRayMode;
  139882. private _convertNormalToDirectionOfRay;
  139883. private _detachController;
  139884. private _generateNewMeshPair;
  139885. private _pickingMoved;
  139886. private _updatePointerDistance;
  139887. /** @hidden */
  139888. get lasterPointerDefaultColor(): Color3;
  139889. }
  139890. }
  139891. declare module BABYLON {
  139892. /**
  139893. * Button which can be used to enter a different mode of XR
  139894. */
  139895. export class WebXREnterExitUIButton {
  139896. /** button element */
  139897. element: HTMLElement;
  139898. /** XR initialization options for the button */
  139899. sessionMode: XRSessionMode;
  139900. /** Reference space type */
  139901. referenceSpaceType: XRReferenceSpaceType;
  139902. /**
  139903. * Creates a WebXREnterExitUIButton
  139904. * @param element button element
  139905. * @param sessionMode XR initialization session mode
  139906. * @param referenceSpaceType the type of reference space to be used
  139907. */
  139908. constructor(
  139909. /** button element */
  139910. element: HTMLElement,
  139911. /** XR initialization options for the button */
  139912. sessionMode: XRSessionMode,
  139913. /** Reference space type */
  139914. referenceSpaceType: XRReferenceSpaceType);
  139915. /**
  139916. * Extendable function which can be used to update the button's visuals when the state changes
  139917. * @param activeButton the current active button in the UI
  139918. */
  139919. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  139920. }
  139921. /**
  139922. * Options to create the webXR UI
  139923. */
  139924. export class WebXREnterExitUIOptions {
  139925. /**
  139926. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  139927. */
  139928. customButtons?: Array<WebXREnterExitUIButton>;
  139929. /**
  139930. * A reference space type to use when creating the default button.
  139931. * Default is local-floor
  139932. */
  139933. referenceSpaceType?: XRReferenceSpaceType;
  139934. /**
  139935. * Context to enter xr with
  139936. */
  139937. renderTarget?: Nullable<WebXRRenderTarget>;
  139938. /**
  139939. * A session mode to use when creating the default button.
  139940. * Default is immersive-vr
  139941. */
  139942. sessionMode?: XRSessionMode;
  139943. /**
  139944. * A list of optional features to init the session with
  139945. */
  139946. optionalFeatures?: string[];
  139947. /**
  139948. * A list of optional features to init the session with
  139949. */
  139950. requiredFeatures?: string[];
  139951. /**
  139952. * If defined, this function will be executed if the UI encounters an error when entering XR
  139953. */
  139954. onError?: (error: any) => void;
  139955. }
  139956. /**
  139957. * UI to allow the user to enter/exit XR mode
  139958. */
  139959. export class WebXREnterExitUI implements IDisposable {
  139960. private scene;
  139961. /** version of the options passed to this UI */
  139962. options: WebXREnterExitUIOptions;
  139963. private _activeButton;
  139964. private _buttons;
  139965. /**
  139966. * The HTML Div Element to which buttons are added.
  139967. */
  139968. readonly overlay: HTMLDivElement;
  139969. /**
  139970. * Fired every time the active button is changed.
  139971. *
  139972. * When xr is entered via a button that launches xr that button will be the callback parameter
  139973. *
  139974. * When exiting xr the callback parameter will be null)
  139975. */
  139976. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  139977. /**
  139978. *
  139979. * @param scene babylon scene object to use
  139980. * @param options (read-only) version of the options passed to this UI
  139981. */
  139982. private constructor();
  139983. /**
  139984. * Creates UI to allow the user to enter/exit XR mode
  139985. * @param scene the scene to add the ui to
  139986. * @param helper the xr experience helper to enter/exit xr with
  139987. * @param options options to configure the UI
  139988. * @returns the created ui
  139989. */
  139990. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  139991. /**
  139992. * Disposes of the XR UI component
  139993. */
  139994. dispose(): void;
  139995. private _updateButtons;
  139996. }
  139997. }
  139998. declare module BABYLON {
  139999. /**
  140000. * Class containing static functions to help procedurally build meshes
  140001. */
  140002. export class LinesBuilder {
  140003. /**
  140004. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  140005. * * 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
  140006. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  140007. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  140008. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  140009. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  140010. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140011. * * 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
  140012. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  140013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  140015. * @param name defines the name of the new line system
  140016. * @param options defines the options used to create the line system
  140017. * @param scene defines the hosting scene
  140018. * @returns a new line system mesh
  140019. */
  140020. static CreateLineSystem(name: string, options: {
  140021. lines: Vector3[][];
  140022. updatable?: boolean;
  140023. instance?: Nullable<LinesMesh>;
  140024. colors?: Nullable<Color4[][]>;
  140025. useVertexAlpha?: boolean;
  140026. }, scene: Nullable<Scene>): LinesMesh;
  140027. /**
  140028. * Creates a line mesh
  140029. * 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
  140030. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140031. * * The parameter `points` is an array successive Vector3
  140032. * * 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
  140033. * * The optional parameter `colors` is an array of successive Color4, one per line point
  140034. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  140035. * * When updating an instance, remember that only point positions can change, not the number of points
  140036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  140038. * @param name defines the name of the new line system
  140039. * @param options defines the options used to create the line system
  140040. * @param scene defines the hosting scene
  140041. * @returns a new line mesh
  140042. */
  140043. static CreateLines(name: string, options: {
  140044. points: Vector3[];
  140045. updatable?: boolean;
  140046. instance?: Nullable<LinesMesh>;
  140047. colors?: Color4[];
  140048. useVertexAlpha?: boolean;
  140049. }, scene?: Nullable<Scene>): LinesMesh;
  140050. /**
  140051. * Creates a dashed line mesh
  140052. * * 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
  140053. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140054. * * The parameter `points` is an array successive Vector3
  140055. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  140056. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  140057. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  140058. * * 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
  140059. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140060. * * When updating an instance, remember that only point positions can change, not the number of points
  140061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140062. * @param name defines the name of the mesh
  140063. * @param options defines the options used to create the mesh
  140064. * @param scene defines the hosting scene
  140065. * @returns the dashed line mesh
  140066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  140067. */
  140068. static CreateDashedLines(name: string, options: {
  140069. points: Vector3[];
  140070. dashSize?: number;
  140071. gapSize?: number;
  140072. dashNb?: number;
  140073. updatable?: boolean;
  140074. instance?: LinesMesh;
  140075. useVertexAlpha?: boolean;
  140076. }, scene?: Nullable<Scene>): LinesMesh;
  140077. }
  140078. }
  140079. declare module BABYLON {
  140080. /**
  140081. * Construction options for a timer
  140082. */
  140083. export interface ITimerOptions<T> {
  140084. /**
  140085. * Time-to-end
  140086. */
  140087. timeout: number;
  140088. /**
  140089. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  140090. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  140091. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  140092. */
  140093. contextObservable: Observable<T>;
  140094. /**
  140095. * Optional parameters when adding an observer to the observable
  140096. */
  140097. observableParameters?: {
  140098. mask?: number;
  140099. insertFirst?: boolean;
  140100. scope?: any;
  140101. };
  140102. /**
  140103. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  140104. */
  140105. breakCondition?: (data?: ITimerData<T>) => boolean;
  140106. /**
  140107. * Will be triggered when the time condition has met
  140108. */
  140109. onEnded?: (data: ITimerData<any>) => void;
  140110. /**
  140111. * Will be triggered when the break condition has met (prematurely ended)
  140112. */
  140113. onAborted?: (data: ITimerData<any>) => void;
  140114. /**
  140115. * Optional function to execute on each tick (or count)
  140116. */
  140117. onTick?: (data: ITimerData<any>) => void;
  140118. }
  140119. /**
  140120. * An interface defining the data sent by the timer
  140121. */
  140122. export interface ITimerData<T> {
  140123. /**
  140124. * When did it start
  140125. */
  140126. startTime: number;
  140127. /**
  140128. * Time now
  140129. */
  140130. currentTime: number;
  140131. /**
  140132. * Time passed since started
  140133. */
  140134. deltaTime: number;
  140135. /**
  140136. * How much is completed, in [0.0...1.0].
  140137. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  140138. */
  140139. completeRate: number;
  140140. /**
  140141. * What the registered observable sent in the last count
  140142. */
  140143. payload: T;
  140144. }
  140145. /**
  140146. * The current state of the timer
  140147. */
  140148. export enum TimerState {
  140149. /**
  140150. * Timer initialized, not yet started
  140151. */
  140152. INIT = 0,
  140153. /**
  140154. * Timer started and counting
  140155. */
  140156. STARTED = 1,
  140157. /**
  140158. * Timer ended (whether aborted or time reached)
  140159. */
  140160. ENDED = 2
  140161. }
  140162. /**
  140163. * A simple version of the timer. Will take options and start the timer immediately after calling it
  140164. *
  140165. * @param options options with which to initialize this timer
  140166. */
  140167. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  140168. /**
  140169. * An advanced implementation of a timer class
  140170. */
  140171. export class AdvancedTimer<T = any> implements IDisposable {
  140172. /**
  140173. * Will notify each time the timer calculates the remaining time
  140174. */
  140175. onEachCountObservable: Observable<ITimerData<T>>;
  140176. /**
  140177. * Will trigger when the timer was aborted due to the break condition
  140178. */
  140179. onTimerAbortedObservable: Observable<ITimerData<T>>;
  140180. /**
  140181. * Will trigger when the timer ended successfully
  140182. */
  140183. onTimerEndedObservable: Observable<ITimerData<T>>;
  140184. /**
  140185. * Will trigger when the timer state has changed
  140186. */
  140187. onStateChangedObservable: Observable<TimerState>;
  140188. private _observer;
  140189. private _contextObservable;
  140190. private _observableParameters;
  140191. private _startTime;
  140192. private _timer;
  140193. private _state;
  140194. private _breakCondition;
  140195. private _timeToEnd;
  140196. private _breakOnNextTick;
  140197. /**
  140198. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  140199. * @param options construction options for this advanced timer
  140200. */
  140201. constructor(options: ITimerOptions<T>);
  140202. /**
  140203. * set a breaking condition for this timer. Default is to never break during count
  140204. * @param predicate the new break condition. Returns true to break, false otherwise
  140205. */
  140206. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  140207. /**
  140208. * Reset ALL associated observables in this advanced timer
  140209. */
  140210. clearObservables(): void;
  140211. /**
  140212. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  140213. *
  140214. * @param timeToEnd how much time to measure until timer ended
  140215. */
  140216. start(timeToEnd?: number): void;
  140217. /**
  140218. * Will force a stop on the next tick.
  140219. */
  140220. stop(): void;
  140221. /**
  140222. * Dispose this timer, clearing all resources
  140223. */
  140224. dispose(): void;
  140225. private _setState;
  140226. private _tick;
  140227. private _stop;
  140228. }
  140229. }
  140230. declare module BABYLON {
  140231. /**
  140232. * The options container for the teleportation module
  140233. */
  140234. export interface IWebXRTeleportationOptions {
  140235. /**
  140236. * if provided, this scene will be used to render meshes.
  140237. */
  140238. customUtilityLayerScene?: Scene;
  140239. /**
  140240. * Values to configure the default target mesh
  140241. */
  140242. defaultTargetMeshOptions?: {
  140243. /**
  140244. * Fill color of the teleportation area
  140245. */
  140246. teleportationFillColor?: string;
  140247. /**
  140248. * Border color for the teleportation area
  140249. */
  140250. teleportationBorderColor?: string;
  140251. /**
  140252. * Disable the mesh's animation sequence
  140253. */
  140254. disableAnimation?: boolean;
  140255. /**
  140256. * Disable lighting on the material or the ring and arrow
  140257. */
  140258. disableLighting?: boolean;
  140259. /**
  140260. * Override the default material of the torus and arrow
  140261. */
  140262. torusArrowMaterial?: Material;
  140263. };
  140264. /**
  140265. * A list of meshes to use as floor meshes.
  140266. * Meshes can be added and removed after initializing the feature using the
  140267. * addFloorMesh and removeFloorMesh functions
  140268. * If empty, rotation will still work
  140269. */
  140270. floorMeshes?: AbstractMesh[];
  140271. /**
  140272. * use this rendering group id for the meshes (optional)
  140273. */
  140274. renderingGroupId?: number;
  140275. /**
  140276. * Should teleportation move only to snap points
  140277. */
  140278. snapPointsOnly?: boolean;
  140279. /**
  140280. * An array of points to which the teleportation will snap to.
  140281. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  140282. */
  140283. snapPositions?: Vector3[];
  140284. /**
  140285. * How close should the teleportation ray be in order to snap to position.
  140286. * Default to 0.8 units (meters)
  140287. */
  140288. snapToPositionRadius?: number;
  140289. /**
  140290. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  140291. * If you want to support rotation, make sure your mesh has a direction indicator.
  140292. *
  140293. * When left untouched, the default mesh will be initialized.
  140294. */
  140295. teleportationTargetMesh?: AbstractMesh;
  140296. /**
  140297. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  140298. */
  140299. timeToTeleport?: number;
  140300. /**
  140301. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  140302. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  140303. */
  140304. useMainComponentOnly?: boolean;
  140305. /**
  140306. * Should meshes created here be added to a utility layer or the main scene
  140307. */
  140308. useUtilityLayer?: boolean;
  140309. /**
  140310. * Babylon XR Input class for controller
  140311. */
  140312. xrInput: WebXRInput;
  140313. /**
  140314. * Meshes that the teleportation ray cannot go through
  140315. */
  140316. pickBlockerMeshes?: AbstractMesh[];
  140317. /**
  140318. * Should teleport work only on a specific hand?
  140319. */
  140320. forceHandedness?: XRHandedness;
  140321. /**
  140322. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  140323. */
  140324. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  140325. }
  140326. /**
  140327. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  140328. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  140329. * the input of the attached controllers.
  140330. */
  140331. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  140332. private _options;
  140333. private _controllers;
  140334. private _currentTeleportationControllerId;
  140335. private _floorMeshes;
  140336. private _quadraticBezierCurve;
  140337. private _selectionFeature;
  140338. private _snapToPositions;
  140339. private _snappedToPoint;
  140340. private _teleportationRingMaterial?;
  140341. private _tmpRay;
  140342. private _tmpVector;
  140343. private _tmpQuaternion;
  140344. /**
  140345. * The module's name
  140346. */
  140347. static readonly Name: string;
  140348. /**
  140349. * The (Babylon) version of this module.
  140350. * This is an integer representing the implementation version.
  140351. * This number does not correspond to the webxr specs version
  140352. */
  140353. static readonly Version: number;
  140354. /**
  140355. * Is movement backwards enabled
  140356. */
  140357. backwardsMovementEnabled: boolean;
  140358. /**
  140359. * Distance to travel when moving backwards
  140360. */
  140361. backwardsTeleportationDistance: number;
  140362. /**
  140363. * The distance from the user to the inspection point in the direction of the controller
  140364. * A higher number will allow the user to move further
  140365. * defaults to 5 (meters, in xr units)
  140366. */
  140367. parabolicCheckRadius: number;
  140368. /**
  140369. * Should the module support parabolic ray on top of direct ray
  140370. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  140371. * Very helpful when moving between floors / different heights
  140372. */
  140373. parabolicRayEnabled: boolean;
  140374. /**
  140375. * The second type of ray - straight line.
  140376. * Should it be enabled or should the parabolic line be the only one.
  140377. */
  140378. straightRayEnabled: boolean;
  140379. /**
  140380. * How much rotation should be applied when rotating right and left
  140381. */
  140382. rotationAngle: number;
  140383. private _rotationEnabled;
  140384. /**
  140385. * Is rotation enabled when moving forward?
  140386. * Disabling this feature will prevent the user from deciding the direction when teleporting
  140387. */
  140388. get rotationEnabled(): boolean;
  140389. /**
  140390. * Sets wether rotation is enabled or not
  140391. * @param enabled is rotation enabled when teleportation is shown
  140392. */
  140393. set rotationEnabled(enabled: boolean);
  140394. /**
  140395. * Exposes the currently set teleportation target mesh.
  140396. */
  140397. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  140398. /**
  140399. * constructs a new anchor system
  140400. * @param _xrSessionManager an instance of WebXRSessionManager
  140401. * @param _options configuration object for this feature
  140402. */
  140403. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  140404. /**
  140405. * Get the snapPointsOnly flag
  140406. */
  140407. get snapPointsOnly(): boolean;
  140408. /**
  140409. * Sets the snapPointsOnly flag
  140410. * @param snapToPoints should teleportation be exclusively to snap points
  140411. */
  140412. set snapPointsOnly(snapToPoints: boolean);
  140413. /**
  140414. * Add a new mesh to the floor meshes array
  140415. * @param mesh the mesh to use as floor mesh
  140416. */
  140417. addFloorMesh(mesh: AbstractMesh): void;
  140418. /**
  140419. * Add a new snap-to point to fix teleportation to this position
  140420. * @param newSnapPoint The new Snap-To point
  140421. */
  140422. addSnapPoint(newSnapPoint: Vector3): void;
  140423. attach(): boolean;
  140424. detach(): boolean;
  140425. dispose(): void;
  140426. /**
  140427. * Remove a mesh from the floor meshes array
  140428. * @param mesh the mesh to remove
  140429. */
  140430. removeFloorMesh(mesh: AbstractMesh): void;
  140431. /**
  140432. * Remove a mesh from the floor meshes array using its name
  140433. * @param name the mesh name to remove
  140434. */
  140435. removeFloorMeshByName(name: string): void;
  140436. /**
  140437. * 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
  140438. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  140439. * @returns was the point found and removed or not
  140440. */
  140441. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  140442. /**
  140443. * This function sets a selection feature that will be disabled when
  140444. * the forward ray is shown and will be reattached when hidden.
  140445. * This is used to remove the selection rays when moving.
  140446. * @param selectionFeature the feature to disable when forward movement is enabled
  140447. */
  140448. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  140449. protected _onXRFrame(_xrFrame: XRFrame): void;
  140450. private _attachController;
  140451. private _createDefaultTargetMesh;
  140452. private _detachController;
  140453. private _findClosestSnapPointWithRadius;
  140454. private _setTargetMeshPosition;
  140455. private _setTargetMeshVisibility;
  140456. private _showParabolicPath;
  140457. private _teleportForward;
  140458. }
  140459. }
  140460. declare module BABYLON {
  140461. /**
  140462. * Options for the default xr helper
  140463. */
  140464. export class WebXRDefaultExperienceOptions {
  140465. /**
  140466. * Enable or disable default UI to enter XR
  140467. */
  140468. disableDefaultUI?: boolean;
  140469. /**
  140470. * Should teleportation not initialize. defaults to false.
  140471. */
  140472. disableTeleportation?: boolean;
  140473. /**
  140474. * Floor meshes that will be used for teleport
  140475. */
  140476. floorMeshes?: Array<AbstractMesh>;
  140477. /**
  140478. * If set to true, the first frame will not be used to reset position
  140479. * The first frame is mainly used when copying transformation from the old camera
  140480. * Mainly used in AR
  140481. */
  140482. ignoreNativeCameraTransformation?: boolean;
  140483. /**
  140484. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  140485. */
  140486. inputOptions?: IWebXRInputOptions;
  140487. /**
  140488. * optional configuration for the output canvas
  140489. */
  140490. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  140491. /**
  140492. * optional UI options. This can be used among other to change session mode and reference space type
  140493. */
  140494. uiOptions?: WebXREnterExitUIOptions;
  140495. /**
  140496. * When loading teleportation and pointer select, use stable versions instead of latest.
  140497. */
  140498. useStablePlugins?: boolean;
  140499. /**
  140500. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  140501. */
  140502. renderingGroupId?: number;
  140503. /**
  140504. * A list of optional features to init the session with
  140505. * If set to true, all features we support will be added
  140506. */
  140507. optionalFeatures?: boolean | string[];
  140508. }
  140509. /**
  140510. * Default experience which provides a similar setup to the previous webVRExperience
  140511. */
  140512. export class WebXRDefaultExperience {
  140513. /**
  140514. * Base experience
  140515. */
  140516. baseExperience: WebXRExperienceHelper;
  140517. /**
  140518. * Enables ui for entering/exiting xr
  140519. */
  140520. enterExitUI: WebXREnterExitUI;
  140521. /**
  140522. * Input experience extension
  140523. */
  140524. input: WebXRInput;
  140525. /**
  140526. * Enables laser pointer and selection
  140527. */
  140528. pointerSelection: WebXRControllerPointerSelection;
  140529. /**
  140530. * Default target xr should render to
  140531. */
  140532. renderTarget: WebXRRenderTarget;
  140533. /**
  140534. * Enables teleportation
  140535. */
  140536. teleportation: WebXRMotionControllerTeleportation;
  140537. private constructor();
  140538. /**
  140539. * Creates the default xr experience
  140540. * @param scene scene
  140541. * @param options options for basic configuration
  140542. * @returns resulting WebXRDefaultExperience
  140543. */
  140544. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140545. /**
  140546. * DIsposes of the experience helper
  140547. */
  140548. dispose(): void;
  140549. }
  140550. }
  140551. declare module BABYLON {
  140552. /**
  140553. * Options to modify the vr teleportation behavior.
  140554. */
  140555. export interface VRTeleportationOptions {
  140556. /**
  140557. * The name of the mesh which should be used as the teleportation floor. (default: null)
  140558. */
  140559. floorMeshName?: string;
  140560. /**
  140561. * A list of meshes to be used as the teleportation floor. (default: empty)
  140562. */
  140563. floorMeshes?: Mesh[];
  140564. /**
  140565. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  140566. */
  140567. teleportationMode?: number;
  140568. /**
  140569. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  140570. */
  140571. teleportationTime?: number;
  140572. /**
  140573. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  140574. */
  140575. teleportationSpeed?: number;
  140576. /**
  140577. * The easing function used in the animation or null for Linear. (default CircleEase)
  140578. */
  140579. easingFunction?: EasingFunction;
  140580. }
  140581. /**
  140582. * Options to modify the vr experience helper's behavior.
  140583. */
  140584. export interface VRExperienceHelperOptions extends WebVROptions {
  140585. /**
  140586. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  140587. */
  140588. createDeviceOrientationCamera?: boolean;
  140589. /**
  140590. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  140591. */
  140592. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  140593. /**
  140594. * Uses the main button on the controller to toggle the laser casted. (default: true)
  140595. */
  140596. laserToggle?: boolean;
  140597. /**
  140598. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  140599. */
  140600. floorMeshes?: Mesh[];
  140601. /**
  140602. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  140603. */
  140604. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  140605. /**
  140606. * Defines if WebXR should be used instead of WebVR (if available)
  140607. */
  140608. useXR?: boolean;
  140609. }
  140610. /**
  140611. * Event containing information after VR has been entered
  140612. */
  140613. export class OnAfterEnteringVRObservableEvent {
  140614. /**
  140615. * If entering vr was successful
  140616. */
  140617. success: boolean;
  140618. }
  140619. /**
  140620. * Helps to quickly add VR support to an existing scene.
  140621. * See https://doc.babylonjs.com/how_to/webvr_helper
  140622. */
  140623. export class VRExperienceHelper {
  140624. /** Options to modify the vr experience helper's behavior. */
  140625. webVROptions: VRExperienceHelperOptions;
  140626. private _scene;
  140627. private _position;
  140628. private _btnVR;
  140629. private _btnVRDisplayed;
  140630. private _webVRsupported;
  140631. private _webVRready;
  140632. private _webVRrequesting;
  140633. private _webVRpresenting;
  140634. private _hasEnteredVR;
  140635. private _fullscreenVRpresenting;
  140636. private _inputElement;
  140637. private _webVRCamera;
  140638. private _vrDeviceOrientationCamera;
  140639. private _deviceOrientationCamera;
  140640. private _existingCamera;
  140641. private _onKeyDown;
  140642. private _onVrDisplayPresentChange;
  140643. private _onVRDisplayChanged;
  140644. private _onVRRequestPresentStart;
  140645. private _onVRRequestPresentComplete;
  140646. /**
  140647. * 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)
  140648. */
  140649. enableGazeEvenWhenNoPointerLock: boolean;
  140650. /**
  140651. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  140652. */
  140653. exitVROnDoubleTap: boolean;
  140654. /**
  140655. * Observable raised right before entering VR.
  140656. */
  140657. onEnteringVRObservable: Observable<VRExperienceHelper>;
  140658. /**
  140659. * Observable raised when entering VR has completed.
  140660. */
  140661. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  140662. /**
  140663. * Observable raised when exiting VR.
  140664. */
  140665. onExitingVRObservable: Observable<VRExperienceHelper>;
  140666. /**
  140667. * Observable raised when controller mesh is loaded.
  140668. */
  140669. onControllerMeshLoadedObservable: Observable<WebVRController>;
  140670. /** Return this.onEnteringVRObservable
  140671. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  140672. */
  140673. get onEnteringVR(): Observable<VRExperienceHelper>;
  140674. /** Return this.onExitingVRObservable
  140675. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  140676. */
  140677. get onExitingVR(): Observable<VRExperienceHelper>;
  140678. /** Return this.onControllerMeshLoadedObservable
  140679. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  140680. */
  140681. get onControllerMeshLoaded(): Observable<WebVRController>;
  140682. private _rayLength;
  140683. private _useCustomVRButton;
  140684. private _teleportationRequested;
  140685. private _teleportActive;
  140686. private _floorMeshName;
  140687. private _floorMeshesCollection;
  140688. private _teleportationMode;
  140689. private _teleportationTime;
  140690. private _teleportationSpeed;
  140691. private _teleportationEasing;
  140692. private _rotationAllowed;
  140693. private _teleportBackwardsVector;
  140694. private _teleportationTarget;
  140695. private _isDefaultTeleportationTarget;
  140696. private _postProcessMove;
  140697. private _teleportationFillColor;
  140698. private _teleportationBorderColor;
  140699. private _rotationAngle;
  140700. private _haloCenter;
  140701. private _cameraGazer;
  140702. private _padSensibilityUp;
  140703. private _padSensibilityDown;
  140704. private _leftController;
  140705. private _rightController;
  140706. private _gazeColor;
  140707. private _laserColor;
  140708. private _pickedLaserColor;
  140709. private _pickedGazeColor;
  140710. /**
  140711. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  140712. */
  140713. onNewMeshSelected: Observable<AbstractMesh>;
  140714. /**
  140715. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  140716. * This observable will provide the mesh and the controller used to select the mesh
  140717. */
  140718. onMeshSelectedWithController: Observable<{
  140719. mesh: AbstractMesh;
  140720. controller: WebVRController;
  140721. }>;
  140722. /**
  140723. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  140724. */
  140725. onNewMeshPicked: Observable<PickingInfo>;
  140726. private _circleEase;
  140727. /**
  140728. * Observable raised before camera teleportation
  140729. */
  140730. onBeforeCameraTeleport: Observable<Vector3>;
  140731. /**
  140732. * Observable raised after camera teleportation
  140733. */
  140734. onAfterCameraTeleport: Observable<Vector3>;
  140735. /**
  140736. * Observable raised when current selected mesh gets unselected
  140737. */
  140738. onSelectedMeshUnselected: Observable<AbstractMesh>;
  140739. private _raySelectionPredicate;
  140740. /**
  140741. * To be optionaly changed by user to define custom ray selection
  140742. */
  140743. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  140744. /**
  140745. * To be optionaly changed by user to define custom selection logic (after ray selection)
  140746. */
  140747. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140748. /**
  140749. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  140750. */
  140751. teleportationEnabled: boolean;
  140752. private _defaultHeight;
  140753. private _teleportationInitialized;
  140754. private _interactionsEnabled;
  140755. private _interactionsRequested;
  140756. private _displayGaze;
  140757. private _displayLaserPointer;
  140758. /**
  140759. * The mesh used to display where the user is going to teleport.
  140760. */
  140761. get teleportationTarget(): Mesh;
  140762. /**
  140763. * Sets the mesh to be used to display where the user is going to teleport.
  140764. */
  140765. set teleportationTarget(value: Mesh);
  140766. /**
  140767. * 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
  140768. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  140769. * See https://doc.babylonjs.com/resources/baking_transformations
  140770. */
  140771. get gazeTrackerMesh(): Mesh;
  140772. set gazeTrackerMesh(value: Mesh);
  140773. /**
  140774. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  140775. */
  140776. updateGazeTrackerScale: boolean;
  140777. /**
  140778. * If the gaze trackers color should be updated when selecting meshes
  140779. */
  140780. updateGazeTrackerColor: boolean;
  140781. /**
  140782. * If the controller laser color should be updated when selecting meshes
  140783. */
  140784. updateControllerLaserColor: boolean;
  140785. /**
  140786. * The gaze tracking mesh corresponding to the left controller
  140787. */
  140788. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  140789. /**
  140790. * The gaze tracking mesh corresponding to the right controller
  140791. */
  140792. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  140793. /**
  140794. * If the ray of the gaze should be displayed.
  140795. */
  140796. get displayGaze(): boolean;
  140797. /**
  140798. * Sets if the ray of the gaze should be displayed.
  140799. */
  140800. set displayGaze(value: boolean);
  140801. /**
  140802. * If the ray of the LaserPointer should be displayed.
  140803. */
  140804. get displayLaserPointer(): boolean;
  140805. /**
  140806. * Sets if the ray of the LaserPointer should be displayed.
  140807. */
  140808. set displayLaserPointer(value: boolean);
  140809. /**
  140810. * The deviceOrientationCamera used as the camera when not in VR.
  140811. */
  140812. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  140813. /**
  140814. * Based on the current WebVR support, returns the current VR camera used.
  140815. */
  140816. get currentVRCamera(): Nullable<Camera>;
  140817. /**
  140818. * The webVRCamera which is used when in VR.
  140819. */
  140820. get webVRCamera(): WebVRFreeCamera;
  140821. /**
  140822. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  140823. */
  140824. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  140825. /**
  140826. * The html button that is used to trigger entering into VR.
  140827. */
  140828. get vrButton(): Nullable<HTMLButtonElement>;
  140829. private get _teleportationRequestInitiated();
  140830. /**
  140831. * Defines whether or not Pointer lock should be requested when switching to
  140832. * full screen.
  140833. */
  140834. requestPointerLockOnFullScreen: boolean;
  140835. /**
  140836. * If asking to force XR, this will be populated with the default xr experience
  140837. */
  140838. xr: WebXRDefaultExperience;
  140839. /**
  140840. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  140841. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  140842. */
  140843. xrTestDone: boolean;
  140844. /**
  140845. * Instantiates a VRExperienceHelper.
  140846. * Helps to quickly add VR support to an existing scene.
  140847. * @param scene The scene the VRExperienceHelper belongs to.
  140848. * @param webVROptions Options to modify the vr experience helper's behavior.
  140849. */
  140850. constructor(scene: Scene,
  140851. /** Options to modify the vr experience helper's behavior. */
  140852. webVROptions?: VRExperienceHelperOptions);
  140853. private completeVRInit;
  140854. private _onDefaultMeshLoaded;
  140855. private _onResize;
  140856. private _onFullscreenChange;
  140857. /**
  140858. * Gets a value indicating if we are currently in VR mode.
  140859. */
  140860. get isInVRMode(): boolean;
  140861. private onVrDisplayPresentChange;
  140862. private onVRDisplayChanged;
  140863. private moveButtonToBottomRight;
  140864. private displayVRButton;
  140865. private updateButtonVisibility;
  140866. private _cachedAngularSensibility;
  140867. /**
  140868. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  140869. * Otherwise, will use the fullscreen API.
  140870. */
  140871. enterVR(): void;
  140872. /**
  140873. * Attempt to exit VR, or fullscreen.
  140874. */
  140875. exitVR(): void;
  140876. /**
  140877. * The position of the vr experience helper.
  140878. */
  140879. get position(): Vector3;
  140880. /**
  140881. * Sets the position of the vr experience helper.
  140882. */
  140883. set position(value: Vector3);
  140884. /**
  140885. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  140886. */
  140887. enableInteractions(): void;
  140888. private get _noControllerIsActive();
  140889. private beforeRender;
  140890. private _isTeleportationFloor;
  140891. /**
  140892. * Adds a floor mesh to be used for teleportation.
  140893. * @param floorMesh the mesh to be used for teleportation.
  140894. */
  140895. addFloorMesh(floorMesh: Mesh): void;
  140896. /**
  140897. * Removes a floor mesh from being used for teleportation.
  140898. * @param floorMesh the mesh to be removed.
  140899. */
  140900. removeFloorMesh(floorMesh: Mesh): void;
  140901. /**
  140902. * Enables interactions and teleportation using the VR controllers and gaze.
  140903. * @param vrTeleportationOptions options to modify teleportation behavior.
  140904. */
  140905. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  140906. private _onNewGamepadConnected;
  140907. private _tryEnableInteractionOnController;
  140908. private _onNewGamepadDisconnected;
  140909. private _enableInteractionOnController;
  140910. private _checkTeleportWithRay;
  140911. private _checkRotate;
  140912. private _checkTeleportBackwards;
  140913. private _enableTeleportationOnController;
  140914. private _createTeleportationCircles;
  140915. private _displayTeleportationTarget;
  140916. private _hideTeleportationTarget;
  140917. private _rotateCamera;
  140918. private _moveTeleportationSelectorTo;
  140919. private _workingVector;
  140920. private _workingQuaternion;
  140921. private _workingMatrix;
  140922. /**
  140923. * Time Constant Teleportation Mode
  140924. */
  140925. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  140926. /**
  140927. * Speed Constant Teleportation Mode
  140928. */
  140929. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  140930. /**
  140931. * Teleports the users feet to the desired location
  140932. * @param location The location where the user's feet should be placed
  140933. */
  140934. teleportCamera(location: Vector3): void;
  140935. private _convertNormalToDirectionOfRay;
  140936. private _castRayAndSelectObject;
  140937. private _notifySelectedMeshUnselected;
  140938. /**
  140939. * Permanently set new colors for the laser pointer
  140940. * @param color the new laser color
  140941. * @param pickedColor the new laser color when picked mesh detected
  140942. */
  140943. setLaserColor(color: Color3, pickedColor?: Color3): void;
  140944. /**
  140945. * Set lighting enabled / disabled on the laser pointer of both controllers
  140946. * @param enabled should the lighting be enabled on the laser pointer
  140947. */
  140948. setLaserLightingState(enabled?: boolean): void;
  140949. /**
  140950. * Permanently set new colors for the gaze pointer
  140951. * @param color the new gaze color
  140952. * @param pickedColor the new gaze color when picked mesh detected
  140953. */
  140954. setGazeColor(color: Color3, pickedColor?: Color3): void;
  140955. /**
  140956. * Sets the color of the laser ray from the vr controllers.
  140957. * @param color new color for the ray.
  140958. */
  140959. changeLaserColor(color: Color3): void;
  140960. /**
  140961. * Sets the color of the ray from the vr headsets gaze.
  140962. * @param color new color for the ray.
  140963. */
  140964. changeGazeColor(color: Color3): void;
  140965. /**
  140966. * Exits VR and disposes of the vr experience helper
  140967. */
  140968. dispose(): void;
  140969. /**
  140970. * Gets the name of the VRExperienceHelper class
  140971. * @returns "VRExperienceHelper"
  140972. */
  140973. getClassName(): string;
  140974. }
  140975. }
  140976. declare module BABYLON {
  140977. /**
  140978. * Contains an array of blocks representing the octree
  140979. */
  140980. export interface IOctreeContainer<T> {
  140981. /**
  140982. * Blocks within the octree
  140983. */
  140984. blocks: Array<OctreeBlock<T>>;
  140985. }
  140986. /**
  140987. * Class used to store a cell in an octree
  140988. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  140989. */
  140990. export class OctreeBlock<T> {
  140991. /**
  140992. * Gets the content of the current block
  140993. */
  140994. entries: T[];
  140995. /**
  140996. * Gets the list of block children
  140997. */
  140998. blocks: Array<OctreeBlock<T>>;
  140999. private _depth;
  141000. private _maxDepth;
  141001. private _capacity;
  141002. private _minPoint;
  141003. private _maxPoint;
  141004. private _boundingVectors;
  141005. private _creationFunc;
  141006. /**
  141007. * Creates a new block
  141008. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  141009. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  141010. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141011. * @param depth defines the current depth of this block in the octree
  141012. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  141013. * @param creationFunc defines a callback to call when an element is added to the block
  141014. */
  141015. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  141016. /**
  141017. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141018. */
  141019. get capacity(): number;
  141020. /**
  141021. * Gets the minimum vector (in world space) of the block's bounding box
  141022. */
  141023. get minPoint(): Vector3;
  141024. /**
  141025. * Gets the maximum vector (in world space) of the block's bounding box
  141026. */
  141027. get maxPoint(): Vector3;
  141028. /**
  141029. * Add a new element to this block
  141030. * @param entry defines the element to add
  141031. */
  141032. addEntry(entry: T): void;
  141033. /**
  141034. * Remove an element from this block
  141035. * @param entry defines the element to remove
  141036. */
  141037. removeEntry(entry: T): void;
  141038. /**
  141039. * Add an array of elements to this block
  141040. * @param entries defines the array of elements to add
  141041. */
  141042. addEntries(entries: T[]): void;
  141043. /**
  141044. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  141045. * @param frustumPlanes defines the frustum planes to test
  141046. * @param selection defines the array to store current content if selection is positive
  141047. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141048. */
  141049. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141050. /**
  141051. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  141052. * @param sphereCenter defines the bounding sphere center
  141053. * @param sphereRadius defines the bounding sphere radius
  141054. * @param selection defines the array to store current content if selection is positive
  141055. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141056. */
  141057. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141058. /**
  141059. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  141060. * @param ray defines the ray to test with
  141061. * @param selection defines the array to store current content if selection is positive
  141062. */
  141063. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  141064. /**
  141065. * Subdivide the content into child blocks (this block will then be empty)
  141066. */
  141067. createInnerBlocks(): void;
  141068. /**
  141069. * @hidden
  141070. */
  141071. 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;
  141072. }
  141073. }
  141074. declare module BABYLON {
  141075. /**
  141076. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  141077. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141078. */
  141079. export class Octree<T> {
  141080. /** 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.) */
  141081. maxDepth: number;
  141082. /**
  141083. * Blocks within the octree containing objects
  141084. */
  141085. blocks: Array<OctreeBlock<T>>;
  141086. /**
  141087. * Content stored in the octree
  141088. */
  141089. dynamicContent: T[];
  141090. private _maxBlockCapacity;
  141091. private _selectionContent;
  141092. private _creationFunc;
  141093. /**
  141094. * Creates a octree
  141095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141096. * @param creationFunc function to be used to instatiate the octree
  141097. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  141098. * @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.)
  141099. */
  141100. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  141101. /** 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.) */
  141102. maxDepth?: number);
  141103. /**
  141104. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  141105. * @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);
  141106. * @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);
  141107. * @param entries meshes to be added to the octree blocks
  141108. */
  141109. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  141110. /**
  141111. * Adds a mesh to the octree
  141112. * @param entry Mesh to add to the octree
  141113. */
  141114. addMesh(entry: T): void;
  141115. /**
  141116. * Remove an element from the octree
  141117. * @param entry defines the element to remove
  141118. */
  141119. removeMesh(entry: T): void;
  141120. /**
  141121. * Selects an array of meshes within the frustum
  141122. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  141123. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  141124. * @returns array of meshes within the frustum
  141125. */
  141126. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  141127. /**
  141128. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  141129. * @param sphereCenter defines the bounding sphere center
  141130. * @param sphereRadius defines the bounding sphere radius
  141131. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141132. * @returns an array of objects that intersect the sphere
  141133. */
  141134. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  141135. /**
  141136. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  141137. * @param ray defines the ray to test with
  141138. * @returns array of intersected objects
  141139. */
  141140. intersectsRay(ray: Ray): SmartArray<T>;
  141141. /**
  141142. * Adds a mesh into the octree block if it intersects the block
  141143. */
  141144. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  141145. /**
  141146. * Adds a submesh into the octree block if it intersects the block
  141147. */
  141148. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  141149. }
  141150. }
  141151. declare module BABYLON {
  141152. interface Scene {
  141153. /**
  141154. * @hidden
  141155. * Backing Filed
  141156. */
  141157. _selectionOctree: Octree<AbstractMesh>;
  141158. /**
  141159. * Gets the octree used to boost mesh selection (picking)
  141160. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141161. */
  141162. selectionOctree: Octree<AbstractMesh>;
  141163. /**
  141164. * Creates or updates the octree used to boost selection (picking)
  141165. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141166. * @param maxCapacity defines the maximum capacity per leaf
  141167. * @param maxDepth defines the maximum depth of the octree
  141168. * @returns an octree of AbstractMesh
  141169. */
  141170. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  141171. }
  141172. interface AbstractMesh {
  141173. /**
  141174. * @hidden
  141175. * Backing Field
  141176. */
  141177. _submeshesOctree: Octree<SubMesh>;
  141178. /**
  141179. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  141180. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  141181. * @param maxCapacity defines the maximum size of each block (64 by default)
  141182. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  141183. * @returns the new octree
  141184. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  141185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141186. */
  141187. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  141188. }
  141189. /**
  141190. * Defines the octree scene component responsible to manage any octrees
  141191. * in a given scene.
  141192. */
  141193. export class OctreeSceneComponent {
  141194. /**
  141195. * The component name help to identify the component in the list of scene components.
  141196. */
  141197. readonly name: string;
  141198. /**
  141199. * The scene the component belongs to.
  141200. */
  141201. scene: Scene;
  141202. /**
  141203. * Indicates if the meshes have been checked to make sure they are isEnabled()
  141204. */
  141205. readonly checksIsEnabled: boolean;
  141206. /**
  141207. * Creates a new instance of the component for the given scene
  141208. * @param scene Defines the scene to register the component in
  141209. */
  141210. constructor(scene: Scene);
  141211. /**
  141212. * Registers the component in a given scene
  141213. */
  141214. register(): void;
  141215. /**
  141216. * Return the list of active meshes
  141217. * @returns the list of active meshes
  141218. */
  141219. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  141220. /**
  141221. * Return the list of active sub meshes
  141222. * @param mesh The mesh to get the candidates sub meshes from
  141223. * @returns the list of active sub meshes
  141224. */
  141225. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  141226. private _tempRay;
  141227. /**
  141228. * Return the list of sub meshes intersecting with a given local ray
  141229. * @param mesh defines the mesh to find the submesh for
  141230. * @param localRay defines the ray in local space
  141231. * @returns the list of intersecting sub meshes
  141232. */
  141233. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  141234. /**
  141235. * Return the list of sub meshes colliding with a collider
  141236. * @param mesh defines the mesh to find the submesh for
  141237. * @param collider defines the collider to evaluate the collision against
  141238. * @returns the list of colliding sub meshes
  141239. */
  141240. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  141241. /**
  141242. * Rebuilds the elements related to this component in case of
  141243. * context lost for instance.
  141244. */
  141245. rebuild(): void;
  141246. /**
  141247. * Disposes the component and the associated ressources.
  141248. */
  141249. dispose(): void;
  141250. }
  141251. }
  141252. declare module BABYLON {
  141253. /**
  141254. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  141255. */
  141256. export interface GizmoAxisCache {
  141257. /** Mesh used to runder the Gizmo */
  141258. gizmoMeshes: Mesh[];
  141259. /** Mesh used to detect user interaction with Gizmo */
  141260. colliderMeshes: Mesh[];
  141261. /** Material used to inicate color of gizmo mesh */
  141262. material: StandardMaterial;
  141263. /** Material used to inicate hover state of the Gizmo */
  141264. hoverMaterial: StandardMaterial;
  141265. /** Material used to inicate disabled state of the Gizmo */
  141266. disableMaterial: StandardMaterial;
  141267. /** Used to indicate Active state of the Gizmo */
  141268. active: boolean;
  141269. }
  141270. /**
  141271. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  141272. */
  141273. export class Gizmo implements IDisposable {
  141274. /** The utility layer the gizmo will be added to */
  141275. gizmoLayer: UtilityLayerRenderer;
  141276. /**
  141277. * The root mesh of the gizmo
  141278. */
  141279. _rootMesh: Mesh;
  141280. private _attachedMesh;
  141281. private _attachedNode;
  141282. /**
  141283. * Ratio for the scale of the gizmo (Default: 1)
  141284. */
  141285. protected _scaleRatio: number;
  141286. /**
  141287. * boolean updated by pointermove when a gizmo mesh is hovered
  141288. */
  141289. protected _isHovered: boolean;
  141290. /**
  141291. * Ratio for the scale of the gizmo (Default: 1)
  141292. */
  141293. set scaleRatio(value: number);
  141294. get scaleRatio(): number;
  141295. /**
  141296. * True when the mouse pointer is hovered a gizmo mesh
  141297. */
  141298. get isHovered(): boolean;
  141299. /**
  141300. * If a custom mesh has been set (Default: false)
  141301. */
  141302. protected _customMeshSet: boolean;
  141303. /**
  141304. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  141305. * * When set, interactions will be enabled
  141306. */
  141307. get attachedMesh(): Nullable<AbstractMesh>;
  141308. set attachedMesh(value: Nullable<AbstractMesh>);
  141309. /**
  141310. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  141311. * * When set, interactions will be enabled
  141312. */
  141313. get attachedNode(): Nullable<Node>;
  141314. set attachedNode(value: Nullable<Node>);
  141315. /**
  141316. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  141317. * @param mesh The mesh to replace the default mesh of the gizmo
  141318. */
  141319. setCustomMesh(mesh: Mesh): void;
  141320. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  141321. /**
  141322. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  141323. */
  141324. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141325. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141326. /**
  141327. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  141328. */
  141329. updateGizmoPositionToMatchAttachedMesh: boolean;
  141330. /**
  141331. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  141332. */
  141333. updateScale: boolean;
  141334. protected _interactionsEnabled: boolean;
  141335. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141336. private _beforeRenderObserver;
  141337. private _tempQuaternion;
  141338. private _tempVector;
  141339. private _tempVector2;
  141340. private _tempMatrix1;
  141341. private _tempMatrix2;
  141342. private _rightHandtoLeftHandMatrix;
  141343. /**
  141344. * Creates a gizmo
  141345. * @param gizmoLayer The utility layer the gizmo will be added to
  141346. */
  141347. constructor(
  141348. /** The utility layer the gizmo will be added to */
  141349. gizmoLayer?: UtilityLayerRenderer);
  141350. /**
  141351. * Updates the gizmo to match the attached mesh's position/rotation
  141352. */
  141353. protected _update(): void;
  141354. /**
  141355. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  141356. * @param value Node, TransformNode or mesh
  141357. */
  141358. protected _matrixChanged(): void;
  141359. /**
  141360. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  141361. * @param gizmoLayer The utility layer the gizmo will be added to
  141362. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  141363. * @returns {Observer<PointerInfo>} pointerObserver
  141364. */
  141365. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  141366. /**
  141367. * Disposes of the gizmo
  141368. */
  141369. dispose(): void;
  141370. }
  141371. }
  141372. declare module BABYLON {
  141373. /**
  141374. * Single plane drag gizmo
  141375. */
  141376. export class PlaneDragGizmo extends Gizmo {
  141377. /**
  141378. * Drag behavior responsible for the gizmos dragging interactions
  141379. */
  141380. dragBehavior: PointerDragBehavior;
  141381. private _pointerObserver;
  141382. /**
  141383. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141384. */
  141385. snapDistance: number;
  141386. /**
  141387. * Event that fires each time the gizmo snaps to a new location.
  141388. * * snapDistance is the the change in distance
  141389. */
  141390. onSnapObservable: Observable<{
  141391. snapDistance: number;
  141392. }>;
  141393. private _gizmoMesh;
  141394. private _coloredMaterial;
  141395. private _hoverMaterial;
  141396. private _disableMaterial;
  141397. private _isEnabled;
  141398. private _parent;
  141399. private _dragging;
  141400. /** @hidden */
  141401. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  141402. /**
  141403. * Creates a PlaneDragGizmo
  141404. * @param gizmoLayer The utility layer the gizmo will be added to
  141405. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  141406. * @param color The color of the gizmo
  141407. */
  141408. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  141409. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141410. /**
  141411. * If the gizmo is enabled
  141412. */
  141413. set isEnabled(value: boolean);
  141414. get isEnabled(): boolean;
  141415. /**
  141416. * Disposes of the gizmo
  141417. */
  141418. dispose(): void;
  141419. }
  141420. }
  141421. declare module BABYLON {
  141422. /**
  141423. * Single plane rotation gizmo
  141424. */
  141425. export class PlaneRotationGizmo extends Gizmo {
  141426. /**
  141427. * Drag behavior responsible for the gizmos dragging interactions
  141428. */
  141429. dragBehavior: PointerDragBehavior;
  141430. private _pointerObserver;
  141431. /**
  141432. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  141433. */
  141434. snapDistance: number;
  141435. /**
  141436. * Event that fires each time the gizmo snaps to a new location.
  141437. * * snapDistance is the the change in distance
  141438. */
  141439. onSnapObservable: Observable<{
  141440. snapDistance: number;
  141441. }>;
  141442. private _isEnabled;
  141443. private _parent;
  141444. private _coloredMaterial;
  141445. private _hoverMaterial;
  141446. private _disableMaterial;
  141447. private _gizmoMesh;
  141448. private _rotationCircle;
  141449. private _dragging;
  141450. private static _CircleConstants;
  141451. /**
  141452. * Creates a PlaneRotationGizmo
  141453. * @param gizmoLayer The utility layer the gizmo will be added to
  141454. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  141455. * @param color The color of the gizmo
  141456. * @param tessellation Amount of tessellation to be used when creating rotation circles
  141457. * @param useEulerRotation Use and update Euler angle instead of quaternion
  141458. * @param thickness display gizmo axis thickness
  141459. */
  141460. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  141461. /** Create Geometry for Gizmo */
  141462. private _createGizmoMesh;
  141463. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141464. private setupRotationCircle;
  141465. private updateRotationPath;
  141466. private updateRotationCircle;
  141467. /**
  141468. * If the gizmo is enabled
  141469. */
  141470. set isEnabled(value: boolean);
  141471. get isEnabled(): boolean;
  141472. /**
  141473. * Disposes of the gizmo
  141474. */
  141475. dispose(): void;
  141476. }
  141477. }
  141478. declare module BABYLON {
  141479. /**
  141480. * Gizmo that enables rotating a mesh along 3 axis
  141481. */
  141482. export class RotationGizmo extends Gizmo {
  141483. /**
  141484. * Internal gizmo used for interactions on the x axis
  141485. */
  141486. xGizmo: PlaneRotationGizmo;
  141487. /**
  141488. * Internal gizmo used for interactions on the y axis
  141489. */
  141490. yGizmo: PlaneRotationGizmo;
  141491. /**
  141492. * Internal gizmo used for interactions on the z axis
  141493. */
  141494. zGizmo: PlaneRotationGizmo;
  141495. /** Fires an event when any of it's sub gizmos are dragged */
  141496. onDragStartObservable: Observable<unknown>;
  141497. /** Fires an event when any of it's sub gizmos are released from dragging */
  141498. onDragEndObservable: Observable<unknown>;
  141499. private _meshAttached;
  141500. private _nodeAttached;
  141501. private _observables;
  141502. /** Node Caching for quick lookup */
  141503. private _gizmoAxisCache;
  141504. get attachedMesh(): Nullable<AbstractMesh>;
  141505. set attachedMesh(mesh: Nullable<AbstractMesh>);
  141506. get attachedNode(): Nullable<Node>;
  141507. set attachedNode(node: Nullable<Node>);
  141508. protected _checkBillboardTransform(): void;
  141509. /**
  141510. * True when the mouse pointer is hovering a gizmo mesh
  141511. */
  141512. get isHovered(): boolean;
  141513. /**
  141514. * Creates a RotationGizmo
  141515. * @param gizmoLayer The utility layer the gizmo will be added to
  141516. * @param tessellation Amount of tessellation to be used when creating rotation circles
  141517. * @param useEulerRotation Use and update Euler angle instead of quaternion
  141518. * @param thickness display gizmo axis thickness
  141519. */
  141520. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  141521. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141522. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141523. /**
  141524. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141525. */
  141526. set snapDistance(value: number);
  141527. get snapDistance(): number;
  141528. /**
  141529. * Ratio for the scale of the gizmo (Default: 1)
  141530. */
  141531. set scaleRatio(value: number);
  141532. get scaleRatio(): number;
  141533. /**
  141534. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  141535. * @param mesh Axis gizmo mesh
  141536. * @param cache Gizmo axis definition used for reactive gizmo UI
  141537. */
  141538. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  141539. /**
  141540. * Disposes of the gizmo
  141541. */
  141542. dispose(): void;
  141543. /**
  141544. * CustomMeshes are not supported by this gizmo
  141545. * @param mesh The mesh to replace the default mesh of the gizmo
  141546. */
  141547. setCustomMesh(mesh: Mesh): void;
  141548. }
  141549. }
  141550. declare module BABYLON {
  141551. /**
  141552. * Class containing static functions to help procedurally build meshes
  141553. */
  141554. export class PolyhedronBuilder {
  141555. /**
  141556. * Creates a polyhedron mesh
  141557. * * 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
  141558. * * The parameter `size` (positive float, default 1) sets the polygon size
  141559. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141560. * * 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`
  141561. * * 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
  141562. * * 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)`)
  141563. * * 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
  141564. * * 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
  141565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141566. * * 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
  141567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141568. * @param name defines the name of the mesh
  141569. * @param options defines the options used to create the mesh
  141570. * @param scene defines the hosting scene
  141571. * @returns the polyhedron mesh
  141572. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141573. */
  141574. static CreatePolyhedron(name: string, options: {
  141575. type?: number;
  141576. size?: number;
  141577. sizeX?: number;
  141578. sizeY?: number;
  141579. sizeZ?: number;
  141580. custom?: any;
  141581. faceUV?: Vector4[];
  141582. faceColors?: Color4[];
  141583. flat?: boolean;
  141584. updatable?: boolean;
  141585. sideOrientation?: number;
  141586. frontUVs?: Vector4;
  141587. backUVs?: Vector4;
  141588. }, scene?: Nullable<Scene>): Mesh;
  141589. }
  141590. }
  141591. declare module BABYLON {
  141592. /**
  141593. * Class containing static functions to help procedurally build meshes
  141594. */
  141595. export class BoxBuilder {
  141596. /**
  141597. * Creates a box mesh
  141598. * * The parameter `size` sets the size (float) of each box side (default 1)
  141599. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141600. * * 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)
  141601. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141603. * * 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
  141604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141605. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141606. * @param name defines the name of the mesh
  141607. * @param options defines the options used to create the mesh
  141608. * @param scene defines the hosting scene
  141609. * @returns the box mesh
  141610. */
  141611. static CreateBox(name: string, options: {
  141612. size?: number;
  141613. width?: number;
  141614. height?: number;
  141615. depth?: number;
  141616. faceUV?: Vector4[];
  141617. faceColors?: Color4[];
  141618. sideOrientation?: number;
  141619. frontUVs?: Vector4;
  141620. backUVs?: Vector4;
  141621. wrap?: boolean;
  141622. topBaseAt?: number;
  141623. bottomBaseAt?: number;
  141624. updatable?: boolean;
  141625. }, scene?: Nullable<Scene>): Mesh;
  141626. }
  141627. }
  141628. declare module BABYLON {
  141629. /**
  141630. * Single axis scale gizmo
  141631. */
  141632. export class AxisScaleGizmo extends Gizmo {
  141633. /**
  141634. * Drag behavior responsible for the gizmos dragging interactions
  141635. */
  141636. dragBehavior: PointerDragBehavior;
  141637. private _pointerObserver;
  141638. /**
  141639. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141640. */
  141641. snapDistance: number;
  141642. /**
  141643. * Event that fires each time the gizmo snaps to a new location.
  141644. * * snapDistance is the the change in distance
  141645. */
  141646. onSnapObservable: Observable<{
  141647. snapDistance: number;
  141648. }>;
  141649. /**
  141650. * If the scaling operation should be done on all axis (default: false)
  141651. */
  141652. uniformScaling: boolean;
  141653. /**
  141654. * Custom sensitivity value for the drag strength
  141655. */
  141656. sensitivity: number;
  141657. private _isEnabled;
  141658. private _parent;
  141659. private _gizmoMesh;
  141660. private _coloredMaterial;
  141661. private _hoverMaterial;
  141662. private _disableMaterial;
  141663. private _dragging;
  141664. private _tmpVector;
  141665. private _tmpMatrix;
  141666. private _tmpMatrix2;
  141667. /**
  141668. * Creates an AxisScaleGizmo
  141669. * @param gizmoLayer The utility layer the gizmo will be added to
  141670. * @param dragAxis The axis which the gizmo will be able to scale on
  141671. * @param color The color of the gizmo
  141672. * @param thickness display gizmo axis thickness
  141673. */
  141674. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  141675. /** Create Geometry for Gizmo */
  141676. private _createGizmoMesh;
  141677. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141678. /**
  141679. * If the gizmo is enabled
  141680. */
  141681. set isEnabled(value: boolean);
  141682. get isEnabled(): boolean;
  141683. /**
  141684. * Disposes of the gizmo
  141685. */
  141686. dispose(): void;
  141687. /**
  141688. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  141689. * @param mesh The mesh to replace the default mesh of the gizmo
  141690. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  141691. */
  141692. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  141693. }
  141694. }
  141695. declare module BABYLON {
  141696. /**
  141697. * Gizmo that enables scaling a mesh along 3 axis
  141698. */
  141699. export class ScaleGizmo extends Gizmo {
  141700. /**
  141701. * Internal gizmo used for interactions on the x axis
  141702. */
  141703. xGizmo: AxisScaleGizmo;
  141704. /**
  141705. * Internal gizmo used for interactions on the y axis
  141706. */
  141707. yGizmo: AxisScaleGizmo;
  141708. /**
  141709. * Internal gizmo used for interactions on the z axis
  141710. */
  141711. zGizmo: AxisScaleGizmo;
  141712. /**
  141713. * Internal gizmo used to scale all axis equally
  141714. */
  141715. uniformScaleGizmo: AxisScaleGizmo;
  141716. private _meshAttached;
  141717. private _nodeAttached;
  141718. private _snapDistance;
  141719. private _uniformScalingMesh;
  141720. private _octahedron;
  141721. private _sensitivity;
  141722. private _coloredMaterial;
  141723. private _hoverMaterial;
  141724. private _disableMaterial;
  141725. private _observables;
  141726. /** Node Caching for quick lookup */
  141727. private _gizmoAxisCache;
  141728. /** Fires an event when any of it's sub gizmos are dragged */
  141729. onDragStartObservable: Observable<unknown>;
  141730. /** Fires an event when any of it's sub gizmos are released from dragging */
  141731. onDragEndObservable: Observable<unknown>;
  141732. get attachedMesh(): Nullable<AbstractMesh>;
  141733. set attachedMesh(mesh: Nullable<AbstractMesh>);
  141734. get attachedNode(): Nullable<Node>;
  141735. set attachedNode(node: Nullable<Node>);
  141736. /**
  141737. * True when the mouse pointer is hovering a gizmo mesh
  141738. */
  141739. get isHovered(): boolean;
  141740. /**
  141741. * Creates a ScaleGizmo
  141742. * @param gizmoLayer The utility layer the gizmo will be added to
  141743. * @param thickness display gizmo axis thickness
  141744. */
  141745. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  141746. /** Create Geometry for Gizmo */
  141747. private _createUniformScaleMesh;
  141748. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141749. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141750. /**
  141751. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141752. */
  141753. set snapDistance(value: number);
  141754. get snapDistance(): number;
  141755. /**
  141756. * Ratio for the scale of the gizmo (Default: 1)
  141757. */
  141758. set scaleRatio(value: number);
  141759. get scaleRatio(): number;
  141760. /**
  141761. * Sensitivity factor for dragging (Default: 1)
  141762. */
  141763. set sensitivity(value: number);
  141764. get sensitivity(): number;
  141765. /**
  141766. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  141767. * @param mesh Axis gizmo mesh
  141768. * @param cache Gizmo axis definition used for reactive gizmo UI
  141769. */
  141770. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  141771. /**
  141772. * Disposes of the gizmo
  141773. */
  141774. dispose(): void;
  141775. }
  141776. }
  141777. declare module BABYLON {
  141778. /**
  141779. * Bounding box gizmo
  141780. */
  141781. export class BoundingBoxGizmo extends Gizmo {
  141782. private _lineBoundingBox;
  141783. private _rotateSpheresParent;
  141784. private _scaleBoxesParent;
  141785. private _boundingDimensions;
  141786. private _renderObserver;
  141787. private _pointerObserver;
  141788. private _scaleDragSpeed;
  141789. private _tmpQuaternion;
  141790. private _tmpVector;
  141791. private _tmpRotationMatrix;
  141792. /**
  141793. * 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)
  141794. */
  141795. ignoreChildren: boolean;
  141796. /**
  141797. * 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)
  141798. */
  141799. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  141800. /**
  141801. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  141802. */
  141803. rotationSphereSize: number;
  141804. /**
  141805. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  141806. */
  141807. scaleBoxSize: number;
  141808. /**
  141809. * 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)
  141810. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  141811. */
  141812. fixedDragMeshScreenSize: boolean;
  141813. /**
  141814. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  141815. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  141816. */
  141817. fixedDragMeshBoundsSize: boolean;
  141818. /**
  141819. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  141820. */
  141821. fixedDragMeshScreenSizeDistanceFactor: number;
  141822. /**
  141823. * Fired when a rotation sphere or scale box is dragged
  141824. */
  141825. onDragStartObservable: Observable<{}>;
  141826. /**
  141827. * Fired when a scale box is dragged
  141828. */
  141829. onScaleBoxDragObservable: Observable<{}>;
  141830. /**
  141831. * Fired when a scale box drag is ended
  141832. */
  141833. onScaleBoxDragEndObservable: Observable<{}>;
  141834. /**
  141835. * Fired when a rotation sphere is dragged
  141836. */
  141837. onRotationSphereDragObservable: Observable<{}>;
  141838. /**
  141839. * Fired when a rotation sphere drag is ended
  141840. */
  141841. onRotationSphereDragEndObservable: Observable<{}>;
  141842. /**
  141843. * 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)
  141844. */
  141845. scalePivot: Nullable<Vector3>;
  141846. /**
  141847. * Mesh used as a pivot to rotate the attached node
  141848. */
  141849. private _anchorMesh;
  141850. private _existingMeshScale;
  141851. private _dragMesh;
  141852. private pointerDragBehavior;
  141853. private coloredMaterial;
  141854. private hoverColoredMaterial;
  141855. /**
  141856. * Sets the color of the bounding box gizmo
  141857. * @param color the color to set
  141858. */
  141859. setColor(color: Color3): void;
  141860. /**
  141861. * Creates an BoundingBoxGizmo
  141862. * @param gizmoLayer The utility layer the gizmo will be added to
  141863. * @param color The color of the gizmo
  141864. */
  141865. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  141866. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  141867. private _selectNode;
  141868. /**
  141869. * Updates the bounding box information for the Gizmo
  141870. */
  141871. updateBoundingBox(): void;
  141872. private _updateRotationSpheres;
  141873. private _updateScaleBoxes;
  141874. /**
  141875. * Enables rotation on the specified axis and disables rotation on the others
  141876. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  141877. */
  141878. setEnabledRotationAxis(axis: string): void;
  141879. /**
  141880. * Enables/disables scaling
  141881. * @param enable if scaling should be enabled
  141882. * @param homogeneousScaling defines if scaling should only be homogeneous
  141883. */
  141884. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  141885. private _updateDummy;
  141886. /**
  141887. * Enables a pointer drag behavior on the bounding box of the gizmo
  141888. */
  141889. enableDragBehavior(): void;
  141890. /**
  141891. * Disposes of the gizmo
  141892. */
  141893. dispose(): void;
  141894. /**
  141895. * 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)
  141896. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  141897. * @returns the bounding box mesh with the passed in mesh as a child
  141898. */
  141899. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  141900. /**
  141901. * CustomMeshes are not supported by this gizmo
  141902. * @param mesh The mesh to replace the default mesh of the gizmo
  141903. */
  141904. setCustomMesh(mesh: Mesh): void;
  141905. }
  141906. }
  141907. declare module BABYLON {
  141908. /**
  141909. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  141910. */
  141911. export class GizmoManager implements IDisposable {
  141912. private scene;
  141913. /**
  141914. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  141915. */
  141916. gizmos: {
  141917. positionGizmo: Nullable<PositionGizmo>;
  141918. rotationGizmo: Nullable<RotationGizmo>;
  141919. scaleGizmo: Nullable<ScaleGizmo>;
  141920. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  141921. };
  141922. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  141923. clearGizmoOnEmptyPointerEvent: boolean;
  141924. /** Fires an event when the manager is attached to a mesh */
  141925. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  141926. /** Fires an event when the manager is attached to a node */
  141927. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  141928. private _gizmosEnabled;
  141929. private _pointerObservers;
  141930. private _attachedMesh;
  141931. private _attachedNode;
  141932. private _boundingBoxColor;
  141933. private _defaultUtilityLayer;
  141934. private _defaultKeepDepthUtilityLayer;
  141935. private _thickness;
  141936. /** Node Caching for quick lookup */
  141937. private _gizmoAxisCache;
  141938. /**
  141939. * When bounding box gizmo is enabled, this can be used to track drag/end events
  141940. */
  141941. boundingBoxDragBehavior: SixDofDragBehavior;
  141942. /**
  141943. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  141944. */
  141945. attachableMeshes: Nullable<Array<AbstractMesh>>;
  141946. /**
  141947. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  141948. */
  141949. attachableNodes: Nullable<Array<Node>>;
  141950. /**
  141951. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  141952. */
  141953. usePointerToAttachGizmos: boolean;
  141954. /**
  141955. * Utility layer that the bounding box gizmo belongs to
  141956. */
  141957. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  141958. /**
  141959. * Utility layer that all gizmos besides bounding box belong to
  141960. */
  141961. get utilityLayer(): UtilityLayerRenderer;
  141962. /**
  141963. * True when the mouse pointer is hovering a gizmo mesh
  141964. */
  141965. get isHovered(): boolean;
  141966. /**
  141967. * Instatiates a gizmo manager
  141968. * @param scene the scene to overlay the gizmos on top of
  141969. * @param thickness display gizmo axis thickness
  141970. * @param utilityLayer the layer where gizmos are rendered
  141971. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  141972. */
  141973. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  141974. /**
  141975. * Subscribes to pointer down events, for attaching and detaching mesh
  141976. * @param scene The sceme layer the observer will be added to
  141977. */
  141978. private _attachToMeshPointerObserver;
  141979. /**
  141980. * Attaches a set of gizmos to the specified mesh
  141981. * @param mesh The mesh the gizmo's should be attached to
  141982. */
  141983. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141984. /**
  141985. * Attaches a set of gizmos to the specified node
  141986. * @param node The node the gizmo's should be attached to
  141987. */
  141988. attachToNode(node: Nullable<Node>): void;
  141989. /**
  141990. * If the position gizmo is enabled
  141991. */
  141992. set positionGizmoEnabled(value: boolean);
  141993. get positionGizmoEnabled(): boolean;
  141994. /**
  141995. * If the rotation gizmo is enabled
  141996. */
  141997. set rotationGizmoEnabled(value: boolean);
  141998. get rotationGizmoEnabled(): boolean;
  141999. /**
  142000. * If the scale gizmo is enabled
  142001. */
  142002. set scaleGizmoEnabled(value: boolean);
  142003. get scaleGizmoEnabled(): boolean;
  142004. /**
  142005. * If the boundingBox gizmo is enabled
  142006. */
  142007. set boundingBoxGizmoEnabled(value: boolean);
  142008. get boundingBoxGizmoEnabled(): boolean;
  142009. /**
  142010. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142011. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  142012. */
  142013. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  142014. /**
  142015. * Disposes of the gizmo manager
  142016. */
  142017. dispose(): void;
  142018. }
  142019. }
  142020. declare module BABYLON {
  142021. /**
  142022. * Gizmo that enables dragging a mesh along 3 axis
  142023. */
  142024. export class PositionGizmo extends Gizmo {
  142025. /**
  142026. * Internal gizmo used for interactions on the x axis
  142027. */
  142028. xGizmo: AxisDragGizmo;
  142029. /**
  142030. * Internal gizmo used for interactions on the y axis
  142031. */
  142032. yGizmo: AxisDragGizmo;
  142033. /**
  142034. * Internal gizmo used for interactions on the z axis
  142035. */
  142036. zGizmo: AxisDragGizmo;
  142037. /**
  142038. * Internal gizmo used for interactions on the yz plane
  142039. */
  142040. xPlaneGizmo: PlaneDragGizmo;
  142041. /**
  142042. * Internal gizmo used for interactions on the xz plane
  142043. */
  142044. yPlaneGizmo: PlaneDragGizmo;
  142045. /**
  142046. * Internal gizmo used for interactions on the xy plane
  142047. */
  142048. zPlaneGizmo: PlaneDragGizmo;
  142049. /**
  142050. * private variables
  142051. */
  142052. private _meshAttached;
  142053. private _nodeAttached;
  142054. private _snapDistance;
  142055. private _observables;
  142056. /** Node Caching for quick lookup */
  142057. private _gizmoAxisCache;
  142058. /** Fires an event when any of it's sub gizmos are dragged */
  142059. onDragStartObservable: Observable<unknown>;
  142060. /** Fires an event when any of it's sub gizmos are released from dragging */
  142061. onDragEndObservable: Observable<unknown>;
  142062. /**
  142063. * If set to true, planar drag is enabled
  142064. */
  142065. private _planarGizmoEnabled;
  142066. get attachedMesh(): Nullable<AbstractMesh>;
  142067. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142068. get attachedNode(): Nullable<Node>;
  142069. set attachedNode(node: Nullable<Node>);
  142070. /**
  142071. * True when the mouse pointer is hovering a gizmo mesh
  142072. */
  142073. get isHovered(): boolean;
  142074. /**
  142075. * Creates a PositionGizmo
  142076. * @param gizmoLayer The utility layer the gizmo will be added to
  142077. @param thickness display gizmo axis thickness
  142078. */
  142079. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  142080. /**
  142081. * If the planar drag gizmo is enabled
  142082. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  142083. */
  142084. set planarGizmoEnabled(value: boolean);
  142085. get planarGizmoEnabled(): boolean;
  142086. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142087. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142088. /**
  142089. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142090. */
  142091. set snapDistance(value: number);
  142092. get snapDistance(): number;
  142093. /**
  142094. * Ratio for the scale of the gizmo (Default: 1)
  142095. */
  142096. set scaleRatio(value: number);
  142097. get scaleRatio(): number;
  142098. /**
  142099. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142100. * @param mesh Axis gizmo mesh
  142101. * @param cache Gizmo axis definition used for reactive gizmo UI
  142102. */
  142103. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142104. /**
  142105. * Disposes of the gizmo
  142106. */
  142107. dispose(): void;
  142108. /**
  142109. * CustomMeshes are not supported by this gizmo
  142110. * @param mesh The mesh to replace the default mesh of the gizmo
  142111. */
  142112. setCustomMesh(mesh: Mesh): void;
  142113. }
  142114. }
  142115. declare module BABYLON {
  142116. /**
  142117. * Single axis drag gizmo
  142118. */
  142119. export class AxisDragGizmo extends Gizmo {
  142120. /**
  142121. * Drag behavior responsible for the gizmos dragging interactions
  142122. */
  142123. dragBehavior: PointerDragBehavior;
  142124. private _pointerObserver;
  142125. /**
  142126. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142127. */
  142128. snapDistance: number;
  142129. /**
  142130. * Event that fires each time the gizmo snaps to a new location.
  142131. * * snapDistance is the the change in distance
  142132. */
  142133. onSnapObservable: Observable<{
  142134. snapDistance: number;
  142135. }>;
  142136. private _isEnabled;
  142137. private _parent;
  142138. private _gizmoMesh;
  142139. private _coloredMaterial;
  142140. private _hoverMaterial;
  142141. private _disableMaterial;
  142142. private _dragging;
  142143. /** @hidden */
  142144. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  142145. /** @hidden */
  142146. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  142147. /**
  142148. * Creates an AxisDragGizmo
  142149. * @param gizmoLayer The utility layer the gizmo will be added to
  142150. * @param dragAxis The axis which the gizmo will be able to drag on
  142151. * @param color The color of the gizmo
  142152. * @param thickness display gizmo axis thickness
  142153. */
  142154. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  142155. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142156. /**
  142157. * If the gizmo is enabled
  142158. */
  142159. set isEnabled(value: boolean);
  142160. get isEnabled(): boolean;
  142161. /**
  142162. * Disposes of the gizmo
  142163. */
  142164. dispose(): void;
  142165. }
  142166. }
  142167. declare module BABYLON.Debug {
  142168. /**
  142169. * The Axes viewer will show 3 axes in a specific point in space
  142170. */
  142171. export class AxesViewer {
  142172. private _xAxis;
  142173. private _yAxis;
  142174. private _zAxis;
  142175. private _scaleLinesFactor;
  142176. private _instanced;
  142177. /**
  142178. * Gets the hosting scene
  142179. */
  142180. scene: Nullable<Scene>;
  142181. /**
  142182. * Gets or sets a number used to scale line length
  142183. */
  142184. scaleLines: number;
  142185. /** Gets the node hierarchy used to render x-axis */
  142186. get xAxis(): TransformNode;
  142187. /** Gets the node hierarchy used to render y-axis */
  142188. get yAxis(): TransformNode;
  142189. /** Gets the node hierarchy used to render z-axis */
  142190. get zAxis(): TransformNode;
  142191. /**
  142192. * Creates a new AxesViewer
  142193. * @param scene defines the hosting scene
  142194. * @param scaleLines defines a number used to scale line length (1 by default)
  142195. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  142196. * @param xAxis defines the node hierarchy used to render the x-axis
  142197. * @param yAxis defines the node hierarchy used to render the y-axis
  142198. * @param zAxis defines the node hierarchy used to render the z-axis
  142199. */
  142200. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  142201. /**
  142202. * Force the viewer to update
  142203. * @param position defines the position of the viewer
  142204. * @param xaxis defines the x axis of the viewer
  142205. * @param yaxis defines the y axis of the viewer
  142206. * @param zaxis defines the z axis of the viewer
  142207. */
  142208. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  142209. /**
  142210. * Creates an instance of this axes viewer.
  142211. * @returns a new axes viewer with instanced meshes
  142212. */
  142213. createInstance(): AxesViewer;
  142214. /** Releases resources */
  142215. dispose(): void;
  142216. private static _SetRenderingGroupId;
  142217. }
  142218. }
  142219. declare module BABYLON.Debug {
  142220. /**
  142221. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  142222. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  142223. */
  142224. export class BoneAxesViewer extends AxesViewer {
  142225. /**
  142226. * Gets or sets the target mesh where to display the axes viewer
  142227. */
  142228. mesh: Nullable<Mesh>;
  142229. /**
  142230. * Gets or sets the target bone where to display the axes viewer
  142231. */
  142232. bone: Nullable<Bone>;
  142233. /** Gets current position */
  142234. pos: Vector3;
  142235. /** Gets direction of X axis */
  142236. xaxis: Vector3;
  142237. /** Gets direction of Y axis */
  142238. yaxis: Vector3;
  142239. /** Gets direction of Z axis */
  142240. zaxis: Vector3;
  142241. /**
  142242. * Creates a new BoneAxesViewer
  142243. * @param scene defines the hosting scene
  142244. * @param bone defines the target bone
  142245. * @param mesh defines the target mesh
  142246. * @param scaleLines defines a scaling factor for line length (1 by default)
  142247. */
  142248. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  142249. /**
  142250. * Force the viewer to update
  142251. */
  142252. update(): void;
  142253. /** Releases resources */
  142254. dispose(): void;
  142255. }
  142256. }
  142257. declare module BABYLON {
  142258. /**
  142259. * Interface used to define scene explorer extensibility option
  142260. */
  142261. export interface IExplorerExtensibilityOption {
  142262. /**
  142263. * Define the option label
  142264. */
  142265. label: string;
  142266. /**
  142267. * Defines the action to execute on click
  142268. */
  142269. action: (entity: any) => void;
  142270. }
  142271. /**
  142272. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  142273. */
  142274. export interface IExplorerExtensibilityGroup {
  142275. /**
  142276. * Defines a predicate to test if a given type mut be extended
  142277. */
  142278. predicate: (entity: any) => boolean;
  142279. /**
  142280. * Gets the list of options added to a type
  142281. */
  142282. entries: IExplorerExtensibilityOption[];
  142283. }
  142284. /**
  142285. * Interface used to define the options to use to create the Inspector
  142286. */
  142287. export interface IInspectorOptions {
  142288. /**
  142289. * Display in overlay mode (default: false)
  142290. */
  142291. overlay?: boolean;
  142292. /**
  142293. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  142294. */
  142295. globalRoot?: HTMLElement;
  142296. /**
  142297. * Display the Scene explorer
  142298. */
  142299. showExplorer?: boolean;
  142300. /**
  142301. * Display the property inspector
  142302. */
  142303. showInspector?: boolean;
  142304. /**
  142305. * Display in embed mode (both panes on the right)
  142306. */
  142307. embedMode?: boolean;
  142308. /**
  142309. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  142310. */
  142311. handleResize?: boolean;
  142312. /**
  142313. * Allow the panes to popup (default: true)
  142314. */
  142315. enablePopup?: boolean;
  142316. /**
  142317. * Allow the panes to be closed by users (default: true)
  142318. */
  142319. enableClose?: boolean;
  142320. /**
  142321. * Optional list of extensibility entries
  142322. */
  142323. explorerExtensibility?: IExplorerExtensibilityGroup[];
  142324. /**
  142325. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  142326. */
  142327. inspectorURL?: string;
  142328. /**
  142329. * Optional initial tab (default to DebugLayerTab.Properties)
  142330. */
  142331. initialTab?: DebugLayerTab;
  142332. }
  142333. interface Scene {
  142334. /**
  142335. * @hidden
  142336. * Backing field
  142337. */
  142338. _debugLayer: DebugLayer;
  142339. /**
  142340. * Gets the debug layer (aka Inspector) associated with the scene
  142341. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142342. */
  142343. debugLayer: DebugLayer;
  142344. }
  142345. /**
  142346. * Enum of inspector action tab
  142347. */
  142348. export enum DebugLayerTab {
  142349. /**
  142350. * Properties tag (default)
  142351. */
  142352. Properties = 0,
  142353. /**
  142354. * Debug tab
  142355. */
  142356. Debug = 1,
  142357. /**
  142358. * Statistics tab
  142359. */
  142360. Statistics = 2,
  142361. /**
  142362. * Tools tab
  142363. */
  142364. Tools = 3,
  142365. /**
  142366. * Settings tab
  142367. */
  142368. Settings = 4
  142369. }
  142370. /**
  142371. * The debug layer (aka Inspector) is the go to tool in order to better understand
  142372. * what is happening in your scene
  142373. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142374. */
  142375. export class DebugLayer {
  142376. /**
  142377. * Define the url to get the inspector script from.
  142378. * By default it uses the babylonjs CDN.
  142379. * @ignoreNaming
  142380. */
  142381. static InspectorURL: string;
  142382. private _scene;
  142383. private BJSINSPECTOR;
  142384. private _onPropertyChangedObservable?;
  142385. /**
  142386. * Observable triggered when a property is changed through the inspector.
  142387. */
  142388. get onPropertyChangedObservable(): any;
  142389. /**
  142390. * Instantiates a new debug layer.
  142391. * The debug layer (aka Inspector) is the go to tool in order to better understand
  142392. * what is happening in your scene
  142393. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142394. * @param scene Defines the scene to inspect
  142395. */
  142396. constructor(scene: Scene);
  142397. /** Creates the inspector window. */
  142398. private _createInspector;
  142399. /**
  142400. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  142401. * @param entity defines the entity to select
  142402. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  142403. */
  142404. select(entity: any, lineContainerTitles?: string | string[]): void;
  142405. /** Get the inspector from bundle or global */
  142406. private _getGlobalInspector;
  142407. /**
  142408. * Get if the inspector is visible or not.
  142409. * @returns true if visible otherwise, false
  142410. */
  142411. isVisible(): boolean;
  142412. /**
  142413. * Hide the inspector and close its window.
  142414. */
  142415. hide(): void;
  142416. /**
  142417. * Update the scene in the inspector
  142418. */
  142419. setAsActiveScene(): void;
  142420. /**
  142421. * Launch the debugLayer.
  142422. * @param config Define the configuration of the inspector
  142423. * @return a promise fulfilled when the debug layer is visible
  142424. */
  142425. show(config?: IInspectorOptions): Promise<DebugLayer>;
  142426. }
  142427. }
  142428. declare module BABYLON.Debug {
  142429. /**
  142430. * Used to show the physics impostor around the specific mesh
  142431. */
  142432. export class PhysicsViewer {
  142433. /** @hidden */
  142434. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  142435. /** @hidden */
  142436. protected _meshes: Array<Nullable<AbstractMesh>>;
  142437. /** @hidden */
  142438. protected _scene: Nullable<Scene>;
  142439. /** @hidden */
  142440. protected _numMeshes: number;
  142441. /** @hidden */
  142442. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  142443. private _renderFunction;
  142444. private _utilityLayer;
  142445. private _debugBoxMesh;
  142446. private _debugSphereMesh;
  142447. private _debugCylinderMesh;
  142448. private _debugMaterial;
  142449. private _debugMeshMeshes;
  142450. /**
  142451. * Creates a new PhysicsViewer
  142452. * @param scene defines the hosting scene
  142453. */
  142454. constructor(scene: Scene);
  142455. /** @hidden */
  142456. protected _updateDebugMeshes(): void;
  142457. /**
  142458. * Renders a specified physic impostor
  142459. * @param impostor defines the impostor to render
  142460. * @param targetMesh defines the mesh represented by the impostor
  142461. * @returns the new debug mesh used to render the impostor
  142462. */
  142463. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  142464. /**
  142465. * Hides a specified physic impostor
  142466. * @param impostor defines the impostor to hide
  142467. */
  142468. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  142469. private _getDebugMaterial;
  142470. private _getDebugBoxMesh;
  142471. private _getDebugSphereMesh;
  142472. private _getDebugCylinderMesh;
  142473. private _getDebugMeshMesh;
  142474. private _getDebugMesh;
  142475. /** Releases all resources */
  142476. dispose(): void;
  142477. }
  142478. }
  142479. declare module BABYLON {
  142480. /**
  142481. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  142482. * in order to better appreciate the issue one might have.
  142483. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  142484. */
  142485. export class RayHelper {
  142486. /**
  142487. * Defines the ray we are currently tryin to visualize.
  142488. */
  142489. ray: Nullable<Ray>;
  142490. private _renderPoints;
  142491. private _renderLine;
  142492. private _renderFunction;
  142493. private _scene;
  142494. private _onAfterRenderObserver;
  142495. private _onAfterStepObserver;
  142496. private _attachedToMesh;
  142497. private _meshSpaceDirection;
  142498. private _meshSpaceOrigin;
  142499. /**
  142500. * Helper function to create a colored helper in a scene in one line.
  142501. * @param ray Defines the ray we are currently tryin to visualize
  142502. * @param scene Defines the scene the ray is used in
  142503. * @param color Defines the color we want to see the ray in
  142504. * @returns The newly created ray helper.
  142505. */
  142506. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  142507. /**
  142508. * Instantiate a new ray helper.
  142509. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  142510. * in order to better appreciate the issue one might have.
  142511. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  142512. * @param ray Defines the ray we are currently tryin to visualize
  142513. */
  142514. constructor(ray: Ray);
  142515. /**
  142516. * Shows the ray we are willing to debug.
  142517. * @param scene Defines the scene the ray needs to be rendered in
  142518. * @param color Defines the color the ray needs to be rendered in
  142519. */
  142520. show(scene: Scene, color?: Color3): void;
  142521. /**
  142522. * Hides the ray we are debugging.
  142523. */
  142524. hide(): void;
  142525. private _render;
  142526. /**
  142527. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  142528. * @param mesh Defines the mesh we want the helper attached to
  142529. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  142530. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  142531. * @param length Defines the length of the ray
  142532. */
  142533. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  142534. /**
  142535. * Detach the ray helper from the mesh it has previously been attached to.
  142536. */
  142537. detachFromMesh(): void;
  142538. private _updateToMesh;
  142539. /**
  142540. * Dispose the helper and release its associated resources.
  142541. */
  142542. dispose(): void;
  142543. }
  142544. }
  142545. declare module BABYLON {
  142546. /**
  142547. * Defines the options associated with the creation of a SkeletonViewer.
  142548. */
  142549. export interface ISkeletonViewerOptions {
  142550. /** Should the system pause animations before building the Viewer? */
  142551. pauseAnimations: boolean;
  142552. /** Should the system return the skeleton to rest before building? */
  142553. returnToRest: boolean;
  142554. /** public Display Mode of the Viewer */
  142555. displayMode: number;
  142556. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  142557. displayOptions: ISkeletonViewerDisplayOptions;
  142558. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  142559. computeBonesUsingShaders: boolean;
  142560. /** Flag ignore non weighted bones */
  142561. useAllBones: boolean;
  142562. }
  142563. /**
  142564. * Defines how to display the various bone meshes for the viewer.
  142565. */
  142566. export interface ISkeletonViewerDisplayOptions {
  142567. /** How far down to start tapering the bone spurs */
  142568. midStep?: number;
  142569. /** How big is the midStep? */
  142570. midStepFactor?: number;
  142571. /** Base for the Sphere Size */
  142572. sphereBaseSize?: number;
  142573. /** The ratio of the sphere to the longest bone in units */
  142574. sphereScaleUnit?: number;
  142575. /** Ratio for the Sphere Size */
  142576. sphereFactor?: number;
  142577. /** Whether a spur should attach its far end to the child bone position */
  142578. spurFollowsChild?: boolean;
  142579. /** Whether to show local axes or not */
  142580. showLocalAxes?: boolean;
  142581. /** Length of each local axis */
  142582. localAxesSize?: number;
  142583. }
  142584. /**
  142585. * Defines the constructor options for the BoneWeight Shader.
  142586. */
  142587. export interface IBoneWeightShaderOptions {
  142588. /** Skeleton to Map */
  142589. skeleton: Skeleton;
  142590. /** Colors for Uninfluenced bones */
  142591. colorBase?: Color3;
  142592. /** Colors for 0.0-0.25 Weight bones */
  142593. colorZero?: Color3;
  142594. /** Color for 0.25-0.5 Weight Influence */
  142595. colorQuarter?: Color3;
  142596. /** Color for 0.5-0.75 Weight Influence */
  142597. colorHalf?: Color3;
  142598. /** Color for 0.75-1 Weight Influence */
  142599. colorFull?: Color3;
  142600. /** Color for Zero Weight Influence */
  142601. targetBoneIndex?: number;
  142602. }
  142603. /**
  142604. * Simple structure of the gradient steps for the Color Map.
  142605. */
  142606. export interface ISkeletonMapShaderColorMapKnot {
  142607. /** Color of the Knot */
  142608. color: Color3;
  142609. /** Location of the Knot */
  142610. location: number;
  142611. }
  142612. /**
  142613. * Defines the constructor options for the SkeletonMap Shader.
  142614. */
  142615. export interface ISkeletonMapShaderOptions {
  142616. /** Skeleton to Map */
  142617. skeleton: Skeleton;
  142618. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  142619. colorMap?: ISkeletonMapShaderColorMapKnot[];
  142620. }
  142621. }
  142622. declare module BABYLON {
  142623. /**
  142624. * Class containing static functions to help procedurally build meshes
  142625. */
  142626. export class RibbonBuilder {
  142627. /**
  142628. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142629. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142630. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142631. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142632. * * 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
  142633. * * 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
  142634. * * 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
  142635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142636. * * 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
  142637. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142638. * * 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
  142639. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142640. * * 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
  142641. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142643. * @param name defines the name of the mesh
  142644. * @param options defines the options used to create the mesh
  142645. * @param scene defines the hosting scene
  142646. * @returns the ribbon mesh
  142647. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142649. */
  142650. static CreateRibbon(name: string, options: {
  142651. pathArray: Vector3[][];
  142652. closeArray?: boolean;
  142653. closePath?: boolean;
  142654. offset?: number;
  142655. updatable?: boolean;
  142656. sideOrientation?: number;
  142657. frontUVs?: Vector4;
  142658. backUVs?: Vector4;
  142659. instance?: Mesh;
  142660. invertUV?: boolean;
  142661. uvs?: Vector2[];
  142662. colors?: Color4[];
  142663. }, scene?: Nullable<Scene>): Mesh;
  142664. }
  142665. }
  142666. declare module BABYLON {
  142667. /**
  142668. * Class containing static functions to help procedurally build meshes
  142669. */
  142670. export class ShapeBuilder {
  142671. /**
  142672. * 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.
  142673. * * 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.
  142674. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142675. * * 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.
  142676. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142677. * * 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
  142678. * * 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
  142679. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142681. * * 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
  142682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142684. * @param name defines the name of the mesh
  142685. * @param options defines the options used to create the mesh
  142686. * @param scene defines the hosting scene
  142687. * @returns the extruded shape mesh
  142688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142690. */
  142691. static ExtrudeShape(name: string, options: {
  142692. shape: Vector3[];
  142693. path: Vector3[];
  142694. scale?: number;
  142695. rotation?: number;
  142696. cap?: number;
  142697. updatable?: boolean;
  142698. sideOrientation?: number;
  142699. frontUVs?: Vector4;
  142700. backUVs?: Vector4;
  142701. instance?: Mesh;
  142702. invertUV?: boolean;
  142703. }, scene?: Nullable<Scene>): Mesh;
  142704. /**
  142705. * Creates an custom extruded shape mesh.
  142706. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142707. * * 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.
  142708. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142709. * * 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
  142710. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142711. * * 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
  142712. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142713. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142714. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142715. * * 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
  142716. * * 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
  142717. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142719. * * 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
  142720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142722. * @param name defines the name of the mesh
  142723. * @param options defines the options used to create the mesh
  142724. * @param scene defines the hosting scene
  142725. * @returns the custom extruded shape mesh
  142726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142727. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142729. */
  142730. static ExtrudeShapeCustom(name: string, options: {
  142731. shape: Vector3[];
  142732. path: Vector3[];
  142733. scaleFunction?: any;
  142734. rotationFunction?: any;
  142735. ribbonCloseArray?: boolean;
  142736. ribbonClosePath?: boolean;
  142737. cap?: number;
  142738. updatable?: boolean;
  142739. sideOrientation?: number;
  142740. frontUVs?: Vector4;
  142741. backUVs?: Vector4;
  142742. instance?: Mesh;
  142743. invertUV?: boolean;
  142744. }, scene?: Nullable<Scene>): Mesh;
  142745. private static _ExtrudeShapeGeneric;
  142746. }
  142747. }
  142748. declare module BABYLON.Debug {
  142749. /**
  142750. * Class used to render a debug view of a given skeleton
  142751. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  142752. */
  142753. export class SkeletonViewer {
  142754. /** defines the skeleton to render */
  142755. skeleton: Skeleton;
  142756. /** defines the mesh attached to the skeleton */
  142757. mesh: AbstractMesh;
  142758. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  142759. autoUpdateBonesMatrices: boolean;
  142760. /** defines the rendering group id to use with the viewer */
  142761. renderingGroupId: number;
  142762. /** is the options for the viewer */
  142763. options: Partial<ISkeletonViewerOptions>;
  142764. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  142765. static readonly DISPLAY_LINES: number;
  142766. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  142767. static readonly DISPLAY_SPHERES: number;
  142768. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  142769. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  142770. /** public static method to create a BoneWeight Shader
  142771. * @param options The constructor options
  142772. * @param scene The scene that the shader is scoped to
  142773. * @returns The created ShaderMaterial
  142774. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  142775. */
  142776. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  142777. /** public static method to create a BoneWeight Shader
  142778. * @param options The constructor options
  142779. * @param scene The scene that the shader is scoped to
  142780. * @returns The created ShaderMaterial
  142781. */
  142782. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  142783. /** private static method to create a BoneWeight Shader
  142784. * @param size The size of the buffer to create (usually the bone count)
  142785. * @param colorMap The gradient data to generate
  142786. * @param scene The scene that the shader is scoped to
  142787. * @returns an Array of floats from the color gradient values
  142788. */
  142789. private static _CreateBoneMapColorBuffer;
  142790. /** If SkeletonViewer scene scope. */
  142791. private _scene;
  142792. /** Gets or sets the color used to render the skeleton */
  142793. color: Color3;
  142794. /** Array of the points of the skeleton fo the line view. */
  142795. private _debugLines;
  142796. /** The SkeletonViewers Mesh. */
  142797. private _debugMesh;
  142798. /** The local axes Meshes. */
  142799. private _localAxes;
  142800. /** If SkeletonViewer is enabled. */
  142801. private _isEnabled;
  142802. /** If SkeletonViewer is ready. */
  142803. private _ready;
  142804. /** SkeletonViewer render observable. */
  142805. private _obs;
  142806. /** The Utility Layer to render the gizmos in. */
  142807. private _utilityLayer;
  142808. private _boneIndices;
  142809. /** Gets the Scene. */
  142810. get scene(): Scene;
  142811. /** Gets the utilityLayer. */
  142812. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  142813. /** Checks Ready Status. */
  142814. get isReady(): Boolean;
  142815. /** Sets Ready Status. */
  142816. set ready(value: boolean);
  142817. /** Gets the debugMesh */
  142818. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  142819. /** Sets the debugMesh */
  142820. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  142821. /** Gets the displayMode */
  142822. get displayMode(): number;
  142823. /** Sets the displayMode */
  142824. set displayMode(value: number);
  142825. /**
  142826. * Creates a new SkeletonViewer
  142827. * @param skeleton defines the skeleton to render
  142828. * @param mesh defines the mesh attached to the skeleton
  142829. * @param scene defines the hosting scene
  142830. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  142831. * @param renderingGroupId defines the rendering group id to use with the viewer
  142832. * @param options All of the extra constructor options for the SkeletonViewer
  142833. */
  142834. constructor(
  142835. /** defines the skeleton to render */
  142836. skeleton: Skeleton,
  142837. /** defines the mesh attached to the skeleton */
  142838. mesh: AbstractMesh,
  142839. /** The Scene scope*/
  142840. scene: Scene,
  142841. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  142842. autoUpdateBonesMatrices?: boolean,
  142843. /** defines the rendering group id to use with the viewer */
  142844. renderingGroupId?: number,
  142845. /** is the options for the viewer */
  142846. options?: Partial<ISkeletonViewerOptions>);
  142847. /** The Dynamic bindings for the update functions */
  142848. private _bindObs;
  142849. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  142850. update(): void;
  142851. /** Gets or sets a boolean indicating if the viewer is enabled */
  142852. set isEnabled(value: boolean);
  142853. get isEnabled(): boolean;
  142854. private _getBonePosition;
  142855. private _getLinesForBonesWithLength;
  142856. private _getLinesForBonesNoLength;
  142857. /** function to revert the mesh and scene back to the initial state. */
  142858. private _revert;
  142859. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  142860. private _getAbsoluteBindPoseToRef;
  142861. /** function to build and bind sphere joint points and spur bone representations. */
  142862. private _buildSpheresAndSpurs;
  142863. private _buildLocalAxes;
  142864. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  142865. private _displayLinesUpdate;
  142866. /** Changes the displayMode of the skeleton viewer
  142867. * @param mode The displayMode numerical value
  142868. */
  142869. changeDisplayMode(mode: number): void;
  142870. /** Sets a display option of the skeleton viewer
  142871. *
  142872. * | Option | Type | Default | Description |
  142873. * | ---------------- | ------- | ------- | ----------- |
  142874. * | 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`. |
  142875. * | 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`. |
  142876. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  142877. * | 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`. |
  142878. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  142879. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  142880. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  142881. *
  142882. * @param option String of the option name
  142883. * @param value The numerical option value
  142884. */
  142885. changeDisplayOptions(option: string, value: number): void;
  142886. /** Release associated resources */
  142887. dispose(): void;
  142888. }
  142889. }
  142890. declare module BABYLON {
  142891. /**
  142892. * Enum for Device Types
  142893. */
  142894. export enum DeviceType {
  142895. /** Generic */
  142896. Generic = 0,
  142897. /** Keyboard */
  142898. Keyboard = 1,
  142899. /** Mouse */
  142900. Mouse = 2,
  142901. /** Touch Pointers */
  142902. Touch = 3,
  142903. /** PS4 Dual Shock */
  142904. DualShock = 4,
  142905. /** Xbox */
  142906. Xbox = 5,
  142907. /** Switch Controller */
  142908. Switch = 6
  142909. }
  142910. /**
  142911. * Enum for All Pointers (Touch/Mouse)
  142912. */
  142913. export enum PointerInput {
  142914. /** Horizontal Axis */
  142915. Horizontal = 0,
  142916. /** Vertical Axis */
  142917. Vertical = 1,
  142918. /** Left Click or Touch */
  142919. LeftClick = 2,
  142920. /** Middle Click */
  142921. MiddleClick = 3,
  142922. /** Right Click */
  142923. RightClick = 4,
  142924. /** Browser Back */
  142925. BrowserBack = 5,
  142926. /** Browser Forward */
  142927. BrowserForward = 6
  142928. }
  142929. /**
  142930. * Enum for Dual Shock Gamepad
  142931. */
  142932. export enum DualShockInput {
  142933. /** Cross */
  142934. Cross = 0,
  142935. /** Circle */
  142936. Circle = 1,
  142937. /** Square */
  142938. Square = 2,
  142939. /** Triangle */
  142940. Triangle = 3,
  142941. /** L1 */
  142942. L1 = 4,
  142943. /** R1 */
  142944. R1 = 5,
  142945. /** L2 */
  142946. L2 = 6,
  142947. /** R2 */
  142948. R2 = 7,
  142949. /** Share */
  142950. Share = 8,
  142951. /** Options */
  142952. Options = 9,
  142953. /** L3 */
  142954. L3 = 10,
  142955. /** R3 */
  142956. R3 = 11,
  142957. /** DPadUp */
  142958. DPadUp = 12,
  142959. /** DPadDown */
  142960. DPadDown = 13,
  142961. /** DPadLeft */
  142962. DPadLeft = 14,
  142963. /** DRight */
  142964. DPadRight = 15,
  142965. /** Home */
  142966. Home = 16,
  142967. /** TouchPad */
  142968. TouchPad = 17,
  142969. /** LStickXAxis */
  142970. LStickXAxis = 18,
  142971. /** LStickYAxis */
  142972. LStickYAxis = 19,
  142973. /** RStickXAxis */
  142974. RStickXAxis = 20,
  142975. /** RStickYAxis */
  142976. RStickYAxis = 21
  142977. }
  142978. /**
  142979. * Enum for Xbox Gamepad
  142980. */
  142981. export enum XboxInput {
  142982. /** A */
  142983. A = 0,
  142984. /** B */
  142985. B = 1,
  142986. /** X */
  142987. X = 2,
  142988. /** Y */
  142989. Y = 3,
  142990. /** LB */
  142991. LB = 4,
  142992. /** RB */
  142993. RB = 5,
  142994. /** LT */
  142995. LT = 6,
  142996. /** RT */
  142997. RT = 7,
  142998. /** Back */
  142999. Back = 8,
  143000. /** Start */
  143001. Start = 9,
  143002. /** LS */
  143003. LS = 10,
  143004. /** RS */
  143005. RS = 11,
  143006. /** DPadUp */
  143007. DPadUp = 12,
  143008. /** DPadDown */
  143009. DPadDown = 13,
  143010. /** DPadLeft */
  143011. DPadLeft = 14,
  143012. /** DRight */
  143013. DPadRight = 15,
  143014. /** Home */
  143015. Home = 16,
  143016. /** LStickXAxis */
  143017. LStickXAxis = 17,
  143018. /** LStickYAxis */
  143019. LStickYAxis = 18,
  143020. /** RStickXAxis */
  143021. RStickXAxis = 19,
  143022. /** RStickYAxis */
  143023. RStickYAxis = 20
  143024. }
  143025. /**
  143026. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  143027. */
  143028. export enum SwitchInput {
  143029. /** B */
  143030. B = 0,
  143031. /** A */
  143032. A = 1,
  143033. /** Y */
  143034. Y = 2,
  143035. /** X */
  143036. X = 3,
  143037. /** L */
  143038. L = 4,
  143039. /** R */
  143040. R = 5,
  143041. /** ZL */
  143042. ZL = 6,
  143043. /** ZR */
  143044. ZR = 7,
  143045. /** Minus */
  143046. Minus = 8,
  143047. /** Plus */
  143048. Plus = 9,
  143049. /** LS */
  143050. LS = 10,
  143051. /** RS */
  143052. RS = 11,
  143053. /** DPadUp */
  143054. DPadUp = 12,
  143055. /** DPadDown */
  143056. DPadDown = 13,
  143057. /** DPadLeft */
  143058. DPadLeft = 14,
  143059. /** DRight */
  143060. DPadRight = 15,
  143061. /** Home */
  143062. Home = 16,
  143063. /** Capture */
  143064. Capture = 17,
  143065. /** LStickXAxis */
  143066. LStickXAxis = 18,
  143067. /** LStickYAxis */
  143068. LStickYAxis = 19,
  143069. /** RStickXAxis */
  143070. RStickXAxis = 20,
  143071. /** RStickYAxis */
  143072. RStickYAxis = 21
  143073. }
  143074. }
  143075. declare module BABYLON {
  143076. /**
  143077. * This class will take all inputs from Keyboard, Pointer, and
  143078. * any Gamepads and provide a polling system that all devices
  143079. * will use. This class assumes that there will only be one
  143080. * pointer device and one keyboard.
  143081. */
  143082. export class DeviceInputSystem implements IDisposable {
  143083. /**
  143084. * Returns onDeviceConnected callback property
  143085. * @returns Callback with function to execute when a device is connected
  143086. */
  143087. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  143088. /**
  143089. * Sets callback function when a device is connected and executes against all connected devices
  143090. * @param callback Function to execute when a device is connected
  143091. */
  143092. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  143093. /**
  143094. * Callback to be triggered when a device is disconnected
  143095. */
  143096. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  143097. /**
  143098. * Callback to be triggered when event driven input is updated
  143099. */
  143100. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  143101. private _inputs;
  143102. private _gamepads;
  143103. private _keyboardActive;
  143104. private _pointerActive;
  143105. private _elementToAttachTo;
  143106. private _keyboardDownEvent;
  143107. private _keyboardUpEvent;
  143108. private _pointerMoveEvent;
  143109. private _pointerDownEvent;
  143110. private _pointerUpEvent;
  143111. private _gamepadConnectedEvent;
  143112. private _gamepadDisconnectedEvent;
  143113. private _onDeviceConnected;
  143114. private static _MAX_KEYCODES;
  143115. private static _MAX_POINTER_INPUTS;
  143116. private constructor();
  143117. /**
  143118. * Creates a new DeviceInputSystem instance
  143119. * @param engine Engine to pull input element from
  143120. * @returns The new instance
  143121. */
  143122. static Create(engine: Engine): DeviceInputSystem;
  143123. /**
  143124. * Checks for current device input value, given an id and input index
  143125. * @param deviceName Id of connected device
  143126. * @param inputIndex Index of device input
  143127. * @returns Current value of input
  143128. */
  143129. /**
  143130. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  143131. * @param deviceType Enum specifiying device type
  143132. * @param deviceSlot "Slot" or index that device is referenced in
  143133. * @param inputIndex Id of input to be checked
  143134. * @returns Current value of input
  143135. */
  143136. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  143137. /**
  143138. * Dispose of all the eventlisteners
  143139. */
  143140. dispose(): void;
  143141. /**
  143142. * Checks for existing connections to devices and register them, if necessary
  143143. * Currently handles gamepads and mouse
  143144. */
  143145. private _checkForConnectedDevices;
  143146. /**
  143147. * Add a gamepad to the DeviceInputSystem
  143148. * @param gamepad A single DOM Gamepad object
  143149. */
  143150. private _addGamePad;
  143151. /**
  143152. * Add pointer device to DeviceInputSystem
  143153. * @param deviceType Type of Pointer to add
  143154. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  143155. * @param currentX Current X at point of adding
  143156. * @param currentY Current Y at point of adding
  143157. */
  143158. private _addPointerDevice;
  143159. /**
  143160. * Add device and inputs to device array
  143161. * @param deviceType Enum specifiying device type
  143162. * @param deviceSlot "Slot" or index that device is referenced in
  143163. * @param numberOfInputs Number of input entries to create for given device
  143164. */
  143165. private _registerDevice;
  143166. /**
  143167. * Given a specific device name, remove that device from the device map
  143168. * @param deviceType Enum specifiying device type
  143169. * @param deviceSlot "Slot" or index that device is referenced in
  143170. */
  143171. private _unregisterDevice;
  143172. /**
  143173. * Handle all actions that come from keyboard interaction
  143174. */
  143175. private _handleKeyActions;
  143176. /**
  143177. * Handle all actions that come from pointer interaction
  143178. */
  143179. private _handlePointerActions;
  143180. /**
  143181. * Handle all actions that come from gamepad interaction
  143182. */
  143183. private _handleGamepadActions;
  143184. /**
  143185. * Update all non-event based devices with each frame
  143186. * @param deviceType Enum specifiying device type
  143187. * @param deviceSlot "Slot" or index that device is referenced in
  143188. * @param inputIndex Id of input to be checked
  143189. */
  143190. private _updateDevice;
  143191. /**
  143192. * Gets DeviceType from the device name
  143193. * @param deviceName Name of Device from DeviceInputSystem
  143194. * @returns DeviceType enum value
  143195. */
  143196. private _getGamepadDeviceType;
  143197. }
  143198. }
  143199. declare module BABYLON {
  143200. /**
  143201. * Type to handle enforcement of inputs
  143202. */
  143203. 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;
  143204. }
  143205. declare module BABYLON {
  143206. /**
  143207. * Class that handles all input for a specific device
  143208. */
  143209. export class DeviceSource<T extends DeviceType> {
  143210. /** Type of device */
  143211. readonly deviceType: DeviceType;
  143212. /** "Slot" or index that device is referenced in */
  143213. readonly deviceSlot: number;
  143214. /**
  143215. * Observable to handle device input changes per device
  143216. */
  143217. readonly onInputChangedObservable: Observable<{
  143218. inputIndex: DeviceInput<T>;
  143219. previousState: Nullable<number>;
  143220. currentState: Nullable<number>;
  143221. }>;
  143222. private readonly _deviceInputSystem;
  143223. /**
  143224. * Default Constructor
  143225. * @param deviceInputSystem Reference to DeviceInputSystem
  143226. * @param deviceType Type of device
  143227. * @param deviceSlot "Slot" or index that device is referenced in
  143228. */
  143229. constructor(deviceInputSystem: DeviceInputSystem,
  143230. /** Type of device */
  143231. deviceType: DeviceType,
  143232. /** "Slot" or index that device is referenced in */
  143233. deviceSlot?: number);
  143234. /**
  143235. * Get input for specific input
  143236. * @param inputIndex index of specific input on device
  143237. * @returns Input value from DeviceInputSystem
  143238. */
  143239. getInput(inputIndex: DeviceInput<T>): number;
  143240. }
  143241. /**
  143242. * Class to keep track of devices
  143243. */
  143244. export class DeviceSourceManager implements IDisposable {
  143245. /**
  143246. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  143247. */
  143248. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  143249. /**
  143250. * Observable to be triggered when after a device is disconnected
  143251. */
  143252. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  143253. private readonly _devices;
  143254. private readonly _firstDevice;
  143255. private readonly _deviceInputSystem;
  143256. /**
  143257. * Default Constructor
  143258. * @param engine engine to pull input element from
  143259. */
  143260. constructor(engine: Engine);
  143261. /**
  143262. * Gets a DeviceSource, given a type and slot
  143263. * @param deviceType Enum specifying device type
  143264. * @param deviceSlot "Slot" or index that device is referenced in
  143265. * @returns DeviceSource object
  143266. */
  143267. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  143268. /**
  143269. * Gets an array of DeviceSource objects for a given device type
  143270. * @param deviceType Enum specifying device type
  143271. * @returns Array of DeviceSource objects
  143272. */
  143273. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  143274. /**
  143275. * Returns a read-only list of all available devices
  143276. * @returns Read-only array with active devices
  143277. */
  143278. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  143279. /**
  143280. * Dispose of DeviceInputSystem and other parts
  143281. */
  143282. dispose(): void;
  143283. /**
  143284. * Function to add device name to device list
  143285. * @param deviceType Enum specifying device type
  143286. * @param deviceSlot "Slot" or index that device is referenced in
  143287. */
  143288. private _addDevice;
  143289. /**
  143290. * Function to remove device name to device list
  143291. * @param deviceType Enum specifying device type
  143292. * @param deviceSlot "Slot" or index that device is referenced in
  143293. */
  143294. private _removeDevice;
  143295. /**
  143296. * Updates array storing first connected device of each type
  143297. * @param type Type of Device
  143298. */
  143299. private _updateFirstDevices;
  143300. }
  143301. }
  143302. declare module BABYLON {
  143303. /**
  143304. * Options to create the null engine
  143305. */
  143306. export class NullEngineOptions {
  143307. /**
  143308. * Render width (Default: 512)
  143309. */
  143310. renderWidth: number;
  143311. /**
  143312. * Render height (Default: 256)
  143313. */
  143314. renderHeight: number;
  143315. /**
  143316. * Texture size (Default: 512)
  143317. */
  143318. textureSize: number;
  143319. /**
  143320. * If delta time between frames should be constant
  143321. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143322. */
  143323. deterministicLockstep: boolean;
  143324. /**
  143325. * Maximum about of steps between frames (Default: 4)
  143326. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143327. */
  143328. lockstepMaxSteps: number;
  143329. /**
  143330. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  143331. */
  143332. useHighPrecisionMatrix?: boolean;
  143333. }
  143334. /**
  143335. * The null engine class provides support for headless version of babylon.js.
  143336. * This can be used in server side scenario or for testing purposes
  143337. */
  143338. export class NullEngine extends Engine {
  143339. private _options;
  143340. /**
  143341. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  143342. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143343. * @returns true if engine is in deterministic lock step mode
  143344. */
  143345. isDeterministicLockStep(): boolean;
  143346. /**
  143347. * Gets the max steps when engine is running in deterministic lock step
  143348. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143349. * @returns the max steps
  143350. */
  143351. getLockstepMaxSteps(): number;
  143352. /**
  143353. * Gets the current hardware scaling level.
  143354. * By default the hardware scaling level is computed from the window device ratio.
  143355. * 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.
  143356. * @returns a number indicating the current hardware scaling level
  143357. */
  143358. getHardwareScalingLevel(): number;
  143359. constructor(options?: NullEngineOptions);
  143360. /**
  143361. * Creates a vertex buffer
  143362. * @param vertices the data for the vertex buffer
  143363. * @returns the new WebGL static buffer
  143364. */
  143365. createVertexBuffer(vertices: FloatArray): DataBuffer;
  143366. /**
  143367. * Creates a new index buffer
  143368. * @param indices defines the content of the index buffer
  143369. * @param updatable defines if the index buffer must be updatable
  143370. * @returns a new webGL buffer
  143371. */
  143372. createIndexBuffer(indices: IndicesArray): DataBuffer;
  143373. /**
  143374. * Clear the current render buffer or the current render target (if any is set up)
  143375. * @param color defines the color to use
  143376. * @param backBuffer defines if the back buffer must be cleared
  143377. * @param depth defines if the depth buffer must be cleared
  143378. * @param stencil defines if the stencil buffer must be cleared
  143379. */
  143380. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  143381. /**
  143382. * Gets the current render width
  143383. * @param useScreen defines if screen size must be used (or the current render target if any)
  143384. * @returns a number defining the current render width
  143385. */
  143386. getRenderWidth(useScreen?: boolean): number;
  143387. /**
  143388. * Gets the current render height
  143389. * @param useScreen defines if screen size must be used (or the current render target if any)
  143390. * @returns a number defining the current render height
  143391. */
  143392. getRenderHeight(useScreen?: boolean): number;
  143393. /**
  143394. * Set the WebGL's viewport
  143395. * @param viewport defines the viewport element to be used
  143396. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  143397. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  143398. */
  143399. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  143400. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  143401. /**
  143402. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  143403. * @param pipelineContext defines the pipeline context to use
  143404. * @param uniformsNames defines the list of uniform names
  143405. * @returns an array of webGL uniform locations
  143406. */
  143407. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  143408. /**
  143409. * Gets the lsit of active attributes for a given webGL program
  143410. * @param pipelineContext defines the pipeline context to use
  143411. * @param attributesNames defines the list of attribute names to get
  143412. * @returns an array of indices indicating the offset of each attribute
  143413. */
  143414. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  143415. /**
  143416. * Binds an effect to the webGL context
  143417. * @param effect defines the effect to bind
  143418. */
  143419. bindSamplers(effect: Effect): void;
  143420. /**
  143421. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  143422. * @param effect defines the effect to activate
  143423. */
  143424. enableEffect(effect: Effect): void;
  143425. /**
  143426. * Set various states to the webGL context
  143427. * @param culling defines backface culling state
  143428. * @param zOffset defines the value to apply to zOffset (0 by default)
  143429. * @param force defines if states must be applied even if cache is up to date
  143430. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  143431. */
  143432. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  143433. /**
  143434. * Set the value of an uniform to an array of int32
  143435. * @param uniform defines the webGL uniform location where to store the value
  143436. * @param array defines the array of int32 to store
  143437. * @returns true if value was set
  143438. */
  143439. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143440. /**
  143441. * Set the value of an uniform to an array of int32 (stored as vec2)
  143442. * @param uniform defines the webGL uniform location where to store the value
  143443. * @param array defines the array of int32 to store
  143444. * @returns true if value was set
  143445. */
  143446. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143447. /**
  143448. * Set the value of an uniform to an array of int32 (stored as vec3)
  143449. * @param uniform defines the webGL uniform location where to store the value
  143450. * @param array defines the array of int32 to store
  143451. * @returns true if value was set
  143452. */
  143453. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143454. /**
  143455. * Set the value of an uniform to an array of int32 (stored as vec4)
  143456. * @param uniform defines the webGL uniform location where to store the value
  143457. * @param array defines the array of int32 to store
  143458. * @returns true if value was set
  143459. */
  143460. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143461. /**
  143462. * Set the value of an uniform to an array of float32
  143463. * @param uniform defines the webGL uniform location where to store the value
  143464. * @param array defines the array of float32 to store
  143465. * @returns true if value was set
  143466. */
  143467. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143468. /**
  143469. * Set the value of an uniform to an array of float32 (stored as vec2)
  143470. * @param uniform defines the webGL uniform location where to store the value
  143471. * @param array defines the array of float32 to store
  143472. * @returns true if value was set
  143473. */
  143474. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143475. /**
  143476. * Set the value of an uniform to an array of float32 (stored as vec3)
  143477. * @param uniform defines the webGL uniform location where to store the value
  143478. * @param array defines the array of float32 to store
  143479. * @returns true if value was set
  143480. */
  143481. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143482. /**
  143483. * Set the value of an uniform to an array of float32 (stored as vec4)
  143484. * @param uniform defines the webGL uniform location where to store the value
  143485. * @param array defines the array of float32 to store
  143486. * @returns true if value was set
  143487. */
  143488. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143489. /**
  143490. * Set the value of an uniform to an array of number
  143491. * @param uniform defines the webGL uniform location where to store the value
  143492. * @param array defines the array of number to store
  143493. * @returns true if value was set
  143494. */
  143495. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  143496. /**
  143497. * Set the value of an uniform to an array of number (stored as vec2)
  143498. * @param uniform defines the webGL uniform location where to store the value
  143499. * @param array defines the array of number to store
  143500. * @returns true if value was set
  143501. */
  143502. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  143503. /**
  143504. * Set the value of an uniform to an array of number (stored as vec3)
  143505. * @param uniform defines the webGL uniform location where to store the value
  143506. * @param array defines the array of number to store
  143507. * @returns true if value was set
  143508. */
  143509. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  143510. /**
  143511. * Set the value of an uniform to an array of number (stored as vec4)
  143512. * @param uniform defines the webGL uniform location where to store the value
  143513. * @param array defines the array of number to store
  143514. * @returns true if value was set
  143515. */
  143516. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  143517. /**
  143518. * Set the value of an uniform to an array of float32 (stored as matrices)
  143519. * @param uniform defines the webGL uniform location where to store the value
  143520. * @param matrices defines the array of float32 to store
  143521. * @returns true if value was set
  143522. */
  143523. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  143524. /**
  143525. * Set the value of an uniform to a matrix (3x3)
  143526. * @param uniform defines the webGL uniform location where to store the value
  143527. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  143528. * @returns true if value was set
  143529. */
  143530. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  143531. /**
  143532. * Set the value of an uniform to a matrix (2x2)
  143533. * @param uniform defines the webGL uniform location where to store the value
  143534. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  143535. * @returns true if value was set
  143536. */
  143537. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  143538. /**
  143539. * Set the value of an uniform to a number (float)
  143540. * @param uniform defines the webGL uniform location where to store the value
  143541. * @param value defines the float number to store
  143542. * @returns true if value was set
  143543. */
  143544. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  143545. /**
  143546. * Set the value of an uniform to a vec2
  143547. * @param uniform defines the webGL uniform location where to store the value
  143548. * @param x defines the 1st component of the value
  143549. * @param y defines the 2nd component of the value
  143550. * @returns true if value was set
  143551. */
  143552. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  143553. /**
  143554. * Set the value of an uniform to a vec3
  143555. * @param uniform defines the webGL uniform location where to store the value
  143556. * @param x defines the 1st component of the value
  143557. * @param y defines the 2nd component of the value
  143558. * @param z defines the 3rd component of the value
  143559. * @returns true if value was set
  143560. */
  143561. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  143562. /**
  143563. * Set the value of an uniform to a boolean
  143564. * @param uniform defines the webGL uniform location where to store the value
  143565. * @param bool defines the boolean to store
  143566. * @returns true if value was set
  143567. */
  143568. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  143569. /**
  143570. * Set the value of an uniform to a vec4
  143571. * @param uniform defines the webGL uniform location where to store the value
  143572. * @param x defines the 1st component of the value
  143573. * @param y defines the 2nd component of the value
  143574. * @param z defines the 3rd component of the value
  143575. * @param w defines the 4th component of the value
  143576. * @returns true if value was set
  143577. */
  143578. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  143579. /**
  143580. * Sets the current alpha mode
  143581. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  143582. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  143583. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  143584. */
  143585. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  143586. /**
  143587. * Bind webGl buffers directly to the webGL context
  143588. * @param vertexBuffers defines the vertex buffer to bind
  143589. * @param indexBuffer defines the index buffer to bind
  143590. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  143591. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  143592. * @param effect defines the effect associated with the vertex buffer
  143593. */
  143594. bindBuffers(vertexBuffers: {
  143595. [key: string]: VertexBuffer;
  143596. }, indexBuffer: DataBuffer, effect: Effect): void;
  143597. /**
  143598. * Force the entire cache to be cleared
  143599. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  143600. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  143601. */
  143602. wipeCaches(bruteForce?: boolean): void;
  143603. /**
  143604. * Send a draw order
  143605. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  143606. * @param indexStart defines the starting index
  143607. * @param indexCount defines the number of index to draw
  143608. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  143609. */
  143610. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  143611. /**
  143612. * Draw a list of indexed primitives
  143613. * @param fillMode defines the primitive to use
  143614. * @param indexStart defines the starting index
  143615. * @param indexCount defines the number of index to draw
  143616. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  143617. */
  143618. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  143619. /**
  143620. * Draw a list of unindexed primitives
  143621. * @param fillMode defines the primitive to use
  143622. * @param verticesStart defines the index of first vertex to draw
  143623. * @param verticesCount defines the count of vertices to draw
  143624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  143625. */
  143626. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  143627. /** @hidden */
  143628. protected _createTexture(): WebGLTexture;
  143629. /** @hidden */
  143630. _releaseTexture(texture: InternalTexture): void;
  143631. /**
  143632. * Usually called from Texture.ts.
  143633. * Passed information to create a WebGLTexture
  143634. * @param urlArg defines a value which contains one of the following:
  143635. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  143636. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  143637. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  143638. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  143639. * @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)
  143640. * @param scene needed for loading to the correct scene
  143641. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  143642. * @param onLoad optional callback to be called upon successful completion
  143643. * @param onError optional callback to be called upon failure
  143644. * @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
  143645. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  143646. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  143647. * @param forcedExtension defines the extension to use to pick the right loader
  143648. * @param mimeType defines an optional mime type
  143649. * @returns a InternalTexture for assignment back into BABYLON.Texture
  143650. */
  143651. 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;
  143652. /**
  143653. * Creates a new render target texture
  143654. * @param size defines the size of the texture
  143655. * @param options defines the options used to create the texture
  143656. * @returns a new render target texture stored in an InternalTexture
  143657. */
  143658. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  143659. /**
  143660. * Update the sampling mode of a given texture
  143661. * @param samplingMode defines the required sampling mode
  143662. * @param texture defines the texture to update
  143663. */
  143664. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  143665. /**
  143666. * Binds the frame buffer to the specified texture.
  143667. * @param texture The texture to render to or null for the default canvas
  143668. * @param faceIndex The face of the texture to render to in case of cube texture
  143669. * @param requiredWidth The width of the target to render to
  143670. * @param requiredHeight The height of the target to render to
  143671. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  143672. * @param lodLevel defines le lod level to bind to the frame buffer
  143673. */
  143674. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  143675. /**
  143676. * Unbind the current render target texture from the webGL context
  143677. * @param texture defines the render target texture to unbind
  143678. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  143679. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  143680. */
  143681. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  143682. /**
  143683. * Creates a dynamic vertex buffer
  143684. * @param vertices the data for the dynamic vertex buffer
  143685. * @returns the new WebGL dynamic buffer
  143686. */
  143687. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  143688. /**
  143689. * Update the content of a dynamic texture
  143690. * @param texture defines the texture to update
  143691. * @param canvas defines the canvas containing the source
  143692. * @param invertY defines if data must be stored with Y axis inverted
  143693. * @param premulAlpha defines if alpha is stored as premultiplied
  143694. * @param format defines the format of the data
  143695. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  143696. */
  143697. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  143698. /**
  143699. * Gets a boolean indicating if all created effects are ready
  143700. * @returns true if all effects are ready
  143701. */
  143702. areAllEffectsReady(): boolean;
  143703. /**
  143704. * @hidden
  143705. * Get the current error code of the webGL context
  143706. * @returns the error code
  143707. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  143708. */
  143709. getError(): number;
  143710. /** @hidden */
  143711. _getUnpackAlignement(): number;
  143712. /** @hidden */
  143713. _unpackFlipY(value: boolean): void;
  143714. /**
  143715. * Update a dynamic index buffer
  143716. * @param indexBuffer defines the target index buffer
  143717. * @param indices defines the data to update
  143718. * @param offset defines the offset in the target index buffer where update should start
  143719. */
  143720. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  143721. /**
  143722. * Updates a dynamic vertex buffer.
  143723. * @param vertexBuffer the vertex buffer to update
  143724. * @param vertices the data used to update the vertex buffer
  143725. * @param byteOffset the byte offset of the data (optional)
  143726. * @param byteLength the byte length of the data (optional)
  143727. */
  143728. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  143729. /** @hidden */
  143730. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  143731. /** @hidden */
  143732. _bindTexture(channel: number, texture: InternalTexture): void;
  143733. protected _deleteBuffer(buffer: WebGLBuffer): void;
  143734. /**
  143735. * 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
  143736. */
  143737. releaseEffects(): void;
  143738. displayLoadingUI(): void;
  143739. hideLoadingUI(): void;
  143740. /** @hidden */
  143741. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  143742. /** @hidden */
  143743. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  143744. /** @hidden */
  143745. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  143746. /** @hidden */
  143747. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  143748. }
  143749. }
  143750. declare module BABYLON {
  143751. /** @hidden */
  143752. export class _OcclusionDataStorage {
  143753. /** @hidden */
  143754. occlusionInternalRetryCounter: number;
  143755. /** @hidden */
  143756. isOcclusionQueryInProgress: boolean;
  143757. /** @hidden */
  143758. isOccluded: boolean;
  143759. /** @hidden */
  143760. occlusionRetryCount: number;
  143761. /** @hidden */
  143762. occlusionType: number;
  143763. /** @hidden */
  143764. occlusionQueryAlgorithmType: number;
  143765. }
  143766. interface Engine {
  143767. /**
  143768. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  143769. * @return the new query
  143770. */
  143771. createQuery(): WebGLQuery;
  143772. /**
  143773. * Delete and release a webGL query
  143774. * @param query defines the query to delete
  143775. * @return the current engine
  143776. */
  143777. deleteQuery(query: WebGLQuery): Engine;
  143778. /**
  143779. * Check if a given query has resolved and got its value
  143780. * @param query defines the query to check
  143781. * @returns true if the query got its value
  143782. */
  143783. isQueryResultAvailable(query: WebGLQuery): boolean;
  143784. /**
  143785. * Gets the value of a given query
  143786. * @param query defines the query to check
  143787. * @returns the value of the query
  143788. */
  143789. getQueryResult(query: WebGLQuery): number;
  143790. /**
  143791. * Initiates an occlusion query
  143792. * @param algorithmType defines the algorithm to use
  143793. * @param query defines the query to use
  143794. * @returns the current engine
  143795. * @see https://doc.babylonjs.com/features/occlusionquery
  143796. */
  143797. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  143798. /**
  143799. * Ends an occlusion query
  143800. * @see https://doc.babylonjs.com/features/occlusionquery
  143801. * @param algorithmType defines the algorithm to use
  143802. * @returns the current engine
  143803. */
  143804. endOcclusionQuery(algorithmType: number): Engine;
  143805. /**
  143806. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  143807. * Please note that only one query can be issued at a time
  143808. * @returns a time token used to track the time span
  143809. */
  143810. startTimeQuery(): Nullable<_TimeToken>;
  143811. /**
  143812. * Ends a time query
  143813. * @param token defines the token used to measure the time span
  143814. * @returns the time spent (in ns)
  143815. */
  143816. endTimeQuery(token: _TimeToken): int;
  143817. /** @hidden */
  143818. _currentNonTimestampToken: Nullable<_TimeToken>;
  143819. /** @hidden */
  143820. _createTimeQuery(): WebGLQuery;
  143821. /** @hidden */
  143822. _deleteTimeQuery(query: WebGLQuery): void;
  143823. /** @hidden */
  143824. _getGlAlgorithmType(algorithmType: number): number;
  143825. /** @hidden */
  143826. _getTimeQueryResult(query: WebGLQuery): any;
  143827. /** @hidden */
  143828. _getTimeQueryAvailability(query: WebGLQuery): any;
  143829. }
  143830. interface AbstractMesh {
  143831. /**
  143832. * Backing filed
  143833. * @hidden
  143834. */
  143835. __occlusionDataStorage: _OcclusionDataStorage;
  143836. /**
  143837. * Access property
  143838. * @hidden
  143839. */
  143840. _occlusionDataStorage: _OcclusionDataStorage;
  143841. /**
  143842. * 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.
  143843. * The default value is -1 which means don't break the query and wait till the result
  143844. * @see https://doc.babylonjs.com/features/occlusionquery
  143845. */
  143846. occlusionRetryCount: number;
  143847. /**
  143848. * 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:
  143849. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  143850. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  143851. * * 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.
  143852. * @see https://doc.babylonjs.com/features/occlusionquery
  143853. */
  143854. occlusionType: number;
  143855. /**
  143856. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  143857. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  143858. * * 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.
  143859. * @see https://doc.babylonjs.com/features/occlusionquery
  143860. */
  143861. occlusionQueryAlgorithmType: number;
  143862. /**
  143863. * 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
  143864. * @see https://doc.babylonjs.com/features/occlusionquery
  143865. */
  143866. isOccluded: boolean;
  143867. /**
  143868. * Flag to check the progress status of the query
  143869. * @see https://doc.babylonjs.com/features/occlusionquery
  143870. */
  143871. isOcclusionQueryInProgress: boolean;
  143872. }
  143873. }
  143874. declare module BABYLON {
  143875. /** @hidden */
  143876. export var _forceTransformFeedbackToBundle: boolean;
  143877. interface Engine {
  143878. /**
  143879. * Creates a webGL transform feedback object
  143880. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  143881. * @returns the webGL transform feedback object
  143882. */
  143883. createTransformFeedback(): WebGLTransformFeedback;
  143884. /**
  143885. * Delete a webGL transform feedback object
  143886. * @param value defines the webGL transform feedback object to delete
  143887. */
  143888. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  143889. /**
  143890. * Bind a webGL transform feedback object to the webgl context
  143891. * @param value defines the webGL transform feedback object to bind
  143892. */
  143893. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  143894. /**
  143895. * Begins a transform feedback operation
  143896. * @param usePoints defines if points or triangles must be used
  143897. */
  143898. beginTransformFeedback(usePoints: boolean): void;
  143899. /**
  143900. * Ends a transform feedback operation
  143901. */
  143902. endTransformFeedback(): void;
  143903. /**
  143904. * Specify the varyings to use with transform feedback
  143905. * @param program defines the associated webGL program
  143906. * @param value defines the list of strings representing the varying names
  143907. */
  143908. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  143909. /**
  143910. * Bind a webGL buffer for a transform feedback operation
  143911. * @param value defines the webGL buffer to bind
  143912. */
  143913. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  143914. }
  143915. }
  143916. declare module BABYLON {
  143917. /**
  143918. * Class used to define an additional view for the engine
  143919. * @see https://doc.babylonjs.com/how_to/multi_canvases
  143920. */
  143921. export class EngineView {
  143922. /** Defines the canvas where to render the view */
  143923. target: HTMLCanvasElement;
  143924. /** Defines an optional camera used to render the view (will use active camera else) */
  143925. camera?: Camera;
  143926. }
  143927. interface Engine {
  143928. /**
  143929. * Gets or sets the HTML element to use for attaching events
  143930. */
  143931. inputElement: Nullable<HTMLElement>;
  143932. /**
  143933. * Gets the current engine view
  143934. * @see https://doc.babylonjs.com/how_to/multi_canvases
  143935. */
  143936. activeView: Nullable<EngineView>;
  143937. /** Gets or sets the list of views */
  143938. views: EngineView[];
  143939. /**
  143940. * Register a new child canvas
  143941. * @param canvas defines the canvas to register
  143942. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  143943. * @returns the associated view
  143944. */
  143945. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  143946. /**
  143947. * Remove a registered child canvas
  143948. * @param canvas defines the canvas to remove
  143949. * @returns the current engine
  143950. */
  143951. unRegisterView(canvas: HTMLCanvasElement): Engine;
  143952. }
  143953. }
  143954. declare module BABYLON {
  143955. interface Engine {
  143956. /** @hidden */
  143957. _excludedCompressedTextures: string[];
  143958. /** @hidden */
  143959. _textureFormatInUse: string;
  143960. /**
  143961. * Gets the list of texture formats supported
  143962. */
  143963. readonly texturesSupported: Array<string>;
  143964. /**
  143965. * Gets the texture format in use
  143966. */
  143967. readonly textureFormatInUse: Nullable<string>;
  143968. /**
  143969. * Set the compressed texture extensions or file names to skip.
  143970. *
  143971. * @param skippedFiles defines the list of those texture files you want to skip
  143972. * Example: [".dds", ".env", "myfile.png"]
  143973. */
  143974. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  143975. /**
  143976. * Set the compressed texture format to use, based on the formats you have, and the formats
  143977. * supported by the hardware / browser.
  143978. *
  143979. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  143980. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  143981. * to API arguments needed to compressed textures. This puts the burden on the container
  143982. * generator to house the arcane code for determining these for current & future formats.
  143983. *
  143984. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  143985. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  143986. *
  143987. * Note: The result of this call is not taken into account when a texture is base64.
  143988. *
  143989. * @param formatsAvailable defines the list of those format families you have created
  143990. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  143991. *
  143992. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  143993. * @returns The extension selected.
  143994. */
  143995. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  143996. }
  143997. }
  143998. declare module BABYLON {
  143999. /** @hidden */
  144000. export var rgbdEncodePixelShader: {
  144001. name: string;
  144002. shader: string;
  144003. };
  144004. }
  144005. declare module BABYLON {
  144006. /**
  144007. * Raw texture data and descriptor sufficient for WebGL texture upload
  144008. */
  144009. export interface EnvironmentTextureInfo {
  144010. /**
  144011. * Version of the environment map
  144012. */
  144013. version: number;
  144014. /**
  144015. * Width of image
  144016. */
  144017. width: number;
  144018. /**
  144019. * Irradiance information stored in the file.
  144020. */
  144021. irradiance: any;
  144022. /**
  144023. * Specular information stored in the file.
  144024. */
  144025. specular: any;
  144026. }
  144027. /**
  144028. * Defines One Image in the file. It requires only the position in the file
  144029. * as well as the length.
  144030. */
  144031. interface BufferImageData {
  144032. /**
  144033. * Length of the image data.
  144034. */
  144035. length: number;
  144036. /**
  144037. * Position of the data from the null terminator delimiting the end of the JSON.
  144038. */
  144039. position: number;
  144040. }
  144041. /**
  144042. * Defines the specular data enclosed in the file.
  144043. * This corresponds to the version 1 of the data.
  144044. */
  144045. export interface EnvironmentTextureSpecularInfoV1 {
  144046. /**
  144047. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  144048. */
  144049. specularDataPosition?: number;
  144050. /**
  144051. * This contains all the images data needed to reconstruct the cubemap.
  144052. */
  144053. mipmaps: Array<BufferImageData>;
  144054. /**
  144055. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  144056. */
  144057. lodGenerationScale: number;
  144058. }
  144059. /**
  144060. * Sets of helpers addressing the serialization and deserialization of environment texture
  144061. * stored in a BabylonJS env file.
  144062. * Those files are usually stored as .env files.
  144063. */
  144064. export class EnvironmentTextureTools {
  144065. /**
  144066. * Magic number identifying the env file.
  144067. */
  144068. private static _MagicBytes;
  144069. /**
  144070. * Gets the environment info from an env file.
  144071. * @param data The array buffer containing the .env bytes.
  144072. * @returns the environment file info (the json header) if successfully parsed.
  144073. */
  144074. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  144075. /**
  144076. * Creates an environment texture from a loaded cube texture.
  144077. * @param texture defines the cube texture to convert in env file
  144078. * @return a promise containing the environment data if succesfull.
  144079. */
  144080. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  144081. /**
  144082. * Creates a JSON representation of the spherical data.
  144083. * @param texture defines the texture containing the polynomials
  144084. * @return the JSON representation of the spherical info
  144085. */
  144086. private static _CreateEnvTextureIrradiance;
  144087. /**
  144088. * Creates the ArrayBufferViews used for initializing environment texture image data.
  144089. * @param data the image data
  144090. * @param info parameters that determine what views will be created for accessing the underlying buffer
  144091. * @return the views described by info providing access to the underlying buffer
  144092. */
  144093. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  144094. /**
  144095. * Uploads the texture info contained in the env file to the GPU.
  144096. * @param texture defines the internal texture to upload to
  144097. * @param data defines the data to load
  144098. * @param info defines the texture info retrieved through the GetEnvInfo method
  144099. * @returns a promise
  144100. */
  144101. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  144102. private static _OnImageReadyAsync;
  144103. /**
  144104. * Uploads the levels of image data to the GPU.
  144105. * @param texture defines the internal texture to upload to
  144106. * @param imageData defines the array buffer views of image data [mipmap][face]
  144107. * @returns a promise
  144108. */
  144109. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  144110. /**
  144111. * Uploads spherical polynomials information to the texture.
  144112. * @param texture defines the texture we are trying to upload the information to
  144113. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  144114. */
  144115. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  144116. /** @hidden */
  144117. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144118. }
  144119. }
  144120. declare module BABYLON {
  144121. /**
  144122. * Container for accessors for natively-stored mesh data buffers.
  144123. */
  144124. class NativeDataBuffer extends DataBuffer {
  144125. /**
  144126. * Accessor value used to identify/retrieve a natively-stored index buffer.
  144127. */
  144128. nativeIndexBuffer?: any;
  144129. /**
  144130. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  144131. */
  144132. nativeVertexBuffer?: any;
  144133. }
  144134. /** @hidden */
  144135. class NativeTexture extends InternalTexture {
  144136. getInternalTexture(): InternalTexture;
  144137. getViewCount(): number;
  144138. }
  144139. /** @hidden */
  144140. export class NativeEngine extends Engine {
  144141. private readonly _native;
  144142. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  144143. private readonly INVALID_HANDLE;
  144144. private _boundBuffersVertexArray;
  144145. private _currentDepthTest;
  144146. getHardwareScalingLevel(): number;
  144147. constructor();
  144148. dispose(): void;
  144149. /**
  144150. * Can be used to override the current requestAnimationFrame requester.
  144151. * @hidden
  144152. */
  144153. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  144154. /**
  144155. * Override default engine behavior.
  144156. * @param color
  144157. * @param backBuffer
  144158. * @param depth
  144159. * @param stencil
  144160. */
  144161. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  144162. /**
  144163. * Gets host document
  144164. * @returns the host document object
  144165. */
  144166. getHostDocument(): Nullable<Document>;
  144167. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  144168. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  144169. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  144170. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  144171. [key: string]: VertexBuffer;
  144172. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  144173. bindBuffers(vertexBuffers: {
  144174. [key: string]: VertexBuffer;
  144175. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  144176. recordVertexArrayObject(vertexBuffers: {
  144177. [key: string]: VertexBuffer;
  144178. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  144179. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  144180. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  144181. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  144182. /**
  144183. * Draw a list of indexed primitives
  144184. * @param fillMode defines the primitive to use
  144185. * @param indexStart defines the starting index
  144186. * @param indexCount defines the number of index to draw
  144187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144188. */
  144189. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  144190. /**
  144191. * Draw a list of unindexed primitives
  144192. * @param fillMode defines the primitive to use
  144193. * @param verticesStart defines the index of first vertex to draw
  144194. * @param verticesCount defines the count of vertices to draw
  144195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144196. */
  144197. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  144198. createPipelineContext(): IPipelineContext;
  144199. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  144200. /** @hidden */
  144201. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  144202. /** @hidden */
  144203. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  144204. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  144205. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  144206. protected _setProgram(program: WebGLProgram): void;
  144207. _releaseEffect(effect: Effect): void;
  144208. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  144209. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  144210. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  144211. bindSamplers(effect: Effect): void;
  144212. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  144213. getRenderWidth(useScreen?: boolean): number;
  144214. getRenderHeight(useScreen?: boolean): number;
  144215. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  144216. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  144217. /**
  144218. * Set the z offset to apply to current rendering
  144219. * @param value defines the offset to apply
  144220. */
  144221. setZOffset(value: number): void;
  144222. /**
  144223. * Gets the current value of the zOffset
  144224. * @returns the current zOffset state
  144225. */
  144226. getZOffset(): number;
  144227. /**
  144228. * Enable or disable depth buffering
  144229. * @param enable defines the state to set
  144230. */
  144231. setDepthBuffer(enable: boolean): void;
  144232. /**
  144233. * Gets a boolean indicating if depth writing is enabled
  144234. * @returns the current depth writing state
  144235. */
  144236. getDepthWrite(): boolean;
  144237. setDepthFunctionToGreater(): void;
  144238. setDepthFunctionToGreaterOrEqual(): void;
  144239. setDepthFunctionToLess(): void;
  144240. setDepthFunctionToLessOrEqual(): void;
  144241. /**
  144242. * Enable or disable depth writing
  144243. * @param enable defines the state to set
  144244. */
  144245. setDepthWrite(enable: boolean): void;
  144246. /**
  144247. * Enable or disable color writing
  144248. * @param enable defines the state to set
  144249. */
  144250. setColorWrite(enable: boolean): void;
  144251. /**
  144252. * Gets a boolean indicating if color writing is enabled
  144253. * @returns the current color writing state
  144254. */
  144255. getColorWrite(): boolean;
  144256. /**
  144257. * Sets alpha constants used by some alpha blending modes
  144258. * @param r defines the red component
  144259. * @param g defines the green component
  144260. * @param b defines the blue component
  144261. * @param a defines the alpha component
  144262. */
  144263. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  144264. /**
  144265. * Sets the current alpha mode
  144266. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  144267. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  144268. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144269. */
  144270. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  144271. /**
  144272. * Gets the current alpha mode
  144273. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144274. * @returns the current alpha mode
  144275. */
  144276. getAlphaMode(): number;
  144277. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  144278. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144279. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144280. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144281. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144282. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144283. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144284. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144285. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144286. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  144287. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  144288. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  144289. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  144290. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  144291. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144292. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144293. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  144294. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  144295. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  144296. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  144297. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  144298. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  144299. wipeCaches(bruteForce?: boolean): void;
  144300. protected _createTexture(): WebGLTexture;
  144301. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  144302. /**
  144303. * Update the content of a dynamic texture
  144304. * @param texture defines the texture to update
  144305. * @param canvas defines the canvas containing the source
  144306. * @param invertY defines if data must be stored with Y axis inverted
  144307. * @param premulAlpha defines if alpha is stored as premultiplied
  144308. * @param format defines the format of the data
  144309. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  144310. */
  144311. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  144312. /**
  144313. * Usually called from Texture.ts.
  144314. * Passed information to create a WebGLTexture
  144315. * @param url defines a value which contains one of the following:
  144316. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  144317. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  144318. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  144319. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  144320. * @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)
  144321. * @param scene needed for loading to the correct scene
  144322. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  144323. * @param onLoad optional callback to be called upon successful completion
  144324. * @param onError optional callback to be called upon failure
  144325. * @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
  144326. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  144327. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  144328. * @param forcedExtension defines the extension to use to pick the right loader
  144329. * @param mimeType defines an optional mime type
  144330. * @param loaderOptions options to be passed to the loader
  144331. * @returns a InternalTexture for assignment back into BABYLON.Texture
  144332. */
  144333. 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;
  144334. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  144335. _releaseFramebufferObjects(texture: InternalTexture): void;
  144336. /**
  144337. * Creates a cube texture
  144338. * @param rootUrl defines the url where the files to load is located
  144339. * @param scene defines the current scene
  144340. * @param files defines the list of files to load (1 per face)
  144341. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  144342. * @param onLoad defines an optional callback raised when the texture is loaded
  144343. * @param onError defines an optional callback raised if there is an issue to load the texture
  144344. * @param format defines the format of the data
  144345. * @param forcedExtension defines the extension to use to pick the right loader
  144346. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  144347. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144348. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144349. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  144350. * @returns the cube texture as an InternalTexture
  144351. */
  144352. 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;
  144353. createRenderTargetTexture(size: number | {
  144354. width: number;
  144355. height: number;
  144356. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  144357. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  144358. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  144359. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  144360. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  144361. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  144362. /**
  144363. * Updates a dynamic vertex buffer.
  144364. * @param vertexBuffer the vertex buffer to update
  144365. * @param data the data used to update the vertex buffer
  144366. * @param byteOffset the byte offset of the data (optional)
  144367. * @param byteLength the byte length of the data (optional)
  144368. */
  144369. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  144370. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  144371. private _updateAnisotropicLevel;
  144372. private _getAddressMode;
  144373. /** @hidden */
  144374. _bindTexture(channel: number, texture: InternalTexture): void;
  144375. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  144376. releaseEffects(): void;
  144377. /** @hidden */
  144378. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144379. /** @hidden */
  144380. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144381. /** @hidden */
  144382. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144383. /** @hidden */
  144384. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  144385. private _getNativeSamplingMode;
  144386. private _getNativeTextureFormat;
  144387. private _getNativeAlphaMode;
  144388. private _getNativeAttribType;
  144389. }
  144390. }
  144391. declare module BABYLON {
  144392. /**
  144393. * Gather the list of clipboard event types as constants.
  144394. */
  144395. export class ClipboardEventTypes {
  144396. /**
  144397. * The clipboard event is fired when a copy command is active (pressed).
  144398. */
  144399. static readonly COPY: number;
  144400. /**
  144401. * The clipboard event is fired when a cut command is active (pressed).
  144402. */
  144403. static readonly CUT: number;
  144404. /**
  144405. * The clipboard event is fired when a paste command is active (pressed).
  144406. */
  144407. static readonly PASTE: number;
  144408. }
  144409. /**
  144410. * This class is used to store clipboard related info for the onClipboardObservable event.
  144411. */
  144412. export class ClipboardInfo {
  144413. /**
  144414. * Defines the type of event (BABYLON.ClipboardEventTypes)
  144415. */
  144416. type: number;
  144417. /**
  144418. * Defines the related dom event
  144419. */
  144420. event: ClipboardEvent;
  144421. /**
  144422. *Creates an instance of ClipboardInfo.
  144423. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  144424. * @param event Defines the related dom event
  144425. */
  144426. constructor(
  144427. /**
  144428. * Defines the type of event (BABYLON.ClipboardEventTypes)
  144429. */
  144430. type: number,
  144431. /**
  144432. * Defines the related dom event
  144433. */
  144434. event: ClipboardEvent);
  144435. /**
  144436. * Get the clipboard event's type from the keycode.
  144437. * @param keyCode Defines the keyCode for the current keyboard event.
  144438. * @return {number}
  144439. */
  144440. static GetTypeFromCharacter(keyCode: number): number;
  144441. }
  144442. }
  144443. declare module BABYLON {
  144444. /**
  144445. * Google Daydream controller
  144446. */
  144447. export class DaydreamController extends WebVRController {
  144448. /**
  144449. * Base Url for the controller model.
  144450. */
  144451. static MODEL_BASE_URL: string;
  144452. /**
  144453. * File name for the controller model.
  144454. */
  144455. static MODEL_FILENAME: string;
  144456. /**
  144457. * Gamepad Id prefix used to identify Daydream Controller.
  144458. */
  144459. static readonly GAMEPAD_ID_PREFIX: string;
  144460. /**
  144461. * Creates a new DaydreamController from a gamepad
  144462. * @param vrGamepad the gamepad that the controller should be created from
  144463. */
  144464. constructor(vrGamepad: any);
  144465. /**
  144466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144467. * @param scene scene in which to add meshes
  144468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144469. */
  144470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144471. /**
  144472. * Called once for each button that changed state since the last frame
  144473. * @param buttonIdx Which button index changed
  144474. * @param state New state of the button
  144475. * @param changes Which properties on the state changed since last frame
  144476. */
  144477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144478. }
  144479. }
  144480. declare module BABYLON {
  144481. /**
  144482. * Gear VR Controller
  144483. */
  144484. export class GearVRController extends WebVRController {
  144485. /**
  144486. * Base Url for the controller model.
  144487. */
  144488. static MODEL_BASE_URL: string;
  144489. /**
  144490. * File name for the controller model.
  144491. */
  144492. static MODEL_FILENAME: string;
  144493. /**
  144494. * Gamepad Id prefix used to identify this controller.
  144495. */
  144496. static readonly GAMEPAD_ID_PREFIX: string;
  144497. private readonly _buttonIndexToObservableNameMap;
  144498. /**
  144499. * Creates a new GearVRController from a gamepad
  144500. * @param vrGamepad the gamepad that the controller should be created from
  144501. */
  144502. constructor(vrGamepad: any);
  144503. /**
  144504. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144505. * @param scene scene in which to add meshes
  144506. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144507. */
  144508. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144509. /**
  144510. * Called once for each button that changed state since the last frame
  144511. * @param buttonIdx Which button index changed
  144512. * @param state New state of the button
  144513. * @param changes Which properties on the state changed since last frame
  144514. */
  144515. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144516. }
  144517. }
  144518. declare module BABYLON {
  144519. /**
  144520. * Generic Controller
  144521. */
  144522. export class GenericController extends WebVRController {
  144523. /**
  144524. * Base Url for the controller model.
  144525. */
  144526. static readonly MODEL_BASE_URL: string;
  144527. /**
  144528. * File name for the controller model.
  144529. */
  144530. static readonly MODEL_FILENAME: string;
  144531. /**
  144532. * Creates a new GenericController from a gamepad
  144533. * @param vrGamepad the gamepad that the controller should be created from
  144534. */
  144535. constructor(vrGamepad: any);
  144536. /**
  144537. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144538. * @param scene scene in which to add meshes
  144539. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144540. */
  144541. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144542. /**
  144543. * Called once for each button that changed state since the last frame
  144544. * @param buttonIdx Which button index changed
  144545. * @param state New state of the button
  144546. * @param changes Which properties on the state changed since last frame
  144547. */
  144548. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144549. }
  144550. }
  144551. declare module BABYLON {
  144552. /**
  144553. * Oculus Touch Controller
  144554. */
  144555. export class OculusTouchController extends WebVRController {
  144556. /**
  144557. * Base Url for the controller model.
  144558. */
  144559. static MODEL_BASE_URL: string;
  144560. /**
  144561. * File name for the left controller model.
  144562. */
  144563. static MODEL_LEFT_FILENAME: string;
  144564. /**
  144565. * File name for the right controller model.
  144566. */
  144567. static MODEL_RIGHT_FILENAME: string;
  144568. /**
  144569. * Base Url for the Quest controller model.
  144570. */
  144571. static QUEST_MODEL_BASE_URL: string;
  144572. /**
  144573. * @hidden
  144574. * If the controllers are running on a device that needs the updated Quest controller models
  144575. */
  144576. static _IsQuest: boolean;
  144577. /**
  144578. * Fired when the secondary trigger on this controller is modified
  144579. */
  144580. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  144581. /**
  144582. * Fired when the thumb rest on this controller is modified
  144583. */
  144584. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  144585. /**
  144586. * Creates a new OculusTouchController from a gamepad
  144587. * @param vrGamepad the gamepad that the controller should be created from
  144588. */
  144589. constructor(vrGamepad: any);
  144590. /**
  144591. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144592. * @param scene scene in which to add meshes
  144593. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144594. */
  144595. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144596. /**
  144597. * Fired when the A button on this controller is modified
  144598. */
  144599. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144600. /**
  144601. * Fired when the B button on this controller is modified
  144602. */
  144603. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144604. /**
  144605. * Fired when the X button on this controller is modified
  144606. */
  144607. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144608. /**
  144609. * Fired when the Y button on this controller is modified
  144610. */
  144611. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144612. /**
  144613. * Called once for each button that changed state since the last frame
  144614. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  144615. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  144616. * 2) secondary trigger (same)
  144617. * 3) A (right) X (left), touch, pressed = value
  144618. * 4) B / Y
  144619. * 5) thumb rest
  144620. * @param buttonIdx Which button index changed
  144621. * @param state New state of the button
  144622. * @param changes Which properties on the state changed since last frame
  144623. */
  144624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144625. }
  144626. }
  144627. declare module BABYLON {
  144628. /**
  144629. * Vive Controller
  144630. */
  144631. export class ViveController extends WebVRController {
  144632. /**
  144633. * Base Url for the controller model.
  144634. */
  144635. static MODEL_BASE_URL: string;
  144636. /**
  144637. * File name for the controller model.
  144638. */
  144639. static MODEL_FILENAME: string;
  144640. /**
  144641. * Creates a new ViveController from a gamepad
  144642. * @param vrGamepad the gamepad that the controller should be created from
  144643. */
  144644. constructor(vrGamepad: any);
  144645. /**
  144646. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144647. * @param scene scene in which to add meshes
  144648. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144649. */
  144650. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144651. /**
  144652. * Fired when the left button on this controller is modified
  144653. */
  144654. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144655. /**
  144656. * Fired when the right button on this controller is modified
  144657. */
  144658. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144659. /**
  144660. * Fired when the menu button on this controller is modified
  144661. */
  144662. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144663. /**
  144664. * Called once for each button that changed state since the last frame
  144665. * Vive mapping:
  144666. * 0: touchpad
  144667. * 1: trigger
  144668. * 2: left AND right buttons
  144669. * 3: menu button
  144670. * @param buttonIdx Which button index changed
  144671. * @param state New state of the button
  144672. * @param changes Which properties on the state changed since last frame
  144673. */
  144674. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144675. }
  144676. }
  144677. declare module BABYLON {
  144678. /**
  144679. * Defines the WindowsMotionController object that the state of the windows motion controller
  144680. */
  144681. export class WindowsMotionController extends WebVRController {
  144682. /**
  144683. * The base url used to load the left and right controller models
  144684. */
  144685. static MODEL_BASE_URL: string;
  144686. /**
  144687. * The name of the left controller model file
  144688. */
  144689. static MODEL_LEFT_FILENAME: string;
  144690. /**
  144691. * The name of the right controller model file
  144692. */
  144693. static MODEL_RIGHT_FILENAME: string;
  144694. /**
  144695. * The controller name prefix for this controller type
  144696. */
  144697. static readonly GAMEPAD_ID_PREFIX: string;
  144698. /**
  144699. * The controller id pattern for this controller type
  144700. */
  144701. private static readonly GAMEPAD_ID_PATTERN;
  144702. private _loadedMeshInfo;
  144703. protected readonly _mapping: {
  144704. buttons: string[];
  144705. buttonMeshNames: {
  144706. trigger: string;
  144707. menu: string;
  144708. grip: string;
  144709. thumbstick: string;
  144710. trackpad: string;
  144711. };
  144712. buttonObservableNames: {
  144713. trigger: string;
  144714. menu: string;
  144715. grip: string;
  144716. thumbstick: string;
  144717. trackpad: string;
  144718. };
  144719. axisMeshNames: string[];
  144720. pointingPoseMeshName: string;
  144721. };
  144722. /**
  144723. * Fired when the trackpad on this controller is clicked
  144724. */
  144725. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  144726. /**
  144727. * Fired when the trackpad on this controller is modified
  144728. */
  144729. onTrackpadValuesChangedObservable: Observable<StickValues>;
  144730. /**
  144731. * The current x and y values of this controller's trackpad
  144732. */
  144733. trackpad: StickValues;
  144734. /**
  144735. * Creates a new WindowsMotionController from a gamepad
  144736. * @param vrGamepad the gamepad that the controller should be created from
  144737. */
  144738. constructor(vrGamepad: any);
  144739. /**
  144740. * Fired when the trigger on this controller is modified
  144741. */
  144742. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144743. /**
  144744. * Fired when the menu button on this controller is modified
  144745. */
  144746. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144747. /**
  144748. * Fired when the grip button on this controller is modified
  144749. */
  144750. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144751. /**
  144752. * Fired when the thumbstick button on this controller is modified
  144753. */
  144754. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144755. /**
  144756. * Fired when the touchpad button on this controller is modified
  144757. */
  144758. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144759. /**
  144760. * Fired when the touchpad values on this controller are modified
  144761. */
  144762. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  144763. protected _updateTrackpad(): void;
  144764. /**
  144765. * Called once per frame by the engine.
  144766. */
  144767. update(): void;
  144768. /**
  144769. * Called once for each button that changed state since the last frame
  144770. * @param buttonIdx Which button index changed
  144771. * @param state New state of the button
  144772. * @param changes Which properties on the state changed since last frame
  144773. */
  144774. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144775. /**
  144776. * Moves the buttons on the controller mesh based on their current state
  144777. * @param buttonName the name of the button to move
  144778. * @param buttonValue the value of the button which determines the buttons new position
  144779. */
  144780. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  144781. /**
  144782. * Moves the axis on the controller mesh based on its current state
  144783. * @param axis the index of the axis
  144784. * @param axisValue the value of the axis which determines the meshes new position
  144785. * @hidden
  144786. */
  144787. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  144788. /**
  144789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144790. * @param scene scene in which to add meshes
  144791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144792. */
  144793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  144794. /**
  144795. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  144796. * can be transformed by button presses and axes values, based on this._mapping.
  144797. *
  144798. * @param scene scene in which the meshes exist
  144799. * @param meshes list of meshes that make up the controller model to process
  144800. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  144801. */
  144802. private processModel;
  144803. private createMeshInfo;
  144804. /**
  144805. * Gets the ray of the controller in the direction the controller is pointing
  144806. * @param length the length the resulting ray should be
  144807. * @returns a ray in the direction the controller is pointing
  144808. */
  144809. getForwardRay(length?: number): Ray;
  144810. /**
  144811. * Disposes of the controller
  144812. */
  144813. dispose(): void;
  144814. }
  144815. /**
  144816. * This class represents a new windows motion controller in XR.
  144817. */
  144818. export class XRWindowsMotionController extends WindowsMotionController {
  144819. /**
  144820. * Changing the original WIndowsMotionController mapping to fir the new mapping
  144821. */
  144822. protected readonly _mapping: {
  144823. buttons: string[];
  144824. buttonMeshNames: {
  144825. trigger: string;
  144826. menu: string;
  144827. grip: string;
  144828. thumbstick: string;
  144829. trackpad: string;
  144830. };
  144831. buttonObservableNames: {
  144832. trigger: string;
  144833. menu: string;
  144834. grip: string;
  144835. thumbstick: string;
  144836. trackpad: string;
  144837. };
  144838. axisMeshNames: string[];
  144839. pointingPoseMeshName: string;
  144840. };
  144841. /**
  144842. * Construct a new XR-Based windows motion controller
  144843. *
  144844. * @param gamepadInfo the gamepad object from the browser
  144845. */
  144846. constructor(gamepadInfo: any);
  144847. /**
  144848. * holds the thumbstick values (X,Y)
  144849. */
  144850. thumbstickValues: StickValues;
  144851. /**
  144852. * Fired when the thumbstick on this controller is clicked
  144853. */
  144854. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  144855. /**
  144856. * Fired when the thumbstick on this controller is modified
  144857. */
  144858. onThumbstickValuesChangedObservable: Observable<StickValues>;
  144859. /**
  144860. * Fired when the touchpad button on this controller is modified
  144861. */
  144862. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  144863. /**
  144864. * Fired when the touchpad values on this controller are modified
  144865. */
  144866. onTrackpadValuesChangedObservable: Observable<StickValues>;
  144867. /**
  144868. * Fired when the thumbstick button on this controller is modified
  144869. * here to prevent breaking changes
  144870. */
  144871. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144872. /**
  144873. * updating the thumbstick(!) and not the trackpad.
  144874. * This is named this way due to the difference between WebVR and XR and to avoid
  144875. * changing the parent class.
  144876. */
  144877. protected _updateTrackpad(): void;
  144878. /**
  144879. * Disposes the class with joy
  144880. */
  144881. dispose(): void;
  144882. }
  144883. }
  144884. declare module BABYLON {
  144885. /**
  144886. * A directional light is defined by a direction (what a surprise!).
  144887. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  144888. * 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.
  144889. * Documentation: https://doc.babylonjs.com/babylon101/lights
  144890. */
  144891. export class DirectionalLight extends ShadowLight {
  144892. private _shadowFrustumSize;
  144893. /**
  144894. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  144895. */
  144896. get shadowFrustumSize(): number;
  144897. /**
  144898. * Specifies a fix frustum size for the shadow generation.
  144899. */
  144900. set shadowFrustumSize(value: number);
  144901. private _shadowOrthoScale;
  144902. /**
  144903. * Gets the shadow projection scale against the optimal computed one.
  144904. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  144905. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  144906. */
  144907. get shadowOrthoScale(): number;
  144908. /**
  144909. * Sets the shadow projection scale against the optimal computed one.
  144910. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  144911. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  144912. */
  144913. set shadowOrthoScale(value: number);
  144914. /**
  144915. * Automatically compute the projection matrix to best fit (including all the casters)
  144916. * on each frame.
  144917. */
  144918. autoUpdateExtends: boolean;
  144919. /**
  144920. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  144921. * on each frame. autoUpdateExtends must be set to true for this to work
  144922. */
  144923. autoCalcShadowZBounds: boolean;
  144924. private _orthoLeft;
  144925. private _orthoRight;
  144926. private _orthoTop;
  144927. private _orthoBottom;
  144928. /**
  144929. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  144930. * The directional light is emitted from everywhere in the given direction.
  144931. * It can cast shadows.
  144932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  144933. * @param name The friendly name of the light
  144934. * @param direction The direction of the light
  144935. * @param scene The scene the light belongs to
  144936. */
  144937. constructor(name: string, direction: Vector3, scene: Scene);
  144938. /**
  144939. * Returns the string "DirectionalLight".
  144940. * @return The class name
  144941. */
  144942. getClassName(): string;
  144943. /**
  144944. * Returns the integer 1.
  144945. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  144946. */
  144947. getTypeID(): number;
  144948. /**
  144949. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  144950. * Returns the DirectionalLight Shadow projection matrix.
  144951. */
  144952. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  144953. /**
  144954. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  144955. * Returns the DirectionalLight Shadow projection matrix.
  144956. */
  144957. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  144958. /**
  144959. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  144960. * Returns the DirectionalLight Shadow projection matrix.
  144961. */
  144962. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  144963. protected _buildUniformLayout(): void;
  144964. /**
  144965. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  144966. * @param effect The effect to update
  144967. * @param lightIndex The index of the light in the effect to update
  144968. * @returns The directional light
  144969. */
  144970. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  144971. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  144972. /**
  144973. * Gets the minZ used for shadow according to both the scene and the light.
  144974. *
  144975. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  144976. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  144977. * @param activeCamera The camera we are returning the min for
  144978. * @returns the depth min z
  144979. */
  144980. getDepthMinZ(activeCamera: Camera): number;
  144981. /**
  144982. * Gets the maxZ used for shadow according to both the scene and the light.
  144983. *
  144984. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  144985. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  144986. * @param activeCamera The camera we are returning the max for
  144987. * @returns the depth max z
  144988. */
  144989. getDepthMaxZ(activeCamera: Camera): number;
  144990. /**
  144991. * Prepares the list of defines specific to the light type.
  144992. * @param defines the list of defines
  144993. * @param lightIndex defines the index of the light for the effect
  144994. */
  144995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  144996. }
  144997. }
  144998. declare module BABYLON {
  144999. /**
  145000. * Class containing static functions to help procedurally build meshes
  145001. */
  145002. export class HemisphereBuilder {
  145003. /**
  145004. * Creates a hemisphere mesh
  145005. * @param name defines the name of the mesh
  145006. * @param options defines the options used to create the mesh
  145007. * @param scene defines the hosting scene
  145008. * @returns the hemisphere mesh
  145009. */
  145010. static CreateHemisphere(name: string, options: {
  145011. segments?: number;
  145012. diameter?: number;
  145013. sideOrientation?: number;
  145014. }, scene: any): Mesh;
  145015. }
  145016. }
  145017. declare module BABYLON {
  145018. /**
  145019. * A spot light is defined by a position, a direction, an angle, and an exponent.
  145020. * These values define a cone of light starting from the position, emitting toward the direction.
  145021. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  145022. * and the exponent defines the speed of the decay of the light with distance (reach).
  145023. * Documentation: https://doc.babylonjs.com/babylon101/lights
  145024. */
  145025. export class SpotLight extends ShadowLight {
  145026. private _angle;
  145027. private _innerAngle;
  145028. private _cosHalfAngle;
  145029. private _lightAngleScale;
  145030. private _lightAngleOffset;
  145031. /**
  145032. * Gets the cone angle of the spot light in Radians.
  145033. */
  145034. get angle(): number;
  145035. /**
  145036. * Sets the cone angle of the spot light in Radians.
  145037. */
  145038. set angle(value: number);
  145039. /**
  145040. * Only used in gltf falloff mode, this defines the angle where
  145041. * the directional falloff will start before cutting at angle which could be seen
  145042. * as outer angle.
  145043. */
  145044. get innerAngle(): number;
  145045. /**
  145046. * Only used in gltf falloff mode, this defines the angle where
  145047. * the directional falloff will start before cutting at angle which could be seen
  145048. * as outer angle.
  145049. */
  145050. set innerAngle(value: number);
  145051. private _shadowAngleScale;
  145052. /**
  145053. * Allows scaling the angle of the light for shadow generation only.
  145054. */
  145055. get shadowAngleScale(): number;
  145056. /**
  145057. * Allows scaling the angle of the light for shadow generation only.
  145058. */
  145059. set shadowAngleScale(value: number);
  145060. /**
  145061. * The light decay speed with the distance from the emission spot.
  145062. */
  145063. exponent: number;
  145064. private _projectionTextureMatrix;
  145065. /**
  145066. * Allows reading the projecton texture
  145067. */
  145068. get projectionTextureMatrix(): Matrix;
  145069. protected _projectionTextureLightNear: number;
  145070. /**
  145071. * Gets the near clip of the Spotlight for texture projection.
  145072. */
  145073. get projectionTextureLightNear(): number;
  145074. /**
  145075. * Sets the near clip of the Spotlight for texture projection.
  145076. */
  145077. set projectionTextureLightNear(value: number);
  145078. protected _projectionTextureLightFar: number;
  145079. /**
  145080. * Gets the far clip of the Spotlight for texture projection.
  145081. */
  145082. get projectionTextureLightFar(): number;
  145083. /**
  145084. * Sets the far clip of the Spotlight for texture projection.
  145085. */
  145086. set projectionTextureLightFar(value: number);
  145087. protected _projectionTextureUpDirection: Vector3;
  145088. /**
  145089. * Gets the Up vector of the Spotlight for texture projection.
  145090. */
  145091. get projectionTextureUpDirection(): Vector3;
  145092. /**
  145093. * Sets the Up vector of the Spotlight for texture projection.
  145094. */
  145095. set projectionTextureUpDirection(value: Vector3);
  145096. private _projectionTexture;
  145097. /**
  145098. * Gets the projection texture of the light.
  145099. */
  145100. get projectionTexture(): Nullable<BaseTexture>;
  145101. /**
  145102. * Sets the projection texture of the light.
  145103. */
  145104. set projectionTexture(value: Nullable<BaseTexture>);
  145105. private static _IsProceduralTexture;
  145106. private static _IsTexture;
  145107. private _projectionTextureViewLightDirty;
  145108. private _projectionTextureProjectionLightDirty;
  145109. private _projectionTextureDirty;
  145110. private _projectionTextureViewTargetVector;
  145111. private _projectionTextureViewLightMatrix;
  145112. private _projectionTextureProjectionLightMatrix;
  145113. private _projectionTextureScalingMatrix;
  145114. /**
  145115. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  145116. * It can cast shadows.
  145117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  145118. * @param name The light friendly name
  145119. * @param position The position of the spot light in the scene
  145120. * @param direction The direction of the light in the scene
  145121. * @param angle The cone angle of the light in Radians
  145122. * @param exponent The light decay speed with the distance from the emission spot
  145123. * @param scene The scene the lights belongs to
  145124. */
  145125. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  145126. /**
  145127. * Returns the string "SpotLight".
  145128. * @returns the class name
  145129. */
  145130. getClassName(): string;
  145131. /**
  145132. * Returns the integer 2.
  145133. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  145134. */
  145135. getTypeID(): number;
  145136. /**
  145137. * Overrides the direction setter to recompute the projection texture view light Matrix.
  145138. */
  145139. protected _setDirection(value: Vector3): void;
  145140. /**
  145141. * Overrides the position setter to recompute the projection texture view light Matrix.
  145142. */
  145143. protected _setPosition(value: Vector3): void;
  145144. /**
  145145. * 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.
  145146. * Returns the SpotLight.
  145147. */
  145148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145149. protected _computeProjectionTextureViewLightMatrix(): void;
  145150. protected _computeProjectionTextureProjectionLightMatrix(): void;
  145151. /**
  145152. * Main function for light texture projection matrix computing.
  145153. */
  145154. protected _computeProjectionTextureMatrix(): void;
  145155. protected _buildUniformLayout(): void;
  145156. private _computeAngleValues;
  145157. /**
  145158. * Sets the passed Effect "effect" with the Light textures.
  145159. * @param effect The effect to update
  145160. * @param lightIndex The index of the light in the effect to update
  145161. * @returns The light
  145162. */
  145163. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  145164. /**
  145165. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  145166. * @param effect The effect to update
  145167. * @param lightIndex The index of the light in the effect to update
  145168. * @returns The spot light
  145169. */
  145170. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  145171. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  145172. /**
  145173. * Disposes the light and the associated resources.
  145174. */
  145175. dispose(): void;
  145176. /**
  145177. * Prepares the list of defines specific to the light type.
  145178. * @param defines the list of defines
  145179. * @param lightIndex defines the index of the light for the effect
  145180. */
  145181. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  145182. }
  145183. }
  145184. declare module BABYLON {
  145185. /**
  145186. * Gizmo that enables viewing a light
  145187. */
  145188. export class LightGizmo extends Gizmo {
  145189. private _lightMesh;
  145190. private _material;
  145191. private _cachedPosition;
  145192. private _cachedForward;
  145193. private _attachedMeshParent;
  145194. private _pointerObserver;
  145195. /**
  145196. * Event that fires each time the gizmo is clicked
  145197. */
  145198. onClickedObservable: Observable<Light>;
  145199. /**
  145200. * Creates a LightGizmo
  145201. * @param gizmoLayer The utility layer the gizmo will be added to
  145202. */
  145203. constructor(gizmoLayer?: UtilityLayerRenderer);
  145204. private _light;
  145205. /**
  145206. * The light that the gizmo is attached to
  145207. */
  145208. set light(light: Nullable<Light>);
  145209. get light(): Nullable<Light>;
  145210. /**
  145211. * Gets the material used to render the light gizmo
  145212. */
  145213. get material(): StandardMaterial;
  145214. /**
  145215. * @hidden
  145216. * Updates the gizmo to match the attached mesh's position/rotation
  145217. */
  145218. protected _update(): void;
  145219. private static _Scale;
  145220. /**
  145221. * Creates the lines for a light mesh
  145222. */
  145223. private static _CreateLightLines;
  145224. /**
  145225. * Disposes of the light gizmo
  145226. */
  145227. dispose(): void;
  145228. private static _CreateHemisphericLightMesh;
  145229. private static _CreatePointLightMesh;
  145230. private static _CreateSpotLightMesh;
  145231. private static _CreateDirectionalLightMesh;
  145232. }
  145233. }
  145234. declare module BABYLON {
  145235. /**
  145236. * Gizmo that enables viewing a camera
  145237. */
  145238. export class CameraGizmo extends Gizmo {
  145239. private _cameraMesh;
  145240. private _cameraLinesMesh;
  145241. private _material;
  145242. private _pointerObserver;
  145243. /**
  145244. * Event that fires each time the gizmo is clicked
  145245. */
  145246. onClickedObservable: Observable<Camera>;
  145247. /**
  145248. * Creates a CameraGizmo
  145249. * @param gizmoLayer The utility layer the gizmo will be added to
  145250. */
  145251. constructor(gizmoLayer?: UtilityLayerRenderer);
  145252. private _camera;
  145253. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  145254. get displayFrustum(): boolean;
  145255. set displayFrustum(value: boolean);
  145256. /**
  145257. * The camera that the gizmo is attached to
  145258. */
  145259. set camera(camera: Nullable<Camera>);
  145260. get camera(): Nullable<Camera>;
  145261. /**
  145262. * Gets the material used to render the camera gizmo
  145263. */
  145264. get material(): StandardMaterial;
  145265. /**
  145266. * @hidden
  145267. * Updates the gizmo to match the attached mesh's position/rotation
  145268. */
  145269. protected _update(): void;
  145270. private static _Scale;
  145271. private _invProjection;
  145272. /**
  145273. * Disposes of the camera gizmo
  145274. */
  145275. dispose(): void;
  145276. private static _CreateCameraMesh;
  145277. private static _CreateCameraFrustum;
  145278. }
  145279. }
  145280. declare module BABYLON {
  145281. /** @hidden */
  145282. export var backgroundFragmentDeclaration: {
  145283. name: string;
  145284. shader: string;
  145285. };
  145286. }
  145287. declare module BABYLON {
  145288. /** @hidden */
  145289. export var backgroundUboDeclaration: {
  145290. name: string;
  145291. shader: string;
  145292. };
  145293. }
  145294. declare module BABYLON {
  145295. /** @hidden */
  145296. export var backgroundPixelShader: {
  145297. name: string;
  145298. shader: string;
  145299. };
  145300. }
  145301. declare module BABYLON {
  145302. /** @hidden */
  145303. export var backgroundVertexDeclaration: {
  145304. name: string;
  145305. shader: string;
  145306. };
  145307. }
  145308. declare module BABYLON {
  145309. /** @hidden */
  145310. export var backgroundVertexShader: {
  145311. name: string;
  145312. shader: string;
  145313. };
  145314. }
  145315. declare module BABYLON {
  145316. /**
  145317. * Background material used to create an efficient environement around your scene.
  145318. */
  145319. export class BackgroundMaterial extends PushMaterial {
  145320. /**
  145321. * Standard reflectance value at parallel view angle.
  145322. */
  145323. static StandardReflectance0: number;
  145324. /**
  145325. * Standard reflectance value at grazing angle.
  145326. */
  145327. static StandardReflectance90: number;
  145328. protected _primaryColor: Color3;
  145329. /**
  145330. * Key light Color (multiply against the environement texture)
  145331. */
  145332. primaryColor: Color3;
  145333. protected __perceptualColor: Nullable<Color3>;
  145334. /**
  145335. * Experimental Internal Use Only.
  145336. *
  145337. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  145338. * This acts as a helper to set the primary color to a more "human friendly" value.
  145339. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  145340. * output color as close as possible from the chosen value.
  145341. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  145342. * part of lighting setup.)
  145343. */
  145344. get _perceptualColor(): Nullable<Color3>;
  145345. set _perceptualColor(value: Nullable<Color3>);
  145346. protected _primaryColorShadowLevel: float;
  145347. /**
  145348. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  145349. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  145350. */
  145351. get primaryColorShadowLevel(): float;
  145352. set primaryColorShadowLevel(value: float);
  145353. protected _primaryColorHighlightLevel: float;
  145354. /**
  145355. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  145356. * The primary color is used at the level chosen to define what the white area would look.
  145357. */
  145358. get primaryColorHighlightLevel(): float;
  145359. set primaryColorHighlightLevel(value: float);
  145360. protected _reflectionTexture: Nullable<BaseTexture>;
  145361. /**
  145362. * Reflection Texture used in the material.
  145363. * Should be author in a specific way for the best result (refer to the documentation).
  145364. */
  145365. reflectionTexture: Nullable<BaseTexture>;
  145366. protected _reflectionBlur: float;
  145367. /**
  145368. * Reflection Texture level of blur.
  145369. *
  145370. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  145371. * texture twice.
  145372. */
  145373. reflectionBlur: float;
  145374. protected _diffuseTexture: Nullable<BaseTexture>;
  145375. /**
  145376. * Diffuse Texture used in the material.
  145377. * Should be author in a specific way for the best result (refer to the documentation).
  145378. */
  145379. diffuseTexture: Nullable<BaseTexture>;
  145380. protected _shadowLights: Nullable<IShadowLight[]>;
  145381. /**
  145382. * Specify the list of lights casting shadow on the material.
  145383. * All scene shadow lights will be included if null.
  145384. */
  145385. shadowLights: Nullable<IShadowLight[]>;
  145386. protected _shadowLevel: float;
  145387. /**
  145388. * Helps adjusting the shadow to a softer level if required.
  145389. * 0 means black shadows and 1 means no shadows.
  145390. */
  145391. shadowLevel: float;
  145392. protected _sceneCenter: Vector3;
  145393. /**
  145394. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  145395. * It is usually zero but might be interesting to modify according to your setup.
  145396. */
  145397. sceneCenter: Vector3;
  145398. protected _opacityFresnel: boolean;
  145399. /**
  145400. * This helps specifying that the material is falling off to the sky box at grazing angle.
  145401. * This helps ensuring a nice transition when the camera goes under the ground.
  145402. */
  145403. opacityFresnel: boolean;
  145404. protected _reflectionFresnel: boolean;
  145405. /**
  145406. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  145407. * This helps adding a mirror texture on the ground.
  145408. */
  145409. reflectionFresnel: boolean;
  145410. protected _reflectionFalloffDistance: number;
  145411. /**
  145412. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  145413. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  145414. */
  145415. reflectionFalloffDistance: number;
  145416. protected _reflectionAmount: number;
  145417. /**
  145418. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  145419. */
  145420. reflectionAmount: number;
  145421. protected _reflectionReflectance0: number;
  145422. /**
  145423. * This specifies the weight of the reflection at grazing angle.
  145424. */
  145425. reflectionReflectance0: number;
  145426. protected _reflectionReflectance90: number;
  145427. /**
  145428. * This specifies the weight of the reflection at a perpendicular point of view.
  145429. */
  145430. reflectionReflectance90: number;
  145431. /**
  145432. * Sets the reflection reflectance fresnel values according to the default standard
  145433. * empirically know to work well :-)
  145434. */
  145435. set reflectionStandardFresnelWeight(value: number);
  145436. protected _useRGBColor: boolean;
  145437. /**
  145438. * Helps to directly use the maps channels instead of their level.
  145439. */
  145440. useRGBColor: boolean;
  145441. protected _enableNoise: boolean;
  145442. /**
  145443. * This helps reducing the banding effect that could occur on the background.
  145444. */
  145445. enableNoise: boolean;
  145446. /**
  145447. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  145448. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  145449. * Recommended to be keep at 1.0 except for special cases.
  145450. */
  145451. get fovMultiplier(): number;
  145452. set fovMultiplier(value: number);
  145453. private _fovMultiplier;
  145454. /**
  145455. * Enable the FOV adjustment feature controlled by fovMultiplier.
  145456. */
  145457. useEquirectangularFOV: boolean;
  145458. private _maxSimultaneousLights;
  145459. /**
  145460. * Number of Simultaneous lights allowed on the material.
  145461. */
  145462. maxSimultaneousLights: int;
  145463. private _shadowOnly;
  145464. /**
  145465. * Make the material only render shadows
  145466. */
  145467. shadowOnly: boolean;
  145468. /**
  145469. * Default configuration related to image processing available in the Background Material.
  145470. */
  145471. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  145472. /**
  145473. * Keep track of the image processing observer to allow dispose and replace.
  145474. */
  145475. private _imageProcessingObserver;
  145476. /**
  145477. * Attaches a new image processing configuration to the PBR Material.
  145478. * @param configuration (if null the scene configuration will be use)
  145479. */
  145480. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  145481. /**
  145482. * Gets the image processing configuration used either in this material.
  145483. */
  145484. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  145485. /**
  145486. * Sets the Default image processing configuration used either in the this material.
  145487. *
  145488. * If sets to null, the scene one is in use.
  145489. */
  145490. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  145491. /**
  145492. * Gets wether the color curves effect is enabled.
  145493. */
  145494. get cameraColorCurvesEnabled(): boolean;
  145495. /**
  145496. * Sets wether the color curves effect is enabled.
  145497. */
  145498. set cameraColorCurvesEnabled(value: boolean);
  145499. /**
  145500. * Gets wether the color grading effect is enabled.
  145501. */
  145502. get cameraColorGradingEnabled(): boolean;
  145503. /**
  145504. * Gets wether the color grading effect is enabled.
  145505. */
  145506. set cameraColorGradingEnabled(value: boolean);
  145507. /**
  145508. * Gets wether tonemapping is enabled or not.
  145509. */
  145510. get cameraToneMappingEnabled(): boolean;
  145511. /**
  145512. * Sets wether tonemapping is enabled or not
  145513. */
  145514. set cameraToneMappingEnabled(value: boolean);
  145515. /**
  145516. * The camera exposure used on this material.
  145517. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  145518. * This corresponds to a photographic exposure.
  145519. */
  145520. get cameraExposure(): float;
  145521. /**
  145522. * The camera exposure used on this material.
  145523. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  145524. * This corresponds to a photographic exposure.
  145525. */
  145526. set cameraExposure(value: float);
  145527. /**
  145528. * Gets The camera contrast used on this material.
  145529. */
  145530. get cameraContrast(): float;
  145531. /**
  145532. * Sets The camera contrast used on this material.
  145533. */
  145534. set cameraContrast(value: float);
  145535. /**
  145536. * Gets the Color Grading 2D Lookup Texture.
  145537. */
  145538. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  145539. /**
  145540. * Sets the Color Grading 2D Lookup Texture.
  145541. */
  145542. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  145543. /**
  145544. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  145545. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  145546. * 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;
  145547. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  145548. */
  145549. get cameraColorCurves(): Nullable<ColorCurves>;
  145550. /**
  145551. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  145552. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  145553. * 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;
  145554. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  145555. */
  145556. set cameraColorCurves(value: Nullable<ColorCurves>);
  145557. /**
  145558. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  145559. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  145560. */
  145561. switchToBGR: boolean;
  145562. private _renderTargets;
  145563. private _reflectionControls;
  145564. private _white;
  145565. private _primaryShadowColor;
  145566. private _primaryHighlightColor;
  145567. /**
  145568. * Instantiates a Background Material in the given scene
  145569. * @param name The friendly name of the material
  145570. * @param scene The scene to add the material to
  145571. */
  145572. constructor(name: string, scene: Scene);
  145573. /**
  145574. * Gets a boolean indicating that current material needs to register RTT
  145575. */
  145576. get hasRenderTargetTextures(): boolean;
  145577. /**
  145578. * The entire material has been created in order to prevent overdraw.
  145579. * @returns false
  145580. */
  145581. needAlphaTesting(): boolean;
  145582. /**
  145583. * The entire material has been created in order to prevent overdraw.
  145584. * @returns true if blending is enable
  145585. */
  145586. needAlphaBlending(): boolean;
  145587. /**
  145588. * Checks wether the material is ready to be rendered for a given mesh.
  145589. * @param mesh The mesh to render
  145590. * @param subMesh The submesh to check against
  145591. * @param useInstances Specify wether or not the material is used with instances
  145592. * @returns true if all the dependencies are ready (Textures, Effects...)
  145593. */
  145594. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  145595. /**
  145596. * Compute the primary color according to the chosen perceptual color.
  145597. */
  145598. private _computePrimaryColorFromPerceptualColor;
  145599. /**
  145600. * Compute the highlights and shadow colors according to their chosen levels.
  145601. */
  145602. private _computePrimaryColors;
  145603. /**
  145604. * Build the uniform buffer used in the material.
  145605. */
  145606. buildUniformLayout(): void;
  145607. /**
  145608. * Unbind the material.
  145609. */
  145610. unbind(): void;
  145611. /**
  145612. * Bind only the world matrix to the material.
  145613. * @param world The world matrix to bind.
  145614. */
  145615. bindOnlyWorldMatrix(world: Matrix): void;
  145616. /**
  145617. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  145618. * @param world The world matrix to bind.
  145619. * @param subMesh The submesh to bind for.
  145620. */
  145621. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  145622. /**
  145623. * Checks to see if a texture is used in the material.
  145624. * @param texture - Base texture to use.
  145625. * @returns - Boolean specifying if a texture is used in the material.
  145626. */
  145627. hasTexture(texture: BaseTexture): boolean;
  145628. /**
  145629. * Dispose the material.
  145630. * @param forceDisposeEffect Force disposal of the associated effect.
  145631. * @param forceDisposeTextures Force disposal of the associated textures.
  145632. */
  145633. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  145634. /**
  145635. * Clones the material.
  145636. * @param name The cloned name.
  145637. * @returns The cloned material.
  145638. */
  145639. clone(name: string): BackgroundMaterial;
  145640. /**
  145641. * Serializes the current material to its JSON representation.
  145642. * @returns The JSON representation.
  145643. */
  145644. serialize(): any;
  145645. /**
  145646. * Gets the class name of the material
  145647. * @returns "BackgroundMaterial"
  145648. */
  145649. getClassName(): string;
  145650. /**
  145651. * Parse a JSON input to create back a background material.
  145652. * @param source The JSON data to parse
  145653. * @param scene The scene to create the parsed material in
  145654. * @param rootUrl The root url of the assets the material depends upon
  145655. * @returns the instantiated BackgroundMaterial.
  145656. */
  145657. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  145658. }
  145659. }
  145660. declare module BABYLON {
  145661. /**
  145662. * Represents the different options available during the creation of
  145663. * a Environment helper.
  145664. *
  145665. * This can control the default ground, skybox and image processing setup of your scene.
  145666. */
  145667. export interface IEnvironmentHelperOptions {
  145668. /**
  145669. * Specifies whether or not to create a ground.
  145670. * True by default.
  145671. */
  145672. createGround: boolean;
  145673. /**
  145674. * Specifies the ground size.
  145675. * 15 by default.
  145676. */
  145677. groundSize: number;
  145678. /**
  145679. * The texture used on the ground for the main color.
  145680. * Comes from the BabylonJS CDN by default.
  145681. *
  145682. * Remarks: Can be either a texture or a url.
  145683. */
  145684. groundTexture: string | BaseTexture;
  145685. /**
  145686. * The color mixed in the ground texture by default.
  145687. * BabylonJS clearColor by default.
  145688. */
  145689. groundColor: Color3;
  145690. /**
  145691. * Specifies the ground opacity.
  145692. * 1 by default.
  145693. */
  145694. groundOpacity: number;
  145695. /**
  145696. * Enables the ground to receive shadows.
  145697. * True by default.
  145698. */
  145699. enableGroundShadow: boolean;
  145700. /**
  145701. * Helps preventing the shadow to be fully black on the ground.
  145702. * 0.5 by default.
  145703. */
  145704. groundShadowLevel: number;
  145705. /**
  145706. * Creates a mirror texture attach to the ground.
  145707. * false by default.
  145708. */
  145709. enableGroundMirror: boolean;
  145710. /**
  145711. * Specifies the ground mirror size ratio.
  145712. * 0.3 by default as the default kernel is 64.
  145713. */
  145714. groundMirrorSizeRatio: number;
  145715. /**
  145716. * Specifies the ground mirror blur kernel size.
  145717. * 64 by default.
  145718. */
  145719. groundMirrorBlurKernel: number;
  145720. /**
  145721. * Specifies the ground mirror visibility amount.
  145722. * 1 by default
  145723. */
  145724. groundMirrorAmount: number;
  145725. /**
  145726. * Specifies the ground mirror reflectance weight.
  145727. * This uses the standard weight of the background material to setup the fresnel effect
  145728. * of the mirror.
  145729. * 1 by default.
  145730. */
  145731. groundMirrorFresnelWeight: number;
  145732. /**
  145733. * Specifies the ground mirror Falloff distance.
  145734. * This can helps reducing the size of the reflection.
  145735. * 0 by Default.
  145736. */
  145737. groundMirrorFallOffDistance: number;
  145738. /**
  145739. * Specifies the ground mirror texture type.
  145740. * Unsigned Int by Default.
  145741. */
  145742. groundMirrorTextureType: number;
  145743. /**
  145744. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  145745. * the shown objects.
  145746. */
  145747. groundYBias: number;
  145748. /**
  145749. * Specifies whether or not to create a skybox.
  145750. * True by default.
  145751. */
  145752. createSkybox: boolean;
  145753. /**
  145754. * Specifies the skybox size.
  145755. * 20 by default.
  145756. */
  145757. skyboxSize: number;
  145758. /**
  145759. * The texture used on the skybox for the main color.
  145760. * Comes from the BabylonJS CDN by default.
  145761. *
  145762. * Remarks: Can be either a texture or a url.
  145763. */
  145764. skyboxTexture: string | BaseTexture;
  145765. /**
  145766. * The color mixed in the skybox texture by default.
  145767. * BabylonJS clearColor by default.
  145768. */
  145769. skyboxColor: Color3;
  145770. /**
  145771. * The background rotation around the Y axis of the scene.
  145772. * This helps aligning the key lights of your scene with the background.
  145773. * 0 by default.
  145774. */
  145775. backgroundYRotation: number;
  145776. /**
  145777. * Compute automatically the size of the elements to best fit with the scene.
  145778. */
  145779. sizeAuto: boolean;
  145780. /**
  145781. * Default position of the rootMesh if autoSize is not true.
  145782. */
  145783. rootPosition: Vector3;
  145784. /**
  145785. * Sets up the image processing in the scene.
  145786. * true by default.
  145787. */
  145788. setupImageProcessing: boolean;
  145789. /**
  145790. * The texture used as your environment texture in the scene.
  145791. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  145792. *
  145793. * Remarks: Can be either a texture or a url.
  145794. */
  145795. environmentTexture: string | BaseTexture;
  145796. /**
  145797. * The value of the exposure to apply to the scene.
  145798. * 0.6 by default if setupImageProcessing is true.
  145799. */
  145800. cameraExposure: number;
  145801. /**
  145802. * The value of the contrast to apply to the scene.
  145803. * 1.6 by default if setupImageProcessing is true.
  145804. */
  145805. cameraContrast: number;
  145806. /**
  145807. * Specifies whether or not tonemapping should be enabled in the scene.
  145808. * true by default if setupImageProcessing is true.
  145809. */
  145810. toneMappingEnabled: boolean;
  145811. }
  145812. /**
  145813. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  145814. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  145815. * It also helps with the default setup of your imageProcessing configuration.
  145816. */
  145817. export class EnvironmentHelper {
  145818. /**
  145819. * Default ground texture URL.
  145820. */
  145821. private static _groundTextureCDNUrl;
  145822. /**
  145823. * Default skybox texture URL.
  145824. */
  145825. private static _skyboxTextureCDNUrl;
  145826. /**
  145827. * Default environment texture URL.
  145828. */
  145829. private static _environmentTextureCDNUrl;
  145830. /**
  145831. * Creates the default options for the helper.
  145832. */
  145833. private static _getDefaultOptions;
  145834. private _rootMesh;
  145835. /**
  145836. * Gets the root mesh created by the helper.
  145837. */
  145838. get rootMesh(): Mesh;
  145839. private _skybox;
  145840. /**
  145841. * Gets the skybox created by the helper.
  145842. */
  145843. get skybox(): Nullable<Mesh>;
  145844. private _skyboxTexture;
  145845. /**
  145846. * Gets the skybox texture created by the helper.
  145847. */
  145848. get skyboxTexture(): Nullable<BaseTexture>;
  145849. private _skyboxMaterial;
  145850. /**
  145851. * Gets the skybox material created by the helper.
  145852. */
  145853. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  145854. private _ground;
  145855. /**
  145856. * Gets the ground mesh created by the helper.
  145857. */
  145858. get ground(): Nullable<Mesh>;
  145859. private _groundTexture;
  145860. /**
  145861. * Gets the ground texture created by the helper.
  145862. */
  145863. get groundTexture(): Nullable<BaseTexture>;
  145864. private _groundMirror;
  145865. /**
  145866. * Gets the ground mirror created by the helper.
  145867. */
  145868. get groundMirror(): Nullable<MirrorTexture>;
  145869. /**
  145870. * Gets the ground mirror render list to helps pushing the meshes
  145871. * you wish in the ground reflection.
  145872. */
  145873. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  145874. private _groundMaterial;
  145875. /**
  145876. * Gets the ground material created by the helper.
  145877. */
  145878. get groundMaterial(): Nullable<BackgroundMaterial>;
  145879. /**
  145880. * Stores the creation options.
  145881. */
  145882. private readonly _scene;
  145883. private _options;
  145884. /**
  145885. * This observable will be notified with any error during the creation of the environment,
  145886. * mainly texture creation errors.
  145887. */
  145888. onErrorObservable: Observable<{
  145889. message?: string;
  145890. exception?: any;
  145891. }>;
  145892. /**
  145893. * constructor
  145894. * @param options Defines the options we want to customize the helper
  145895. * @param scene The scene to add the material to
  145896. */
  145897. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  145898. /**
  145899. * Updates the background according to the new options
  145900. * @param options
  145901. */
  145902. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  145903. /**
  145904. * Sets the primary color of all the available elements.
  145905. * @param color the main color to affect to the ground and the background
  145906. */
  145907. setMainColor(color: Color3): void;
  145908. /**
  145909. * Setup the image processing according to the specified options.
  145910. */
  145911. private _setupImageProcessing;
  145912. /**
  145913. * Setup the environment texture according to the specified options.
  145914. */
  145915. private _setupEnvironmentTexture;
  145916. /**
  145917. * Setup the background according to the specified options.
  145918. */
  145919. private _setupBackground;
  145920. /**
  145921. * Get the scene sizes according to the setup.
  145922. */
  145923. private _getSceneSize;
  145924. /**
  145925. * Setup the ground according to the specified options.
  145926. */
  145927. private _setupGround;
  145928. /**
  145929. * Setup the ground material according to the specified options.
  145930. */
  145931. private _setupGroundMaterial;
  145932. /**
  145933. * Setup the ground diffuse texture according to the specified options.
  145934. */
  145935. private _setupGroundDiffuseTexture;
  145936. /**
  145937. * Setup the ground mirror texture according to the specified options.
  145938. */
  145939. private _setupGroundMirrorTexture;
  145940. /**
  145941. * Setup the ground to receive the mirror texture.
  145942. */
  145943. private _setupMirrorInGroundMaterial;
  145944. /**
  145945. * Setup the skybox according to the specified options.
  145946. */
  145947. private _setupSkybox;
  145948. /**
  145949. * Setup the skybox material according to the specified options.
  145950. */
  145951. private _setupSkyboxMaterial;
  145952. /**
  145953. * Setup the skybox reflection texture according to the specified options.
  145954. */
  145955. private _setupSkyboxReflectionTexture;
  145956. private _errorHandler;
  145957. /**
  145958. * Dispose all the elements created by the Helper.
  145959. */
  145960. dispose(): void;
  145961. }
  145962. }
  145963. declare module BABYLON {
  145964. /**
  145965. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  145966. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  145967. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  145968. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  145969. */
  145970. export abstract class TextureDome<T extends Texture> extends TransformNode {
  145971. protected onError: Nullable<(message?: string, exception?: any) => void>;
  145972. /**
  145973. * Define the source as a Monoscopic panoramic 360/180.
  145974. */
  145975. static readonly MODE_MONOSCOPIC: number;
  145976. /**
  145977. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  145978. */
  145979. static readonly MODE_TOPBOTTOM: number;
  145980. /**
  145981. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  145982. */
  145983. static readonly MODE_SIDEBYSIDE: number;
  145984. private _halfDome;
  145985. private _crossEye;
  145986. protected _useDirectMapping: boolean;
  145987. /**
  145988. * The texture being displayed on the sphere
  145989. */
  145990. protected _texture: T;
  145991. /**
  145992. * Gets the texture being displayed on the sphere
  145993. */
  145994. get texture(): T;
  145995. /**
  145996. * Sets the texture being displayed on the sphere
  145997. */
  145998. set texture(newTexture: T);
  145999. /**
  146000. * The skybox material
  146001. */
  146002. protected _material: BackgroundMaterial;
  146003. /**
  146004. * The surface used for the dome
  146005. */
  146006. protected _mesh: Mesh;
  146007. /**
  146008. * Gets the mesh used for the dome.
  146009. */
  146010. get mesh(): Mesh;
  146011. /**
  146012. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  146013. */
  146014. private _halfDomeMask;
  146015. /**
  146016. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  146017. * Also see the options.resolution property.
  146018. */
  146019. get fovMultiplier(): number;
  146020. set fovMultiplier(value: number);
  146021. protected _textureMode: number;
  146022. /**
  146023. * Gets or set the current texture mode for the texture. It can be:
  146024. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146025. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146026. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146027. */
  146028. get textureMode(): number;
  146029. /**
  146030. * Sets the current texture mode for the texture. It can be:
  146031. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146032. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146033. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146034. */
  146035. set textureMode(value: number);
  146036. /**
  146037. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  146038. */
  146039. get halfDome(): boolean;
  146040. /**
  146041. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  146042. */
  146043. set halfDome(enabled: boolean);
  146044. /**
  146045. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  146046. */
  146047. set crossEye(enabled: boolean);
  146048. /**
  146049. * Is it a cross-eye texture?
  146050. */
  146051. get crossEye(): boolean;
  146052. /**
  146053. * The background material of this dome.
  146054. */
  146055. get material(): BackgroundMaterial;
  146056. /**
  146057. * Oberserver used in Stereoscopic VR Mode.
  146058. */
  146059. private _onBeforeCameraRenderObserver;
  146060. /**
  146061. * Observable raised when an error occured while loading the 360 image
  146062. */
  146063. onLoadErrorObservable: Observable<string>;
  146064. /**
  146065. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  146066. * @param name Element's name, child elements will append suffixes for their own names.
  146067. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  146068. * @param options An object containing optional or exposed sub element properties
  146069. */
  146070. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  146071. resolution?: number;
  146072. clickToPlay?: boolean;
  146073. autoPlay?: boolean;
  146074. loop?: boolean;
  146075. size?: number;
  146076. poster?: string;
  146077. faceForward?: boolean;
  146078. useDirectMapping?: boolean;
  146079. halfDomeMode?: boolean;
  146080. crossEyeMode?: boolean;
  146081. generateMipMaps?: boolean;
  146082. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  146083. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  146084. protected _changeTextureMode(value: number): void;
  146085. /**
  146086. * Releases resources associated with this node.
  146087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  146088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  146089. */
  146090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  146091. }
  146092. }
  146093. declare module BABYLON {
  146094. /**
  146095. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  146096. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  146097. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  146098. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146099. */
  146100. export class PhotoDome extends TextureDome<Texture> {
  146101. /**
  146102. * Define the image as a Monoscopic panoramic 360 image.
  146103. */
  146104. static readonly MODE_MONOSCOPIC: number;
  146105. /**
  146106. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  146107. */
  146108. static readonly MODE_TOPBOTTOM: number;
  146109. /**
  146110. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  146111. */
  146112. static readonly MODE_SIDEBYSIDE: number;
  146113. /**
  146114. * Gets or sets the texture being displayed on the sphere
  146115. */
  146116. get photoTexture(): Texture;
  146117. /**
  146118. * sets the texture being displayed on the sphere
  146119. */
  146120. set photoTexture(value: Texture);
  146121. /**
  146122. * Gets the current video mode for the video. It can be:
  146123. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146124. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146125. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146126. */
  146127. get imageMode(): number;
  146128. /**
  146129. * Sets the current video mode for the video. It can be:
  146130. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146131. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146132. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146133. */
  146134. set imageMode(value: number);
  146135. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  146136. }
  146137. }
  146138. declare module BABYLON {
  146139. /**
  146140. * Direct draw surface info
  146141. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  146142. */
  146143. export interface DDSInfo {
  146144. /**
  146145. * Width of the texture
  146146. */
  146147. width: number;
  146148. /**
  146149. * Width of the texture
  146150. */
  146151. height: number;
  146152. /**
  146153. * Number of Mipmaps for the texture
  146154. * @see https://en.wikipedia.org/wiki/Mipmap
  146155. */
  146156. mipmapCount: number;
  146157. /**
  146158. * If the textures format is a known fourCC format
  146159. * @see https://www.fourcc.org/
  146160. */
  146161. isFourCC: boolean;
  146162. /**
  146163. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  146164. */
  146165. isRGB: boolean;
  146166. /**
  146167. * If the texture is a lumincance format
  146168. */
  146169. isLuminance: boolean;
  146170. /**
  146171. * If this is a cube texture
  146172. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  146173. */
  146174. isCube: boolean;
  146175. /**
  146176. * If the texture is a compressed format eg. FOURCC_DXT1
  146177. */
  146178. isCompressed: boolean;
  146179. /**
  146180. * The dxgiFormat of the texture
  146181. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  146182. */
  146183. dxgiFormat: number;
  146184. /**
  146185. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  146186. */
  146187. textureType: number;
  146188. /**
  146189. * Sphericle polynomial created for the dds texture
  146190. */
  146191. sphericalPolynomial?: SphericalPolynomial;
  146192. }
  146193. /**
  146194. * Class used to provide DDS decompression tools
  146195. */
  146196. export class DDSTools {
  146197. /**
  146198. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  146199. */
  146200. static StoreLODInAlphaChannel: boolean;
  146201. /**
  146202. * Gets DDS information from an array buffer
  146203. * @param data defines the array buffer view to read data from
  146204. * @returns the DDS information
  146205. */
  146206. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  146207. private static _FloatView;
  146208. private static _Int32View;
  146209. private static _ToHalfFloat;
  146210. private static _FromHalfFloat;
  146211. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  146212. private static _GetHalfFloatRGBAArrayBuffer;
  146213. private static _GetFloatRGBAArrayBuffer;
  146214. private static _GetFloatAsUIntRGBAArrayBuffer;
  146215. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  146216. private static _GetRGBAArrayBuffer;
  146217. private static _ExtractLongWordOrder;
  146218. private static _GetRGBArrayBuffer;
  146219. private static _GetLuminanceArrayBuffer;
  146220. /**
  146221. * Uploads DDS Levels to a Babylon Texture
  146222. * @hidden
  146223. */
  146224. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  146225. }
  146226. interface ThinEngine {
  146227. /**
  146228. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  146229. * @param rootUrl defines the url where the file to load is located
  146230. * @param scene defines the current scene
  146231. * @param lodScale defines scale to apply to the mip map selection
  146232. * @param lodOffset defines offset to apply to the mip map selection
  146233. * @param onLoad defines an optional callback raised when the texture is loaded
  146234. * @param onError defines an optional callback raised if there is an issue to load the texture
  146235. * @param format defines the format of the data
  146236. * @param forcedExtension defines the extension to use to pick the right loader
  146237. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  146238. * @returns the cube texture as an InternalTexture
  146239. */
  146240. 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;
  146241. }
  146242. }
  146243. declare module BABYLON {
  146244. /**
  146245. * Implementation of the DDS Texture Loader.
  146246. * @hidden
  146247. */
  146248. export class _DDSTextureLoader implements IInternalTextureLoader {
  146249. /**
  146250. * Defines wether the loader supports cascade loading the different faces.
  146251. */
  146252. readonly supportCascades: boolean;
  146253. /**
  146254. * This returns if the loader support the current file information.
  146255. * @param extension defines the file extension of the file being loaded
  146256. * @returns true if the loader can load the specified file
  146257. */
  146258. canLoad(extension: string): boolean;
  146259. /**
  146260. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146261. * @param data contains the texture data
  146262. * @param texture defines the BabylonJS internal texture
  146263. * @param createPolynomials will be true if polynomials have been requested
  146264. * @param onLoad defines the callback to trigger once the texture is ready
  146265. * @param onError defines the callback to trigger in case of error
  146266. */
  146267. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146268. /**
  146269. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146270. * @param data contains the texture data
  146271. * @param texture defines the BabylonJS internal texture
  146272. * @param callback defines the method to call once ready to upload
  146273. */
  146274. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  146275. }
  146276. }
  146277. declare module BABYLON {
  146278. /**
  146279. * Implementation of the ENV Texture Loader.
  146280. * @hidden
  146281. */
  146282. export class _ENVTextureLoader implements IInternalTextureLoader {
  146283. /**
  146284. * Defines wether the loader supports cascade loading the different faces.
  146285. */
  146286. readonly supportCascades: boolean;
  146287. /**
  146288. * This returns if the loader support the current file information.
  146289. * @param extension defines the file extension of the file being loaded
  146290. * @returns true if the loader can load the specified file
  146291. */
  146292. canLoad(extension: string): boolean;
  146293. /**
  146294. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146295. * @param data contains the texture data
  146296. * @param texture defines the BabylonJS internal texture
  146297. * @param createPolynomials will be true if polynomials have been requested
  146298. * @param onLoad defines the callback to trigger once the texture is ready
  146299. * @param onError defines the callback to trigger in case of error
  146300. */
  146301. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146302. /**
  146303. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146304. * @param data contains the texture data
  146305. * @param texture defines the BabylonJS internal texture
  146306. * @param callback defines the method to call once ready to upload
  146307. */
  146308. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  146309. }
  146310. }
  146311. declare module BABYLON {
  146312. /**
  146313. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  146314. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  146315. */
  146316. export class KhronosTextureContainer {
  146317. /** contents of the KTX container file */
  146318. data: ArrayBufferView;
  146319. private static HEADER_LEN;
  146320. private static COMPRESSED_2D;
  146321. private static COMPRESSED_3D;
  146322. private static TEX_2D;
  146323. private static TEX_3D;
  146324. /**
  146325. * Gets the openGL type
  146326. */
  146327. glType: number;
  146328. /**
  146329. * Gets the openGL type size
  146330. */
  146331. glTypeSize: number;
  146332. /**
  146333. * Gets the openGL format
  146334. */
  146335. glFormat: number;
  146336. /**
  146337. * Gets the openGL internal format
  146338. */
  146339. glInternalFormat: number;
  146340. /**
  146341. * Gets the base internal format
  146342. */
  146343. glBaseInternalFormat: number;
  146344. /**
  146345. * Gets image width in pixel
  146346. */
  146347. pixelWidth: number;
  146348. /**
  146349. * Gets image height in pixel
  146350. */
  146351. pixelHeight: number;
  146352. /**
  146353. * Gets image depth in pixels
  146354. */
  146355. pixelDepth: number;
  146356. /**
  146357. * Gets the number of array elements
  146358. */
  146359. numberOfArrayElements: number;
  146360. /**
  146361. * Gets the number of faces
  146362. */
  146363. numberOfFaces: number;
  146364. /**
  146365. * Gets the number of mipmap levels
  146366. */
  146367. numberOfMipmapLevels: number;
  146368. /**
  146369. * Gets the bytes of key value data
  146370. */
  146371. bytesOfKeyValueData: number;
  146372. /**
  146373. * Gets the load type
  146374. */
  146375. loadType: number;
  146376. /**
  146377. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  146378. */
  146379. isInvalid: boolean;
  146380. /**
  146381. * Creates a new KhronosTextureContainer
  146382. * @param data contents of the KTX container file
  146383. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  146384. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  146385. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  146386. */
  146387. constructor(
  146388. /** contents of the KTX container file */
  146389. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  146390. /**
  146391. * Uploads KTX content to a Babylon Texture.
  146392. * It is assumed that the texture has already been created & is currently bound
  146393. * @hidden
  146394. */
  146395. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  146396. private _upload2DCompressedLevels;
  146397. /**
  146398. * Checks if the given data starts with a KTX file identifier.
  146399. * @param data the data to check
  146400. * @returns true if the data is a KTX file or false otherwise
  146401. */
  146402. static IsValid(data: ArrayBufferView): boolean;
  146403. }
  146404. }
  146405. declare module BABYLON {
  146406. /**
  146407. * Helper class to push actions to a pool of workers.
  146408. */
  146409. export class WorkerPool implements IDisposable {
  146410. private _workerInfos;
  146411. private _pendingActions;
  146412. /**
  146413. * Constructor
  146414. * @param workers Array of workers to use for actions
  146415. */
  146416. constructor(workers: Array<Worker>);
  146417. /**
  146418. * Terminates all workers and clears any pending actions.
  146419. */
  146420. dispose(): void;
  146421. /**
  146422. * Pushes an action to the worker pool. If all the workers are active, the action will be
  146423. * pended until a worker has completed its action.
  146424. * @param action The action to perform. Call onComplete when the action is complete.
  146425. */
  146426. push(action: (worker: Worker, onComplete: () => void) => void): void;
  146427. private _execute;
  146428. }
  146429. }
  146430. declare module BABYLON {
  146431. /**
  146432. * Class for loading KTX2 files
  146433. */
  146434. export class KhronosTextureContainer2 {
  146435. private static _WorkerPoolPromise?;
  146436. private static _Initialized;
  146437. private static _Ktx2Decoder;
  146438. /**
  146439. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  146440. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  146441. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  146442. * Urls you can change:
  146443. * URLConfig.jsDecoderModule
  146444. * URLConfig.wasmUASTCToASTC
  146445. * URLConfig.wasmUASTCToBC7
  146446. * URLConfig.wasmUASTCToRGBA_UNORM
  146447. * URLConfig.wasmUASTCToRGBA_SRGB
  146448. * URLConfig.jsMSCTranscoder
  146449. * URLConfig.wasmMSCTranscoder
  146450. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  146451. */
  146452. static URLConfig: {
  146453. jsDecoderModule: string;
  146454. wasmUASTCToASTC: null;
  146455. wasmUASTCToBC7: null;
  146456. wasmUASTCToRGBA_UNORM: null;
  146457. wasmUASTCToRGBA_SRGB: null;
  146458. jsMSCTranscoder: null;
  146459. wasmMSCTranscoder: null;
  146460. };
  146461. /**
  146462. * Default number of workers used to handle data decoding
  146463. */
  146464. static DefaultNumWorkers: number;
  146465. private static GetDefaultNumWorkers;
  146466. private _engine;
  146467. private static _CreateWorkerPool;
  146468. /**
  146469. * Constructor
  146470. * @param engine The engine to use
  146471. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146472. */
  146473. constructor(engine: ThinEngine, numWorkers?: number);
  146474. /** @hidden */
  146475. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  146476. /**
  146477. * Stop all async operations and release resources.
  146478. */
  146479. dispose(): void;
  146480. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  146481. /**
  146482. * Checks if the given data starts with a KTX2 file identifier.
  146483. * @param data the data to check
  146484. * @returns true if the data is a KTX2 file or false otherwise
  146485. */
  146486. static IsValid(data: ArrayBufferView): boolean;
  146487. }
  146488. }
  146489. declare module BABYLON {
  146490. /**
  146491. * Implementation of the KTX Texture Loader.
  146492. * @hidden
  146493. */
  146494. export class _KTXTextureLoader implements IInternalTextureLoader {
  146495. /**
  146496. * Defines wether the loader supports cascade loading the different faces.
  146497. */
  146498. readonly supportCascades: boolean;
  146499. /**
  146500. * This returns if the loader support the current file information.
  146501. * @param extension defines the file extension of the file being loaded
  146502. * @param mimeType defines the optional mime type of the file being loaded
  146503. * @returns true if the loader can load the specified file
  146504. */
  146505. canLoad(extension: string, mimeType?: string): boolean;
  146506. /**
  146507. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146508. * @param data contains the texture data
  146509. * @param texture defines the BabylonJS internal texture
  146510. * @param createPolynomials will be true if polynomials have been requested
  146511. * @param onLoad defines the callback to trigger once the texture is ready
  146512. * @param onError defines the callback to trigger in case of error
  146513. */
  146514. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146515. /**
  146516. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146517. * @param data contains the texture data
  146518. * @param texture defines the BabylonJS internal texture
  146519. * @param callback defines the method to call once ready to upload
  146520. */
  146521. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  146522. }
  146523. }
  146524. declare module BABYLON {
  146525. /** @hidden */
  146526. export var _forceSceneHelpersToBundle: boolean;
  146527. interface Scene {
  146528. /**
  146529. * Creates a default light for the scene.
  146530. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  146531. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  146532. */
  146533. createDefaultLight(replace?: boolean): void;
  146534. /**
  146535. * Creates a default camera for the scene.
  146536. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  146537. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  146538. * @param replace has default false, when true replaces the active camera in the scene
  146539. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  146540. */
  146541. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  146542. /**
  146543. * Creates a default camera and a default light.
  146544. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  146545. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  146546. * @param replace has the default false, when true replaces the active camera/light in the scene
  146547. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  146548. */
  146549. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  146550. /**
  146551. * Creates a new sky box
  146552. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  146553. * @param environmentTexture defines the texture to use as environment texture
  146554. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  146555. * @param scale defines the overall scale of the skybox
  146556. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  146557. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  146558. * @returns a new mesh holding the sky box
  146559. */
  146560. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  146561. /**
  146562. * Creates a new environment
  146563. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  146564. * @param options defines the options you can use to configure the environment
  146565. * @returns the new EnvironmentHelper
  146566. */
  146567. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  146568. /**
  146569. * Creates a new VREXperienceHelper
  146570. * @see https://doc.babylonjs.com/how_to/webvr_helper
  146571. * @param webVROptions defines the options used to create the new VREXperienceHelper
  146572. * @returns a new VREXperienceHelper
  146573. */
  146574. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  146575. /**
  146576. * Creates a new WebXRDefaultExperience
  146577. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  146578. * @param options experience options
  146579. * @returns a promise for a new WebXRDefaultExperience
  146580. */
  146581. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  146582. }
  146583. }
  146584. declare module BABYLON {
  146585. /**
  146586. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  146587. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  146588. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  146589. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146590. */
  146591. export class VideoDome extends TextureDome<VideoTexture> {
  146592. /**
  146593. * Define the video source as a Monoscopic panoramic 360 video.
  146594. */
  146595. static readonly MODE_MONOSCOPIC: number;
  146596. /**
  146597. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  146598. */
  146599. static readonly MODE_TOPBOTTOM: number;
  146600. /**
  146601. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  146602. */
  146603. static readonly MODE_SIDEBYSIDE: number;
  146604. /**
  146605. * Get the video texture associated with this video dome
  146606. */
  146607. get videoTexture(): VideoTexture;
  146608. /**
  146609. * Get the video mode of this dome
  146610. */
  146611. get videoMode(): number;
  146612. /**
  146613. * Set the video mode of this dome.
  146614. * @see textureMode
  146615. */
  146616. set videoMode(value: number);
  146617. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  146618. }
  146619. }
  146620. declare module BABYLON {
  146621. /**
  146622. * This class can be used to get instrumentation data from a Babylon engine
  146623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  146624. */
  146625. export class EngineInstrumentation implements IDisposable {
  146626. /**
  146627. * Define the instrumented engine.
  146628. */
  146629. engine: Engine;
  146630. private _captureGPUFrameTime;
  146631. private _gpuFrameTimeToken;
  146632. private _gpuFrameTime;
  146633. private _captureShaderCompilationTime;
  146634. private _shaderCompilationTime;
  146635. private _onBeginFrameObserver;
  146636. private _onEndFrameObserver;
  146637. private _onBeforeShaderCompilationObserver;
  146638. private _onAfterShaderCompilationObserver;
  146639. /**
  146640. * Gets the perf counter used for GPU frame time
  146641. */
  146642. get gpuFrameTimeCounter(): PerfCounter;
  146643. /**
  146644. * Gets the GPU frame time capture status
  146645. */
  146646. get captureGPUFrameTime(): boolean;
  146647. /**
  146648. * Enable or disable the GPU frame time capture
  146649. */
  146650. set captureGPUFrameTime(value: boolean);
  146651. /**
  146652. * Gets the perf counter used for shader compilation time
  146653. */
  146654. get shaderCompilationTimeCounter(): PerfCounter;
  146655. /**
  146656. * Gets the shader compilation time capture status
  146657. */
  146658. get captureShaderCompilationTime(): boolean;
  146659. /**
  146660. * Enable or disable the shader compilation time capture
  146661. */
  146662. set captureShaderCompilationTime(value: boolean);
  146663. /**
  146664. * Instantiates a new engine instrumentation.
  146665. * This class can be used to get instrumentation data from a Babylon engine
  146666. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  146667. * @param engine Defines the engine to instrument
  146668. */
  146669. constructor(
  146670. /**
  146671. * Define the instrumented engine.
  146672. */
  146673. engine: Engine);
  146674. /**
  146675. * Dispose and release associated resources.
  146676. */
  146677. dispose(): void;
  146678. }
  146679. }
  146680. declare module BABYLON {
  146681. /**
  146682. * This class can be used to get instrumentation data from a Babylon engine
  146683. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  146684. */
  146685. export class SceneInstrumentation implements IDisposable {
  146686. /**
  146687. * Defines the scene to instrument
  146688. */
  146689. scene: Scene;
  146690. private _captureActiveMeshesEvaluationTime;
  146691. private _activeMeshesEvaluationTime;
  146692. private _captureRenderTargetsRenderTime;
  146693. private _renderTargetsRenderTime;
  146694. private _captureFrameTime;
  146695. private _frameTime;
  146696. private _captureRenderTime;
  146697. private _renderTime;
  146698. private _captureInterFrameTime;
  146699. private _interFrameTime;
  146700. private _captureParticlesRenderTime;
  146701. private _particlesRenderTime;
  146702. private _captureSpritesRenderTime;
  146703. private _spritesRenderTime;
  146704. private _capturePhysicsTime;
  146705. private _physicsTime;
  146706. private _captureAnimationsTime;
  146707. private _animationsTime;
  146708. private _captureCameraRenderTime;
  146709. private _cameraRenderTime;
  146710. private _onBeforeActiveMeshesEvaluationObserver;
  146711. private _onAfterActiveMeshesEvaluationObserver;
  146712. private _onBeforeRenderTargetsRenderObserver;
  146713. private _onAfterRenderTargetsRenderObserver;
  146714. private _onAfterRenderObserver;
  146715. private _onBeforeDrawPhaseObserver;
  146716. private _onAfterDrawPhaseObserver;
  146717. private _onBeforeAnimationsObserver;
  146718. private _onBeforeParticlesRenderingObserver;
  146719. private _onAfterParticlesRenderingObserver;
  146720. private _onBeforeSpritesRenderingObserver;
  146721. private _onAfterSpritesRenderingObserver;
  146722. private _onBeforePhysicsObserver;
  146723. private _onAfterPhysicsObserver;
  146724. private _onAfterAnimationsObserver;
  146725. private _onBeforeCameraRenderObserver;
  146726. private _onAfterCameraRenderObserver;
  146727. /**
  146728. * Gets the perf counter used for active meshes evaluation time
  146729. */
  146730. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  146731. /**
  146732. * Gets the active meshes evaluation time capture status
  146733. */
  146734. get captureActiveMeshesEvaluationTime(): boolean;
  146735. /**
  146736. * Enable or disable the active meshes evaluation time capture
  146737. */
  146738. set captureActiveMeshesEvaluationTime(value: boolean);
  146739. /**
  146740. * Gets the perf counter used for render targets render time
  146741. */
  146742. get renderTargetsRenderTimeCounter(): PerfCounter;
  146743. /**
  146744. * Gets the render targets render time capture status
  146745. */
  146746. get captureRenderTargetsRenderTime(): boolean;
  146747. /**
  146748. * Enable or disable the render targets render time capture
  146749. */
  146750. set captureRenderTargetsRenderTime(value: boolean);
  146751. /**
  146752. * Gets the perf counter used for particles render time
  146753. */
  146754. get particlesRenderTimeCounter(): PerfCounter;
  146755. /**
  146756. * Gets the particles render time capture status
  146757. */
  146758. get captureParticlesRenderTime(): boolean;
  146759. /**
  146760. * Enable or disable the particles render time capture
  146761. */
  146762. set captureParticlesRenderTime(value: boolean);
  146763. /**
  146764. * Gets the perf counter used for sprites render time
  146765. */
  146766. get spritesRenderTimeCounter(): PerfCounter;
  146767. /**
  146768. * Gets the sprites render time capture status
  146769. */
  146770. get captureSpritesRenderTime(): boolean;
  146771. /**
  146772. * Enable or disable the sprites render time capture
  146773. */
  146774. set captureSpritesRenderTime(value: boolean);
  146775. /**
  146776. * Gets the perf counter used for physics time
  146777. */
  146778. get physicsTimeCounter(): PerfCounter;
  146779. /**
  146780. * Gets the physics time capture status
  146781. */
  146782. get capturePhysicsTime(): boolean;
  146783. /**
  146784. * Enable or disable the physics time capture
  146785. */
  146786. set capturePhysicsTime(value: boolean);
  146787. /**
  146788. * Gets the perf counter used for animations time
  146789. */
  146790. get animationsTimeCounter(): PerfCounter;
  146791. /**
  146792. * Gets the animations time capture status
  146793. */
  146794. get captureAnimationsTime(): boolean;
  146795. /**
  146796. * Enable or disable the animations time capture
  146797. */
  146798. set captureAnimationsTime(value: boolean);
  146799. /**
  146800. * Gets the perf counter used for frame time capture
  146801. */
  146802. get frameTimeCounter(): PerfCounter;
  146803. /**
  146804. * Gets the frame time capture status
  146805. */
  146806. get captureFrameTime(): boolean;
  146807. /**
  146808. * Enable or disable the frame time capture
  146809. */
  146810. set captureFrameTime(value: boolean);
  146811. /**
  146812. * Gets the perf counter used for inter-frames time capture
  146813. */
  146814. get interFrameTimeCounter(): PerfCounter;
  146815. /**
  146816. * Gets the inter-frames time capture status
  146817. */
  146818. get captureInterFrameTime(): boolean;
  146819. /**
  146820. * Enable or disable the inter-frames time capture
  146821. */
  146822. set captureInterFrameTime(value: boolean);
  146823. /**
  146824. * Gets the perf counter used for render time capture
  146825. */
  146826. get renderTimeCounter(): PerfCounter;
  146827. /**
  146828. * Gets the render time capture status
  146829. */
  146830. get captureRenderTime(): boolean;
  146831. /**
  146832. * Enable or disable the render time capture
  146833. */
  146834. set captureRenderTime(value: boolean);
  146835. /**
  146836. * Gets the perf counter used for camera render time capture
  146837. */
  146838. get cameraRenderTimeCounter(): PerfCounter;
  146839. /**
  146840. * Gets the camera render time capture status
  146841. */
  146842. get captureCameraRenderTime(): boolean;
  146843. /**
  146844. * Enable or disable the camera render time capture
  146845. */
  146846. set captureCameraRenderTime(value: boolean);
  146847. /**
  146848. * Gets the perf counter used for draw calls
  146849. */
  146850. get drawCallsCounter(): PerfCounter;
  146851. /**
  146852. * Instantiates a new scene instrumentation.
  146853. * This class can be used to get instrumentation data from a Babylon engine
  146854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  146855. * @param scene Defines the scene to instrument
  146856. */
  146857. constructor(
  146858. /**
  146859. * Defines the scene to instrument
  146860. */
  146861. scene: Scene);
  146862. /**
  146863. * Dispose and release associated resources.
  146864. */
  146865. dispose(): void;
  146866. }
  146867. }
  146868. declare module BABYLON {
  146869. /** @hidden */
  146870. export var glowMapGenerationPixelShader: {
  146871. name: string;
  146872. shader: string;
  146873. };
  146874. }
  146875. declare module BABYLON {
  146876. /** @hidden */
  146877. export var glowMapGenerationVertexShader: {
  146878. name: string;
  146879. shader: string;
  146880. };
  146881. }
  146882. declare module BABYLON {
  146883. /**
  146884. * Effect layer options. This helps customizing the behaviour
  146885. * of the effect layer.
  146886. */
  146887. export interface IEffectLayerOptions {
  146888. /**
  146889. * Multiplication factor apply to the canvas size to compute the render target size
  146890. * used to generated the objects (the smaller the faster).
  146891. */
  146892. mainTextureRatio: number;
  146893. /**
  146894. * Enforces a fixed size texture to ensure effect stability across devices.
  146895. */
  146896. mainTextureFixedSize?: number;
  146897. /**
  146898. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  146899. */
  146900. alphaBlendingMode: number;
  146901. /**
  146902. * The camera attached to the layer.
  146903. */
  146904. camera: Nullable<Camera>;
  146905. /**
  146906. * The rendering group to draw the layer in.
  146907. */
  146908. renderingGroupId: number;
  146909. }
  146910. /**
  146911. * The effect layer Helps adding post process effect blended with the main pass.
  146912. *
  146913. * This can be for instance use to generate glow or higlight effects on the scene.
  146914. *
  146915. * The effect layer class can not be used directly and is intented to inherited from to be
  146916. * customized per effects.
  146917. */
  146918. export abstract class EffectLayer {
  146919. private _vertexBuffers;
  146920. private _indexBuffer;
  146921. private _cachedDefines;
  146922. private _effectLayerMapGenerationEffect;
  146923. private _effectLayerOptions;
  146924. private _mergeEffect;
  146925. protected _scene: Scene;
  146926. protected _engine: Engine;
  146927. protected _maxSize: number;
  146928. protected _mainTextureDesiredSize: ISize;
  146929. protected _mainTexture: RenderTargetTexture;
  146930. protected _shouldRender: boolean;
  146931. protected _postProcesses: PostProcess[];
  146932. protected _textures: BaseTexture[];
  146933. protected _emissiveTextureAndColor: {
  146934. texture: Nullable<BaseTexture>;
  146935. color: Color4;
  146936. };
  146937. /**
  146938. * The name of the layer
  146939. */
  146940. name: string;
  146941. /**
  146942. * The clear color of the texture used to generate the glow map.
  146943. */
  146944. neutralColor: Color4;
  146945. /**
  146946. * Specifies whether the highlight layer is enabled or not.
  146947. */
  146948. isEnabled: boolean;
  146949. /**
  146950. * Gets the camera attached to the layer.
  146951. */
  146952. get camera(): Nullable<Camera>;
  146953. /**
  146954. * Gets the rendering group id the layer should render in.
  146955. */
  146956. get renderingGroupId(): number;
  146957. set renderingGroupId(renderingGroupId: number);
  146958. /**
  146959. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  146960. */
  146961. disableBoundingBoxesFromEffectLayer: boolean;
  146962. /**
  146963. * An event triggered when the effect layer has been disposed.
  146964. */
  146965. onDisposeObservable: Observable<EffectLayer>;
  146966. /**
  146967. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  146968. */
  146969. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  146970. /**
  146971. * An event triggered when the generated texture is being merged in the scene.
  146972. */
  146973. onBeforeComposeObservable: Observable<EffectLayer>;
  146974. /**
  146975. * An event triggered when the mesh is rendered into the effect render target.
  146976. */
  146977. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  146978. /**
  146979. * An event triggered after the mesh has been rendered into the effect render target.
  146980. */
  146981. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  146982. /**
  146983. * An event triggered when the generated texture has been merged in the scene.
  146984. */
  146985. onAfterComposeObservable: Observable<EffectLayer>;
  146986. /**
  146987. * An event triggered when the efffect layer changes its size.
  146988. */
  146989. onSizeChangedObservable: Observable<EffectLayer>;
  146990. /** @hidden */
  146991. static _SceneComponentInitialization: (scene: Scene) => void;
  146992. /**
  146993. * Instantiates a new effect Layer and references it in the scene.
  146994. * @param name The name of the layer
  146995. * @param scene The scene to use the layer in
  146996. */
  146997. constructor(
  146998. /** The Friendly of the effect in the scene */
  146999. name: string, scene: Scene);
  147000. /**
  147001. * Get the effect name of the layer.
  147002. * @return The effect name
  147003. */
  147004. abstract getEffectName(): string;
  147005. /**
  147006. * Checks for the readiness of the element composing the layer.
  147007. * @param subMesh the mesh to check for
  147008. * @param useInstances specify whether or not to use instances to render the mesh
  147009. * @return true if ready otherwise, false
  147010. */
  147011. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147012. /**
  147013. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  147014. * @returns true if the effect requires stencil during the main canvas render pass.
  147015. */
  147016. abstract needStencil(): boolean;
  147017. /**
  147018. * Create the merge effect. This is the shader use to blit the information back
  147019. * to the main canvas at the end of the scene rendering.
  147020. * @returns The effect containing the shader used to merge the effect on the main canvas
  147021. */
  147022. protected abstract _createMergeEffect(): Effect;
  147023. /**
  147024. * Creates the render target textures and post processes used in the effect layer.
  147025. */
  147026. protected abstract _createTextureAndPostProcesses(): void;
  147027. /**
  147028. * Implementation specific of rendering the generating effect on the main canvas.
  147029. * @param effect The effect used to render through
  147030. */
  147031. protected abstract _internalRender(effect: Effect): void;
  147032. /**
  147033. * Sets the required values for both the emissive texture and and the main color.
  147034. */
  147035. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147036. /**
  147037. * Free any resources and references associated to a mesh.
  147038. * Internal use
  147039. * @param mesh The mesh to free.
  147040. */
  147041. abstract _disposeMesh(mesh: Mesh): void;
  147042. /**
  147043. * Serializes this layer (Glow or Highlight for example)
  147044. * @returns a serialized layer object
  147045. */
  147046. abstract serialize?(): any;
  147047. /**
  147048. * Initializes the effect layer with the required options.
  147049. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  147050. */
  147051. protected _init(options: Partial<IEffectLayerOptions>): void;
  147052. /**
  147053. * Generates the index buffer of the full screen quad blending to the main canvas.
  147054. */
  147055. private _generateIndexBuffer;
  147056. /**
  147057. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  147058. */
  147059. private _generateVertexBuffer;
  147060. /**
  147061. * Sets the main texture desired size which is the closest power of two
  147062. * of the engine canvas size.
  147063. */
  147064. private _setMainTextureSize;
  147065. /**
  147066. * Creates the main texture for the effect layer.
  147067. */
  147068. protected _createMainTexture(): void;
  147069. /**
  147070. * Adds specific effects defines.
  147071. * @param defines The defines to add specifics to.
  147072. */
  147073. protected _addCustomEffectDefines(defines: string[]): void;
  147074. /**
  147075. * Checks for the readiness of the element composing the layer.
  147076. * @param subMesh the mesh to check for
  147077. * @param useInstances specify whether or not to use instances to render the mesh
  147078. * @param emissiveTexture the associated emissive texture used to generate the glow
  147079. * @return true if ready otherwise, false
  147080. */
  147081. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  147082. /**
  147083. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  147084. */
  147085. render(): void;
  147086. /**
  147087. * Determine if a given mesh will be used in the current effect.
  147088. * @param mesh mesh to test
  147089. * @returns true if the mesh will be used
  147090. */
  147091. hasMesh(mesh: AbstractMesh): boolean;
  147092. /**
  147093. * Returns true if the layer contains information to display, otherwise false.
  147094. * @returns true if the glow layer should be rendered
  147095. */
  147096. shouldRender(): boolean;
  147097. /**
  147098. * Returns true if the mesh should render, otherwise false.
  147099. * @param mesh The mesh to render
  147100. * @returns true if it should render otherwise false
  147101. */
  147102. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  147103. /**
  147104. * Returns true if the mesh can be rendered, otherwise false.
  147105. * @param mesh The mesh to render
  147106. * @param material The material used on the mesh
  147107. * @returns true if it can be rendered otherwise false
  147108. */
  147109. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147110. /**
  147111. * Returns true if the mesh should render, otherwise false.
  147112. * @param mesh The mesh to render
  147113. * @returns true if it should render otherwise false
  147114. */
  147115. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  147116. /**
  147117. * Renders the submesh passed in parameter to the generation map.
  147118. */
  147119. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  147120. /**
  147121. * Defines whether the current material of the mesh should be use to render the effect.
  147122. * @param mesh defines the current mesh to render
  147123. */
  147124. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  147125. /**
  147126. * Rebuild the required buffers.
  147127. * @hidden Internal use only.
  147128. */
  147129. _rebuild(): void;
  147130. /**
  147131. * Dispose only the render target textures and post process.
  147132. */
  147133. private _disposeTextureAndPostProcesses;
  147134. /**
  147135. * Dispose the highlight layer and free resources.
  147136. */
  147137. dispose(): void;
  147138. /**
  147139. * Gets the class name of the effect layer
  147140. * @returns the string with the class name of the effect layer
  147141. */
  147142. getClassName(): string;
  147143. /**
  147144. * Creates an effect layer from parsed effect layer data
  147145. * @param parsedEffectLayer defines effect layer data
  147146. * @param scene defines the current scene
  147147. * @param rootUrl defines the root URL containing the effect layer information
  147148. * @returns a parsed effect Layer
  147149. */
  147150. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  147151. }
  147152. }
  147153. declare module BABYLON {
  147154. interface AbstractScene {
  147155. /**
  147156. * The list of effect layers (highlights/glow) added to the scene
  147157. * @see https://doc.babylonjs.com/how_to/highlight_layer
  147158. * @see https://doc.babylonjs.com/how_to/glow_layer
  147159. */
  147160. effectLayers: Array<EffectLayer>;
  147161. /**
  147162. * Removes the given effect layer from this scene.
  147163. * @param toRemove defines the effect layer to remove
  147164. * @returns the index of the removed effect layer
  147165. */
  147166. removeEffectLayer(toRemove: EffectLayer): number;
  147167. /**
  147168. * Adds the given effect layer to this scene
  147169. * @param newEffectLayer defines the effect layer to add
  147170. */
  147171. addEffectLayer(newEffectLayer: EffectLayer): void;
  147172. }
  147173. /**
  147174. * Defines the layer scene component responsible to manage any effect layers
  147175. * in a given scene.
  147176. */
  147177. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  147178. /**
  147179. * The component name helpfull to identify the component in the list of scene components.
  147180. */
  147181. readonly name: string;
  147182. /**
  147183. * The scene the component belongs to.
  147184. */
  147185. scene: Scene;
  147186. private _engine;
  147187. private _renderEffects;
  147188. private _needStencil;
  147189. private _previousStencilState;
  147190. /**
  147191. * Creates a new instance of the component for the given scene
  147192. * @param scene Defines the scene to register the component in
  147193. */
  147194. constructor(scene: Scene);
  147195. /**
  147196. * Registers the component in a given scene
  147197. */
  147198. register(): void;
  147199. /**
  147200. * Rebuilds the elements related to this component in case of
  147201. * context lost for instance.
  147202. */
  147203. rebuild(): void;
  147204. /**
  147205. * Serializes the component data to the specified json object
  147206. * @param serializationObject The object to serialize to
  147207. */
  147208. serialize(serializationObject: any): void;
  147209. /**
  147210. * Adds all the elements from the container to the scene
  147211. * @param container the container holding the elements
  147212. */
  147213. addFromContainer(container: AbstractScene): void;
  147214. /**
  147215. * Removes all the elements in the container from the scene
  147216. * @param container contains the elements to remove
  147217. * @param dispose if the removed element should be disposed (default: false)
  147218. */
  147219. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  147220. /**
  147221. * Disposes the component and the associated ressources.
  147222. */
  147223. dispose(): void;
  147224. private _isReadyForMesh;
  147225. private _renderMainTexture;
  147226. private _setStencil;
  147227. private _setStencilBack;
  147228. private _draw;
  147229. private _drawCamera;
  147230. private _drawRenderingGroup;
  147231. }
  147232. }
  147233. declare module BABYLON {
  147234. /** @hidden */
  147235. export var glowMapMergePixelShader: {
  147236. name: string;
  147237. shader: string;
  147238. };
  147239. }
  147240. declare module BABYLON {
  147241. /** @hidden */
  147242. export var glowMapMergeVertexShader: {
  147243. name: string;
  147244. shader: string;
  147245. };
  147246. }
  147247. declare module BABYLON {
  147248. interface AbstractScene {
  147249. /**
  147250. * Return a the first highlight layer of the scene with a given name.
  147251. * @param name The name of the highlight layer to look for.
  147252. * @return The highlight layer if found otherwise null.
  147253. */
  147254. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  147255. }
  147256. /**
  147257. * Glow layer options. This helps customizing the behaviour
  147258. * of the glow layer.
  147259. */
  147260. export interface IGlowLayerOptions {
  147261. /**
  147262. * Multiplication factor apply to the canvas size to compute the render target size
  147263. * used to generated the glowing objects (the smaller the faster).
  147264. */
  147265. mainTextureRatio: number;
  147266. /**
  147267. * Enforces a fixed size texture to ensure resize independant blur.
  147268. */
  147269. mainTextureFixedSize?: number;
  147270. /**
  147271. * How big is the kernel of the blur texture.
  147272. */
  147273. blurKernelSize: number;
  147274. /**
  147275. * The camera attached to the layer.
  147276. */
  147277. camera: Nullable<Camera>;
  147278. /**
  147279. * Enable MSAA by chosing the number of samples.
  147280. */
  147281. mainTextureSamples?: number;
  147282. /**
  147283. * The rendering group to draw the layer in.
  147284. */
  147285. renderingGroupId: number;
  147286. }
  147287. /**
  147288. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  147289. *
  147290. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  147291. *
  147292. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  147293. */
  147294. export class GlowLayer extends EffectLayer {
  147295. /**
  147296. * Effect Name of the layer.
  147297. */
  147298. static readonly EffectName: string;
  147299. /**
  147300. * The default blur kernel size used for the glow.
  147301. */
  147302. static DefaultBlurKernelSize: number;
  147303. /**
  147304. * The default texture size ratio used for the glow.
  147305. */
  147306. static DefaultTextureRatio: number;
  147307. /**
  147308. * Sets the kernel size of the blur.
  147309. */
  147310. set blurKernelSize(value: number);
  147311. /**
  147312. * Gets the kernel size of the blur.
  147313. */
  147314. get blurKernelSize(): number;
  147315. /**
  147316. * Sets the glow intensity.
  147317. */
  147318. set intensity(value: number);
  147319. /**
  147320. * Gets the glow intensity.
  147321. */
  147322. get intensity(): number;
  147323. private _options;
  147324. private _intensity;
  147325. private _horizontalBlurPostprocess1;
  147326. private _verticalBlurPostprocess1;
  147327. private _horizontalBlurPostprocess2;
  147328. private _verticalBlurPostprocess2;
  147329. private _blurTexture1;
  147330. private _blurTexture2;
  147331. private _postProcesses1;
  147332. private _postProcesses2;
  147333. private _includedOnlyMeshes;
  147334. private _excludedMeshes;
  147335. private _meshesUsingTheirOwnMaterials;
  147336. /**
  147337. * Callback used to let the user override the color selection on a per mesh basis
  147338. */
  147339. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  147340. /**
  147341. * Callback used to let the user override the texture selection on a per mesh basis
  147342. */
  147343. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  147344. /**
  147345. * Instantiates a new glow Layer and references it to the scene.
  147346. * @param name The name of the layer
  147347. * @param scene The scene to use the layer in
  147348. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  147349. */
  147350. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  147351. /**
  147352. * Get the effect name of the layer.
  147353. * @return The effect name
  147354. */
  147355. getEffectName(): string;
  147356. /**
  147357. * Create the merge effect. This is the shader use to blit the information back
  147358. * to the main canvas at the end of the scene rendering.
  147359. */
  147360. protected _createMergeEffect(): Effect;
  147361. /**
  147362. * Creates the render target textures and post processes used in the glow layer.
  147363. */
  147364. protected _createTextureAndPostProcesses(): void;
  147365. /**
  147366. * Checks for the readiness of the element composing the layer.
  147367. * @param subMesh the mesh to check for
  147368. * @param useInstances specify wether or not to use instances to render the mesh
  147369. * @param emissiveTexture the associated emissive texture used to generate the glow
  147370. * @return true if ready otherwise, false
  147371. */
  147372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147373. /**
  147374. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  147375. */
  147376. needStencil(): boolean;
  147377. /**
  147378. * Returns true if the mesh can be rendered, otherwise false.
  147379. * @param mesh The mesh to render
  147380. * @param material The material used on the mesh
  147381. * @returns true if it can be rendered otherwise false
  147382. */
  147383. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147384. /**
  147385. * Implementation specific of rendering the generating effect on the main canvas.
  147386. * @param effect The effect used to render through
  147387. */
  147388. protected _internalRender(effect: Effect): void;
  147389. /**
  147390. * Sets the required values for both the emissive texture and and the main color.
  147391. */
  147392. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147393. /**
  147394. * Returns true if the mesh should render, otherwise false.
  147395. * @param mesh The mesh to render
  147396. * @returns true if it should render otherwise false
  147397. */
  147398. protected _shouldRenderMesh(mesh: Mesh): boolean;
  147399. /**
  147400. * Adds specific effects defines.
  147401. * @param defines The defines to add specifics to.
  147402. */
  147403. protected _addCustomEffectDefines(defines: string[]): void;
  147404. /**
  147405. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  147406. * @param mesh The mesh to exclude from the glow layer
  147407. */
  147408. addExcludedMesh(mesh: Mesh): void;
  147409. /**
  147410. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  147411. * @param mesh The mesh to remove
  147412. */
  147413. removeExcludedMesh(mesh: Mesh): void;
  147414. /**
  147415. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  147416. * @param mesh The mesh to include in the glow layer
  147417. */
  147418. addIncludedOnlyMesh(mesh: Mesh): void;
  147419. /**
  147420. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  147421. * @param mesh The mesh to remove
  147422. */
  147423. removeIncludedOnlyMesh(mesh: Mesh): void;
  147424. /**
  147425. * Determine if a given mesh will be used in the glow layer
  147426. * @param mesh The mesh to test
  147427. * @returns true if the mesh will be highlighted by the current glow layer
  147428. */
  147429. hasMesh(mesh: AbstractMesh): boolean;
  147430. /**
  147431. * Defines whether the current material of the mesh should be use to render the effect.
  147432. * @param mesh defines the current mesh to render
  147433. */
  147434. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  147435. /**
  147436. * Add a mesh to be rendered through its own material and not with emissive only.
  147437. * @param mesh The mesh for which we need to use its material
  147438. */
  147439. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  147440. /**
  147441. * Remove a mesh from being rendered through its own material and not with emissive only.
  147442. * @param mesh The mesh for which we need to not use its material
  147443. */
  147444. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  147445. /**
  147446. * Free any resources and references associated to a mesh.
  147447. * Internal use
  147448. * @param mesh The mesh to free.
  147449. * @hidden
  147450. */
  147451. _disposeMesh(mesh: Mesh): void;
  147452. /**
  147453. * Gets the class name of the effect layer
  147454. * @returns the string with the class name of the effect layer
  147455. */
  147456. getClassName(): string;
  147457. /**
  147458. * Serializes this glow layer
  147459. * @returns a serialized glow layer object
  147460. */
  147461. serialize(): any;
  147462. /**
  147463. * Creates a Glow Layer from parsed glow layer data
  147464. * @param parsedGlowLayer defines glow layer data
  147465. * @param scene defines the current scene
  147466. * @param rootUrl defines the root URL containing the glow layer information
  147467. * @returns a parsed Glow Layer
  147468. */
  147469. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  147470. }
  147471. }
  147472. declare module BABYLON {
  147473. /** @hidden */
  147474. export var glowBlurPostProcessPixelShader: {
  147475. name: string;
  147476. shader: string;
  147477. };
  147478. }
  147479. declare module BABYLON {
  147480. interface AbstractScene {
  147481. /**
  147482. * Return a the first highlight layer of the scene with a given name.
  147483. * @param name The name of the highlight layer to look for.
  147484. * @return The highlight layer if found otherwise null.
  147485. */
  147486. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  147487. }
  147488. /**
  147489. * Highlight layer options. This helps customizing the behaviour
  147490. * of the highlight layer.
  147491. */
  147492. export interface IHighlightLayerOptions {
  147493. /**
  147494. * Multiplication factor apply to the canvas size to compute the render target size
  147495. * used to generated the glowing objects (the smaller the faster).
  147496. */
  147497. mainTextureRatio: number;
  147498. /**
  147499. * Enforces a fixed size texture to ensure resize independant blur.
  147500. */
  147501. mainTextureFixedSize?: number;
  147502. /**
  147503. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  147504. * of the picture to blur (the smaller the faster).
  147505. */
  147506. blurTextureSizeRatio: number;
  147507. /**
  147508. * How big in texel of the blur texture is the vertical blur.
  147509. */
  147510. blurVerticalSize: number;
  147511. /**
  147512. * How big in texel of the blur texture is the horizontal blur.
  147513. */
  147514. blurHorizontalSize: number;
  147515. /**
  147516. * Alpha blending mode used to apply the blur. Default is combine.
  147517. */
  147518. alphaBlendingMode: number;
  147519. /**
  147520. * The camera attached to the layer.
  147521. */
  147522. camera: Nullable<Camera>;
  147523. /**
  147524. * Should we display highlight as a solid stroke?
  147525. */
  147526. isStroke?: boolean;
  147527. /**
  147528. * The rendering group to draw the layer in.
  147529. */
  147530. renderingGroupId: number;
  147531. }
  147532. /**
  147533. * The highlight layer Helps adding a glow effect around a mesh.
  147534. *
  147535. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  147536. * glowy meshes to your scene.
  147537. *
  147538. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  147539. */
  147540. export class HighlightLayer extends EffectLayer {
  147541. name: string;
  147542. /**
  147543. * Effect Name of the highlight layer.
  147544. */
  147545. static readonly EffectName: string;
  147546. /**
  147547. * The neutral color used during the preparation of the glow effect.
  147548. * This is black by default as the blend operation is a blend operation.
  147549. */
  147550. static NeutralColor: Color4;
  147551. /**
  147552. * Stencil value used for glowing meshes.
  147553. */
  147554. static GlowingMeshStencilReference: number;
  147555. /**
  147556. * Stencil value used for the other meshes in the scene.
  147557. */
  147558. static NormalMeshStencilReference: number;
  147559. /**
  147560. * Specifies whether or not the inner glow is ACTIVE in the layer.
  147561. */
  147562. innerGlow: boolean;
  147563. /**
  147564. * Specifies whether or not the outer glow is ACTIVE in the layer.
  147565. */
  147566. outerGlow: boolean;
  147567. /**
  147568. * Specifies the horizontal size of the blur.
  147569. */
  147570. set blurHorizontalSize(value: number);
  147571. /**
  147572. * Specifies the vertical size of the blur.
  147573. */
  147574. set blurVerticalSize(value: number);
  147575. /**
  147576. * Gets the horizontal size of the blur.
  147577. */
  147578. get blurHorizontalSize(): number;
  147579. /**
  147580. * Gets the vertical size of the blur.
  147581. */
  147582. get blurVerticalSize(): number;
  147583. /**
  147584. * An event triggered when the highlight layer is being blurred.
  147585. */
  147586. onBeforeBlurObservable: Observable<HighlightLayer>;
  147587. /**
  147588. * An event triggered when the highlight layer has been blurred.
  147589. */
  147590. onAfterBlurObservable: Observable<HighlightLayer>;
  147591. private _instanceGlowingMeshStencilReference;
  147592. private _options;
  147593. private _downSamplePostprocess;
  147594. private _horizontalBlurPostprocess;
  147595. private _verticalBlurPostprocess;
  147596. private _blurTexture;
  147597. private _meshes;
  147598. private _excludedMeshes;
  147599. /**
  147600. * Instantiates a new highlight Layer and references it to the scene..
  147601. * @param name The name of the layer
  147602. * @param scene The scene to use the layer in
  147603. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  147604. */
  147605. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  147606. /**
  147607. * Get the effect name of the layer.
  147608. * @return The effect name
  147609. */
  147610. getEffectName(): string;
  147611. /**
  147612. * Create the merge effect. This is the shader use to blit the information back
  147613. * to the main canvas at the end of the scene rendering.
  147614. */
  147615. protected _createMergeEffect(): Effect;
  147616. /**
  147617. * Creates the render target textures and post processes used in the highlight layer.
  147618. */
  147619. protected _createTextureAndPostProcesses(): void;
  147620. /**
  147621. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  147622. */
  147623. needStencil(): boolean;
  147624. /**
  147625. * Checks for the readiness of the element composing the layer.
  147626. * @param subMesh the mesh to check for
  147627. * @param useInstances specify wether or not to use instances to render the mesh
  147628. * @param emissiveTexture the associated emissive texture used to generate the glow
  147629. * @return true if ready otherwise, false
  147630. */
  147631. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147632. /**
  147633. * Implementation specific of rendering the generating effect on the main canvas.
  147634. * @param effect The effect used to render through
  147635. */
  147636. protected _internalRender(effect: Effect): void;
  147637. /**
  147638. * Returns true if the layer contains information to display, otherwise false.
  147639. */
  147640. shouldRender(): boolean;
  147641. /**
  147642. * Returns true if the mesh should render, otherwise false.
  147643. * @param mesh The mesh to render
  147644. * @returns true if it should render otherwise false
  147645. */
  147646. protected _shouldRenderMesh(mesh: Mesh): boolean;
  147647. /**
  147648. * Returns true if the mesh can be rendered, otherwise false.
  147649. * @param mesh The mesh to render
  147650. * @param material The material used on the mesh
  147651. * @returns true if it can be rendered otherwise false
  147652. */
  147653. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147654. /**
  147655. * Adds specific effects defines.
  147656. * @param defines The defines to add specifics to.
  147657. */
  147658. protected _addCustomEffectDefines(defines: string[]): void;
  147659. /**
  147660. * Sets the required values for both the emissive texture and and the main color.
  147661. */
  147662. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147663. /**
  147664. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  147665. * @param mesh The mesh to exclude from the highlight layer
  147666. */
  147667. addExcludedMesh(mesh: Mesh): void;
  147668. /**
  147669. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  147670. * @param mesh The mesh to highlight
  147671. */
  147672. removeExcludedMesh(mesh: Mesh): void;
  147673. /**
  147674. * Determine if a given mesh will be highlighted by the current HighlightLayer
  147675. * @param mesh mesh to test
  147676. * @returns true if the mesh will be highlighted by the current HighlightLayer
  147677. */
  147678. hasMesh(mesh: AbstractMesh): boolean;
  147679. /**
  147680. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  147681. * @param mesh The mesh to highlight
  147682. * @param color The color of the highlight
  147683. * @param glowEmissiveOnly Extract the glow from the emissive texture
  147684. */
  147685. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  147686. /**
  147687. * Remove a mesh from the highlight layer in order to make it stop glowing.
  147688. * @param mesh The mesh to highlight
  147689. */
  147690. removeMesh(mesh: Mesh): void;
  147691. /**
  147692. * Remove all the meshes currently referenced in the highlight layer
  147693. */
  147694. removeAllMeshes(): void;
  147695. /**
  147696. * Force the stencil to the normal expected value for none glowing parts
  147697. */
  147698. private _defaultStencilReference;
  147699. /**
  147700. * Free any resources and references associated to a mesh.
  147701. * Internal use
  147702. * @param mesh The mesh to free.
  147703. * @hidden
  147704. */
  147705. _disposeMesh(mesh: Mesh): void;
  147706. /**
  147707. * Dispose the highlight layer and free resources.
  147708. */
  147709. dispose(): void;
  147710. /**
  147711. * Gets the class name of the effect layer
  147712. * @returns the string with the class name of the effect layer
  147713. */
  147714. getClassName(): string;
  147715. /**
  147716. * Serializes this Highlight layer
  147717. * @returns a serialized Highlight layer object
  147718. */
  147719. serialize(): any;
  147720. /**
  147721. * Creates a Highlight layer from parsed Highlight layer data
  147722. * @param parsedHightlightLayer defines the Highlight layer data
  147723. * @param scene defines the current scene
  147724. * @param rootUrl defines the root URL containing the Highlight layer information
  147725. * @returns a parsed Highlight layer
  147726. */
  147727. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  147728. }
  147729. }
  147730. declare module BABYLON {
  147731. interface AbstractScene {
  147732. /**
  147733. * The list of layers (background and foreground) of the scene
  147734. */
  147735. layers: Array<Layer>;
  147736. }
  147737. /**
  147738. * Defines the layer scene component responsible to manage any layers
  147739. * in a given scene.
  147740. */
  147741. export class LayerSceneComponent implements ISceneComponent {
  147742. /**
  147743. * The component name helpfull to identify the component in the list of scene components.
  147744. */
  147745. readonly name: string;
  147746. /**
  147747. * The scene the component belongs to.
  147748. */
  147749. scene: Scene;
  147750. private _engine;
  147751. /**
  147752. * Creates a new instance of the component for the given scene
  147753. * @param scene Defines the scene to register the component in
  147754. */
  147755. constructor(scene: Scene);
  147756. /**
  147757. * Registers the component in a given scene
  147758. */
  147759. register(): void;
  147760. /**
  147761. * Rebuilds the elements related to this component in case of
  147762. * context lost for instance.
  147763. */
  147764. rebuild(): void;
  147765. /**
  147766. * Disposes the component and the associated ressources.
  147767. */
  147768. dispose(): void;
  147769. private _draw;
  147770. private _drawCameraPredicate;
  147771. private _drawCameraBackground;
  147772. private _drawCameraForeground;
  147773. private _drawRenderTargetPredicate;
  147774. private _drawRenderTargetBackground;
  147775. private _drawRenderTargetForeground;
  147776. /**
  147777. * Adds all the elements from the container to the scene
  147778. * @param container the container holding the elements
  147779. */
  147780. addFromContainer(container: AbstractScene): void;
  147781. /**
  147782. * Removes all the elements in the container from the scene
  147783. * @param container contains the elements to remove
  147784. * @param dispose if the removed element should be disposed (default: false)
  147785. */
  147786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  147787. }
  147788. }
  147789. declare module BABYLON {
  147790. /** @hidden */
  147791. export var layerPixelShader: {
  147792. name: string;
  147793. shader: string;
  147794. };
  147795. }
  147796. declare module BABYLON {
  147797. /** @hidden */
  147798. export var layerVertexShader: {
  147799. name: string;
  147800. shader: string;
  147801. };
  147802. }
  147803. declare module BABYLON {
  147804. /**
  147805. * This represents a full screen 2d layer.
  147806. * This can be useful to display a picture in the background of your scene for instance.
  147807. * @see https://www.babylonjs-playground.com/#08A2BS#1
  147808. */
  147809. export class Layer {
  147810. /**
  147811. * Define the name of the layer.
  147812. */
  147813. name: string;
  147814. /**
  147815. * Define the texture the layer should display.
  147816. */
  147817. texture: Nullable<Texture>;
  147818. /**
  147819. * Is the layer in background or foreground.
  147820. */
  147821. isBackground: boolean;
  147822. /**
  147823. * Define the color of the layer (instead of texture).
  147824. */
  147825. color: Color4;
  147826. /**
  147827. * Define the scale of the layer in order to zoom in out of the texture.
  147828. */
  147829. scale: Vector2;
  147830. /**
  147831. * Define an offset for the layer in order to shift the texture.
  147832. */
  147833. offset: Vector2;
  147834. /**
  147835. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  147836. */
  147837. alphaBlendingMode: number;
  147838. /**
  147839. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  147840. * Alpha test will not mix with the background color in case of transparency.
  147841. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  147842. */
  147843. alphaTest: boolean;
  147844. /**
  147845. * Define a mask to restrict the layer to only some of the scene cameras.
  147846. */
  147847. layerMask: number;
  147848. /**
  147849. * Define the list of render target the layer is visible into.
  147850. */
  147851. renderTargetTextures: RenderTargetTexture[];
  147852. /**
  147853. * Define if the layer is only used in renderTarget or if it also
  147854. * renders in the main frame buffer of the canvas.
  147855. */
  147856. renderOnlyInRenderTargetTextures: boolean;
  147857. private _scene;
  147858. private _vertexBuffers;
  147859. private _indexBuffer;
  147860. private _effect;
  147861. private _previousDefines;
  147862. /**
  147863. * An event triggered when the layer is disposed.
  147864. */
  147865. onDisposeObservable: Observable<Layer>;
  147866. private _onDisposeObserver;
  147867. /**
  147868. * Back compatibility with callback before the onDisposeObservable existed.
  147869. * The set callback will be triggered when the layer has been disposed.
  147870. */
  147871. set onDispose(callback: () => void);
  147872. /**
  147873. * An event triggered before rendering the scene
  147874. */
  147875. onBeforeRenderObservable: Observable<Layer>;
  147876. private _onBeforeRenderObserver;
  147877. /**
  147878. * Back compatibility with callback before the onBeforeRenderObservable existed.
  147879. * The set callback will be triggered just before rendering the layer.
  147880. */
  147881. set onBeforeRender(callback: () => void);
  147882. /**
  147883. * An event triggered after rendering the scene
  147884. */
  147885. onAfterRenderObservable: Observable<Layer>;
  147886. private _onAfterRenderObserver;
  147887. /**
  147888. * Back compatibility with callback before the onAfterRenderObservable existed.
  147889. * The set callback will be triggered just after rendering the layer.
  147890. */
  147891. set onAfterRender(callback: () => void);
  147892. /**
  147893. * Instantiates a new layer.
  147894. * This represents a full screen 2d layer.
  147895. * This can be useful to display a picture in the background of your scene for instance.
  147896. * @see https://www.babylonjs-playground.com/#08A2BS#1
  147897. * @param name Define the name of the layer in the scene
  147898. * @param imgUrl Define the url of the texture to display in the layer
  147899. * @param scene Define the scene the layer belongs to
  147900. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  147901. * @param color Defines a color for the layer
  147902. */
  147903. constructor(
  147904. /**
  147905. * Define the name of the layer.
  147906. */
  147907. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  147908. private _createIndexBuffer;
  147909. /** @hidden */
  147910. _rebuild(): void;
  147911. /**
  147912. * Renders the layer in the scene.
  147913. */
  147914. render(): void;
  147915. /**
  147916. * Disposes and releases the associated ressources.
  147917. */
  147918. dispose(): void;
  147919. }
  147920. }
  147921. declare module BABYLON {
  147922. /** @hidden */
  147923. export var lensFlarePixelShader: {
  147924. name: string;
  147925. shader: string;
  147926. };
  147927. }
  147928. declare module BABYLON {
  147929. /** @hidden */
  147930. export var lensFlareVertexShader: {
  147931. name: string;
  147932. shader: string;
  147933. };
  147934. }
  147935. declare module BABYLON {
  147936. /**
  147937. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  147938. * It is usually composed of several `lensFlare`.
  147939. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  147940. */
  147941. export class LensFlareSystem {
  147942. /**
  147943. * Define the name of the lens flare system
  147944. */
  147945. name: string;
  147946. /**
  147947. * List of lens flares used in this system.
  147948. */
  147949. lensFlares: LensFlare[];
  147950. /**
  147951. * Define a limit from the border the lens flare can be visible.
  147952. */
  147953. borderLimit: number;
  147954. /**
  147955. * Define a viewport border we do not want to see the lens flare in.
  147956. */
  147957. viewportBorder: number;
  147958. /**
  147959. * Define a predicate which could limit the list of meshes able to occlude the effect.
  147960. */
  147961. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  147962. /**
  147963. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  147964. */
  147965. layerMask: number;
  147966. /**
  147967. * Define the id of the lens flare system in the scene.
  147968. * (equal to name by default)
  147969. */
  147970. id: string;
  147971. private _scene;
  147972. private _emitter;
  147973. private _vertexBuffers;
  147974. private _indexBuffer;
  147975. private _effect;
  147976. private _positionX;
  147977. private _positionY;
  147978. private _isEnabled;
  147979. /** @hidden */
  147980. static _SceneComponentInitialization: (scene: Scene) => void;
  147981. /**
  147982. * Instantiates a lens flare system.
  147983. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  147984. * It is usually composed of several `lensFlare`.
  147985. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  147986. * @param name Define the name of the lens flare system in the scene
  147987. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  147988. * @param scene Define the scene the lens flare system belongs to
  147989. */
  147990. constructor(
  147991. /**
  147992. * Define the name of the lens flare system
  147993. */
  147994. name: string, emitter: any, scene: Scene);
  147995. /**
  147996. * Define if the lens flare system is enabled.
  147997. */
  147998. get isEnabled(): boolean;
  147999. set isEnabled(value: boolean);
  148000. /**
  148001. * Get the scene the effects belongs to.
  148002. * @returns the scene holding the lens flare system
  148003. */
  148004. getScene(): Scene;
  148005. /**
  148006. * Get the emitter of the lens flare system.
  148007. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148008. * @returns the emitter of the lens flare system
  148009. */
  148010. getEmitter(): any;
  148011. /**
  148012. * Set the emitter of the lens flare system.
  148013. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148014. * @param newEmitter Define the new emitter of the system
  148015. */
  148016. setEmitter(newEmitter: any): void;
  148017. /**
  148018. * Get the lens flare system emitter position.
  148019. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  148020. * @returns the position
  148021. */
  148022. getEmitterPosition(): Vector3;
  148023. /**
  148024. * @hidden
  148025. */
  148026. computeEffectivePosition(globalViewport: Viewport): boolean;
  148027. /** @hidden */
  148028. _isVisible(): boolean;
  148029. /**
  148030. * @hidden
  148031. */
  148032. render(): boolean;
  148033. /**
  148034. * Dispose and release the lens flare with its associated resources.
  148035. */
  148036. dispose(): void;
  148037. /**
  148038. * Parse a lens flare system from a JSON repressentation
  148039. * @param parsedLensFlareSystem Define the JSON to parse
  148040. * @param scene Define the scene the parsed system should be instantiated in
  148041. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  148042. * @returns the parsed system
  148043. */
  148044. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  148045. /**
  148046. * Serialize the current Lens Flare System into a JSON representation.
  148047. * @returns the serialized JSON
  148048. */
  148049. serialize(): any;
  148050. }
  148051. }
  148052. declare module BABYLON {
  148053. /**
  148054. * This represents one of the lens effect in a `lensFlareSystem`.
  148055. * It controls one of the indiviual texture used in the effect.
  148056. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148057. */
  148058. export class LensFlare {
  148059. /**
  148060. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148061. */
  148062. size: number;
  148063. /**
  148064. * 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.
  148065. */
  148066. position: number;
  148067. /**
  148068. * Define the lens color.
  148069. */
  148070. color: Color3;
  148071. /**
  148072. * Define the lens texture.
  148073. */
  148074. texture: Nullable<Texture>;
  148075. /**
  148076. * Define the alpha mode to render this particular lens.
  148077. */
  148078. alphaMode: number;
  148079. private _system;
  148080. /**
  148081. * Creates a new Lens Flare.
  148082. * This represents one of the lens effect in a `lensFlareSystem`.
  148083. * It controls one of the indiviual texture used in the effect.
  148084. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148085. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  148086. * @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.
  148087. * @param color Define the lens color
  148088. * @param imgUrl Define the lens texture url
  148089. * @param system Define the `lensFlareSystem` this flare is part of
  148090. * @returns The newly created Lens Flare
  148091. */
  148092. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  148093. /**
  148094. * Instantiates a new Lens Flare.
  148095. * This represents one of the lens effect in a `lensFlareSystem`.
  148096. * It controls one of the indiviual texture used in the effect.
  148097. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148098. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  148099. * @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.
  148100. * @param color Define the lens color
  148101. * @param imgUrl Define the lens texture url
  148102. * @param system Define the `lensFlareSystem` this flare is part of
  148103. */
  148104. constructor(
  148105. /**
  148106. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148107. */
  148108. size: number,
  148109. /**
  148110. * 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.
  148111. */
  148112. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  148113. /**
  148114. * Dispose and release the lens flare with its associated resources.
  148115. */
  148116. dispose(): void;
  148117. }
  148118. }
  148119. declare module BABYLON {
  148120. interface AbstractScene {
  148121. /**
  148122. * The list of lens flare system added to the scene
  148123. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148124. */
  148125. lensFlareSystems: Array<LensFlareSystem>;
  148126. /**
  148127. * Removes the given lens flare system from this scene.
  148128. * @param toRemove The lens flare system to remove
  148129. * @returns The index of the removed lens flare system
  148130. */
  148131. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  148132. /**
  148133. * Adds the given lens flare system to this scene
  148134. * @param newLensFlareSystem The lens flare system to add
  148135. */
  148136. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  148137. /**
  148138. * Gets a lens flare system using its name
  148139. * @param name defines the name to look for
  148140. * @returns the lens flare system or null if not found
  148141. */
  148142. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  148143. /**
  148144. * Gets a lens flare system using its id
  148145. * @param id defines the id to look for
  148146. * @returns the lens flare system or null if not found
  148147. */
  148148. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  148149. }
  148150. /**
  148151. * Defines the lens flare scene component responsible to manage any lens flares
  148152. * in a given scene.
  148153. */
  148154. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  148155. /**
  148156. * The component name helpfull to identify the component in the list of scene components.
  148157. */
  148158. readonly name: string;
  148159. /**
  148160. * The scene the component belongs to.
  148161. */
  148162. scene: Scene;
  148163. /**
  148164. * Creates a new instance of the component for the given scene
  148165. * @param scene Defines the scene to register the component in
  148166. */
  148167. constructor(scene: Scene);
  148168. /**
  148169. * Registers the component in a given scene
  148170. */
  148171. register(): void;
  148172. /**
  148173. * Rebuilds the elements related to this component in case of
  148174. * context lost for instance.
  148175. */
  148176. rebuild(): void;
  148177. /**
  148178. * Adds all the elements from the container to the scene
  148179. * @param container the container holding the elements
  148180. */
  148181. addFromContainer(container: AbstractScene): void;
  148182. /**
  148183. * Removes all the elements in the container from the scene
  148184. * @param container contains the elements to remove
  148185. * @param dispose if the removed element should be disposed (default: false)
  148186. */
  148187. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148188. /**
  148189. * Serializes the component data to the specified json object
  148190. * @param serializationObject The object to serialize to
  148191. */
  148192. serialize(serializationObject: any): void;
  148193. /**
  148194. * Disposes the component and the associated ressources.
  148195. */
  148196. dispose(): void;
  148197. private _draw;
  148198. }
  148199. }
  148200. declare module BABYLON {
  148201. /** @hidden */
  148202. export var depthPixelShader: {
  148203. name: string;
  148204. shader: string;
  148205. };
  148206. }
  148207. declare module BABYLON {
  148208. /** @hidden */
  148209. export var depthVertexShader: {
  148210. name: string;
  148211. shader: string;
  148212. };
  148213. }
  148214. declare module BABYLON {
  148215. /**
  148216. * This represents a depth renderer in Babylon.
  148217. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  148218. */
  148219. export class DepthRenderer {
  148220. private _scene;
  148221. private _depthMap;
  148222. private _effect;
  148223. private readonly _storeNonLinearDepth;
  148224. private readonly _clearColor;
  148225. /** Get if the depth renderer is using packed depth or not */
  148226. readonly isPacked: boolean;
  148227. private _cachedDefines;
  148228. private _camera;
  148229. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  148230. enabled: boolean;
  148231. /**
  148232. * Specifiess that the depth renderer will only be used within
  148233. * the camera it is created for.
  148234. * This can help forcing its rendering during the camera processing.
  148235. */
  148236. useOnlyInActiveCamera: boolean;
  148237. /** @hidden */
  148238. static _SceneComponentInitialization: (scene: Scene) => void;
  148239. /**
  148240. * Instantiates a depth renderer
  148241. * @param scene The scene the renderer belongs to
  148242. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  148243. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  148244. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148245. */
  148246. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  148247. /**
  148248. * Creates the depth rendering effect and checks if the effect is ready.
  148249. * @param subMesh The submesh to be used to render the depth map of
  148250. * @param useInstances If multiple world instances should be used
  148251. * @returns if the depth renderer is ready to render the depth map
  148252. */
  148253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148254. /**
  148255. * Gets the texture which the depth map will be written to.
  148256. * @returns The depth map texture
  148257. */
  148258. getDepthMap(): RenderTargetTexture;
  148259. /**
  148260. * Disposes of the depth renderer.
  148261. */
  148262. dispose(): void;
  148263. }
  148264. }
  148265. declare module BABYLON {
  148266. /** @hidden */
  148267. export var minmaxReduxPixelShader: {
  148268. name: string;
  148269. shader: string;
  148270. };
  148271. }
  148272. declare module BABYLON {
  148273. /**
  148274. * This class computes a min/max reduction from a texture: it means it computes the minimum
  148275. * and maximum values from all values of the texture.
  148276. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  148277. * The source values are read from the red channel of the texture.
  148278. */
  148279. export class MinMaxReducer {
  148280. /**
  148281. * Observable triggered when the computation has been performed
  148282. */
  148283. onAfterReductionPerformed: Observable<{
  148284. min: number;
  148285. max: number;
  148286. }>;
  148287. protected _camera: Camera;
  148288. protected _sourceTexture: Nullable<RenderTargetTexture>;
  148289. protected _reductionSteps: Nullable<Array<PostProcess>>;
  148290. protected _postProcessManager: PostProcessManager;
  148291. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  148292. protected _forceFullscreenViewport: boolean;
  148293. /**
  148294. * Creates a min/max reducer
  148295. * @param camera The camera to use for the post processes
  148296. */
  148297. constructor(camera: Camera);
  148298. /**
  148299. * Gets the texture used to read the values from.
  148300. */
  148301. get sourceTexture(): Nullable<RenderTargetTexture>;
  148302. /**
  148303. * Sets the source texture to read the values from.
  148304. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  148305. * because in such textures '1' value must not be taken into account to compute the maximum
  148306. * as this value is used to clear the texture.
  148307. * Note that the computation is not activated by calling this function, you must call activate() for that!
  148308. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  148309. * @param depthRedux Indicates if the texture is a depth texture or not
  148310. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  148311. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  148312. */
  148313. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  148314. /**
  148315. * Defines the refresh rate of the computation.
  148316. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  148317. */
  148318. get refreshRate(): number;
  148319. set refreshRate(value: number);
  148320. protected _activated: boolean;
  148321. /**
  148322. * Gets the activation status of the reducer
  148323. */
  148324. get activated(): boolean;
  148325. /**
  148326. * Activates the reduction computation.
  148327. * When activated, the observers registered in onAfterReductionPerformed are
  148328. * called after the compuation is performed
  148329. */
  148330. activate(): void;
  148331. /**
  148332. * Deactivates the reduction computation.
  148333. */
  148334. deactivate(): void;
  148335. /**
  148336. * Disposes the min/max reducer
  148337. * @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.
  148338. */
  148339. dispose(disposeAll?: boolean): void;
  148340. }
  148341. }
  148342. declare module BABYLON {
  148343. /**
  148344. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  148345. */
  148346. export class DepthReducer extends MinMaxReducer {
  148347. private _depthRenderer;
  148348. private _depthRendererId;
  148349. /**
  148350. * Gets the depth renderer used for the computation.
  148351. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  148352. */
  148353. get depthRenderer(): Nullable<DepthRenderer>;
  148354. /**
  148355. * Creates a depth reducer
  148356. * @param camera The camera used to render the depth texture
  148357. */
  148358. constructor(camera: Camera);
  148359. /**
  148360. * Sets the depth renderer to use to generate the depth map
  148361. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  148362. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  148363. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  148364. */
  148365. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  148366. /** @hidden */
  148367. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  148368. /**
  148369. * Activates the reduction computation.
  148370. * When activated, the observers registered in onAfterReductionPerformed are
  148371. * called after the compuation is performed
  148372. */
  148373. activate(): void;
  148374. /**
  148375. * Deactivates the reduction computation.
  148376. */
  148377. deactivate(): void;
  148378. /**
  148379. * Disposes the depth reducer
  148380. * @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.
  148381. */
  148382. dispose(disposeAll?: boolean): void;
  148383. }
  148384. }
  148385. declare module BABYLON {
  148386. /**
  148387. * A CSM implementation allowing casting shadows on large scenes.
  148388. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  148389. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  148390. */
  148391. export class CascadedShadowGenerator extends ShadowGenerator {
  148392. private static readonly frustumCornersNDCSpace;
  148393. /**
  148394. * Name of the CSM class
  148395. */
  148396. static CLASSNAME: string;
  148397. /**
  148398. * Defines the default number of cascades used by the CSM.
  148399. */
  148400. static readonly DEFAULT_CASCADES_COUNT: number;
  148401. /**
  148402. * Defines the minimum number of cascades used by the CSM.
  148403. */
  148404. static readonly MIN_CASCADES_COUNT: number;
  148405. /**
  148406. * Defines the maximum number of cascades used by the CSM.
  148407. */
  148408. static readonly MAX_CASCADES_COUNT: number;
  148409. protected _validateFilter(filter: number): number;
  148410. /**
  148411. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  148412. */
  148413. penumbraDarkness: number;
  148414. private _numCascades;
  148415. /**
  148416. * Gets or set the number of cascades used by the CSM.
  148417. */
  148418. get numCascades(): number;
  148419. set numCascades(value: number);
  148420. /**
  148421. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  148422. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  148423. */
  148424. stabilizeCascades: boolean;
  148425. private _freezeShadowCastersBoundingInfo;
  148426. private _freezeShadowCastersBoundingInfoObservable;
  148427. /**
  148428. * Enables or disables the shadow casters bounding info computation.
  148429. * If your shadow casters don't move, you can disable this feature.
  148430. * If it is enabled, the bounding box computation is done every frame.
  148431. */
  148432. get freezeShadowCastersBoundingInfo(): boolean;
  148433. set freezeShadowCastersBoundingInfo(freeze: boolean);
  148434. private _scbiMin;
  148435. private _scbiMax;
  148436. protected _computeShadowCastersBoundingInfo(): void;
  148437. protected _shadowCastersBoundingInfo: BoundingInfo;
  148438. /**
  148439. * Gets or sets the shadow casters bounding info.
  148440. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  148441. * so that the system won't overwrite the bounds you provide
  148442. */
  148443. get shadowCastersBoundingInfo(): BoundingInfo;
  148444. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  148445. protected _breaksAreDirty: boolean;
  148446. protected _minDistance: number;
  148447. protected _maxDistance: number;
  148448. /**
  148449. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  148450. *
  148451. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  148452. * If you don't know these values, simply leave them to their defaults and don't call this function.
  148453. * @param min minimal distance for the breaks (default to 0.)
  148454. * @param max maximal distance for the breaks (default to 1.)
  148455. */
  148456. setMinMaxDistance(min: number, max: number): void;
  148457. /** Gets the minimal distance used in the cascade break computation */
  148458. get minDistance(): number;
  148459. /** Gets the maximal distance used in the cascade break computation */
  148460. get maxDistance(): number;
  148461. /**
  148462. * Gets the class name of that object
  148463. * @returns "CascadedShadowGenerator"
  148464. */
  148465. getClassName(): string;
  148466. private _cascadeMinExtents;
  148467. private _cascadeMaxExtents;
  148468. /**
  148469. * Gets a cascade minimum extents
  148470. * @param cascadeIndex index of the cascade
  148471. * @returns the minimum cascade extents
  148472. */
  148473. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  148474. /**
  148475. * Gets a cascade maximum extents
  148476. * @param cascadeIndex index of the cascade
  148477. * @returns the maximum cascade extents
  148478. */
  148479. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  148480. private _cascades;
  148481. private _currentLayer;
  148482. private _viewSpaceFrustumsZ;
  148483. private _viewMatrices;
  148484. private _projectionMatrices;
  148485. private _transformMatrices;
  148486. private _transformMatricesAsArray;
  148487. private _frustumLengths;
  148488. private _lightSizeUVCorrection;
  148489. private _depthCorrection;
  148490. private _frustumCornersWorldSpace;
  148491. private _frustumCenter;
  148492. private _shadowCameraPos;
  148493. private _shadowMaxZ;
  148494. /**
  148495. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  148496. * It defaults to camera.maxZ
  148497. */
  148498. get shadowMaxZ(): number;
  148499. /**
  148500. * Sets the shadow max z distance.
  148501. */
  148502. set shadowMaxZ(value: number);
  148503. protected _debug: boolean;
  148504. /**
  148505. * Gets or sets the debug flag.
  148506. * When enabled, the cascades are materialized by different colors on the screen.
  148507. */
  148508. get debug(): boolean;
  148509. set debug(dbg: boolean);
  148510. private _depthClamp;
  148511. /**
  148512. * Gets or sets the depth clamping value.
  148513. *
  148514. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  148515. * to account for the shadow casters far away.
  148516. *
  148517. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  148518. */
  148519. get depthClamp(): boolean;
  148520. set depthClamp(value: boolean);
  148521. private _cascadeBlendPercentage;
  148522. /**
  148523. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  148524. * It defaults to 0.1 (10% blending).
  148525. */
  148526. get cascadeBlendPercentage(): number;
  148527. set cascadeBlendPercentage(value: number);
  148528. private _lambda;
  148529. /**
  148530. * Gets or set the lambda parameter.
  148531. * This parameter is used to split the camera frustum and create the cascades.
  148532. * 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.
  148533. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  148534. */
  148535. get lambda(): number;
  148536. set lambda(value: number);
  148537. /**
  148538. * Gets the view matrix corresponding to a given cascade
  148539. * @param cascadeNum cascade to retrieve the view matrix from
  148540. * @returns the cascade view matrix
  148541. */
  148542. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  148543. /**
  148544. * Gets the projection matrix corresponding to a given cascade
  148545. * @param cascadeNum cascade to retrieve the projection matrix from
  148546. * @returns the cascade projection matrix
  148547. */
  148548. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  148549. /**
  148550. * Gets the transformation matrix corresponding to a given cascade
  148551. * @param cascadeNum cascade to retrieve the transformation matrix from
  148552. * @returns the cascade transformation matrix
  148553. */
  148554. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  148555. private _depthRenderer;
  148556. /**
  148557. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  148558. *
  148559. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  148560. *
  148561. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  148562. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  148563. * @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
  148564. */
  148565. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  148566. private _depthReducer;
  148567. private _autoCalcDepthBounds;
  148568. /**
  148569. * Gets or sets the autoCalcDepthBounds property.
  148570. *
  148571. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  148572. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  148573. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  148574. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  148575. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  148576. */
  148577. get autoCalcDepthBounds(): boolean;
  148578. set autoCalcDepthBounds(value: boolean);
  148579. /**
  148580. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  148581. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  148582. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  148583. * for setting the refresh rate on the renderer yourself!
  148584. */
  148585. get autoCalcDepthBoundsRefreshRate(): number;
  148586. set autoCalcDepthBoundsRefreshRate(value: number);
  148587. /**
  148588. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  148589. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  148590. * you change the camera near/far planes!
  148591. */
  148592. splitFrustum(): void;
  148593. private _splitFrustum;
  148594. private _computeMatrices;
  148595. private _computeFrustumInWorldSpace;
  148596. private _computeCascadeFrustum;
  148597. /**
  148598. * Support test.
  148599. */
  148600. static get IsSupported(): boolean;
  148601. /** @hidden */
  148602. static _SceneComponentInitialization: (scene: Scene) => void;
  148603. /**
  148604. * Creates a Cascaded Shadow Generator object.
  148605. * A ShadowGenerator is the required tool to use the shadows.
  148606. * Each directional light casting shadows needs to use its own ShadowGenerator.
  148607. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  148608. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  148609. * @param light The directional light object generating the shadows.
  148610. * @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.
  148611. */
  148612. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  148613. protected _initializeGenerator(): void;
  148614. protected _createTargetRenderTexture(): void;
  148615. protected _initializeShadowMap(): void;
  148616. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  148617. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  148618. /**
  148619. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  148620. * @param defines Defines of the material we want to update
  148621. * @param lightIndex Index of the light in the enabled light list of the material
  148622. */
  148623. prepareDefines(defines: any, lightIndex: number): void;
  148624. /**
  148625. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  148626. * defined in the generator but impacting the effect).
  148627. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  148628. * @param effect The effect we are binfing the information for
  148629. */
  148630. bindShadowLight(lightIndex: string, effect: Effect): void;
  148631. /**
  148632. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  148633. * (eq to view projection * shadow projection matrices)
  148634. * @returns The transform matrix used to create the shadow map
  148635. */
  148636. getTransformMatrix(): Matrix;
  148637. /**
  148638. * Disposes the ShadowGenerator.
  148639. * Returns nothing.
  148640. */
  148641. dispose(): void;
  148642. /**
  148643. * Serializes the shadow generator setup to a json object.
  148644. * @returns The serialized JSON object
  148645. */
  148646. serialize(): any;
  148647. /**
  148648. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  148649. * @param parsedShadowGenerator The JSON object to parse
  148650. * @param scene The scene to create the shadow map for
  148651. * @returns The parsed shadow generator
  148652. */
  148653. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  148654. }
  148655. }
  148656. declare module BABYLON {
  148657. /**
  148658. * Defines the shadow generator component responsible to manage any shadow generators
  148659. * in a given scene.
  148660. */
  148661. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  148662. /**
  148663. * The component name helpfull to identify the component in the list of scene components.
  148664. */
  148665. readonly name: string;
  148666. /**
  148667. * The scene the component belongs to.
  148668. */
  148669. scene: Scene;
  148670. /**
  148671. * Creates a new instance of the component for the given scene
  148672. * @param scene Defines the scene to register the component in
  148673. */
  148674. constructor(scene: Scene);
  148675. /**
  148676. * Registers the component in a given scene
  148677. */
  148678. register(): void;
  148679. /**
  148680. * Rebuilds the elements related to this component in case of
  148681. * context lost for instance.
  148682. */
  148683. rebuild(): void;
  148684. /**
  148685. * Serializes the component data to the specified json object
  148686. * @param serializationObject The object to serialize to
  148687. */
  148688. serialize(serializationObject: any): void;
  148689. /**
  148690. * Adds all the elements from the container to the scene
  148691. * @param container the container holding the elements
  148692. */
  148693. addFromContainer(container: AbstractScene): void;
  148694. /**
  148695. * Removes all the elements in the container from the scene
  148696. * @param container contains the elements to remove
  148697. * @param dispose if the removed element should be disposed (default: false)
  148698. */
  148699. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148700. /**
  148701. * Rebuilds the elements related to this component in case of
  148702. * context lost for instance.
  148703. */
  148704. dispose(): void;
  148705. private _gatherRenderTargets;
  148706. }
  148707. }
  148708. declare module BABYLON {
  148709. /**
  148710. * A point light is a light defined by an unique point in world space.
  148711. * The light is emitted in every direction from this point.
  148712. * A good example of a point light is a standard light bulb.
  148713. * Documentation: https://doc.babylonjs.com/babylon101/lights
  148714. */
  148715. export class PointLight extends ShadowLight {
  148716. private _shadowAngle;
  148717. /**
  148718. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148719. * This specifies what angle the shadow will use to be created.
  148720. *
  148721. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  148722. */
  148723. get shadowAngle(): number;
  148724. /**
  148725. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148726. * This specifies what angle the shadow will use to be created.
  148727. *
  148728. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  148729. */
  148730. set shadowAngle(value: number);
  148731. /**
  148732. * Gets the direction if it has been set.
  148733. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148734. */
  148735. get direction(): Vector3;
  148736. /**
  148737. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148738. */
  148739. set direction(value: Vector3);
  148740. /**
  148741. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  148742. * A PointLight emits the light in every direction.
  148743. * It can cast shadows.
  148744. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  148745. * ```javascript
  148746. * var pointLight = new PointLight("pl", camera.position, scene);
  148747. * ```
  148748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  148749. * @param name The light friendly name
  148750. * @param position The position of the point light in the scene
  148751. * @param scene The scene the lights belongs to
  148752. */
  148753. constructor(name: string, position: Vector3, scene: Scene);
  148754. /**
  148755. * Returns the string "PointLight"
  148756. * @returns the class name
  148757. */
  148758. getClassName(): string;
  148759. /**
  148760. * Returns the integer 0.
  148761. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  148762. */
  148763. getTypeID(): number;
  148764. /**
  148765. * Specifies wether or not the shadowmap should be a cube texture.
  148766. * @returns true if the shadowmap needs to be a cube texture.
  148767. */
  148768. needCube(): boolean;
  148769. /**
  148770. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  148771. * @param faceIndex The index of the face we are computed the direction to generate shadow
  148772. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  148773. */
  148774. getShadowDirection(faceIndex?: number): Vector3;
  148775. /**
  148776. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  148777. * - fov = PI / 2
  148778. * - aspect ratio : 1.0
  148779. * - z-near and far equal to the active camera minZ and maxZ.
  148780. * Returns the PointLight.
  148781. */
  148782. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  148783. protected _buildUniformLayout(): void;
  148784. /**
  148785. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  148786. * @param effect The effect to update
  148787. * @param lightIndex The index of the light in the effect to update
  148788. * @returns The point light
  148789. */
  148790. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  148791. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  148792. /**
  148793. * Prepares the list of defines specific to the light type.
  148794. * @param defines the list of defines
  148795. * @param lightIndex defines the index of the light for the effect
  148796. */
  148797. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  148798. }
  148799. }
  148800. declare module BABYLON {
  148801. /**
  148802. * Header information of HDR texture files.
  148803. */
  148804. export interface HDRInfo {
  148805. /**
  148806. * The height of the texture in pixels.
  148807. */
  148808. height: number;
  148809. /**
  148810. * The width of the texture in pixels.
  148811. */
  148812. width: number;
  148813. /**
  148814. * The index of the beginning of the data in the binary file.
  148815. */
  148816. dataPosition: number;
  148817. }
  148818. /**
  148819. * This groups tools to convert HDR texture to native colors array.
  148820. */
  148821. export class HDRTools {
  148822. private static Ldexp;
  148823. private static Rgbe2float;
  148824. private static readStringLine;
  148825. /**
  148826. * Reads header information from an RGBE texture stored in a native array.
  148827. * More information on this format are available here:
  148828. * https://en.wikipedia.org/wiki/RGBE_image_format
  148829. *
  148830. * @param uint8array The binary file stored in native array.
  148831. * @return The header information.
  148832. */
  148833. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  148834. /**
  148835. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  148836. * This RGBE texture needs to store the information as a panorama.
  148837. *
  148838. * More information on this format are available here:
  148839. * https://en.wikipedia.org/wiki/RGBE_image_format
  148840. *
  148841. * @param buffer The binary file stored in an array buffer.
  148842. * @param size The expected size of the extracted cubemap.
  148843. * @return The Cube Map information.
  148844. */
  148845. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  148846. /**
  148847. * Returns the pixels data extracted from an RGBE texture.
  148848. * This pixels will be stored left to right up to down in the R G B order in one array.
  148849. *
  148850. * More information on this format are available here:
  148851. * https://en.wikipedia.org/wiki/RGBE_image_format
  148852. *
  148853. * @param uint8array The binary file stored in an array buffer.
  148854. * @param hdrInfo The header information of the file.
  148855. * @return The pixels data in RGB right to left up to down order.
  148856. */
  148857. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  148858. private static RGBE_ReadPixels_RLE;
  148859. private static RGBE_ReadPixels_NOT_RLE;
  148860. }
  148861. }
  148862. declare module BABYLON {
  148863. /**
  148864. * Effect Render Options
  148865. */
  148866. export interface IEffectRendererOptions {
  148867. /**
  148868. * Defines the vertices positions.
  148869. */
  148870. positions?: number[];
  148871. /**
  148872. * Defines the indices.
  148873. */
  148874. indices?: number[];
  148875. }
  148876. /**
  148877. * Helper class to render one or more effects.
  148878. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  148879. */
  148880. export class EffectRenderer {
  148881. private engine;
  148882. private static _DefaultOptions;
  148883. private _vertexBuffers;
  148884. private _indexBuffer;
  148885. private _fullscreenViewport;
  148886. /**
  148887. * Creates an effect renderer
  148888. * @param engine the engine to use for rendering
  148889. * @param options defines the options of the effect renderer
  148890. */
  148891. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  148892. /**
  148893. * Sets the current viewport in normalized coordinates 0-1
  148894. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  148895. */
  148896. setViewport(viewport?: Viewport): void;
  148897. /**
  148898. * Binds the embedded attributes buffer to the effect.
  148899. * @param effect Defines the effect to bind the attributes for
  148900. */
  148901. bindBuffers(effect: Effect): void;
  148902. /**
  148903. * Sets the current effect wrapper to use during draw.
  148904. * The effect needs to be ready before calling this api.
  148905. * This also sets the default full screen position attribute.
  148906. * @param effectWrapper Defines the effect to draw with
  148907. */
  148908. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  148909. /**
  148910. * Restores engine states
  148911. */
  148912. restoreStates(): void;
  148913. /**
  148914. * Draws a full screen quad.
  148915. */
  148916. draw(): void;
  148917. private isRenderTargetTexture;
  148918. /**
  148919. * renders one or more effects to a specified texture
  148920. * @param effectWrapper the effect to renderer
  148921. * @param outputTexture texture to draw to, if null it will render to the screen.
  148922. */
  148923. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  148924. /**
  148925. * Disposes of the effect renderer
  148926. */
  148927. dispose(): void;
  148928. }
  148929. /**
  148930. * Options to create an EffectWrapper
  148931. */
  148932. interface EffectWrapperCreationOptions {
  148933. /**
  148934. * Engine to use to create the effect
  148935. */
  148936. engine: ThinEngine;
  148937. /**
  148938. * Fragment shader for the effect
  148939. */
  148940. fragmentShader: string;
  148941. /**
  148942. * Use the shader store instead of direct source code
  148943. */
  148944. useShaderStore?: boolean;
  148945. /**
  148946. * Vertex shader for the effect
  148947. */
  148948. vertexShader?: string;
  148949. /**
  148950. * Attributes to use in the shader
  148951. */
  148952. attributeNames?: Array<string>;
  148953. /**
  148954. * Uniforms to use in the shader
  148955. */
  148956. uniformNames?: Array<string>;
  148957. /**
  148958. * Texture sampler names to use in the shader
  148959. */
  148960. samplerNames?: Array<string>;
  148961. /**
  148962. * Defines to use in the shader
  148963. */
  148964. defines?: Array<string>;
  148965. /**
  148966. * Callback when effect is compiled
  148967. */
  148968. onCompiled?: Nullable<(effect: Effect) => void>;
  148969. /**
  148970. * The friendly name of the effect displayed in Spector.
  148971. */
  148972. name?: string;
  148973. }
  148974. /**
  148975. * Wraps an effect to be used for rendering
  148976. */
  148977. export class EffectWrapper {
  148978. /**
  148979. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  148980. */
  148981. onApplyObservable: Observable<{}>;
  148982. /**
  148983. * The underlying effect
  148984. */
  148985. effect: Effect;
  148986. /**
  148987. * Creates an effect to be renderer
  148988. * @param creationOptions options to create the effect
  148989. */
  148990. constructor(creationOptions: EffectWrapperCreationOptions);
  148991. /**
  148992. * Disposes of the effect wrapper
  148993. */
  148994. dispose(): void;
  148995. }
  148996. }
  148997. declare module BABYLON {
  148998. /** @hidden */
  148999. export var hdrFilteringVertexShader: {
  149000. name: string;
  149001. shader: string;
  149002. };
  149003. }
  149004. declare module BABYLON {
  149005. /** @hidden */
  149006. export var hdrFilteringPixelShader: {
  149007. name: string;
  149008. shader: string;
  149009. };
  149010. }
  149011. declare module BABYLON {
  149012. /**
  149013. * Options for texture filtering
  149014. */
  149015. interface IHDRFilteringOptions {
  149016. /**
  149017. * Scales pixel intensity for the input HDR map.
  149018. */
  149019. hdrScale?: number;
  149020. /**
  149021. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  149022. */
  149023. quality?: number;
  149024. }
  149025. /**
  149026. * Filters HDR maps to get correct renderings of PBR reflections
  149027. */
  149028. export class HDRFiltering {
  149029. private _engine;
  149030. private _effectRenderer;
  149031. private _effectWrapper;
  149032. private _lodGenerationOffset;
  149033. private _lodGenerationScale;
  149034. /**
  149035. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  149036. * you care about baking speed.
  149037. */
  149038. quality: number;
  149039. /**
  149040. * Scales pixel intensity for the input HDR map.
  149041. */
  149042. hdrScale: number;
  149043. /**
  149044. * Instantiates HDR filter for reflection maps
  149045. *
  149046. * @param engine Thin engine
  149047. * @param options Options
  149048. */
  149049. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  149050. private _createRenderTarget;
  149051. private _prefilterInternal;
  149052. private _createEffect;
  149053. /**
  149054. * Get a value indicating if the filter is ready to be used
  149055. * @param texture Texture to filter
  149056. * @returns true if the filter is ready
  149057. */
  149058. isReady(texture: BaseTexture): boolean;
  149059. /**
  149060. * Prefilters a cube texture to have mipmap levels representing roughness values.
  149061. * Prefiltering will be invoked at the end of next rendering pass.
  149062. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  149063. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  149064. * @param texture Texture to filter
  149065. * @param onFinished Callback when filtering is done
  149066. * @return Promise called when prefiltering is done
  149067. */
  149068. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  149069. }
  149070. }
  149071. declare module BABYLON {
  149072. /**
  149073. * This represents a texture coming from an HDR input.
  149074. *
  149075. * The only supported format is currently panorama picture stored in RGBE format.
  149076. * Example of such files can be found on HDRLib: http://hdrlib.com/
  149077. */
  149078. export class HDRCubeTexture extends BaseTexture {
  149079. private static _facesMapping;
  149080. private _generateHarmonics;
  149081. private _noMipmap;
  149082. private _prefilterOnLoad;
  149083. private _textureMatrix;
  149084. private _size;
  149085. private _onLoad;
  149086. private _onError;
  149087. /**
  149088. * The texture URL.
  149089. */
  149090. url: string;
  149091. protected _isBlocking: boolean;
  149092. /**
  149093. * Sets wether or not the texture is blocking during loading.
  149094. */
  149095. set isBlocking(value: boolean);
  149096. /**
  149097. * Gets wether or not the texture is blocking during loading.
  149098. */
  149099. get isBlocking(): boolean;
  149100. protected _rotationY: number;
  149101. /**
  149102. * Sets texture matrix rotation angle around Y axis in radians.
  149103. */
  149104. set rotationY(value: number);
  149105. /**
  149106. * Gets texture matrix rotation angle around Y axis radians.
  149107. */
  149108. get rotationY(): number;
  149109. /**
  149110. * Gets or sets the center of the bounding box associated with the cube texture
  149111. * It must define where the camera used to render the texture was set
  149112. */
  149113. boundingBoxPosition: Vector3;
  149114. private _boundingBoxSize;
  149115. /**
  149116. * Gets or sets the size of the bounding box associated with the cube texture
  149117. * When defined, the cubemap will switch to local mode
  149118. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  149119. * @example https://www.babylonjs-playground.com/#RNASML
  149120. */
  149121. set boundingBoxSize(value: Vector3);
  149122. get boundingBoxSize(): Vector3;
  149123. /**
  149124. * Instantiates an HDRTexture from the following parameters.
  149125. *
  149126. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  149127. * @param sceneOrEngine The scene or engine the texture will be used in
  149128. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  149129. * @param noMipmap Forces to not generate the mipmap if true
  149130. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  149131. * @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)
  149132. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  149133. */
  149134. 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>);
  149135. /**
  149136. * Get the current class name of the texture useful for serialization or dynamic coding.
  149137. * @returns "HDRCubeTexture"
  149138. */
  149139. getClassName(): string;
  149140. /**
  149141. * Occurs when the file is raw .hdr file.
  149142. */
  149143. private loadTexture;
  149144. clone(): HDRCubeTexture;
  149145. delayLoad(): void;
  149146. /**
  149147. * Get the texture reflection matrix used to rotate/transform the reflection.
  149148. * @returns the reflection matrix
  149149. */
  149150. getReflectionTextureMatrix(): Matrix;
  149151. /**
  149152. * Set the texture reflection matrix used to rotate/transform the reflection.
  149153. * @param value Define the reflection matrix to set
  149154. */
  149155. setReflectionTextureMatrix(value: Matrix): void;
  149156. /**
  149157. * Parses a JSON representation of an HDR Texture in order to create the texture
  149158. * @param parsedTexture Define the JSON representation
  149159. * @param scene Define the scene the texture should be created in
  149160. * @param rootUrl Define the root url in case we need to load relative dependencies
  149161. * @returns the newly created texture after parsing
  149162. */
  149163. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  149164. serialize(): any;
  149165. }
  149166. }
  149167. declare module BABYLON {
  149168. /**
  149169. * Class used to control physics engine
  149170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149171. */
  149172. export class PhysicsEngine implements IPhysicsEngine {
  149173. private _physicsPlugin;
  149174. /**
  149175. * Global value used to control the smallest number supported by the simulation
  149176. */
  149177. static Epsilon: number;
  149178. private _impostors;
  149179. private _joints;
  149180. private _subTimeStep;
  149181. /**
  149182. * Gets the gravity vector used by the simulation
  149183. */
  149184. gravity: Vector3;
  149185. /**
  149186. * Factory used to create the default physics plugin.
  149187. * @returns The default physics plugin
  149188. */
  149189. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  149190. /**
  149191. * Creates a new Physics Engine
  149192. * @param gravity defines the gravity vector used by the simulation
  149193. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  149194. */
  149195. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  149196. /**
  149197. * Sets the gravity vector used by the simulation
  149198. * @param gravity defines the gravity vector to use
  149199. */
  149200. setGravity(gravity: Vector3): void;
  149201. /**
  149202. * Set the time step of the physics engine.
  149203. * Default is 1/60.
  149204. * To slow it down, enter 1/600 for example.
  149205. * To speed it up, 1/30
  149206. * @param newTimeStep defines the new timestep to apply to this world.
  149207. */
  149208. setTimeStep(newTimeStep?: number): void;
  149209. /**
  149210. * Get the time step of the physics engine.
  149211. * @returns the current time step
  149212. */
  149213. getTimeStep(): number;
  149214. /**
  149215. * Set the sub time step of the physics engine.
  149216. * Default is 0 meaning there is no sub steps
  149217. * To increase physics resolution precision, set a small value (like 1 ms)
  149218. * @param subTimeStep defines the new sub timestep used for physics resolution.
  149219. */
  149220. setSubTimeStep(subTimeStep?: number): void;
  149221. /**
  149222. * Get the sub time step of the physics engine.
  149223. * @returns the current sub time step
  149224. */
  149225. getSubTimeStep(): number;
  149226. /**
  149227. * Release all resources
  149228. */
  149229. dispose(): void;
  149230. /**
  149231. * Gets the name of the current physics plugin
  149232. * @returns the name of the plugin
  149233. */
  149234. getPhysicsPluginName(): string;
  149235. /**
  149236. * Adding a new impostor for the impostor tracking.
  149237. * This will be done by the impostor itself.
  149238. * @param impostor the impostor to add
  149239. */
  149240. addImpostor(impostor: PhysicsImpostor): void;
  149241. /**
  149242. * Remove an impostor from the engine.
  149243. * This impostor and its mesh will not longer be updated by the physics engine.
  149244. * @param impostor the impostor to remove
  149245. */
  149246. removeImpostor(impostor: PhysicsImpostor): void;
  149247. /**
  149248. * Add a joint to the physics engine
  149249. * @param mainImpostor defines the main impostor to which the joint is added.
  149250. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  149251. * @param joint defines the joint that will connect both impostors.
  149252. */
  149253. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  149254. /**
  149255. * Removes a joint from the simulation
  149256. * @param mainImpostor defines the impostor used with the joint
  149257. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  149258. * @param joint defines the joint to remove
  149259. */
  149260. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  149261. /**
  149262. * Called by the scene. No need to call it.
  149263. * @param delta defines the timespam between frames
  149264. */
  149265. _step(delta: number): void;
  149266. /**
  149267. * Gets the current plugin used to run the simulation
  149268. * @returns current plugin
  149269. */
  149270. getPhysicsPlugin(): IPhysicsEnginePlugin;
  149271. /**
  149272. * Gets the list of physic impostors
  149273. * @returns an array of PhysicsImpostor
  149274. */
  149275. getImpostors(): Array<PhysicsImpostor>;
  149276. /**
  149277. * Gets the impostor for a physics enabled object
  149278. * @param object defines the object impersonated by the impostor
  149279. * @returns the PhysicsImpostor or null if not found
  149280. */
  149281. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  149282. /**
  149283. * Gets the impostor for a physics body object
  149284. * @param body defines physics body used by the impostor
  149285. * @returns the PhysicsImpostor or null if not found
  149286. */
  149287. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  149288. /**
  149289. * Does a raycast in the physics world
  149290. * @param from when should the ray start?
  149291. * @param to when should the ray end?
  149292. * @returns PhysicsRaycastResult
  149293. */
  149294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149295. }
  149296. }
  149297. declare module BABYLON {
  149298. /** @hidden */
  149299. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  149300. private _useDeltaForWorldStep;
  149301. world: any;
  149302. name: string;
  149303. private _physicsMaterials;
  149304. private _fixedTimeStep;
  149305. private _cannonRaycastResult;
  149306. private _raycastResult;
  149307. private _physicsBodysToRemoveAfterStep;
  149308. private _firstFrame;
  149309. BJSCANNON: any;
  149310. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  149311. setGravity(gravity: Vector3): void;
  149312. setTimeStep(timeStep: number): void;
  149313. getTimeStep(): number;
  149314. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149315. private _removeMarkedPhysicsBodiesFromWorld;
  149316. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149317. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149318. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149319. private _processChildMeshes;
  149320. removePhysicsBody(impostor: PhysicsImpostor): void;
  149321. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149322. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149323. private _addMaterial;
  149324. private _checkWithEpsilon;
  149325. private _createShape;
  149326. private _createHeightmap;
  149327. private _minus90X;
  149328. private _plus90X;
  149329. private _tmpPosition;
  149330. private _tmpDeltaPosition;
  149331. private _tmpUnityRotation;
  149332. private _updatePhysicsBodyTransformation;
  149333. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149334. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149335. isSupported(): boolean;
  149336. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149337. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149338. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149339. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149340. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149341. getBodyMass(impostor: PhysicsImpostor): number;
  149342. getBodyFriction(impostor: PhysicsImpostor): number;
  149343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149344. getBodyRestitution(impostor: PhysicsImpostor): number;
  149345. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149346. sleepBody(impostor: PhysicsImpostor): void;
  149347. wakeUpBody(impostor: PhysicsImpostor): void;
  149348. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  149349. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  149350. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  149351. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  149352. getRadius(impostor: PhysicsImpostor): number;
  149353. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  149354. dispose(): void;
  149355. private _extendNamespace;
  149356. /**
  149357. * Does a raycast in the physics world
  149358. * @param from when should the ray start?
  149359. * @param to when should the ray end?
  149360. * @returns PhysicsRaycastResult
  149361. */
  149362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149363. }
  149364. }
  149365. declare module BABYLON {
  149366. /** @hidden */
  149367. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  149368. private _useDeltaForWorldStep;
  149369. world: any;
  149370. name: string;
  149371. BJSOIMO: any;
  149372. private _raycastResult;
  149373. private _fixedTimeStep;
  149374. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  149375. setGravity(gravity: Vector3): void;
  149376. setTimeStep(timeStep: number): void;
  149377. getTimeStep(): number;
  149378. private _tmpImpostorsArray;
  149379. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149380. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149381. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149382. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149383. private _tmpPositionVector;
  149384. removePhysicsBody(impostor: PhysicsImpostor): void;
  149385. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149386. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149387. isSupported(): boolean;
  149388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149395. getBodyMass(impostor: PhysicsImpostor): number;
  149396. getBodyFriction(impostor: PhysicsImpostor): number;
  149397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149398. getBodyRestitution(impostor: PhysicsImpostor): number;
  149399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149400. sleepBody(impostor: PhysicsImpostor): void;
  149401. wakeUpBody(impostor: PhysicsImpostor): void;
  149402. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  149403. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  149404. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  149405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  149406. getRadius(impostor: PhysicsImpostor): number;
  149407. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  149408. dispose(): void;
  149409. /**
  149410. * Does a raycast in the physics world
  149411. * @param from when should the ray start?
  149412. * @param to when should the ray end?
  149413. * @returns PhysicsRaycastResult
  149414. */
  149415. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149416. }
  149417. }
  149418. declare module BABYLON {
  149419. /**
  149420. * AmmoJS Physics plugin
  149421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149422. * @see https://github.com/kripken/ammo.js/
  149423. */
  149424. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  149425. private _useDeltaForWorldStep;
  149426. /**
  149427. * Reference to the Ammo library
  149428. */
  149429. bjsAMMO: any;
  149430. /**
  149431. * Created ammoJS world which physics bodies are added to
  149432. */
  149433. world: any;
  149434. /**
  149435. * Name of the plugin
  149436. */
  149437. name: string;
  149438. private _timeStep;
  149439. private _fixedTimeStep;
  149440. private _maxSteps;
  149441. private _tmpQuaternion;
  149442. private _tmpAmmoTransform;
  149443. private _tmpAmmoQuaternion;
  149444. private _tmpAmmoConcreteContactResultCallback;
  149445. private _collisionConfiguration;
  149446. private _dispatcher;
  149447. private _overlappingPairCache;
  149448. private _solver;
  149449. private _softBodySolver;
  149450. private _tmpAmmoVectorA;
  149451. private _tmpAmmoVectorB;
  149452. private _tmpAmmoVectorC;
  149453. private _tmpAmmoVectorD;
  149454. private _tmpContactCallbackResult;
  149455. private _tmpAmmoVectorRCA;
  149456. private _tmpAmmoVectorRCB;
  149457. private _raycastResult;
  149458. private _tmpContactPoint;
  149459. private static readonly DISABLE_COLLISION_FLAG;
  149460. private static readonly KINEMATIC_FLAG;
  149461. private static readonly DISABLE_DEACTIVATION_FLAG;
  149462. /**
  149463. * Initializes the ammoJS plugin
  149464. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  149465. * @param ammoInjection can be used to inject your own ammo reference
  149466. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  149467. */
  149468. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  149469. /**
  149470. * Sets the gravity of the physics world (m/(s^2))
  149471. * @param gravity Gravity to set
  149472. */
  149473. setGravity(gravity: Vector3): void;
  149474. /**
  149475. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  149476. * @param timeStep timestep to use in seconds
  149477. */
  149478. setTimeStep(timeStep: number): void;
  149479. /**
  149480. * 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)
  149481. * @param fixedTimeStep fixedTimeStep to use in seconds
  149482. */
  149483. setFixedTimeStep(fixedTimeStep: number): void;
  149484. /**
  149485. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  149486. * @param maxSteps the maximum number of steps by the physics engine per frame
  149487. */
  149488. setMaxSteps(maxSteps: number): void;
  149489. /**
  149490. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  149491. * @returns the current timestep in seconds
  149492. */
  149493. getTimeStep(): number;
  149494. /**
  149495. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  149496. */
  149497. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  149498. private _isImpostorInContact;
  149499. private _isImpostorPairInContact;
  149500. private _stepSimulation;
  149501. /**
  149502. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  149503. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  149504. * After the step the babylon meshes are set to the position of the physics imposters
  149505. * @param delta amount of time to step forward
  149506. * @param impostors array of imposters to update before/after the step
  149507. */
  149508. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149509. /**
  149510. * Update babylon mesh to match physics world object
  149511. * @param impostor imposter to match
  149512. */
  149513. private _afterSoftStep;
  149514. /**
  149515. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  149516. * @param impostor imposter to match
  149517. */
  149518. private _ropeStep;
  149519. /**
  149520. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  149521. * @param impostor imposter to match
  149522. */
  149523. private _softbodyOrClothStep;
  149524. private _tmpMatrix;
  149525. /**
  149526. * Applies an impulse on the imposter
  149527. * @param impostor imposter to apply impulse to
  149528. * @param force amount of force to be applied to the imposter
  149529. * @param contactPoint the location to apply the impulse on the imposter
  149530. */
  149531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149532. /**
  149533. * Applies a force on the imposter
  149534. * @param impostor imposter to apply force
  149535. * @param force amount of force to be applied to the imposter
  149536. * @param contactPoint the location to apply the force on the imposter
  149537. */
  149538. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149539. /**
  149540. * Creates a physics body using the plugin
  149541. * @param impostor the imposter to create the physics body on
  149542. */
  149543. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149544. /**
  149545. * Removes the physics body from the imposter and disposes of the body's memory
  149546. * @param impostor imposter to remove the physics body from
  149547. */
  149548. removePhysicsBody(impostor: PhysicsImpostor): void;
  149549. /**
  149550. * Generates a joint
  149551. * @param impostorJoint the imposter joint to create the joint with
  149552. */
  149553. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149554. /**
  149555. * Removes a joint
  149556. * @param impostorJoint the imposter joint to remove the joint from
  149557. */
  149558. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149559. private _addMeshVerts;
  149560. /**
  149561. * Initialise the soft body vertices to match its object's (mesh) vertices
  149562. * Softbody vertices (nodes) are in world space and to match this
  149563. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  149564. * @param impostor to create the softbody for
  149565. */
  149566. private _softVertexData;
  149567. /**
  149568. * Create an impostor's soft body
  149569. * @param impostor to create the softbody for
  149570. */
  149571. private _createSoftbody;
  149572. /**
  149573. * Create cloth for an impostor
  149574. * @param impostor to create the softbody for
  149575. */
  149576. private _createCloth;
  149577. /**
  149578. * Create rope for an impostor
  149579. * @param impostor to create the softbody for
  149580. */
  149581. private _createRope;
  149582. /**
  149583. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  149584. * @param impostor to create the custom physics shape for
  149585. */
  149586. private _createCustom;
  149587. private _addHullVerts;
  149588. private _createShape;
  149589. /**
  149590. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  149591. * @param impostor imposter containing the physics body and babylon object
  149592. */
  149593. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149594. /**
  149595. * Sets the babylon object's position/rotation from the physics body's position/rotation
  149596. * @param impostor imposter containing the physics body and babylon object
  149597. * @param newPosition new position
  149598. * @param newRotation new rotation
  149599. */
  149600. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149601. /**
  149602. * If this plugin is supported
  149603. * @returns true if its supported
  149604. */
  149605. isSupported(): boolean;
  149606. /**
  149607. * Sets the linear velocity of the physics body
  149608. * @param impostor imposter to set the velocity on
  149609. * @param velocity velocity to set
  149610. */
  149611. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149612. /**
  149613. * Sets the angular velocity of the physics body
  149614. * @param impostor imposter to set the velocity on
  149615. * @param velocity velocity to set
  149616. */
  149617. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149618. /**
  149619. * gets the linear velocity
  149620. * @param impostor imposter to get linear velocity from
  149621. * @returns linear velocity
  149622. */
  149623. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149624. /**
  149625. * gets the angular velocity
  149626. * @param impostor imposter to get angular velocity from
  149627. * @returns angular velocity
  149628. */
  149629. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149630. /**
  149631. * Sets the mass of physics body
  149632. * @param impostor imposter to set the mass on
  149633. * @param mass mass to set
  149634. */
  149635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149636. /**
  149637. * Gets the mass of the physics body
  149638. * @param impostor imposter to get the mass from
  149639. * @returns mass
  149640. */
  149641. getBodyMass(impostor: PhysicsImpostor): number;
  149642. /**
  149643. * Gets friction of the impostor
  149644. * @param impostor impostor to get friction from
  149645. * @returns friction value
  149646. */
  149647. getBodyFriction(impostor: PhysicsImpostor): number;
  149648. /**
  149649. * Sets friction of the impostor
  149650. * @param impostor impostor to set friction on
  149651. * @param friction friction value
  149652. */
  149653. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149654. /**
  149655. * Gets restitution of the impostor
  149656. * @param impostor impostor to get restitution from
  149657. * @returns restitution value
  149658. */
  149659. getBodyRestitution(impostor: PhysicsImpostor): number;
  149660. /**
  149661. * Sets resitution of the impostor
  149662. * @param impostor impostor to set resitution on
  149663. * @param restitution resitution value
  149664. */
  149665. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149666. /**
  149667. * Gets pressure inside the impostor
  149668. * @param impostor impostor to get pressure from
  149669. * @returns pressure value
  149670. */
  149671. getBodyPressure(impostor: PhysicsImpostor): number;
  149672. /**
  149673. * Sets pressure inside a soft body impostor
  149674. * Cloth and rope must remain 0 pressure
  149675. * @param impostor impostor to set pressure on
  149676. * @param pressure pressure value
  149677. */
  149678. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  149679. /**
  149680. * Gets stiffness of the impostor
  149681. * @param impostor impostor to get stiffness from
  149682. * @returns pressure value
  149683. */
  149684. getBodyStiffness(impostor: PhysicsImpostor): number;
  149685. /**
  149686. * Sets stiffness of the impostor
  149687. * @param impostor impostor to set stiffness on
  149688. * @param stiffness stiffness value from 0 to 1
  149689. */
  149690. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  149691. /**
  149692. * Gets velocityIterations of the impostor
  149693. * @param impostor impostor to get velocity iterations from
  149694. * @returns velocityIterations value
  149695. */
  149696. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  149697. /**
  149698. * Sets velocityIterations of the impostor
  149699. * @param impostor impostor to set velocity iterations on
  149700. * @param velocityIterations velocityIterations value
  149701. */
  149702. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  149703. /**
  149704. * Gets positionIterations of the impostor
  149705. * @param impostor impostor to get position iterations from
  149706. * @returns positionIterations value
  149707. */
  149708. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  149709. /**
  149710. * Sets positionIterations of the impostor
  149711. * @param impostor impostor to set position on
  149712. * @param positionIterations positionIterations value
  149713. */
  149714. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  149715. /**
  149716. * Append an anchor to a cloth object
  149717. * @param impostor is the cloth impostor to add anchor to
  149718. * @param otherImpostor is the rigid impostor to anchor to
  149719. * @param width ratio across width from 0 to 1
  149720. * @param height ratio up height from 0 to 1
  149721. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  149722. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  149723. */
  149724. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  149725. /**
  149726. * Append an hook to a rope object
  149727. * @param impostor is the rope impostor to add hook to
  149728. * @param otherImpostor is the rigid impostor to hook to
  149729. * @param length ratio along the rope from 0 to 1
  149730. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  149731. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  149732. */
  149733. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  149734. /**
  149735. * Sleeps the physics body and stops it from being active
  149736. * @param impostor impostor to sleep
  149737. */
  149738. sleepBody(impostor: PhysicsImpostor): void;
  149739. /**
  149740. * Activates the physics body
  149741. * @param impostor impostor to activate
  149742. */
  149743. wakeUpBody(impostor: PhysicsImpostor): void;
  149744. /**
  149745. * Updates the distance parameters of the joint
  149746. * @param joint joint to update
  149747. * @param maxDistance maximum distance of the joint
  149748. * @param minDistance minimum distance of the joint
  149749. */
  149750. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  149751. /**
  149752. * Sets a motor on the joint
  149753. * @param joint joint to set motor on
  149754. * @param speed speed of the motor
  149755. * @param maxForce maximum force of the motor
  149756. * @param motorIndex index of the motor
  149757. */
  149758. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  149759. /**
  149760. * Sets the motors limit
  149761. * @param joint joint to set limit on
  149762. * @param upperLimit upper limit
  149763. * @param lowerLimit lower limit
  149764. */
  149765. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  149766. /**
  149767. * Syncs the position and rotation of a mesh with the impostor
  149768. * @param mesh mesh to sync
  149769. * @param impostor impostor to update the mesh with
  149770. */
  149771. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  149772. /**
  149773. * Gets the radius of the impostor
  149774. * @param impostor impostor to get radius from
  149775. * @returns the radius
  149776. */
  149777. getRadius(impostor: PhysicsImpostor): number;
  149778. /**
  149779. * Gets the box size of the impostor
  149780. * @param impostor impostor to get box size from
  149781. * @param result the resulting box size
  149782. */
  149783. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  149784. /**
  149785. * Disposes of the impostor
  149786. */
  149787. dispose(): void;
  149788. /**
  149789. * Does a raycast in the physics world
  149790. * @param from when should the ray start?
  149791. * @param to when should the ray end?
  149792. * @returns PhysicsRaycastResult
  149793. */
  149794. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149795. }
  149796. }
  149797. declare module BABYLON {
  149798. interface AbstractScene {
  149799. /**
  149800. * The list of reflection probes added to the scene
  149801. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  149802. */
  149803. reflectionProbes: Array<ReflectionProbe>;
  149804. /**
  149805. * Removes the given reflection probe from this scene.
  149806. * @param toRemove The reflection probe to remove
  149807. * @returns The index of the removed reflection probe
  149808. */
  149809. removeReflectionProbe(toRemove: ReflectionProbe): number;
  149810. /**
  149811. * Adds the given reflection probe to this scene.
  149812. * @param newReflectionProbe The reflection probe to add
  149813. */
  149814. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  149815. }
  149816. /**
  149817. * Class used to generate realtime reflection / refraction cube textures
  149818. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  149819. */
  149820. export class ReflectionProbe {
  149821. /** defines the name of the probe */
  149822. name: string;
  149823. private _scene;
  149824. private _renderTargetTexture;
  149825. private _projectionMatrix;
  149826. private _viewMatrix;
  149827. private _target;
  149828. private _add;
  149829. private _attachedMesh;
  149830. private _invertYAxis;
  149831. /** Gets or sets probe position (center of the cube map) */
  149832. position: Vector3;
  149833. /**
  149834. * Creates a new reflection probe
  149835. * @param name defines the name of the probe
  149836. * @param size defines the texture resolution (for each face)
  149837. * @param scene defines the hosting scene
  149838. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  149839. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  149840. */
  149841. constructor(
  149842. /** defines the name of the probe */
  149843. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  149844. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  149845. get samples(): number;
  149846. set samples(value: number);
  149847. /** Gets or sets the refresh rate to use (on every frame by default) */
  149848. get refreshRate(): number;
  149849. set refreshRate(value: number);
  149850. /**
  149851. * Gets the hosting scene
  149852. * @returns a Scene
  149853. */
  149854. getScene(): Scene;
  149855. /** Gets the internal CubeTexture used to render to */
  149856. get cubeTexture(): RenderTargetTexture;
  149857. /** Gets the list of meshes to render */
  149858. get renderList(): Nullable<AbstractMesh[]>;
  149859. /**
  149860. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  149861. * @param mesh defines the mesh to attach to
  149862. */
  149863. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  149864. /**
  149865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  149866. * @param renderingGroupId The rendering group id corresponding to its index
  149867. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  149868. */
  149869. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  149870. /**
  149871. * Clean all associated resources
  149872. */
  149873. dispose(): void;
  149874. /**
  149875. * Converts the reflection probe information to a readable string for debug purpose.
  149876. * @param fullDetails Supports for multiple levels of logging within scene loading
  149877. * @returns the human readable reflection probe info
  149878. */
  149879. toString(fullDetails?: boolean): string;
  149880. /**
  149881. * Get the class name of the relfection probe.
  149882. * @returns "ReflectionProbe"
  149883. */
  149884. getClassName(): string;
  149885. /**
  149886. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  149887. * @returns The JSON representation of the texture
  149888. */
  149889. serialize(): any;
  149890. /**
  149891. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  149892. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  149893. * @param scene Define the scene the parsed reflection probe should be instantiated in
  149894. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  149895. * @returns The parsed reflection probe if successful
  149896. */
  149897. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  149898. }
  149899. }
  149900. declare module BABYLON {
  149901. /** @hidden */
  149902. export var _BabylonLoaderRegistered: boolean;
  149903. /**
  149904. * Helps setting up some configuration for the babylon file loader.
  149905. */
  149906. export class BabylonFileLoaderConfiguration {
  149907. /**
  149908. * The loader does not allow injecting custom physix engine into the plugins.
  149909. * Unfortunately in ES6, we need to manually inject them into the plugin.
  149910. * So you could set this variable to your engine import to make it work.
  149911. */
  149912. static LoaderInjectedPhysicsEngine: any;
  149913. }
  149914. }
  149915. declare module BABYLON {
  149916. /**
  149917. * A material to use for fast depth-only rendering.
  149918. */
  149919. export class OcclusionMaterial extends ShaderMaterial {
  149920. constructor(name: string, scene: Scene);
  149921. }
  149922. }
  149923. declare module BABYLON {
  149924. /**
  149925. * The Physically based simple base material of BJS.
  149926. *
  149927. * This enables better naming and convention enforcements on top of the pbrMaterial.
  149928. * It is used as the base class for both the specGloss and metalRough conventions.
  149929. */
  149930. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  149931. /**
  149932. * Number of Simultaneous lights allowed on the material.
  149933. */
  149934. maxSimultaneousLights: number;
  149935. /**
  149936. * If sets to true, disables all the lights affecting the material.
  149937. */
  149938. disableLighting: boolean;
  149939. /**
  149940. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  149941. */
  149942. environmentTexture: BaseTexture;
  149943. /**
  149944. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  149945. */
  149946. invertNormalMapX: boolean;
  149947. /**
  149948. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  149949. */
  149950. invertNormalMapY: boolean;
  149951. /**
  149952. * Normal map used in the model.
  149953. */
  149954. normalTexture: BaseTexture;
  149955. /**
  149956. * Emissivie color used to self-illuminate the model.
  149957. */
  149958. emissiveColor: Color3;
  149959. /**
  149960. * Emissivie texture used to self-illuminate the model.
  149961. */
  149962. emissiveTexture: BaseTexture;
  149963. /**
  149964. * Occlusion Channel Strenght.
  149965. */
  149966. occlusionStrength: number;
  149967. /**
  149968. * Occlusion Texture of the material (adding extra occlusion effects).
  149969. */
  149970. occlusionTexture: BaseTexture;
  149971. /**
  149972. * Defines the alpha limits in alpha test mode.
  149973. */
  149974. alphaCutOff: number;
  149975. /**
  149976. * Gets the current double sided mode.
  149977. */
  149978. get doubleSided(): boolean;
  149979. /**
  149980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  149981. */
  149982. set doubleSided(value: boolean);
  149983. /**
  149984. * Stores the pre-calculated light information of a mesh in a texture.
  149985. */
  149986. lightmapTexture: BaseTexture;
  149987. /**
  149988. * If true, the light map contains occlusion information instead of lighting info.
  149989. */
  149990. useLightmapAsShadowmap: boolean;
  149991. /**
  149992. * Instantiates a new PBRMaterial instance.
  149993. *
  149994. * @param name The material name
  149995. * @param scene The scene the material will be use in.
  149996. */
  149997. constructor(name: string, scene: Scene);
  149998. getClassName(): string;
  149999. }
  150000. }
  150001. declare module BABYLON {
  150002. /**
  150003. * The PBR material of BJS following the metal roughness convention.
  150004. *
  150005. * This fits to the PBR convention in the GLTF definition:
  150006. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  150007. */
  150008. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  150009. /**
  150010. * The base color has two different interpretations depending on the value of metalness.
  150011. * When the material is a metal, the base color is the specific measured reflectance value
  150012. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  150013. * of the material.
  150014. */
  150015. baseColor: Color3;
  150016. /**
  150017. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  150018. * well as opacity information in the alpha channel.
  150019. */
  150020. baseTexture: BaseTexture;
  150021. /**
  150022. * Specifies the metallic scalar value of the material.
  150023. * Can also be used to scale the metalness values of the metallic texture.
  150024. */
  150025. metallic: number;
  150026. /**
  150027. * Specifies the roughness scalar value of the material.
  150028. * Can also be used to scale the roughness values of the metallic texture.
  150029. */
  150030. roughness: number;
  150031. /**
  150032. * Texture containing both the metallic value in the B channel and the
  150033. * roughness value in the G channel to keep better precision.
  150034. */
  150035. metallicRoughnessTexture: BaseTexture;
  150036. /**
  150037. * Instantiates a new PBRMetalRoughnessMaterial instance.
  150038. *
  150039. * @param name The material name
  150040. * @param scene The scene the material will be use in.
  150041. */
  150042. constructor(name: string, scene: Scene);
  150043. /**
  150044. * Return the currrent class name of the material.
  150045. */
  150046. getClassName(): string;
  150047. /**
  150048. * Makes a duplicate of the current material.
  150049. * @param name - name to use for the new material.
  150050. */
  150051. clone(name: string): PBRMetallicRoughnessMaterial;
  150052. /**
  150053. * Serialize the material to a parsable JSON object.
  150054. */
  150055. serialize(): any;
  150056. /**
  150057. * Parses a JSON object correponding to the serialize function.
  150058. */
  150059. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  150060. }
  150061. }
  150062. declare module BABYLON {
  150063. /**
  150064. * The PBR material of BJS following the specular glossiness convention.
  150065. *
  150066. * This fits to the PBR convention in the GLTF definition:
  150067. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  150068. */
  150069. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  150070. /**
  150071. * Specifies the diffuse color of the material.
  150072. */
  150073. diffuseColor: Color3;
  150074. /**
  150075. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  150076. * channel.
  150077. */
  150078. diffuseTexture: BaseTexture;
  150079. /**
  150080. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  150081. */
  150082. specularColor: Color3;
  150083. /**
  150084. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  150085. */
  150086. glossiness: number;
  150087. /**
  150088. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  150089. */
  150090. specularGlossinessTexture: BaseTexture;
  150091. /**
  150092. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  150093. */
  150094. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  150095. /**
  150096. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  150097. *
  150098. * @param name The material name
  150099. * @param scene The scene the material will be use in.
  150100. */
  150101. constructor(name: string, scene: Scene);
  150102. /**
  150103. * Return the currrent class name of the material.
  150104. */
  150105. getClassName(): string;
  150106. /**
  150107. * Makes a duplicate of the current material.
  150108. * @param name - name to use for the new material.
  150109. */
  150110. clone(name: string): PBRSpecularGlossinessMaterial;
  150111. /**
  150112. * Serialize the material to a parsable JSON object.
  150113. */
  150114. serialize(): any;
  150115. /**
  150116. * Parses a JSON object correponding to the serialize function.
  150117. */
  150118. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  150119. }
  150120. }
  150121. declare module BABYLON {
  150122. /**
  150123. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  150124. * It can help converting any input color in a desired output one. This can then be used to create effects
  150125. * from sepia, black and white to sixties or futuristic rendering...
  150126. *
  150127. * The only supported format is currently 3dl.
  150128. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  150129. */
  150130. export class ColorGradingTexture extends BaseTexture {
  150131. /**
  150132. * The texture URL.
  150133. */
  150134. url: string;
  150135. /**
  150136. * Empty line regex stored for GC.
  150137. */
  150138. private static _noneEmptyLineRegex;
  150139. private _textureMatrix;
  150140. private _onLoad;
  150141. /**
  150142. * Instantiates a ColorGradingTexture from the following parameters.
  150143. *
  150144. * @param url The location of the color gradind data (currently only supporting 3dl)
  150145. * @param sceneOrEngine The scene or engine the texture will be used in
  150146. * @param onLoad defines a callback triggered when the texture has been loaded
  150147. */
  150148. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  150149. /**
  150150. * Fires the onload event from the constructor if requested.
  150151. */
  150152. private _triggerOnLoad;
  150153. /**
  150154. * Returns the texture matrix used in most of the material.
  150155. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  150156. */
  150157. getTextureMatrix(): Matrix;
  150158. /**
  150159. * Occurs when the file being loaded is a .3dl LUT file.
  150160. */
  150161. private load3dlTexture;
  150162. /**
  150163. * Starts the loading process of the texture.
  150164. */
  150165. private loadTexture;
  150166. /**
  150167. * Clones the color gradind texture.
  150168. */
  150169. clone(): ColorGradingTexture;
  150170. /**
  150171. * Called during delayed load for textures.
  150172. */
  150173. delayLoad(): void;
  150174. /**
  150175. * Parses a color grading texture serialized by Babylon.
  150176. * @param parsedTexture The texture information being parsedTexture
  150177. * @param scene The scene to load the texture in
  150178. * @param rootUrl The root url of the data assets to load
  150179. * @return A color gradind texture
  150180. */
  150181. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  150182. /**
  150183. * Serializes the LUT texture to json format.
  150184. */
  150185. serialize(): any;
  150186. }
  150187. }
  150188. declare module BABYLON {
  150189. /**
  150190. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  150191. */
  150192. export class EquiRectangularCubeTexture extends BaseTexture {
  150193. /** The six faces of the cube. */
  150194. private static _FacesMapping;
  150195. private _noMipmap;
  150196. private _onLoad;
  150197. private _onError;
  150198. /** The size of the cubemap. */
  150199. private _size;
  150200. /** The buffer of the image. */
  150201. private _buffer;
  150202. /** The width of the input image. */
  150203. private _width;
  150204. /** The height of the input image. */
  150205. private _height;
  150206. /** The URL to the image. */
  150207. url: string;
  150208. /**
  150209. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  150210. * @param url The location of the image
  150211. * @param scene The scene the texture will be used in
  150212. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  150213. * @param noMipmap Forces to not generate the mipmap if true
  150214. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150215. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150216. * @param onLoad — defines a callback called when texture is loaded
  150217. * @param onError — defines a callback called if there is an error
  150218. */
  150219. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  150220. /**
  150221. * Load the image data, by putting the image on a canvas and extracting its buffer.
  150222. */
  150223. private loadImage;
  150224. /**
  150225. * Convert the image buffer into a cubemap and create a CubeTexture.
  150226. */
  150227. private loadTexture;
  150228. /**
  150229. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  150230. * @param buffer The ArrayBuffer that should be converted.
  150231. * @returns The buffer as Float32Array.
  150232. */
  150233. private getFloat32ArrayFromArrayBuffer;
  150234. /**
  150235. * Get the current class name of the texture useful for serialization or dynamic coding.
  150236. * @returns "EquiRectangularCubeTexture"
  150237. */
  150238. getClassName(): string;
  150239. /**
  150240. * Create a clone of the current EquiRectangularCubeTexture and return it.
  150241. * @returns A clone of the current EquiRectangularCubeTexture.
  150242. */
  150243. clone(): EquiRectangularCubeTexture;
  150244. }
  150245. }
  150246. declare module BABYLON {
  150247. /**
  150248. * Defines the options related to the creation of an HtmlElementTexture
  150249. */
  150250. export interface IHtmlElementTextureOptions {
  150251. /**
  150252. * Defines wether mip maps should be created or not.
  150253. */
  150254. generateMipMaps?: boolean;
  150255. /**
  150256. * Defines the sampling mode of the texture.
  150257. */
  150258. samplingMode?: number;
  150259. /**
  150260. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  150261. */
  150262. engine: Nullable<ThinEngine>;
  150263. /**
  150264. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  150265. */
  150266. scene: Nullable<Scene>;
  150267. }
  150268. /**
  150269. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  150270. * To be as efficient as possible depending on your constraints nothing aside the first upload
  150271. * is automatically managed.
  150272. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  150273. * in your application.
  150274. *
  150275. * As the update is not automatic, you need to call them manually.
  150276. */
  150277. export class HtmlElementTexture extends BaseTexture {
  150278. /**
  150279. * The texture URL.
  150280. */
  150281. element: HTMLVideoElement | HTMLCanvasElement;
  150282. private static readonly DefaultOptions;
  150283. private _textureMatrix;
  150284. private _isVideo;
  150285. private _generateMipMaps;
  150286. private _samplingMode;
  150287. /**
  150288. * Instantiates a HtmlElementTexture from the following parameters.
  150289. *
  150290. * @param name Defines the name of the texture
  150291. * @param element Defines the video or canvas the texture is filled with
  150292. * @param options Defines the other none mandatory texture creation options
  150293. */
  150294. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  150295. private _createInternalTexture;
  150296. /**
  150297. * Returns the texture matrix used in most of the material.
  150298. */
  150299. getTextureMatrix(): Matrix;
  150300. /**
  150301. * Updates the content of the texture.
  150302. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  150303. */
  150304. update(invertY?: Nullable<boolean>): void;
  150305. }
  150306. }
  150307. declare module BABYLON {
  150308. /**
  150309. * Based on jsTGALoader - Javascript loader for TGA file
  150310. * By Vincent Thibault
  150311. * @see http://blog.robrowser.com/javascript-tga-loader.html
  150312. */
  150313. export class TGATools {
  150314. private static _TYPE_INDEXED;
  150315. private static _TYPE_RGB;
  150316. private static _TYPE_GREY;
  150317. private static _TYPE_RLE_INDEXED;
  150318. private static _TYPE_RLE_RGB;
  150319. private static _TYPE_RLE_GREY;
  150320. private static _ORIGIN_MASK;
  150321. private static _ORIGIN_SHIFT;
  150322. private static _ORIGIN_BL;
  150323. private static _ORIGIN_BR;
  150324. private static _ORIGIN_UL;
  150325. private static _ORIGIN_UR;
  150326. /**
  150327. * Gets the header of a TGA file
  150328. * @param data defines the TGA data
  150329. * @returns the header
  150330. */
  150331. static GetTGAHeader(data: Uint8Array): any;
  150332. /**
  150333. * Uploads TGA content to a Babylon Texture
  150334. * @hidden
  150335. */
  150336. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  150337. /** @hidden */
  150338. 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;
  150339. /** @hidden */
  150340. 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;
  150341. /** @hidden */
  150342. 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;
  150343. /** @hidden */
  150344. 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;
  150345. /** @hidden */
  150346. 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;
  150347. /** @hidden */
  150348. 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;
  150349. }
  150350. }
  150351. declare module BABYLON {
  150352. /**
  150353. * Implementation of the TGA Texture Loader.
  150354. * @hidden
  150355. */
  150356. export class _TGATextureLoader implements IInternalTextureLoader {
  150357. /**
  150358. * Defines wether the loader supports cascade loading the different faces.
  150359. */
  150360. readonly supportCascades: boolean;
  150361. /**
  150362. * This returns if the loader support the current file information.
  150363. * @param extension defines the file extension of the file being loaded
  150364. * @returns true if the loader can load the specified file
  150365. */
  150366. canLoad(extension: string): boolean;
  150367. /**
  150368. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  150369. * @param data contains the texture data
  150370. * @param texture defines the BabylonJS internal texture
  150371. * @param createPolynomials will be true if polynomials have been requested
  150372. * @param onLoad defines the callback to trigger once the texture is ready
  150373. * @param onError defines the callback to trigger in case of error
  150374. */
  150375. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  150376. /**
  150377. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  150378. * @param data contains the texture data
  150379. * @param texture defines the BabylonJS internal texture
  150380. * @param callback defines the method to call once ready to upload
  150381. */
  150382. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  150383. }
  150384. }
  150385. declare module BABYLON {
  150386. /**
  150387. * Info about the .basis files
  150388. */
  150389. class BasisFileInfo {
  150390. /**
  150391. * If the file has alpha
  150392. */
  150393. hasAlpha: boolean;
  150394. /**
  150395. * Info about each image of the basis file
  150396. */
  150397. images: Array<{
  150398. levels: Array<{
  150399. width: number;
  150400. height: number;
  150401. transcodedPixels: ArrayBufferView;
  150402. }>;
  150403. }>;
  150404. }
  150405. /**
  150406. * Result of transcoding a basis file
  150407. */
  150408. class TranscodeResult {
  150409. /**
  150410. * Info about the .basis file
  150411. */
  150412. fileInfo: BasisFileInfo;
  150413. /**
  150414. * Format to use when loading the file
  150415. */
  150416. format: number;
  150417. }
  150418. /**
  150419. * Configuration options for the Basis transcoder
  150420. */
  150421. export class BasisTranscodeConfiguration {
  150422. /**
  150423. * Supported compression formats used to determine the supported output format of the transcoder
  150424. */
  150425. supportedCompressionFormats?: {
  150426. /**
  150427. * etc1 compression format
  150428. */
  150429. etc1?: boolean;
  150430. /**
  150431. * s3tc compression format
  150432. */
  150433. s3tc?: boolean;
  150434. /**
  150435. * pvrtc compression format
  150436. */
  150437. pvrtc?: boolean;
  150438. /**
  150439. * etc2 compression format
  150440. */
  150441. etc2?: boolean;
  150442. };
  150443. /**
  150444. * If mipmap levels should be loaded for transcoded images (Default: true)
  150445. */
  150446. loadMipmapLevels?: boolean;
  150447. /**
  150448. * Index of a single image to load (Default: all images)
  150449. */
  150450. loadSingleImage?: number;
  150451. }
  150452. /**
  150453. * Used to load .Basis files
  150454. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  150455. */
  150456. export class BasisTools {
  150457. private static _IgnoreSupportedFormats;
  150458. /**
  150459. * URL to use when loading the basis transcoder
  150460. */
  150461. static JSModuleURL: string;
  150462. /**
  150463. * URL to use when loading the wasm module for the transcoder
  150464. */
  150465. static WasmModuleURL: string;
  150466. /**
  150467. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  150468. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  150469. * @returns internal format corresponding to the Basis format
  150470. */
  150471. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  150472. private static _WorkerPromise;
  150473. private static _Worker;
  150474. private static _actionId;
  150475. private static _CreateWorkerAsync;
  150476. /**
  150477. * Transcodes a loaded image file to compressed pixel data
  150478. * @param data image data to transcode
  150479. * @param config configuration options for the transcoding
  150480. * @returns a promise resulting in the transcoded image
  150481. */
  150482. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  150483. /**
  150484. * Loads a texture from the transcode result
  150485. * @param texture texture load to
  150486. * @param transcodeResult the result of transcoding the basis file to load from
  150487. */
  150488. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  150489. }
  150490. }
  150491. declare module BABYLON {
  150492. /**
  150493. * Loader for .basis file format
  150494. */
  150495. export class _BasisTextureLoader implements IInternalTextureLoader {
  150496. /**
  150497. * Defines whether the loader supports cascade loading the different faces.
  150498. */
  150499. readonly supportCascades: boolean;
  150500. /**
  150501. * This returns if the loader support the current file information.
  150502. * @param extension defines the file extension of the file being loaded
  150503. * @returns true if the loader can load the specified file
  150504. */
  150505. canLoad(extension: string): boolean;
  150506. /**
  150507. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  150508. * @param data contains the texture data
  150509. * @param texture defines the BabylonJS internal texture
  150510. * @param createPolynomials will be true if polynomials have been requested
  150511. * @param onLoad defines the callback to trigger once the texture is ready
  150512. * @param onError defines the callback to trigger in case of error
  150513. */
  150514. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  150515. /**
  150516. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  150517. * @param data contains the texture data
  150518. * @param texture defines the BabylonJS internal texture
  150519. * @param callback defines the method to call once ready to upload
  150520. */
  150521. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  150522. }
  150523. }
  150524. declare module BABYLON {
  150525. /**
  150526. * Defines the basic options interface of a TexturePacker Frame
  150527. */
  150528. export interface ITexturePackerFrame {
  150529. /**
  150530. * The frame ID
  150531. */
  150532. id: number;
  150533. /**
  150534. * The frames Scale
  150535. */
  150536. scale: Vector2;
  150537. /**
  150538. * The Frames offset
  150539. */
  150540. offset: Vector2;
  150541. }
  150542. /**
  150543. * This is a support class for frame Data on texture packer sets.
  150544. */
  150545. export class TexturePackerFrame implements ITexturePackerFrame {
  150546. /**
  150547. * The frame ID
  150548. */
  150549. id: number;
  150550. /**
  150551. * The frames Scale
  150552. */
  150553. scale: Vector2;
  150554. /**
  150555. * The Frames offset
  150556. */
  150557. offset: Vector2;
  150558. /**
  150559. * Initializes a texture package frame.
  150560. * @param id The numerical frame identifier
  150561. * @param scale Scalar Vector2 for UV frame
  150562. * @param offset Vector2 for the frame position in UV units.
  150563. * @returns TexturePackerFrame
  150564. */
  150565. constructor(id: number, scale: Vector2, offset: Vector2);
  150566. }
  150567. }
  150568. declare module BABYLON {
  150569. /**
  150570. * Defines the basic options interface of a TexturePacker
  150571. */
  150572. export interface ITexturePackerOptions {
  150573. /**
  150574. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  150575. */
  150576. map?: string[];
  150577. /**
  150578. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  150579. */
  150580. uvsIn?: string;
  150581. /**
  150582. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  150583. */
  150584. uvsOut?: string;
  150585. /**
  150586. * number representing the layout style. Defaults to LAYOUT_STRIP
  150587. */
  150588. layout?: number;
  150589. /**
  150590. * number of columns if using custom column count layout(2). This defaults to 4.
  150591. */
  150592. colnum?: number;
  150593. /**
  150594. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  150595. */
  150596. updateInputMeshes?: boolean;
  150597. /**
  150598. * boolean flag to dispose all the source textures. Defaults to true.
  150599. */
  150600. disposeSources?: boolean;
  150601. /**
  150602. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  150603. */
  150604. fillBlanks?: boolean;
  150605. /**
  150606. * string value representing the context fill style color. Defaults to 'black'.
  150607. */
  150608. customFillColor?: string;
  150609. /**
  150610. * Width and Height Value of each Frame in the TexturePacker Sets
  150611. */
  150612. frameSize?: number;
  150613. /**
  150614. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  150615. */
  150616. paddingRatio?: number;
  150617. /**
  150618. * Number that declares the fill method for the padding gutter.
  150619. */
  150620. paddingMode?: number;
  150621. /**
  150622. * If in SUBUV_COLOR padding mode what color to use.
  150623. */
  150624. paddingColor?: Color3 | Color4;
  150625. }
  150626. /**
  150627. * Defines the basic interface of a TexturePacker JSON File
  150628. */
  150629. export interface ITexturePackerJSON {
  150630. /**
  150631. * The frame ID
  150632. */
  150633. name: string;
  150634. /**
  150635. * The base64 channel data
  150636. */
  150637. sets: any;
  150638. /**
  150639. * The options of the Packer
  150640. */
  150641. options: ITexturePackerOptions;
  150642. /**
  150643. * The frame data of the Packer
  150644. */
  150645. frames: Array<number>;
  150646. }
  150647. /**
  150648. * This is a support class that generates a series of packed texture sets.
  150649. * @see https://doc.babylonjs.com/babylon101/materials
  150650. */
  150651. export class TexturePacker {
  150652. /** Packer Layout Constant 0 */
  150653. static readonly LAYOUT_STRIP: number;
  150654. /** Packer Layout Constant 1 */
  150655. static readonly LAYOUT_POWER2: number;
  150656. /** Packer Layout Constant 2 */
  150657. static readonly LAYOUT_COLNUM: number;
  150658. /** Packer Layout Constant 0 */
  150659. static readonly SUBUV_WRAP: number;
  150660. /** Packer Layout Constant 1 */
  150661. static readonly SUBUV_EXTEND: number;
  150662. /** Packer Layout Constant 2 */
  150663. static readonly SUBUV_COLOR: number;
  150664. /** The Name of the Texture Package */
  150665. name: string;
  150666. /** The scene scope of the TexturePacker */
  150667. scene: Scene;
  150668. /** The Meshes to target */
  150669. meshes: AbstractMesh[];
  150670. /** Arguments passed with the Constructor */
  150671. options: ITexturePackerOptions;
  150672. /** The promise that is started upon initialization */
  150673. promise: Nullable<Promise<TexturePacker | string>>;
  150674. /** The Container object for the channel sets that are generated */
  150675. sets: object;
  150676. /** The Container array for the frames that are generated */
  150677. frames: TexturePackerFrame[];
  150678. /** The expected number of textures the system is parsing. */
  150679. private _expecting;
  150680. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  150681. private _paddingValue;
  150682. /**
  150683. * Initializes a texture package series from an array of meshes or a single mesh.
  150684. * @param name The name of the package
  150685. * @param meshes The target meshes to compose the package from
  150686. * @param options The arguments that texture packer should follow while building.
  150687. * @param scene The scene which the textures are scoped to.
  150688. * @returns TexturePacker
  150689. */
  150690. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  150691. /**
  150692. * Starts the package process
  150693. * @param resolve The promises resolution function
  150694. * @returns TexturePacker
  150695. */
  150696. private _createFrames;
  150697. /**
  150698. * Calculates the Size of the Channel Sets
  150699. * @returns Vector2
  150700. */
  150701. private _calculateSize;
  150702. /**
  150703. * Calculates the UV data for the frames.
  150704. * @param baseSize the base frameSize
  150705. * @param padding the base frame padding
  150706. * @param dtSize size of the Dynamic Texture for that channel
  150707. * @param dtUnits is 1/dtSize
  150708. * @param update flag to update the input meshes
  150709. */
  150710. private _calculateMeshUVFrames;
  150711. /**
  150712. * Calculates the frames Offset.
  150713. * @param index of the frame
  150714. * @returns Vector2
  150715. */
  150716. private _getFrameOffset;
  150717. /**
  150718. * Updates a Mesh to the frame data
  150719. * @param mesh that is the target
  150720. * @param frameID or the frame index
  150721. */
  150722. private _updateMeshUV;
  150723. /**
  150724. * Updates a Meshes materials to use the texture packer channels
  150725. * @param m is the mesh to target
  150726. * @param force all channels on the packer to be set.
  150727. */
  150728. private _updateTextureReferences;
  150729. /**
  150730. * Public method to set a Mesh to a frame
  150731. * @param m that is the target
  150732. * @param frameID or the frame index
  150733. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  150734. */
  150735. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  150736. /**
  150737. * Starts the async promise to compile the texture packer.
  150738. * @returns Promise<void>
  150739. */
  150740. processAsync(): Promise<void>;
  150741. /**
  150742. * Disposes all textures associated with this packer
  150743. */
  150744. dispose(): void;
  150745. /**
  150746. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  150747. * @param imageType is the image type to use.
  150748. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  150749. */
  150750. download(imageType?: string, quality?: number): void;
  150751. /**
  150752. * Public method to load a texturePacker JSON file.
  150753. * @param data of the JSON file in string format.
  150754. */
  150755. updateFromJSON(data: string): void;
  150756. }
  150757. }
  150758. declare module BABYLON {
  150759. /**
  150760. * 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.
  150761. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  150762. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  150763. */
  150764. export class CustomProceduralTexture extends ProceduralTexture {
  150765. private _animate;
  150766. private _time;
  150767. private _config;
  150768. private _texturePath;
  150769. /**
  150770. * Instantiates a new Custom Procedural Texture.
  150771. * 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.
  150772. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  150773. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  150774. * @param name Define the name of the texture
  150775. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  150776. * @param size Define the size of the texture to create
  150777. * @param scene Define the scene the texture belongs to
  150778. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  150779. * @param generateMipMaps Define if the texture should creates mip maps or not
  150780. */
  150781. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  150782. private _loadJson;
  150783. /**
  150784. * Is the texture ready to be used ? (rendered at least once)
  150785. * @returns true if ready, otherwise, false.
  150786. */
  150787. isReady(): boolean;
  150788. /**
  150789. * Render the texture to its associated render target.
  150790. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  150791. */
  150792. render(useCameraPostProcess?: boolean): void;
  150793. /**
  150794. * Update the list of dependant textures samplers in the shader.
  150795. */
  150796. updateTextures(): void;
  150797. /**
  150798. * Update the uniform values of the procedural texture in the shader.
  150799. */
  150800. updateShaderUniforms(): void;
  150801. /**
  150802. * Define if the texture animates or not.
  150803. */
  150804. get animate(): boolean;
  150805. set animate(value: boolean);
  150806. }
  150807. }
  150808. declare module BABYLON {
  150809. /** @hidden */
  150810. export var noisePixelShader: {
  150811. name: string;
  150812. shader: string;
  150813. };
  150814. }
  150815. declare module BABYLON {
  150816. /**
  150817. * Class used to generate noise procedural textures
  150818. */
  150819. export class NoiseProceduralTexture extends ProceduralTexture {
  150820. /** Gets or sets the start time (default is 0) */
  150821. time: number;
  150822. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  150823. brightness: number;
  150824. /** Defines the number of octaves to process */
  150825. octaves: number;
  150826. /** Defines the level of persistence (0.8 by default) */
  150827. persistence: number;
  150828. /** Gets or sets animation speed factor (default is 1) */
  150829. animationSpeedFactor: number;
  150830. /**
  150831. * Creates a new NoiseProceduralTexture
  150832. * @param name defines the name fo the texture
  150833. * @param size defines the size of the texture (default is 256)
  150834. * @param scene defines the hosting scene
  150835. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  150836. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  150837. */
  150838. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  150839. private _updateShaderUniforms;
  150840. protected _getDefines(): string;
  150841. /** Generate the current state of the procedural texture */
  150842. render(useCameraPostProcess?: boolean): void;
  150843. /**
  150844. * Serializes this noise procedural texture
  150845. * @returns a serialized noise procedural texture object
  150846. */
  150847. serialize(): any;
  150848. /**
  150849. * Clone the texture.
  150850. * @returns the cloned texture
  150851. */
  150852. clone(): NoiseProceduralTexture;
  150853. /**
  150854. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  150855. * @param parsedTexture defines parsed texture data
  150856. * @param scene defines the current scene
  150857. * @param rootUrl defines the root URL containing noise procedural texture information
  150858. * @returns a parsed NoiseProceduralTexture
  150859. */
  150860. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  150861. }
  150862. }
  150863. declare module BABYLON {
  150864. /**
  150865. * Raw cube texture where the raw buffers are passed in
  150866. */
  150867. export class RawCubeTexture extends CubeTexture {
  150868. /**
  150869. * Creates a cube texture where the raw buffers are passed in.
  150870. * @param scene defines the scene the texture is attached to
  150871. * @param data defines the array of data to use to create each face
  150872. * @param size defines the size of the textures
  150873. * @param format defines the format of the data
  150874. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  150875. * @param generateMipMaps defines if the engine should generate the mip levels
  150876. * @param invertY defines if data must be stored with Y axis inverted
  150877. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  150878. * @param compression defines the compression used (null by default)
  150879. */
  150880. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  150881. /**
  150882. * Updates the raw cube texture.
  150883. * @param data defines the data to store
  150884. * @param format defines the data format
  150885. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150886. * @param invertY defines if data must be stored with Y axis inverted
  150887. * @param compression defines the compression used (null by default)
  150888. * @param level defines which level of the texture to update
  150889. */
  150890. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  150891. /**
  150892. * Updates a raw cube texture with RGBD encoded data.
  150893. * @param data defines the array of data [mipmap][face] to use to create each face
  150894. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  150895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  150896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  150897. * @returns a promsie that resolves when the operation is complete
  150898. */
  150899. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  150900. /**
  150901. * Clones the raw cube texture.
  150902. * @return a new cube texture
  150903. */
  150904. clone(): CubeTexture;
  150905. /** @hidden */
  150906. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  150907. }
  150908. }
  150909. declare module BABYLON {
  150910. /**
  150911. * Class used to store 2D array textures containing user data
  150912. */
  150913. export class RawTexture2DArray extends Texture {
  150914. /** Gets or sets the texture format to use */
  150915. format: number;
  150916. /**
  150917. * Create a new RawTexture2DArray
  150918. * @param data defines the data of the texture
  150919. * @param width defines the width of the texture
  150920. * @param height defines the height of the texture
  150921. * @param depth defines the number of layers of the texture
  150922. * @param format defines the texture format to use
  150923. * @param scene defines the hosting scene
  150924. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  150925. * @param invertY defines if texture must be stored with Y axis inverted
  150926. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150927. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  150928. */
  150929. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  150930. /** Gets or sets the texture format to use */
  150931. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  150932. /**
  150933. * Update the texture with new data
  150934. * @param data defines the data to store in the texture
  150935. */
  150936. update(data: ArrayBufferView): void;
  150937. }
  150938. }
  150939. declare module BABYLON {
  150940. /**
  150941. * Class used to store 3D textures containing user data
  150942. */
  150943. export class RawTexture3D extends Texture {
  150944. /** Gets or sets the texture format to use */
  150945. format: number;
  150946. /**
  150947. * Create a new RawTexture3D
  150948. * @param data defines the data of the texture
  150949. * @param width defines the width of the texture
  150950. * @param height defines the height of the texture
  150951. * @param depth defines the depth of the texture
  150952. * @param format defines the texture format to use
  150953. * @param scene defines the hosting scene
  150954. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  150955. * @param invertY defines if texture must be stored with Y axis inverted
  150956. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150957. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  150958. */
  150959. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  150960. /** Gets or sets the texture format to use */
  150961. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  150962. /**
  150963. * Update the texture with new data
  150964. * @param data defines the data to store in the texture
  150965. */
  150966. update(data: ArrayBufferView): void;
  150967. }
  150968. }
  150969. declare module BABYLON {
  150970. /**
  150971. * Creates a refraction texture used by refraction channel of the standard material.
  150972. * It is like a mirror but to see through a material.
  150973. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  150974. */
  150975. export class RefractionTexture extends RenderTargetTexture {
  150976. /**
  150977. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  150978. * 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.
  150979. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  150980. */
  150981. refractionPlane: Plane;
  150982. /**
  150983. * Define how deep under the surface we should see.
  150984. */
  150985. depth: number;
  150986. /**
  150987. * Creates a refraction texture used by refraction channel of the standard material.
  150988. * It is like a mirror but to see through a material.
  150989. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  150990. * @param name Define the texture name
  150991. * @param size Define the size of the underlying texture
  150992. * @param scene Define the scene the refraction belongs to
  150993. * @param generateMipMaps Define if we need to generate mips level for the refraction
  150994. */
  150995. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  150996. /**
  150997. * Clone the refraction texture.
  150998. * @returns the cloned texture
  150999. */
  151000. clone(): RefractionTexture;
  151001. /**
  151002. * Serialize the texture to a JSON representation you could use in Parse later on
  151003. * @returns the serialized JSON representation
  151004. */
  151005. serialize(): any;
  151006. }
  151007. }
  151008. declare module BABYLON {
  151009. /**
  151010. * Block used to add support for vertex skinning (bones)
  151011. */
  151012. export class BonesBlock extends NodeMaterialBlock {
  151013. /**
  151014. * Creates a new BonesBlock
  151015. * @param name defines the block name
  151016. */
  151017. constructor(name: string);
  151018. /**
  151019. * Initialize the block and prepare the context for build
  151020. * @param state defines the state that will be used for the build
  151021. */
  151022. initialize(state: NodeMaterialBuildState): void;
  151023. /**
  151024. * Gets the current class name
  151025. * @returns the class name
  151026. */
  151027. getClassName(): string;
  151028. /**
  151029. * Gets the matrix indices input component
  151030. */
  151031. get matricesIndices(): NodeMaterialConnectionPoint;
  151032. /**
  151033. * Gets the matrix weights input component
  151034. */
  151035. get matricesWeights(): NodeMaterialConnectionPoint;
  151036. /**
  151037. * Gets the extra matrix indices input component
  151038. */
  151039. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  151040. /**
  151041. * Gets the extra matrix weights input component
  151042. */
  151043. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  151044. /**
  151045. * Gets the world input component
  151046. */
  151047. get world(): NodeMaterialConnectionPoint;
  151048. /**
  151049. * Gets the output component
  151050. */
  151051. get output(): NodeMaterialConnectionPoint;
  151052. autoConfigure(material: NodeMaterial): void;
  151053. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  151054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151056. protected _buildBlock(state: NodeMaterialBuildState): this;
  151057. }
  151058. }
  151059. declare module BABYLON {
  151060. /**
  151061. * Block used to add support for instances
  151062. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  151063. */
  151064. export class InstancesBlock extends NodeMaterialBlock {
  151065. /**
  151066. * Creates a new InstancesBlock
  151067. * @param name defines the block name
  151068. */
  151069. constructor(name: string);
  151070. /**
  151071. * Gets the current class name
  151072. * @returns the class name
  151073. */
  151074. getClassName(): string;
  151075. /**
  151076. * Gets the first world row input component
  151077. */
  151078. get world0(): NodeMaterialConnectionPoint;
  151079. /**
  151080. * Gets the second world row input component
  151081. */
  151082. get world1(): NodeMaterialConnectionPoint;
  151083. /**
  151084. * Gets the third world row input component
  151085. */
  151086. get world2(): NodeMaterialConnectionPoint;
  151087. /**
  151088. * Gets the forth world row input component
  151089. */
  151090. get world3(): NodeMaterialConnectionPoint;
  151091. /**
  151092. * Gets the world input component
  151093. */
  151094. get world(): NodeMaterialConnectionPoint;
  151095. /**
  151096. * Gets the output component
  151097. */
  151098. get output(): NodeMaterialConnectionPoint;
  151099. /**
  151100. * Gets the isntanceID component
  151101. */
  151102. get instanceID(): NodeMaterialConnectionPoint;
  151103. autoConfigure(material: NodeMaterial): void;
  151104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  151105. protected _buildBlock(state: NodeMaterialBuildState): this;
  151106. }
  151107. }
  151108. declare module BABYLON {
  151109. /**
  151110. * Block used to add morph targets support to vertex shader
  151111. */
  151112. export class MorphTargetsBlock extends NodeMaterialBlock {
  151113. private _repeatableContentAnchor;
  151114. /**
  151115. * Create a new MorphTargetsBlock
  151116. * @param name defines the block name
  151117. */
  151118. constructor(name: string);
  151119. /**
  151120. * Gets the current class name
  151121. * @returns the class name
  151122. */
  151123. getClassName(): string;
  151124. /**
  151125. * Gets the position input component
  151126. */
  151127. get position(): NodeMaterialConnectionPoint;
  151128. /**
  151129. * Gets the normal input component
  151130. */
  151131. get normal(): NodeMaterialConnectionPoint;
  151132. /**
  151133. * Gets the tangent input component
  151134. */
  151135. get tangent(): NodeMaterialConnectionPoint;
  151136. /**
  151137. * Gets the tangent input component
  151138. */
  151139. get uv(): NodeMaterialConnectionPoint;
  151140. /**
  151141. * Gets the position output component
  151142. */
  151143. get positionOutput(): NodeMaterialConnectionPoint;
  151144. /**
  151145. * Gets the normal output component
  151146. */
  151147. get normalOutput(): NodeMaterialConnectionPoint;
  151148. /**
  151149. * Gets the tangent output component
  151150. */
  151151. get tangentOutput(): NodeMaterialConnectionPoint;
  151152. /**
  151153. * Gets the tangent output component
  151154. */
  151155. get uvOutput(): NodeMaterialConnectionPoint;
  151156. initialize(state: NodeMaterialBuildState): void;
  151157. autoConfigure(material: NodeMaterial): void;
  151158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151160. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  151161. protected _buildBlock(state: NodeMaterialBuildState): this;
  151162. }
  151163. }
  151164. declare module BABYLON {
  151165. /**
  151166. * Block used to get data information from a light
  151167. */
  151168. export class LightInformationBlock extends NodeMaterialBlock {
  151169. private _lightDataUniformName;
  151170. private _lightColorUniformName;
  151171. private _lightTypeDefineName;
  151172. /**
  151173. * Gets or sets the light associated with this block
  151174. */
  151175. light: Nullable<Light>;
  151176. /**
  151177. * Creates a new LightInformationBlock
  151178. * @param name defines the block name
  151179. */
  151180. constructor(name: string);
  151181. /**
  151182. * Gets the current class name
  151183. * @returns the class name
  151184. */
  151185. getClassName(): string;
  151186. /**
  151187. * Gets the world position input component
  151188. */
  151189. get worldPosition(): NodeMaterialConnectionPoint;
  151190. /**
  151191. * Gets the direction output component
  151192. */
  151193. get direction(): NodeMaterialConnectionPoint;
  151194. /**
  151195. * Gets the direction output component
  151196. */
  151197. get color(): NodeMaterialConnectionPoint;
  151198. /**
  151199. * Gets the direction output component
  151200. */
  151201. get intensity(): NodeMaterialConnectionPoint;
  151202. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151204. protected _buildBlock(state: NodeMaterialBuildState): this;
  151205. serialize(): any;
  151206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151207. }
  151208. }
  151209. declare module BABYLON {
  151210. /**
  151211. * Block used to add image processing support to fragment shader
  151212. */
  151213. export class ImageProcessingBlock extends NodeMaterialBlock {
  151214. /**
  151215. * Create a new ImageProcessingBlock
  151216. * @param name defines the block name
  151217. */
  151218. constructor(name: string);
  151219. /**
  151220. * Gets the current class name
  151221. * @returns the class name
  151222. */
  151223. getClassName(): string;
  151224. /**
  151225. * Gets the color input component
  151226. */
  151227. get color(): NodeMaterialConnectionPoint;
  151228. /**
  151229. * Gets the output component
  151230. */
  151231. get output(): NodeMaterialConnectionPoint;
  151232. /**
  151233. * Initialize the block and prepare the context for build
  151234. * @param state defines the state that will be used for the build
  151235. */
  151236. initialize(state: NodeMaterialBuildState): void;
  151237. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  151238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151240. protected _buildBlock(state: NodeMaterialBuildState): this;
  151241. }
  151242. }
  151243. declare module BABYLON {
  151244. /**
  151245. * Block used to pertub normals based on a normal map
  151246. */
  151247. export class PerturbNormalBlock extends NodeMaterialBlock {
  151248. private _tangentSpaceParameterName;
  151249. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  151250. invertX: boolean;
  151251. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  151252. invertY: boolean;
  151253. /**
  151254. * Create a new PerturbNormalBlock
  151255. * @param name defines the block name
  151256. */
  151257. constructor(name: string);
  151258. /**
  151259. * Gets the current class name
  151260. * @returns the class name
  151261. */
  151262. getClassName(): string;
  151263. /**
  151264. * Gets the world position input component
  151265. */
  151266. get worldPosition(): NodeMaterialConnectionPoint;
  151267. /**
  151268. * Gets the world normal input component
  151269. */
  151270. get worldNormal(): NodeMaterialConnectionPoint;
  151271. /**
  151272. * Gets the world tangent input component
  151273. */
  151274. get worldTangent(): NodeMaterialConnectionPoint;
  151275. /**
  151276. * Gets the uv input component
  151277. */
  151278. get uv(): NodeMaterialConnectionPoint;
  151279. /**
  151280. * Gets the normal map color input component
  151281. */
  151282. get normalMapColor(): NodeMaterialConnectionPoint;
  151283. /**
  151284. * Gets the strength input component
  151285. */
  151286. get strength(): NodeMaterialConnectionPoint;
  151287. /**
  151288. * Gets the output component
  151289. */
  151290. get output(): NodeMaterialConnectionPoint;
  151291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151292. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151293. autoConfigure(material: NodeMaterial): void;
  151294. protected _buildBlock(state: NodeMaterialBuildState): this;
  151295. protected _dumpPropertiesCode(): string;
  151296. serialize(): any;
  151297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151298. }
  151299. }
  151300. declare module BABYLON {
  151301. /**
  151302. * Block used to discard a pixel if a value is smaller than a cutoff
  151303. */
  151304. export class DiscardBlock extends NodeMaterialBlock {
  151305. /**
  151306. * Create a new DiscardBlock
  151307. * @param name defines the block name
  151308. */
  151309. constructor(name: string);
  151310. /**
  151311. * Gets the current class name
  151312. * @returns the class name
  151313. */
  151314. getClassName(): string;
  151315. /**
  151316. * Gets the color input component
  151317. */
  151318. get value(): NodeMaterialConnectionPoint;
  151319. /**
  151320. * Gets the cutoff input component
  151321. */
  151322. get cutoff(): NodeMaterialConnectionPoint;
  151323. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  151324. }
  151325. }
  151326. declare module BABYLON {
  151327. /**
  151328. * Block used to test if the fragment shader is front facing
  151329. */
  151330. export class FrontFacingBlock extends NodeMaterialBlock {
  151331. /**
  151332. * Creates a new FrontFacingBlock
  151333. * @param name defines the block name
  151334. */
  151335. constructor(name: string);
  151336. /**
  151337. * Gets the current class name
  151338. * @returns the class name
  151339. */
  151340. getClassName(): string;
  151341. /**
  151342. * Gets the output component
  151343. */
  151344. get output(): NodeMaterialConnectionPoint;
  151345. protected _buildBlock(state: NodeMaterialBuildState): this;
  151346. }
  151347. }
  151348. declare module BABYLON {
  151349. /**
  151350. * Block used to get the derivative value on x and y of a given input
  151351. */
  151352. export class DerivativeBlock extends NodeMaterialBlock {
  151353. /**
  151354. * Create a new DerivativeBlock
  151355. * @param name defines the block name
  151356. */
  151357. constructor(name: string);
  151358. /**
  151359. * Gets the current class name
  151360. * @returns the class name
  151361. */
  151362. getClassName(): string;
  151363. /**
  151364. * Gets the input component
  151365. */
  151366. get input(): NodeMaterialConnectionPoint;
  151367. /**
  151368. * Gets the derivative output on x
  151369. */
  151370. get dx(): NodeMaterialConnectionPoint;
  151371. /**
  151372. * Gets the derivative output on y
  151373. */
  151374. get dy(): NodeMaterialConnectionPoint;
  151375. protected _buildBlock(state: NodeMaterialBuildState): this;
  151376. }
  151377. }
  151378. declare module BABYLON {
  151379. /**
  151380. * Block used to make gl_FragCoord available
  151381. */
  151382. export class FragCoordBlock extends NodeMaterialBlock {
  151383. /**
  151384. * Creates a new FragCoordBlock
  151385. * @param name defines the block name
  151386. */
  151387. constructor(name: string);
  151388. /**
  151389. * Gets the current class name
  151390. * @returns the class name
  151391. */
  151392. getClassName(): string;
  151393. /**
  151394. * Gets the xy component
  151395. */
  151396. get xy(): NodeMaterialConnectionPoint;
  151397. /**
  151398. * Gets the xyz component
  151399. */
  151400. get xyz(): NodeMaterialConnectionPoint;
  151401. /**
  151402. * Gets the xyzw component
  151403. */
  151404. get xyzw(): NodeMaterialConnectionPoint;
  151405. /**
  151406. * Gets the x component
  151407. */
  151408. get x(): NodeMaterialConnectionPoint;
  151409. /**
  151410. * Gets the y component
  151411. */
  151412. get y(): NodeMaterialConnectionPoint;
  151413. /**
  151414. * Gets the z component
  151415. */
  151416. get z(): NodeMaterialConnectionPoint;
  151417. /**
  151418. * Gets the w component
  151419. */
  151420. get output(): NodeMaterialConnectionPoint;
  151421. protected writeOutputs(state: NodeMaterialBuildState): string;
  151422. protected _buildBlock(state: NodeMaterialBuildState): this;
  151423. }
  151424. }
  151425. declare module BABYLON {
  151426. /**
  151427. * Block used to get the screen sizes
  151428. */
  151429. export class ScreenSizeBlock extends NodeMaterialBlock {
  151430. private _varName;
  151431. private _scene;
  151432. /**
  151433. * Creates a new ScreenSizeBlock
  151434. * @param name defines the block name
  151435. */
  151436. constructor(name: string);
  151437. /**
  151438. * Gets the current class name
  151439. * @returns the class name
  151440. */
  151441. getClassName(): string;
  151442. /**
  151443. * Gets the xy component
  151444. */
  151445. get xy(): NodeMaterialConnectionPoint;
  151446. /**
  151447. * Gets the x component
  151448. */
  151449. get x(): NodeMaterialConnectionPoint;
  151450. /**
  151451. * Gets the y component
  151452. */
  151453. get y(): NodeMaterialConnectionPoint;
  151454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151455. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  151456. protected _buildBlock(state: NodeMaterialBuildState): this;
  151457. }
  151458. }
  151459. declare module BABYLON {
  151460. /**
  151461. * Block used to add support for scene fog
  151462. */
  151463. export class FogBlock extends NodeMaterialBlock {
  151464. private _fogDistanceName;
  151465. private _fogParameters;
  151466. /**
  151467. * Create a new FogBlock
  151468. * @param name defines the block name
  151469. */
  151470. constructor(name: string);
  151471. /**
  151472. * Gets the current class name
  151473. * @returns the class name
  151474. */
  151475. getClassName(): string;
  151476. /**
  151477. * Gets the world position input component
  151478. */
  151479. get worldPosition(): NodeMaterialConnectionPoint;
  151480. /**
  151481. * Gets the view input component
  151482. */
  151483. get view(): NodeMaterialConnectionPoint;
  151484. /**
  151485. * Gets the color input component
  151486. */
  151487. get input(): NodeMaterialConnectionPoint;
  151488. /**
  151489. * Gets the fog color input component
  151490. */
  151491. get fogColor(): NodeMaterialConnectionPoint;
  151492. /**
  151493. * Gets the output component
  151494. */
  151495. get output(): NodeMaterialConnectionPoint;
  151496. autoConfigure(material: NodeMaterial): void;
  151497. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151499. protected _buildBlock(state: NodeMaterialBuildState): this;
  151500. }
  151501. }
  151502. declare module BABYLON {
  151503. /**
  151504. * Block used to add light in the fragment shader
  151505. */
  151506. export class LightBlock extends NodeMaterialBlock {
  151507. private _lightId;
  151508. /**
  151509. * Gets or sets the light associated with this block
  151510. */
  151511. light: Nullable<Light>;
  151512. /**
  151513. * Create a new LightBlock
  151514. * @param name defines the block name
  151515. */
  151516. constructor(name: string);
  151517. /**
  151518. * Gets the current class name
  151519. * @returns the class name
  151520. */
  151521. getClassName(): string;
  151522. /**
  151523. * Gets the world position input component
  151524. */
  151525. get worldPosition(): NodeMaterialConnectionPoint;
  151526. /**
  151527. * Gets the world normal input component
  151528. */
  151529. get worldNormal(): NodeMaterialConnectionPoint;
  151530. /**
  151531. * Gets the camera (or eye) position component
  151532. */
  151533. get cameraPosition(): NodeMaterialConnectionPoint;
  151534. /**
  151535. * Gets the glossiness component
  151536. */
  151537. get glossiness(): NodeMaterialConnectionPoint;
  151538. /**
  151539. * Gets the glossinness power component
  151540. */
  151541. get glossPower(): NodeMaterialConnectionPoint;
  151542. /**
  151543. * Gets the diffuse color component
  151544. */
  151545. get diffuseColor(): NodeMaterialConnectionPoint;
  151546. /**
  151547. * Gets the specular color component
  151548. */
  151549. get specularColor(): NodeMaterialConnectionPoint;
  151550. /**
  151551. * Gets the view matrix component
  151552. */
  151553. get view(): NodeMaterialConnectionPoint;
  151554. /**
  151555. * Gets the diffuse output component
  151556. */
  151557. get diffuseOutput(): NodeMaterialConnectionPoint;
  151558. /**
  151559. * Gets the specular output component
  151560. */
  151561. get specularOutput(): NodeMaterialConnectionPoint;
  151562. /**
  151563. * Gets the shadow output component
  151564. */
  151565. get shadow(): NodeMaterialConnectionPoint;
  151566. autoConfigure(material: NodeMaterial): void;
  151567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151568. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  151569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151570. private _injectVertexCode;
  151571. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  151572. serialize(): any;
  151573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151574. }
  151575. }
  151576. declare module BABYLON {
  151577. /**
  151578. * Block used to read a reflection texture from a sampler
  151579. */
  151580. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  151581. /**
  151582. * Create a new ReflectionTextureBlock
  151583. * @param name defines the block name
  151584. */
  151585. constructor(name: string);
  151586. /**
  151587. * Gets the current class name
  151588. * @returns the class name
  151589. */
  151590. getClassName(): string;
  151591. /**
  151592. * Gets the world position input component
  151593. */
  151594. get position(): NodeMaterialConnectionPoint;
  151595. /**
  151596. * Gets the world position input component
  151597. */
  151598. get worldPosition(): NodeMaterialConnectionPoint;
  151599. /**
  151600. * Gets the world normal input component
  151601. */
  151602. get worldNormal(): NodeMaterialConnectionPoint;
  151603. /**
  151604. * Gets the world input component
  151605. */
  151606. get world(): NodeMaterialConnectionPoint;
  151607. /**
  151608. * Gets the camera (or eye) position component
  151609. */
  151610. get cameraPosition(): NodeMaterialConnectionPoint;
  151611. /**
  151612. * Gets the view input component
  151613. */
  151614. get view(): NodeMaterialConnectionPoint;
  151615. /**
  151616. * Gets the rgb output component
  151617. */
  151618. get rgb(): NodeMaterialConnectionPoint;
  151619. /**
  151620. * Gets the rgba output component
  151621. */
  151622. get rgba(): NodeMaterialConnectionPoint;
  151623. /**
  151624. * Gets the r output component
  151625. */
  151626. get r(): NodeMaterialConnectionPoint;
  151627. /**
  151628. * Gets the g output component
  151629. */
  151630. get g(): NodeMaterialConnectionPoint;
  151631. /**
  151632. * Gets the b output component
  151633. */
  151634. get b(): NodeMaterialConnectionPoint;
  151635. /**
  151636. * Gets the a output component
  151637. */
  151638. get a(): NodeMaterialConnectionPoint;
  151639. autoConfigure(material: NodeMaterial): void;
  151640. protected _buildBlock(state: NodeMaterialBuildState): this;
  151641. }
  151642. }
  151643. declare module BABYLON {
  151644. /**
  151645. * Block used to add 2 vectors
  151646. */
  151647. export class AddBlock extends NodeMaterialBlock {
  151648. /**
  151649. * Creates a new AddBlock
  151650. * @param name defines the block name
  151651. */
  151652. constructor(name: string);
  151653. /**
  151654. * Gets the current class name
  151655. * @returns the class name
  151656. */
  151657. getClassName(): string;
  151658. /**
  151659. * Gets the left operand input component
  151660. */
  151661. get left(): NodeMaterialConnectionPoint;
  151662. /**
  151663. * Gets the right operand input component
  151664. */
  151665. get right(): NodeMaterialConnectionPoint;
  151666. /**
  151667. * Gets the output component
  151668. */
  151669. get output(): NodeMaterialConnectionPoint;
  151670. protected _buildBlock(state: NodeMaterialBuildState): this;
  151671. }
  151672. }
  151673. declare module BABYLON {
  151674. /**
  151675. * Block used to scale a vector by a float
  151676. */
  151677. export class ScaleBlock extends NodeMaterialBlock {
  151678. /**
  151679. * Creates a new ScaleBlock
  151680. * @param name defines the block name
  151681. */
  151682. constructor(name: string);
  151683. /**
  151684. * Gets the current class name
  151685. * @returns the class name
  151686. */
  151687. getClassName(): string;
  151688. /**
  151689. * Gets the input component
  151690. */
  151691. get input(): NodeMaterialConnectionPoint;
  151692. /**
  151693. * Gets the factor input component
  151694. */
  151695. get factor(): NodeMaterialConnectionPoint;
  151696. /**
  151697. * Gets the output component
  151698. */
  151699. get output(): NodeMaterialConnectionPoint;
  151700. protected _buildBlock(state: NodeMaterialBuildState): this;
  151701. }
  151702. }
  151703. declare module BABYLON {
  151704. /**
  151705. * Block used to clamp a float
  151706. */
  151707. export class ClampBlock extends NodeMaterialBlock {
  151708. /** Gets or sets the minimum range */
  151709. minimum: number;
  151710. /** Gets or sets the maximum range */
  151711. maximum: number;
  151712. /**
  151713. * Creates a new ClampBlock
  151714. * @param name defines the block name
  151715. */
  151716. constructor(name: string);
  151717. /**
  151718. * Gets the current class name
  151719. * @returns the class name
  151720. */
  151721. getClassName(): string;
  151722. /**
  151723. * Gets the value input component
  151724. */
  151725. get value(): NodeMaterialConnectionPoint;
  151726. /**
  151727. * Gets the output component
  151728. */
  151729. get output(): NodeMaterialConnectionPoint;
  151730. protected _buildBlock(state: NodeMaterialBuildState): this;
  151731. protected _dumpPropertiesCode(): string;
  151732. serialize(): any;
  151733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151734. }
  151735. }
  151736. declare module BABYLON {
  151737. /**
  151738. * Block used to apply a cross product between 2 vectors
  151739. */
  151740. export class CrossBlock extends NodeMaterialBlock {
  151741. /**
  151742. * Creates a new CrossBlock
  151743. * @param name defines the block name
  151744. */
  151745. constructor(name: string);
  151746. /**
  151747. * Gets the current class name
  151748. * @returns the class name
  151749. */
  151750. getClassName(): string;
  151751. /**
  151752. * Gets the left operand input component
  151753. */
  151754. get left(): NodeMaterialConnectionPoint;
  151755. /**
  151756. * Gets the right operand input component
  151757. */
  151758. get right(): NodeMaterialConnectionPoint;
  151759. /**
  151760. * Gets the output component
  151761. */
  151762. get output(): NodeMaterialConnectionPoint;
  151763. protected _buildBlock(state: NodeMaterialBuildState): this;
  151764. }
  151765. }
  151766. declare module BABYLON {
  151767. /**
  151768. * Block used to apply a dot product between 2 vectors
  151769. */
  151770. export class DotBlock extends NodeMaterialBlock {
  151771. /**
  151772. * Creates a new DotBlock
  151773. * @param name defines the block name
  151774. */
  151775. constructor(name: string);
  151776. /**
  151777. * Gets the current class name
  151778. * @returns the class name
  151779. */
  151780. getClassName(): string;
  151781. /**
  151782. * Gets the left operand input component
  151783. */
  151784. get left(): NodeMaterialConnectionPoint;
  151785. /**
  151786. * Gets the right operand input component
  151787. */
  151788. get right(): NodeMaterialConnectionPoint;
  151789. /**
  151790. * Gets the output component
  151791. */
  151792. get output(): NodeMaterialConnectionPoint;
  151793. protected _buildBlock(state: NodeMaterialBuildState): this;
  151794. }
  151795. }
  151796. declare module BABYLON {
  151797. /**
  151798. * Block used to normalize a vector
  151799. */
  151800. export class NormalizeBlock extends NodeMaterialBlock {
  151801. /**
  151802. * Creates a new NormalizeBlock
  151803. * @param name defines the block name
  151804. */
  151805. constructor(name: string);
  151806. /**
  151807. * Gets the current class name
  151808. * @returns the class name
  151809. */
  151810. getClassName(): string;
  151811. /**
  151812. * Gets the input component
  151813. */
  151814. get input(): NodeMaterialConnectionPoint;
  151815. /**
  151816. * Gets the output component
  151817. */
  151818. get output(): NodeMaterialConnectionPoint;
  151819. protected _buildBlock(state: NodeMaterialBuildState): this;
  151820. }
  151821. }
  151822. declare module BABYLON {
  151823. /**
  151824. * Block used to create a Color3/4 out of individual inputs (one for each component)
  151825. */
  151826. export class ColorMergerBlock extends NodeMaterialBlock {
  151827. /**
  151828. * Create a new ColorMergerBlock
  151829. * @param name defines the block name
  151830. */
  151831. constructor(name: string);
  151832. /**
  151833. * Gets the current class name
  151834. * @returns the class name
  151835. */
  151836. getClassName(): string;
  151837. /**
  151838. * Gets the rgb component (input)
  151839. */
  151840. get rgbIn(): NodeMaterialConnectionPoint;
  151841. /**
  151842. * Gets the r component (input)
  151843. */
  151844. get r(): NodeMaterialConnectionPoint;
  151845. /**
  151846. * Gets the g component (input)
  151847. */
  151848. get g(): NodeMaterialConnectionPoint;
  151849. /**
  151850. * Gets the b component (input)
  151851. */
  151852. get b(): NodeMaterialConnectionPoint;
  151853. /**
  151854. * Gets the a component (input)
  151855. */
  151856. get a(): NodeMaterialConnectionPoint;
  151857. /**
  151858. * Gets the rgba component (output)
  151859. */
  151860. get rgba(): NodeMaterialConnectionPoint;
  151861. /**
  151862. * Gets the rgb component (output)
  151863. */
  151864. get rgbOut(): NodeMaterialConnectionPoint;
  151865. /**
  151866. * Gets the rgb component (output)
  151867. * @deprecated Please use rgbOut instead.
  151868. */
  151869. get rgb(): NodeMaterialConnectionPoint;
  151870. protected _buildBlock(state: NodeMaterialBuildState): this;
  151871. }
  151872. }
  151873. declare module BABYLON {
  151874. /**
  151875. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  151876. */
  151877. export class VectorSplitterBlock extends NodeMaterialBlock {
  151878. /**
  151879. * Create a new VectorSplitterBlock
  151880. * @param name defines the block name
  151881. */
  151882. constructor(name: string);
  151883. /**
  151884. * Gets the current class name
  151885. * @returns the class name
  151886. */
  151887. getClassName(): string;
  151888. /**
  151889. * Gets the xyzw component (input)
  151890. */
  151891. get xyzw(): NodeMaterialConnectionPoint;
  151892. /**
  151893. * Gets the xyz component (input)
  151894. */
  151895. get xyzIn(): NodeMaterialConnectionPoint;
  151896. /**
  151897. * Gets the xy component (input)
  151898. */
  151899. get xyIn(): NodeMaterialConnectionPoint;
  151900. /**
  151901. * Gets the xyz component (output)
  151902. */
  151903. get xyzOut(): NodeMaterialConnectionPoint;
  151904. /**
  151905. * Gets the xy component (output)
  151906. */
  151907. get xyOut(): NodeMaterialConnectionPoint;
  151908. /**
  151909. * Gets the x component (output)
  151910. */
  151911. get x(): NodeMaterialConnectionPoint;
  151912. /**
  151913. * Gets the y component (output)
  151914. */
  151915. get y(): NodeMaterialConnectionPoint;
  151916. /**
  151917. * Gets the z component (output)
  151918. */
  151919. get z(): NodeMaterialConnectionPoint;
  151920. /**
  151921. * Gets the w component (output)
  151922. */
  151923. get w(): NodeMaterialConnectionPoint;
  151924. protected _inputRename(name: string): string;
  151925. protected _outputRename(name: string): string;
  151926. protected _buildBlock(state: NodeMaterialBuildState): this;
  151927. }
  151928. }
  151929. declare module BABYLON {
  151930. /**
  151931. * Block used to lerp between 2 values
  151932. */
  151933. export class LerpBlock extends NodeMaterialBlock {
  151934. /**
  151935. * Creates a new LerpBlock
  151936. * @param name defines the block name
  151937. */
  151938. constructor(name: string);
  151939. /**
  151940. * Gets the current class name
  151941. * @returns the class name
  151942. */
  151943. getClassName(): string;
  151944. /**
  151945. * Gets the left operand input component
  151946. */
  151947. get left(): NodeMaterialConnectionPoint;
  151948. /**
  151949. * Gets the right operand input component
  151950. */
  151951. get right(): NodeMaterialConnectionPoint;
  151952. /**
  151953. * Gets the gradient operand input component
  151954. */
  151955. get gradient(): NodeMaterialConnectionPoint;
  151956. /**
  151957. * Gets the output component
  151958. */
  151959. get output(): NodeMaterialConnectionPoint;
  151960. protected _buildBlock(state: NodeMaterialBuildState): this;
  151961. }
  151962. }
  151963. declare module BABYLON {
  151964. /**
  151965. * Block used to divide 2 vectors
  151966. */
  151967. export class DivideBlock extends NodeMaterialBlock {
  151968. /**
  151969. * Creates a new DivideBlock
  151970. * @param name defines the block name
  151971. */
  151972. constructor(name: string);
  151973. /**
  151974. * Gets the current class name
  151975. * @returns the class name
  151976. */
  151977. getClassName(): string;
  151978. /**
  151979. * Gets the left operand input component
  151980. */
  151981. get left(): NodeMaterialConnectionPoint;
  151982. /**
  151983. * Gets the right operand input component
  151984. */
  151985. get right(): NodeMaterialConnectionPoint;
  151986. /**
  151987. * Gets the output component
  151988. */
  151989. get output(): NodeMaterialConnectionPoint;
  151990. protected _buildBlock(state: NodeMaterialBuildState): this;
  151991. }
  151992. }
  151993. declare module BABYLON {
  151994. /**
  151995. * Block used to subtract 2 vectors
  151996. */
  151997. export class SubtractBlock extends NodeMaterialBlock {
  151998. /**
  151999. * Creates a new SubtractBlock
  152000. * @param name defines the block name
  152001. */
  152002. constructor(name: string);
  152003. /**
  152004. * Gets the current class name
  152005. * @returns the class name
  152006. */
  152007. getClassName(): string;
  152008. /**
  152009. * Gets the left operand input component
  152010. */
  152011. get left(): NodeMaterialConnectionPoint;
  152012. /**
  152013. * Gets the right operand input component
  152014. */
  152015. get right(): NodeMaterialConnectionPoint;
  152016. /**
  152017. * Gets the output component
  152018. */
  152019. get output(): NodeMaterialConnectionPoint;
  152020. protected _buildBlock(state: NodeMaterialBuildState): this;
  152021. }
  152022. }
  152023. declare module BABYLON {
  152024. /**
  152025. * Block used to step a value
  152026. */
  152027. export class StepBlock extends NodeMaterialBlock {
  152028. /**
  152029. * Creates a new StepBlock
  152030. * @param name defines the block name
  152031. */
  152032. constructor(name: string);
  152033. /**
  152034. * Gets the current class name
  152035. * @returns the class name
  152036. */
  152037. getClassName(): string;
  152038. /**
  152039. * Gets the value operand input component
  152040. */
  152041. get value(): NodeMaterialConnectionPoint;
  152042. /**
  152043. * Gets the edge operand input component
  152044. */
  152045. get edge(): NodeMaterialConnectionPoint;
  152046. /**
  152047. * Gets the output component
  152048. */
  152049. get output(): NodeMaterialConnectionPoint;
  152050. protected _buildBlock(state: NodeMaterialBuildState): this;
  152051. }
  152052. }
  152053. declare module BABYLON {
  152054. /**
  152055. * Block used to get the opposite (1 - x) of a value
  152056. */
  152057. export class OneMinusBlock extends NodeMaterialBlock {
  152058. /**
  152059. * Creates a new OneMinusBlock
  152060. * @param name defines the block name
  152061. */
  152062. constructor(name: string);
  152063. /**
  152064. * Gets the current class name
  152065. * @returns the class name
  152066. */
  152067. getClassName(): string;
  152068. /**
  152069. * Gets the input component
  152070. */
  152071. get input(): NodeMaterialConnectionPoint;
  152072. /**
  152073. * Gets the output component
  152074. */
  152075. get output(): NodeMaterialConnectionPoint;
  152076. protected _buildBlock(state: NodeMaterialBuildState): this;
  152077. }
  152078. }
  152079. declare module BABYLON {
  152080. /**
  152081. * Block used to get the view direction
  152082. */
  152083. export class ViewDirectionBlock extends NodeMaterialBlock {
  152084. /**
  152085. * Creates a new ViewDirectionBlock
  152086. * @param name defines the block name
  152087. */
  152088. constructor(name: string);
  152089. /**
  152090. * Gets the current class name
  152091. * @returns the class name
  152092. */
  152093. getClassName(): string;
  152094. /**
  152095. * Gets the world position component
  152096. */
  152097. get worldPosition(): NodeMaterialConnectionPoint;
  152098. /**
  152099. * Gets the camera position component
  152100. */
  152101. get cameraPosition(): NodeMaterialConnectionPoint;
  152102. /**
  152103. * Gets the output component
  152104. */
  152105. get output(): NodeMaterialConnectionPoint;
  152106. autoConfigure(material: NodeMaterial): void;
  152107. protected _buildBlock(state: NodeMaterialBuildState): this;
  152108. }
  152109. }
  152110. declare module BABYLON {
  152111. /**
  152112. * Block used to compute fresnel value
  152113. */
  152114. export class FresnelBlock extends NodeMaterialBlock {
  152115. /**
  152116. * Create a new FresnelBlock
  152117. * @param name defines the block name
  152118. */
  152119. constructor(name: string);
  152120. /**
  152121. * Gets the current class name
  152122. * @returns the class name
  152123. */
  152124. getClassName(): string;
  152125. /**
  152126. * Gets the world normal input component
  152127. */
  152128. get worldNormal(): NodeMaterialConnectionPoint;
  152129. /**
  152130. * Gets the view direction input component
  152131. */
  152132. get viewDirection(): NodeMaterialConnectionPoint;
  152133. /**
  152134. * Gets the bias input component
  152135. */
  152136. get bias(): NodeMaterialConnectionPoint;
  152137. /**
  152138. * Gets the camera (or eye) position component
  152139. */
  152140. get power(): NodeMaterialConnectionPoint;
  152141. /**
  152142. * Gets the fresnel output component
  152143. */
  152144. get fresnel(): NodeMaterialConnectionPoint;
  152145. autoConfigure(material: NodeMaterial): void;
  152146. protected _buildBlock(state: NodeMaterialBuildState): this;
  152147. }
  152148. }
  152149. declare module BABYLON {
  152150. /**
  152151. * Block used to get the max of 2 values
  152152. */
  152153. export class MaxBlock extends NodeMaterialBlock {
  152154. /**
  152155. * Creates a new MaxBlock
  152156. * @param name defines the block name
  152157. */
  152158. constructor(name: string);
  152159. /**
  152160. * Gets the current class name
  152161. * @returns the class name
  152162. */
  152163. getClassName(): string;
  152164. /**
  152165. * Gets the left operand input component
  152166. */
  152167. get left(): NodeMaterialConnectionPoint;
  152168. /**
  152169. * Gets the right operand input component
  152170. */
  152171. get right(): NodeMaterialConnectionPoint;
  152172. /**
  152173. * Gets the output component
  152174. */
  152175. get output(): NodeMaterialConnectionPoint;
  152176. protected _buildBlock(state: NodeMaterialBuildState): this;
  152177. }
  152178. }
  152179. declare module BABYLON {
  152180. /**
  152181. * Block used to get the min of 2 values
  152182. */
  152183. export class MinBlock extends NodeMaterialBlock {
  152184. /**
  152185. * Creates a new MinBlock
  152186. * @param name defines the block name
  152187. */
  152188. constructor(name: string);
  152189. /**
  152190. * Gets the current class name
  152191. * @returns the class name
  152192. */
  152193. getClassName(): string;
  152194. /**
  152195. * Gets the left operand input component
  152196. */
  152197. get left(): NodeMaterialConnectionPoint;
  152198. /**
  152199. * Gets the right operand input component
  152200. */
  152201. get right(): NodeMaterialConnectionPoint;
  152202. /**
  152203. * Gets the output component
  152204. */
  152205. get output(): NodeMaterialConnectionPoint;
  152206. protected _buildBlock(state: NodeMaterialBuildState): this;
  152207. }
  152208. }
  152209. declare module BABYLON {
  152210. /**
  152211. * Block used to get the distance between 2 values
  152212. */
  152213. export class DistanceBlock extends NodeMaterialBlock {
  152214. /**
  152215. * Creates a new DistanceBlock
  152216. * @param name defines the block name
  152217. */
  152218. constructor(name: string);
  152219. /**
  152220. * Gets the current class name
  152221. * @returns the class name
  152222. */
  152223. getClassName(): string;
  152224. /**
  152225. * Gets the left operand input component
  152226. */
  152227. get left(): NodeMaterialConnectionPoint;
  152228. /**
  152229. * Gets the right operand input component
  152230. */
  152231. get right(): NodeMaterialConnectionPoint;
  152232. /**
  152233. * Gets the output component
  152234. */
  152235. get output(): NodeMaterialConnectionPoint;
  152236. protected _buildBlock(state: NodeMaterialBuildState): this;
  152237. }
  152238. }
  152239. declare module BABYLON {
  152240. /**
  152241. * Block used to get the length of a vector
  152242. */
  152243. export class LengthBlock extends NodeMaterialBlock {
  152244. /**
  152245. * Creates a new LengthBlock
  152246. * @param name defines the block name
  152247. */
  152248. constructor(name: string);
  152249. /**
  152250. * Gets the current class name
  152251. * @returns the class name
  152252. */
  152253. getClassName(): string;
  152254. /**
  152255. * Gets the value input component
  152256. */
  152257. get value(): NodeMaterialConnectionPoint;
  152258. /**
  152259. * Gets the output component
  152260. */
  152261. get output(): NodeMaterialConnectionPoint;
  152262. protected _buildBlock(state: NodeMaterialBuildState): this;
  152263. }
  152264. }
  152265. declare module BABYLON {
  152266. /**
  152267. * Block used to get negative version of a value (i.e. x * -1)
  152268. */
  152269. export class NegateBlock extends NodeMaterialBlock {
  152270. /**
  152271. * Creates a new NegateBlock
  152272. * @param name defines the block name
  152273. */
  152274. constructor(name: string);
  152275. /**
  152276. * Gets the current class name
  152277. * @returns the class name
  152278. */
  152279. getClassName(): string;
  152280. /**
  152281. * Gets the value input component
  152282. */
  152283. get value(): NodeMaterialConnectionPoint;
  152284. /**
  152285. * Gets the output component
  152286. */
  152287. get output(): NodeMaterialConnectionPoint;
  152288. protected _buildBlock(state: NodeMaterialBuildState): this;
  152289. }
  152290. }
  152291. declare module BABYLON {
  152292. /**
  152293. * Block used to get the value of the first parameter raised to the power of the second
  152294. */
  152295. export class PowBlock extends NodeMaterialBlock {
  152296. /**
  152297. * Creates a new PowBlock
  152298. * @param name defines the block name
  152299. */
  152300. constructor(name: string);
  152301. /**
  152302. * Gets the current class name
  152303. * @returns the class name
  152304. */
  152305. getClassName(): string;
  152306. /**
  152307. * Gets the value operand input component
  152308. */
  152309. get value(): NodeMaterialConnectionPoint;
  152310. /**
  152311. * Gets the power operand input component
  152312. */
  152313. get power(): NodeMaterialConnectionPoint;
  152314. /**
  152315. * Gets the output component
  152316. */
  152317. get output(): NodeMaterialConnectionPoint;
  152318. protected _buildBlock(state: NodeMaterialBuildState): this;
  152319. }
  152320. }
  152321. declare module BABYLON {
  152322. /**
  152323. * Block used to get a random number
  152324. */
  152325. export class RandomNumberBlock extends NodeMaterialBlock {
  152326. /**
  152327. * Creates a new RandomNumberBlock
  152328. * @param name defines the block name
  152329. */
  152330. constructor(name: string);
  152331. /**
  152332. * Gets the current class name
  152333. * @returns the class name
  152334. */
  152335. getClassName(): string;
  152336. /**
  152337. * Gets the seed input component
  152338. */
  152339. get seed(): NodeMaterialConnectionPoint;
  152340. /**
  152341. * Gets the output component
  152342. */
  152343. get output(): NodeMaterialConnectionPoint;
  152344. protected _buildBlock(state: NodeMaterialBuildState): this;
  152345. }
  152346. }
  152347. declare module BABYLON {
  152348. /**
  152349. * Block used to compute arc tangent of 2 values
  152350. */
  152351. export class ArcTan2Block extends NodeMaterialBlock {
  152352. /**
  152353. * Creates a new ArcTan2Block
  152354. * @param name defines the block name
  152355. */
  152356. constructor(name: string);
  152357. /**
  152358. * Gets the current class name
  152359. * @returns the class name
  152360. */
  152361. getClassName(): string;
  152362. /**
  152363. * Gets the x operand input component
  152364. */
  152365. get x(): NodeMaterialConnectionPoint;
  152366. /**
  152367. * Gets the y operand input component
  152368. */
  152369. get y(): NodeMaterialConnectionPoint;
  152370. /**
  152371. * Gets the output component
  152372. */
  152373. get output(): NodeMaterialConnectionPoint;
  152374. protected _buildBlock(state: NodeMaterialBuildState): this;
  152375. }
  152376. }
  152377. declare module BABYLON {
  152378. /**
  152379. * Block used to smooth step a value
  152380. */
  152381. export class SmoothStepBlock extends NodeMaterialBlock {
  152382. /**
  152383. * Creates a new SmoothStepBlock
  152384. * @param name defines the block name
  152385. */
  152386. constructor(name: string);
  152387. /**
  152388. * Gets the current class name
  152389. * @returns the class name
  152390. */
  152391. getClassName(): string;
  152392. /**
  152393. * Gets the value operand input component
  152394. */
  152395. get value(): NodeMaterialConnectionPoint;
  152396. /**
  152397. * Gets the first edge operand input component
  152398. */
  152399. get edge0(): NodeMaterialConnectionPoint;
  152400. /**
  152401. * Gets the second edge operand input component
  152402. */
  152403. get edge1(): NodeMaterialConnectionPoint;
  152404. /**
  152405. * Gets the output component
  152406. */
  152407. get output(): NodeMaterialConnectionPoint;
  152408. protected _buildBlock(state: NodeMaterialBuildState): this;
  152409. }
  152410. }
  152411. declare module BABYLON {
  152412. /**
  152413. * Block used to get the reciprocal (1 / x) of a value
  152414. */
  152415. export class ReciprocalBlock extends NodeMaterialBlock {
  152416. /**
  152417. * Creates a new ReciprocalBlock
  152418. * @param name defines the block name
  152419. */
  152420. constructor(name: string);
  152421. /**
  152422. * Gets the current class name
  152423. * @returns the class name
  152424. */
  152425. getClassName(): string;
  152426. /**
  152427. * Gets the input component
  152428. */
  152429. get input(): NodeMaterialConnectionPoint;
  152430. /**
  152431. * Gets the output component
  152432. */
  152433. get output(): NodeMaterialConnectionPoint;
  152434. protected _buildBlock(state: NodeMaterialBuildState): this;
  152435. }
  152436. }
  152437. declare module BABYLON {
  152438. /**
  152439. * Block used to replace a color by another one
  152440. */
  152441. export class ReplaceColorBlock extends NodeMaterialBlock {
  152442. /**
  152443. * Creates a new ReplaceColorBlock
  152444. * @param name defines the block name
  152445. */
  152446. constructor(name: string);
  152447. /**
  152448. * Gets the current class name
  152449. * @returns the class name
  152450. */
  152451. getClassName(): string;
  152452. /**
  152453. * Gets the value input component
  152454. */
  152455. get value(): NodeMaterialConnectionPoint;
  152456. /**
  152457. * Gets the reference input component
  152458. */
  152459. get reference(): NodeMaterialConnectionPoint;
  152460. /**
  152461. * Gets the distance input component
  152462. */
  152463. get distance(): NodeMaterialConnectionPoint;
  152464. /**
  152465. * Gets the replacement input component
  152466. */
  152467. get replacement(): NodeMaterialConnectionPoint;
  152468. /**
  152469. * Gets the output component
  152470. */
  152471. get output(): NodeMaterialConnectionPoint;
  152472. protected _buildBlock(state: NodeMaterialBuildState): this;
  152473. }
  152474. }
  152475. declare module BABYLON {
  152476. /**
  152477. * Block used to posterize a value
  152478. * @see https://en.wikipedia.org/wiki/Posterization
  152479. */
  152480. export class PosterizeBlock extends NodeMaterialBlock {
  152481. /**
  152482. * Creates a new PosterizeBlock
  152483. * @param name defines the block name
  152484. */
  152485. constructor(name: string);
  152486. /**
  152487. * Gets the current class name
  152488. * @returns the class name
  152489. */
  152490. getClassName(): string;
  152491. /**
  152492. * Gets the value input component
  152493. */
  152494. get value(): NodeMaterialConnectionPoint;
  152495. /**
  152496. * Gets the steps input component
  152497. */
  152498. get steps(): NodeMaterialConnectionPoint;
  152499. /**
  152500. * Gets the output component
  152501. */
  152502. get output(): NodeMaterialConnectionPoint;
  152503. protected _buildBlock(state: NodeMaterialBuildState): this;
  152504. }
  152505. }
  152506. declare module BABYLON {
  152507. /**
  152508. * Operations supported by the Wave block
  152509. */
  152510. export enum WaveBlockKind {
  152511. /** SawTooth */
  152512. SawTooth = 0,
  152513. /** Square */
  152514. Square = 1,
  152515. /** Triangle */
  152516. Triangle = 2
  152517. }
  152518. /**
  152519. * Block used to apply wave operation to floats
  152520. */
  152521. export class WaveBlock extends NodeMaterialBlock {
  152522. /**
  152523. * Gets or sets the kibnd of wave to be applied by the block
  152524. */
  152525. kind: WaveBlockKind;
  152526. /**
  152527. * Creates a new WaveBlock
  152528. * @param name defines the block name
  152529. */
  152530. constructor(name: string);
  152531. /**
  152532. * Gets the current class name
  152533. * @returns the class name
  152534. */
  152535. getClassName(): string;
  152536. /**
  152537. * Gets the input component
  152538. */
  152539. get input(): NodeMaterialConnectionPoint;
  152540. /**
  152541. * Gets the output component
  152542. */
  152543. get output(): NodeMaterialConnectionPoint;
  152544. protected _buildBlock(state: NodeMaterialBuildState): this;
  152545. serialize(): any;
  152546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152547. }
  152548. }
  152549. declare module BABYLON {
  152550. /**
  152551. * Class used to store a color step for the GradientBlock
  152552. */
  152553. export class GradientBlockColorStep {
  152554. private _step;
  152555. /**
  152556. * Gets value indicating which step this color is associated with (between 0 and 1)
  152557. */
  152558. get step(): number;
  152559. /**
  152560. * Sets a value indicating which step this color is associated with (between 0 and 1)
  152561. */
  152562. set step(val: number);
  152563. private _color;
  152564. /**
  152565. * Gets the color associated with this step
  152566. */
  152567. get color(): Color3;
  152568. /**
  152569. * Sets the color associated with this step
  152570. */
  152571. set color(val: Color3);
  152572. /**
  152573. * Creates a new GradientBlockColorStep
  152574. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  152575. * @param color defines the color associated with this step
  152576. */
  152577. constructor(step: number, color: Color3);
  152578. }
  152579. /**
  152580. * Block used to return a color from a gradient based on an input value between 0 and 1
  152581. */
  152582. export class GradientBlock extends NodeMaterialBlock {
  152583. /**
  152584. * Gets or sets the list of color steps
  152585. */
  152586. colorSteps: GradientBlockColorStep[];
  152587. /** Gets an observable raised when the value is changed */
  152588. onValueChangedObservable: Observable<GradientBlock>;
  152589. /** calls observable when the value is changed*/
  152590. colorStepsUpdated(): void;
  152591. /**
  152592. * Creates a new GradientBlock
  152593. * @param name defines the block name
  152594. */
  152595. constructor(name: string);
  152596. /**
  152597. * Gets the current class name
  152598. * @returns the class name
  152599. */
  152600. getClassName(): string;
  152601. /**
  152602. * Gets the gradient input component
  152603. */
  152604. get gradient(): NodeMaterialConnectionPoint;
  152605. /**
  152606. * Gets the output component
  152607. */
  152608. get output(): NodeMaterialConnectionPoint;
  152609. private _writeColorConstant;
  152610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152611. serialize(): any;
  152612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152613. protected _dumpPropertiesCode(): string;
  152614. }
  152615. }
  152616. declare module BABYLON {
  152617. /**
  152618. * Block used to normalize lerp between 2 values
  152619. */
  152620. export class NLerpBlock extends NodeMaterialBlock {
  152621. /**
  152622. * Creates a new NLerpBlock
  152623. * @param name defines the block name
  152624. */
  152625. constructor(name: string);
  152626. /**
  152627. * Gets the current class name
  152628. * @returns the class name
  152629. */
  152630. getClassName(): string;
  152631. /**
  152632. * Gets the left operand input component
  152633. */
  152634. get left(): NodeMaterialConnectionPoint;
  152635. /**
  152636. * Gets the right operand input component
  152637. */
  152638. get right(): NodeMaterialConnectionPoint;
  152639. /**
  152640. * Gets the gradient operand input component
  152641. */
  152642. get gradient(): NodeMaterialConnectionPoint;
  152643. /**
  152644. * Gets the output component
  152645. */
  152646. get output(): NodeMaterialConnectionPoint;
  152647. protected _buildBlock(state: NodeMaterialBuildState): this;
  152648. }
  152649. }
  152650. declare module BABYLON {
  152651. /**
  152652. * block used to Generate a Worley Noise 3D Noise Pattern
  152653. */
  152654. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  152655. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  152656. manhattanDistance: boolean;
  152657. /**
  152658. * Creates a new WorleyNoise3DBlock
  152659. * @param name defines the block name
  152660. */
  152661. constructor(name: string);
  152662. /**
  152663. * Gets the current class name
  152664. * @returns the class name
  152665. */
  152666. getClassName(): string;
  152667. /**
  152668. * Gets the seed input component
  152669. */
  152670. get seed(): NodeMaterialConnectionPoint;
  152671. /**
  152672. * Gets the jitter input component
  152673. */
  152674. get jitter(): NodeMaterialConnectionPoint;
  152675. /**
  152676. * Gets the output component
  152677. */
  152678. get output(): NodeMaterialConnectionPoint;
  152679. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152680. /**
  152681. * Exposes the properties to the UI?
  152682. */
  152683. protected _dumpPropertiesCode(): string;
  152684. /**
  152685. * Exposes the properties to the Seralize?
  152686. */
  152687. serialize(): any;
  152688. /**
  152689. * Exposes the properties to the deseralize?
  152690. */
  152691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152692. }
  152693. }
  152694. declare module BABYLON {
  152695. /**
  152696. * block used to Generate a Simplex Perlin 3d Noise Pattern
  152697. */
  152698. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  152699. /**
  152700. * Creates a new SimplexPerlin3DBlock
  152701. * @param name defines the block name
  152702. */
  152703. constructor(name: string);
  152704. /**
  152705. * Gets the current class name
  152706. * @returns the class name
  152707. */
  152708. getClassName(): string;
  152709. /**
  152710. * Gets the seed operand input component
  152711. */
  152712. get seed(): NodeMaterialConnectionPoint;
  152713. /**
  152714. * Gets the output component
  152715. */
  152716. get output(): NodeMaterialConnectionPoint;
  152717. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152718. }
  152719. }
  152720. declare module BABYLON {
  152721. /**
  152722. * Block used to blend normals
  152723. */
  152724. export class NormalBlendBlock extends NodeMaterialBlock {
  152725. /**
  152726. * Creates a new NormalBlendBlock
  152727. * @param name defines the block name
  152728. */
  152729. constructor(name: string);
  152730. /**
  152731. * Gets the current class name
  152732. * @returns the class name
  152733. */
  152734. getClassName(): string;
  152735. /**
  152736. * Gets the first input component
  152737. */
  152738. get normalMap0(): NodeMaterialConnectionPoint;
  152739. /**
  152740. * Gets the second input component
  152741. */
  152742. get normalMap1(): NodeMaterialConnectionPoint;
  152743. /**
  152744. * Gets the output component
  152745. */
  152746. get output(): NodeMaterialConnectionPoint;
  152747. protected _buildBlock(state: NodeMaterialBuildState): this;
  152748. }
  152749. }
  152750. declare module BABYLON {
  152751. /**
  152752. * Block used to rotate a 2d vector by a given angle
  152753. */
  152754. export class Rotate2dBlock extends NodeMaterialBlock {
  152755. /**
  152756. * Creates a new Rotate2dBlock
  152757. * @param name defines the block name
  152758. */
  152759. constructor(name: string);
  152760. /**
  152761. * Gets the current class name
  152762. * @returns the class name
  152763. */
  152764. getClassName(): string;
  152765. /**
  152766. * Gets the input vector
  152767. */
  152768. get input(): NodeMaterialConnectionPoint;
  152769. /**
  152770. * Gets the input angle
  152771. */
  152772. get angle(): NodeMaterialConnectionPoint;
  152773. /**
  152774. * Gets the output component
  152775. */
  152776. get output(): NodeMaterialConnectionPoint;
  152777. autoConfigure(material: NodeMaterial): void;
  152778. protected _buildBlock(state: NodeMaterialBuildState): this;
  152779. }
  152780. }
  152781. declare module BABYLON {
  152782. /**
  152783. * Block used to get the reflected vector from a direction and a normal
  152784. */
  152785. export class ReflectBlock extends NodeMaterialBlock {
  152786. /**
  152787. * Creates a new ReflectBlock
  152788. * @param name defines the block name
  152789. */
  152790. constructor(name: string);
  152791. /**
  152792. * Gets the current class name
  152793. * @returns the class name
  152794. */
  152795. getClassName(): string;
  152796. /**
  152797. * Gets the incident component
  152798. */
  152799. get incident(): NodeMaterialConnectionPoint;
  152800. /**
  152801. * Gets the normal component
  152802. */
  152803. get normal(): NodeMaterialConnectionPoint;
  152804. /**
  152805. * Gets the output component
  152806. */
  152807. get output(): NodeMaterialConnectionPoint;
  152808. protected _buildBlock(state: NodeMaterialBuildState): this;
  152809. }
  152810. }
  152811. declare module BABYLON {
  152812. /**
  152813. * Block used to get the refracted vector from a direction and a normal
  152814. */
  152815. export class RefractBlock extends NodeMaterialBlock {
  152816. /**
  152817. * Creates a new RefractBlock
  152818. * @param name defines the block name
  152819. */
  152820. constructor(name: string);
  152821. /**
  152822. * Gets the current class name
  152823. * @returns the class name
  152824. */
  152825. getClassName(): string;
  152826. /**
  152827. * Gets the incident component
  152828. */
  152829. get incident(): NodeMaterialConnectionPoint;
  152830. /**
  152831. * Gets the normal component
  152832. */
  152833. get normal(): NodeMaterialConnectionPoint;
  152834. /**
  152835. * Gets the index of refraction component
  152836. */
  152837. get ior(): NodeMaterialConnectionPoint;
  152838. /**
  152839. * Gets the output component
  152840. */
  152841. get output(): NodeMaterialConnectionPoint;
  152842. protected _buildBlock(state: NodeMaterialBuildState): this;
  152843. }
  152844. }
  152845. declare module BABYLON {
  152846. /**
  152847. * Block used to desaturate a color
  152848. */
  152849. export class DesaturateBlock extends NodeMaterialBlock {
  152850. /**
  152851. * Creates a new DesaturateBlock
  152852. * @param name defines the block name
  152853. */
  152854. constructor(name: string);
  152855. /**
  152856. * Gets the current class name
  152857. * @returns the class name
  152858. */
  152859. getClassName(): string;
  152860. /**
  152861. * Gets the color operand input component
  152862. */
  152863. get color(): NodeMaterialConnectionPoint;
  152864. /**
  152865. * Gets the level operand input component
  152866. */
  152867. get level(): NodeMaterialConnectionPoint;
  152868. /**
  152869. * Gets the output component
  152870. */
  152871. get output(): NodeMaterialConnectionPoint;
  152872. protected _buildBlock(state: NodeMaterialBuildState): this;
  152873. }
  152874. }
  152875. declare module BABYLON {
  152876. /**
  152877. * Block used to implement the reflection module of the PBR material
  152878. */
  152879. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  152880. /** @hidden */
  152881. _defineLODReflectionAlpha: string;
  152882. /** @hidden */
  152883. _defineLinearSpecularReflection: string;
  152884. private _vEnvironmentIrradianceName;
  152885. /** @hidden */
  152886. _vReflectionMicrosurfaceInfosName: string;
  152887. /** @hidden */
  152888. _vReflectionInfosName: string;
  152889. /** @hidden */
  152890. _vReflectionFilteringInfoName: string;
  152891. private _scene;
  152892. /**
  152893. * The properties below are set by the main PBR block prior to calling methods of this class.
  152894. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  152895. * It's less burden on the user side in the editor part.
  152896. */
  152897. /** @hidden */
  152898. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  152899. /** @hidden */
  152900. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  152901. /** @hidden */
  152902. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  152903. /** @hidden */
  152904. viewConnectionPoint: NodeMaterialConnectionPoint;
  152905. /**
  152906. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  152907. * diffuse part of the IBL.
  152908. */
  152909. useSphericalHarmonics: boolean;
  152910. /**
  152911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  152912. */
  152913. forceIrradianceInFragment: boolean;
  152914. /**
  152915. * Create a new ReflectionBlock
  152916. * @param name defines the block name
  152917. */
  152918. constructor(name: string);
  152919. /**
  152920. * Gets the current class name
  152921. * @returns the class name
  152922. */
  152923. getClassName(): string;
  152924. /**
  152925. * Gets the position input component
  152926. */
  152927. get position(): NodeMaterialConnectionPoint;
  152928. /**
  152929. * Gets the world position input component
  152930. */
  152931. get worldPosition(): NodeMaterialConnectionPoint;
  152932. /**
  152933. * Gets the world normal input component
  152934. */
  152935. get worldNormal(): NodeMaterialConnectionPoint;
  152936. /**
  152937. * Gets the world input component
  152938. */
  152939. get world(): NodeMaterialConnectionPoint;
  152940. /**
  152941. * Gets the camera (or eye) position component
  152942. */
  152943. get cameraPosition(): NodeMaterialConnectionPoint;
  152944. /**
  152945. * Gets the view input component
  152946. */
  152947. get view(): NodeMaterialConnectionPoint;
  152948. /**
  152949. * Gets the color input component
  152950. */
  152951. get color(): NodeMaterialConnectionPoint;
  152952. /**
  152953. * Gets the reflection object output component
  152954. */
  152955. get reflection(): NodeMaterialConnectionPoint;
  152956. /**
  152957. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  152958. */
  152959. get hasTexture(): boolean;
  152960. /**
  152961. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  152962. */
  152963. get reflectionColor(): string;
  152964. protected _getTexture(): Nullable<BaseTexture>;
  152965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  152967. /**
  152968. * Gets the code to inject in the vertex shader
  152969. * @param state current state of the node material building
  152970. * @returns the shader code
  152971. */
  152972. handleVertexSide(state: NodeMaterialBuildState): string;
  152973. /**
  152974. * Gets the main code of the block (fragment side)
  152975. * @param state current state of the node material building
  152976. * @param normalVarName name of the existing variable corresponding to the normal
  152977. * @returns the shader code
  152978. */
  152979. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  152980. protected _buildBlock(state: NodeMaterialBuildState): this;
  152981. protected _dumpPropertiesCode(): string;
  152982. serialize(): any;
  152983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152984. }
  152985. }
  152986. declare module BABYLON {
  152987. /**
  152988. * Block used to implement the sheen module of the PBR material
  152989. */
  152990. export class SheenBlock extends NodeMaterialBlock {
  152991. /**
  152992. * Create a new SheenBlock
  152993. * @param name defines the block name
  152994. */
  152995. constructor(name: string);
  152996. /**
  152997. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  152998. * It allows the strength of the sheen effect to not depend on the base color of the material,
  152999. * making it easier to setup and tweak the effect
  153000. */
  153001. albedoScaling: boolean;
  153002. /**
  153003. * Defines if the sheen is linked to the sheen color.
  153004. */
  153005. linkSheenWithAlbedo: boolean;
  153006. /**
  153007. * Initialize the block and prepare the context for build
  153008. * @param state defines the state that will be used for the build
  153009. */
  153010. initialize(state: NodeMaterialBuildState): void;
  153011. /**
  153012. * Gets the current class name
  153013. * @returns the class name
  153014. */
  153015. getClassName(): string;
  153016. /**
  153017. * Gets the intensity input component
  153018. */
  153019. get intensity(): NodeMaterialConnectionPoint;
  153020. /**
  153021. * Gets the color input component
  153022. */
  153023. get color(): NodeMaterialConnectionPoint;
  153024. /**
  153025. * Gets the roughness input component
  153026. */
  153027. get roughness(): NodeMaterialConnectionPoint;
  153028. /**
  153029. * Gets the sheen object output component
  153030. */
  153031. get sheen(): NodeMaterialConnectionPoint;
  153032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153033. /**
  153034. * Gets the main code of the block (fragment side)
  153035. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153036. * @returns the shader code
  153037. */
  153038. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  153039. protected _buildBlock(state: NodeMaterialBuildState): this;
  153040. protected _dumpPropertiesCode(): string;
  153041. serialize(): any;
  153042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153043. }
  153044. }
  153045. declare module BABYLON {
  153046. /**
  153047. * Block used to implement the anisotropy module of the PBR material
  153048. */
  153049. export class AnisotropyBlock extends NodeMaterialBlock {
  153050. /**
  153051. * The two properties below are set by the main PBR block prior to calling methods of this class.
  153052. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  153053. * It's less burden on the user side in the editor part.
  153054. */
  153055. /** @hidden */
  153056. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  153057. /** @hidden */
  153058. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  153059. /**
  153060. * Create a new AnisotropyBlock
  153061. * @param name defines the block name
  153062. */
  153063. constructor(name: string);
  153064. /**
  153065. * Initialize the block and prepare the context for build
  153066. * @param state defines the state that will be used for the build
  153067. */
  153068. initialize(state: NodeMaterialBuildState): void;
  153069. /**
  153070. * Gets the current class name
  153071. * @returns the class name
  153072. */
  153073. getClassName(): string;
  153074. /**
  153075. * Gets the intensity input component
  153076. */
  153077. get intensity(): NodeMaterialConnectionPoint;
  153078. /**
  153079. * Gets the direction input component
  153080. */
  153081. get direction(): NodeMaterialConnectionPoint;
  153082. /**
  153083. * Gets the uv input component
  153084. */
  153085. get uv(): NodeMaterialConnectionPoint;
  153086. /**
  153087. * Gets the worldTangent input component
  153088. */
  153089. get worldTangent(): NodeMaterialConnectionPoint;
  153090. /**
  153091. * Gets the anisotropy object output component
  153092. */
  153093. get anisotropy(): NodeMaterialConnectionPoint;
  153094. private _generateTBNSpace;
  153095. /**
  153096. * Gets the main code of the block (fragment side)
  153097. * @param state current state of the node material building
  153098. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  153099. * @returns the shader code
  153100. */
  153101. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  153102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153103. protected _buildBlock(state: NodeMaterialBuildState): this;
  153104. }
  153105. }
  153106. declare module BABYLON {
  153107. /**
  153108. * Block used to implement the clear coat module of the PBR material
  153109. */
  153110. export class ClearCoatBlock extends NodeMaterialBlock {
  153111. private _scene;
  153112. /**
  153113. * Create a new ClearCoatBlock
  153114. * @param name defines the block name
  153115. */
  153116. constructor(name: string);
  153117. /**
  153118. * Defines if the F0 value should be remapped to account for the interface change in the material.
  153119. */
  153120. remapF0OnInterfaceChange: boolean;
  153121. /**
  153122. * Initialize the block and prepare the context for build
  153123. * @param state defines the state that will be used for the build
  153124. */
  153125. initialize(state: NodeMaterialBuildState): void;
  153126. /**
  153127. * Gets the current class name
  153128. * @returns the class name
  153129. */
  153130. getClassName(): string;
  153131. /**
  153132. * Gets the intensity input component
  153133. */
  153134. get intensity(): NodeMaterialConnectionPoint;
  153135. /**
  153136. * Gets the roughness input component
  153137. */
  153138. get roughness(): NodeMaterialConnectionPoint;
  153139. /**
  153140. * Gets the ior input component
  153141. */
  153142. get indexOfRefraction(): NodeMaterialConnectionPoint;
  153143. /**
  153144. * Gets the bump texture input component
  153145. */
  153146. get normalMapColor(): NodeMaterialConnectionPoint;
  153147. /**
  153148. * Gets the uv input component
  153149. */
  153150. get uv(): NodeMaterialConnectionPoint;
  153151. /**
  153152. * Gets the tint color input component
  153153. */
  153154. get tintColor(): NodeMaterialConnectionPoint;
  153155. /**
  153156. * Gets the tint "at distance" input component
  153157. */
  153158. get tintAtDistance(): NodeMaterialConnectionPoint;
  153159. /**
  153160. * Gets the tint thickness input component
  153161. */
  153162. get tintThickness(): NodeMaterialConnectionPoint;
  153163. /**
  153164. * Gets the world tangent input component
  153165. */
  153166. get worldTangent(): NodeMaterialConnectionPoint;
  153167. /**
  153168. * Gets the clear coat object output component
  153169. */
  153170. get clearcoat(): NodeMaterialConnectionPoint;
  153171. autoConfigure(material: NodeMaterial): void;
  153172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153173. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  153174. private _generateTBNSpace;
  153175. /**
  153176. * Gets the main code of the block (fragment side)
  153177. * @param state current state of the node material building
  153178. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  153179. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153180. * @param worldPosVarName name of the variable holding the world position
  153181. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  153182. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  153183. * @param worldNormalVarName name of the variable holding the world normal
  153184. * @returns the shader code
  153185. */
  153186. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  153187. protected _buildBlock(state: NodeMaterialBuildState): this;
  153188. protected _dumpPropertiesCode(): string;
  153189. serialize(): any;
  153190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153191. }
  153192. }
  153193. declare module BABYLON {
  153194. /**
  153195. * Block used to implement the sub surface module of the PBR material
  153196. */
  153197. export class SubSurfaceBlock extends NodeMaterialBlock {
  153198. /**
  153199. * Create a new SubSurfaceBlock
  153200. * @param name defines the block name
  153201. */
  153202. constructor(name: string);
  153203. /**
  153204. * Initialize the block and prepare the context for build
  153205. * @param state defines the state that will be used for the build
  153206. */
  153207. initialize(state: NodeMaterialBuildState): void;
  153208. /**
  153209. * Gets the current class name
  153210. * @returns the class name
  153211. */
  153212. getClassName(): string;
  153213. /**
  153214. * Gets the thickness component
  153215. */
  153216. get thickness(): NodeMaterialConnectionPoint;
  153217. /**
  153218. * Gets the tint color input component
  153219. */
  153220. get tintColor(): NodeMaterialConnectionPoint;
  153221. /**
  153222. * Gets the translucency intensity input component
  153223. */
  153224. get translucencyIntensity(): NodeMaterialConnectionPoint;
  153225. /**
  153226. * Gets the translucency diffusion distance input component
  153227. */
  153228. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  153229. /**
  153230. * Gets the refraction object parameters
  153231. */
  153232. get refraction(): NodeMaterialConnectionPoint;
  153233. /**
  153234. * Gets the sub surface object output component
  153235. */
  153236. get subsurface(): NodeMaterialConnectionPoint;
  153237. autoConfigure(material: NodeMaterial): void;
  153238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153239. /**
  153240. * Gets the main code of the block (fragment side)
  153241. * @param state current state of the node material building
  153242. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  153243. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153244. * @param worldPosVarName name of the variable holding the world position
  153245. * @returns the shader code
  153246. */
  153247. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  153248. protected _buildBlock(state: NodeMaterialBuildState): this;
  153249. }
  153250. }
  153251. declare module BABYLON {
  153252. /**
  153253. * Block used to implement the PBR metallic/roughness model
  153254. */
  153255. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  153256. /**
  153257. * Gets or sets the light associated with this block
  153258. */
  153259. light: Nullable<Light>;
  153260. private _lightId;
  153261. private _scene;
  153262. private _environmentBRDFTexture;
  153263. private _environmentBrdfSamplerName;
  153264. private _vNormalWName;
  153265. private _invertNormalName;
  153266. private _metallicReflectanceColor;
  153267. private _metallicF0Factor;
  153268. private _vMetallicReflectanceFactorsName;
  153269. /**
  153270. * Create a new ReflectionBlock
  153271. * @param name defines the block name
  153272. */
  153273. constructor(name: string);
  153274. /**
  153275. * Intensity of the direct lights e.g. the four lights available in your scene.
  153276. * This impacts both the direct diffuse and specular highlights.
  153277. */
  153278. directIntensity: number;
  153279. /**
  153280. * Intensity of the environment e.g. how much the environment will light the object
  153281. * either through harmonics for rough material or through the refelction for shiny ones.
  153282. */
  153283. environmentIntensity: number;
  153284. /**
  153285. * This is a special control allowing the reduction of the specular highlights coming from the
  153286. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  153287. */
  153288. specularIntensity: number;
  153289. /**
  153290. * Defines the falloff type used in this material.
  153291. * It by default is Physical.
  153292. */
  153293. lightFalloff: number;
  153294. /**
  153295. * Specifies that alpha test should be used
  153296. */
  153297. useAlphaTest: boolean;
  153298. /**
  153299. * Defines the alpha limits in alpha test mode.
  153300. */
  153301. alphaTestCutoff: number;
  153302. /**
  153303. * Specifies that alpha blending should be used
  153304. */
  153305. useAlphaBlending: boolean;
  153306. /**
  153307. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  153308. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  153309. */
  153310. useRadianceOverAlpha: boolean;
  153311. /**
  153312. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  153313. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  153314. */
  153315. useSpecularOverAlpha: boolean;
  153316. /**
  153317. * Enables specular anti aliasing in the PBR shader.
  153318. * It will both interacts on the Geometry for analytical and IBL lighting.
  153319. * It also prefilter the roughness map based on the bump values.
  153320. */
  153321. enableSpecularAntiAliasing: boolean;
  153322. /**
  153323. * Enables realtime filtering on the texture.
  153324. */
  153325. realTimeFiltering: boolean;
  153326. /**
  153327. * Quality switch for realtime filtering
  153328. */
  153329. realTimeFilteringQuality: number;
  153330. /**
  153331. * Defines if the material uses energy conservation.
  153332. */
  153333. useEnergyConservation: boolean;
  153334. /**
  153335. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  153336. * too much the area relying on ambient texture to define their ambient occlusion.
  153337. */
  153338. useRadianceOcclusion: boolean;
  153339. /**
  153340. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  153341. * makes the reflect vector face the model (under horizon).
  153342. */
  153343. useHorizonOcclusion: boolean;
  153344. /**
  153345. * If set to true, no lighting calculations will be applied.
  153346. */
  153347. unlit: boolean;
  153348. /**
  153349. * Force normal to face away from face.
  153350. */
  153351. forceNormalForward: boolean;
  153352. /**
  153353. * Defines the material debug mode.
  153354. * It helps seeing only some components of the material while troubleshooting.
  153355. */
  153356. debugMode: number;
  153357. /**
  153358. * Specify from where on screen the debug mode should start.
  153359. * The value goes from -1 (full screen) to 1 (not visible)
  153360. * It helps with side by side comparison against the final render
  153361. * This defaults to 0
  153362. */
  153363. debugLimit: number;
  153364. /**
  153365. * As the default viewing range might not be enough (if the ambient is really small for instance)
  153366. * You can use the factor to better multiply the final value.
  153367. */
  153368. debugFactor: number;
  153369. /**
  153370. * Initialize the block and prepare the context for build
  153371. * @param state defines the state that will be used for the build
  153372. */
  153373. initialize(state: NodeMaterialBuildState): void;
  153374. /**
  153375. * Gets the current class name
  153376. * @returns the class name
  153377. */
  153378. getClassName(): string;
  153379. /**
  153380. * Gets the world position input component
  153381. */
  153382. get worldPosition(): NodeMaterialConnectionPoint;
  153383. /**
  153384. * Gets the world normal input component
  153385. */
  153386. get worldNormal(): NodeMaterialConnectionPoint;
  153387. /**
  153388. * Gets the view matrix parameter
  153389. */
  153390. get view(): NodeMaterialConnectionPoint;
  153391. /**
  153392. * Gets the camera position input component
  153393. */
  153394. get cameraPosition(): NodeMaterialConnectionPoint;
  153395. /**
  153396. * Gets the perturbed normal input component
  153397. */
  153398. get perturbedNormal(): NodeMaterialConnectionPoint;
  153399. /**
  153400. * Gets the base color input component
  153401. */
  153402. get baseColor(): NodeMaterialConnectionPoint;
  153403. /**
  153404. * Gets the metallic input component
  153405. */
  153406. get metallic(): NodeMaterialConnectionPoint;
  153407. /**
  153408. * Gets the roughness input component
  153409. */
  153410. get roughness(): NodeMaterialConnectionPoint;
  153411. /**
  153412. * Gets the ambient occlusion input component
  153413. */
  153414. get ambientOcc(): NodeMaterialConnectionPoint;
  153415. /**
  153416. * Gets the opacity input component
  153417. */
  153418. get opacity(): NodeMaterialConnectionPoint;
  153419. /**
  153420. * Gets the index of refraction input component
  153421. */
  153422. get indexOfRefraction(): NodeMaterialConnectionPoint;
  153423. /**
  153424. * Gets the ambient color input component
  153425. */
  153426. get ambientColor(): NodeMaterialConnectionPoint;
  153427. /**
  153428. * Gets the reflection object parameters
  153429. */
  153430. get reflection(): NodeMaterialConnectionPoint;
  153431. /**
  153432. * Gets the clear coat object parameters
  153433. */
  153434. get clearcoat(): NodeMaterialConnectionPoint;
  153435. /**
  153436. * Gets the sheen object parameters
  153437. */
  153438. get sheen(): NodeMaterialConnectionPoint;
  153439. /**
  153440. * Gets the sub surface object parameters
  153441. */
  153442. get subsurface(): NodeMaterialConnectionPoint;
  153443. /**
  153444. * Gets the anisotropy object parameters
  153445. */
  153446. get anisotropy(): NodeMaterialConnectionPoint;
  153447. /**
  153448. * Gets the ambient output component
  153449. */
  153450. get ambientClr(): NodeMaterialConnectionPoint;
  153451. /**
  153452. * Gets the diffuse output component
  153453. */
  153454. get diffuseDir(): NodeMaterialConnectionPoint;
  153455. /**
  153456. * Gets the specular output component
  153457. */
  153458. get specularDir(): NodeMaterialConnectionPoint;
  153459. /**
  153460. * Gets the clear coat output component
  153461. */
  153462. get clearcoatDir(): NodeMaterialConnectionPoint;
  153463. /**
  153464. * Gets the sheen output component
  153465. */
  153466. get sheenDir(): NodeMaterialConnectionPoint;
  153467. /**
  153468. * Gets the indirect diffuse output component
  153469. */
  153470. get diffuseIndirect(): NodeMaterialConnectionPoint;
  153471. /**
  153472. * Gets the indirect specular output component
  153473. */
  153474. get specularIndirect(): NodeMaterialConnectionPoint;
  153475. /**
  153476. * Gets the indirect clear coat output component
  153477. */
  153478. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  153479. /**
  153480. * Gets the indirect sheen output component
  153481. */
  153482. get sheenIndirect(): NodeMaterialConnectionPoint;
  153483. /**
  153484. * Gets the refraction output component
  153485. */
  153486. get refraction(): NodeMaterialConnectionPoint;
  153487. /**
  153488. * Gets the global lighting output component
  153489. */
  153490. get lighting(): NodeMaterialConnectionPoint;
  153491. /**
  153492. * Gets the shadow output component
  153493. */
  153494. get shadow(): NodeMaterialConnectionPoint;
  153495. /**
  153496. * Gets the alpha output component
  153497. */
  153498. get alpha(): NodeMaterialConnectionPoint;
  153499. autoConfigure(material: NodeMaterial): void;
  153500. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153501. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  153502. isReady(): boolean;
  153503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153504. private _injectVertexCode;
  153505. private _getAlbedoOpacityCode;
  153506. private _getAmbientOcclusionCode;
  153507. private _getReflectivityCode;
  153508. protected _buildBlock(state: NodeMaterialBuildState): this;
  153509. protected _dumpPropertiesCode(): string;
  153510. serialize(): any;
  153511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153512. }
  153513. }
  153514. declare module BABYLON {
  153515. /**
  153516. * Block used to compute value of one parameter modulo another
  153517. */
  153518. export class ModBlock extends NodeMaterialBlock {
  153519. /**
  153520. * Creates a new ModBlock
  153521. * @param name defines the block name
  153522. */
  153523. constructor(name: string);
  153524. /**
  153525. * Gets the current class name
  153526. * @returns the class name
  153527. */
  153528. getClassName(): string;
  153529. /**
  153530. * Gets the left operand input component
  153531. */
  153532. get left(): NodeMaterialConnectionPoint;
  153533. /**
  153534. * Gets the right operand input component
  153535. */
  153536. get right(): NodeMaterialConnectionPoint;
  153537. /**
  153538. * Gets the output component
  153539. */
  153540. get output(): NodeMaterialConnectionPoint;
  153541. protected _buildBlock(state: NodeMaterialBuildState): this;
  153542. }
  153543. }
  153544. declare module BABYLON {
  153545. /**
  153546. * Configuration for Draco compression
  153547. */
  153548. export interface IDracoCompressionConfiguration {
  153549. /**
  153550. * Configuration for the decoder.
  153551. */
  153552. decoder: {
  153553. /**
  153554. * The url to the WebAssembly module.
  153555. */
  153556. wasmUrl?: string;
  153557. /**
  153558. * The url to the WebAssembly binary.
  153559. */
  153560. wasmBinaryUrl?: string;
  153561. /**
  153562. * The url to the fallback JavaScript module.
  153563. */
  153564. fallbackUrl?: string;
  153565. };
  153566. }
  153567. /**
  153568. * Draco compression (https://google.github.io/draco/)
  153569. *
  153570. * This class wraps the Draco module.
  153571. *
  153572. * **Encoder**
  153573. *
  153574. * The encoder is not currently implemented.
  153575. *
  153576. * **Decoder**
  153577. *
  153578. * 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.
  153579. *
  153580. * To update the configuration, use the following code:
  153581. * ```javascript
  153582. * DracoCompression.Configuration = {
  153583. * decoder: {
  153584. * wasmUrl: "<url to the WebAssembly library>",
  153585. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  153586. * fallbackUrl: "<url to the fallback JavaScript library>",
  153587. * }
  153588. * };
  153589. * ```
  153590. *
  153591. * 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.
  153592. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  153593. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  153594. *
  153595. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  153596. * ```javascript
  153597. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  153598. * ```
  153599. *
  153600. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  153601. */
  153602. export class DracoCompression implements IDisposable {
  153603. private _workerPoolPromise?;
  153604. private _decoderModulePromise?;
  153605. /**
  153606. * The configuration. Defaults to the following urls:
  153607. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  153608. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  153609. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  153610. */
  153611. static Configuration: IDracoCompressionConfiguration;
  153612. /**
  153613. * Returns true if the decoder configuration is available.
  153614. */
  153615. static get DecoderAvailable(): boolean;
  153616. /**
  153617. * Default number of workers to create when creating the draco compression object.
  153618. */
  153619. static DefaultNumWorkers: number;
  153620. private static GetDefaultNumWorkers;
  153621. private static _Default;
  153622. /**
  153623. * Default instance for the draco compression object.
  153624. */
  153625. static get Default(): DracoCompression;
  153626. /**
  153627. * Constructor
  153628. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  153629. */
  153630. constructor(numWorkers?: number);
  153631. /**
  153632. * Stop all async operations and release resources.
  153633. */
  153634. dispose(): void;
  153635. /**
  153636. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  153637. * @returns a promise that resolves when ready
  153638. */
  153639. whenReadyAsync(): Promise<void>;
  153640. /**
  153641. * Decode Draco compressed mesh data to vertex data.
  153642. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  153643. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  153644. * @returns A promise that resolves with the decoded vertex data
  153645. */
  153646. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  153647. [kind: string]: number;
  153648. }): Promise<VertexData>;
  153649. }
  153650. }
  153651. declare module BABYLON {
  153652. /**
  153653. * Class for building Constructive Solid Geometry
  153654. */
  153655. export class CSG {
  153656. private polygons;
  153657. /**
  153658. * The world matrix
  153659. */
  153660. matrix: Matrix;
  153661. /**
  153662. * Stores the position
  153663. */
  153664. position: Vector3;
  153665. /**
  153666. * Stores the rotation
  153667. */
  153668. rotation: Vector3;
  153669. /**
  153670. * Stores the rotation quaternion
  153671. */
  153672. rotationQuaternion: Nullable<Quaternion>;
  153673. /**
  153674. * Stores the scaling vector
  153675. */
  153676. scaling: Vector3;
  153677. /**
  153678. * Convert the Mesh to CSG
  153679. * @param mesh The Mesh to convert to CSG
  153680. * @returns A new CSG from the Mesh
  153681. */
  153682. static FromMesh(mesh: Mesh): CSG;
  153683. /**
  153684. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  153685. * @param polygons Polygons used to construct a CSG solid
  153686. */
  153687. private static FromPolygons;
  153688. /**
  153689. * Clones, or makes a deep copy, of the CSG
  153690. * @returns A new CSG
  153691. */
  153692. clone(): CSG;
  153693. /**
  153694. * Unions this CSG with another CSG
  153695. * @param csg The CSG to union against this CSG
  153696. * @returns The unioned CSG
  153697. */
  153698. union(csg: CSG): CSG;
  153699. /**
  153700. * Unions this CSG with another CSG in place
  153701. * @param csg The CSG to union against this CSG
  153702. */
  153703. unionInPlace(csg: CSG): void;
  153704. /**
  153705. * Subtracts this CSG with another CSG
  153706. * @param csg The CSG to subtract against this CSG
  153707. * @returns A new CSG
  153708. */
  153709. subtract(csg: CSG): CSG;
  153710. /**
  153711. * Subtracts this CSG with another CSG in place
  153712. * @param csg The CSG to subtact against this CSG
  153713. */
  153714. subtractInPlace(csg: CSG): void;
  153715. /**
  153716. * Intersect this CSG with another CSG
  153717. * @param csg The CSG to intersect against this CSG
  153718. * @returns A new CSG
  153719. */
  153720. intersect(csg: CSG): CSG;
  153721. /**
  153722. * Intersects this CSG with another CSG in place
  153723. * @param csg The CSG to intersect against this CSG
  153724. */
  153725. intersectInPlace(csg: CSG): void;
  153726. /**
  153727. * Return a new CSG solid with solid and empty space switched. This solid is
  153728. * not modified.
  153729. * @returns A new CSG solid with solid and empty space switched
  153730. */
  153731. inverse(): CSG;
  153732. /**
  153733. * Inverses the CSG in place
  153734. */
  153735. inverseInPlace(): void;
  153736. /**
  153737. * This is used to keep meshes transformations so they can be restored
  153738. * when we build back a Babylon Mesh
  153739. * NB : All CSG operations are performed in world coordinates
  153740. * @param csg The CSG to copy the transform attributes from
  153741. * @returns This CSG
  153742. */
  153743. copyTransformAttributes(csg: CSG): CSG;
  153744. /**
  153745. * Build Raw mesh from CSG
  153746. * Coordinates here are in world space
  153747. * @param name The name of the mesh geometry
  153748. * @param scene The Scene
  153749. * @param keepSubMeshes Specifies if the submeshes should be kept
  153750. * @returns A new Mesh
  153751. */
  153752. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  153753. /**
  153754. * Build Mesh from CSG taking material and transforms into account
  153755. * @param name The name of the Mesh
  153756. * @param material The material of the Mesh
  153757. * @param scene The Scene
  153758. * @param keepSubMeshes Specifies if submeshes should be kept
  153759. * @returns The new Mesh
  153760. */
  153761. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  153762. }
  153763. }
  153764. declare module BABYLON {
  153765. /**
  153766. * Class used to create a trail following a mesh
  153767. */
  153768. export class TrailMesh extends Mesh {
  153769. private _generator;
  153770. private _autoStart;
  153771. private _running;
  153772. private _diameter;
  153773. private _length;
  153774. private _sectionPolygonPointsCount;
  153775. private _sectionVectors;
  153776. private _sectionNormalVectors;
  153777. private _beforeRenderObserver;
  153778. /**
  153779. * @constructor
  153780. * @param name The value used by scene.getMeshByName() to do a lookup.
  153781. * @param generator The mesh or transform node to generate a trail.
  153782. * @param scene The scene to add this mesh to.
  153783. * @param diameter Diameter of trailing mesh. Default is 1.
  153784. * @param length Length of trailing mesh. Default is 60.
  153785. * @param autoStart Automatically start trailing mesh. Default true.
  153786. */
  153787. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  153788. /**
  153789. * "TrailMesh"
  153790. * @returns "TrailMesh"
  153791. */
  153792. getClassName(): string;
  153793. private _createMesh;
  153794. /**
  153795. * Start trailing mesh.
  153796. */
  153797. start(): void;
  153798. /**
  153799. * Stop trailing mesh.
  153800. */
  153801. stop(): void;
  153802. /**
  153803. * Update trailing mesh geometry.
  153804. */
  153805. update(): void;
  153806. /**
  153807. * Returns a new TrailMesh object.
  153808. * @param name is a string, the name given to the new mesh
  153809. * @param newGenerator use new generator object for cloned trail mesh
  153810. * @returns a new mesh
  153811. */
  153812. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  153813. /**
  153814. * Serializes this trail mesh
  153815. * @param serializationObject object to write serialization to
  153816. */
  153817. serialize(serializationObject: any): void;
  153818. /**
  153819. * Parses a serialized trail mesh
  153820. * @param parsedMesh the serialized mesh
  153821. * @param scene the scene to create the trail mesh in
  153822. * @returns the created trail mesh
  153823. */
  153824. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  153825. }
  153826. }
  153827. declare module BABYLON {
  153828. /**
  153829. * Class containing static functions to help procedurally build meshes
  153830. */
  153831. export class TiledBoxBuilder {
  153832. /**
  153833. * Creates a box mesh
  153834. * 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)
  153835. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  153836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  153837. * * 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
  153838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  153839. * @param name defines the name of the mesh
  153840. * @param options defines the options used to create the mesh
  153841. * @param scene defines the hosting scene
  153842. * @returns the box mesh
  153843. */
  153844. static CreateTiledBox(name: string, options: {
  153845. pattern?: number;
  153846. width?: number;
  153847. height?: number;
  153848. depth?: number;
  153849. tileSize?: number;
  153850. tileWidth?: number;
  153851. tileHeight?: number;
  153852. alignHorizontal?: number;
  153853. alignVertical?: number;
  153854. faceUV?: Vector4[];
  153855. faceColors?: Color4[];
  153856. sideOrientation?: number;
  153857. updatable?: boolean;
  153858. }, scene?: Nullable<Scene>): Mesh;
  153859. }
  153860. }
  153861. declare module BABYLON {
  153862. /**
  153863. * Class containing static functions to help procedurally build meshes
  153864. */
  153865. export class TorusKnotBuilder {
  153866. /**
  153867. * Creates a torus knot mesh
  153868. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  153869. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  153870. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  153871. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  153872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  153873. * * 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
  153874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  153875. * @param name defines the name of the mesh
  153876. * @param options defines the options used to create the mesh
  153877. * @param scene defines the hosting scene
  153878. * @returns the torus knot mesh
  153879. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  153880. */
  153881. static CreateTorusKnot(name: string, options: {
  153882. radius?: number;
  153883. tube?: number;
  153884. radialSegments?: number;
  153885. tubularSegments?: number;
  153886. p?: number;
  153887. q?: number;
  153888. updatable?: boolean;
  153889. sideOrientation?: number;
  153890. frontUVs?: Vector4;
  153891. backUVs?: Vector4;
  153892. }, scene: any): Mesh;
  153893. }
  153894. }
  153895. declare module BABYLON {
  153896. /**
  153897. * Polygon
  153898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  153899. */
  153900. export class Polygon {
  153901. /**
  153902. * Creates a rectangle
  153903. * @param xmin bottom X coord
  153904. * @param ymin bottom Y coord
  153905. * @param xmax top X coord
  153906. * @param ymax top Y coord
  153907. * @returns points that make the resulting rectation
  153908. */
  153909. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  153910. /**
  153911. * Creates a circle
  153912. * @param radius radius of circle
  153913. * @param cx scale in x
  153914. * @param cy scale in y
  153915. * @param numberOfSides number of sides that make up the circle
  153916. * @returns points that make the resulting circle
  153917. */
  153918. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  153919. /**
  153920. * Creates a polygon from input string
  153921. * @param input Input polygon data
  153922. * @returns the parsed points
  153923. */
  153924. static Parse(input: string): Vector2[];
  153925. /**
  153926. * Starts building a polygon from x and y coordinates
  153927. * @param x x coordinate
  153928. * @param y y coordinate
  153929. * @returns the started path2
  153930. */
  153931. static StartingAt(x: number, y: number): Path2;
  153932. }
  153933. /**
  153934. * Builds a polygon
  153935. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  153936. */
  153937. export class PolygonMeshBuilder {
  153938. private _points;
  153939. private _outlinepoints;
  153940. private _holes;
  153941. private _name;
  153942. private _scene;
  153943. private _epoints;
  153944. private _eholes;
  153945. private _addToepoint;
  153946. /**
  153947. * Babylon reference to the earcut plugin.
  153948. */
  153949. bjsEarcut: any;
  153950. /**
  153951. * Creates a PolygonMeshBuilder
  153952. * @param name name of the builder
  153953. * @param contours Path of the polygon
  153954. * @param scene scene to add to when creating the mesh
  153955. * @param earcutInjection can be used to inject your own earcut reference
  153956. */
  153957. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  153958. /**
  153959. * Adds a whole within the polygon
  153960. * @param hole Array of points defining the hole
  153961. * @returns this
  153962. */
  153963. addHole(hole: Vector2[]): PolygonMeshBuilder;
  153964. /**
  153965. * Creates the polygon
  153966. * @param updatable If the mesh should be updatable
  153967. * @param depth The depth of the mesh created
  153968. * @returns the created mesh
  153969. */
  153970. build(updatable?: boolean, depth?: number): Mesh;
  153971. /**
  153972. * Creates the polygon
  153973. * @param depth The depth of the mesh created
  153974. * @returns the created VertexData
  153975. */
  153976. buildVertexData(depth?: number): VertexData;
  153977. /**
  153978. * Adds a side to the polygon
  153979. * @param positions points that make the polygon
  153980. * @param normals normals of the polygon
  153981. * @param uvs uvs of the polygon
  153982. * @param indices indices of the polygon
  153983. * @param bounds bounds of the polygon
  153984. * @param points points of the polygon
  153985. * @param depth depth of the polygon
  153986. * @param flip flip of the polygon
  153987. */
  153988. private addSide;
  153989. }
  153990. }
  153991. declare module BABYLON {
  153992. /**
  153993. * Class containing static functions to help procedurally build meshes
  153994. */
  153995. export class PolygonBuilder {
  153996. /**
  153997. * Creates a polygon mesh
  153998. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  153999. * * 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
  154000. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154002. * * 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)
  154003. * * Remember you can only change the shape positions, not their number when updating a polygon
  154004. * @param name defines the name of the mesh
  154005. * @param options defines the options used to create the mesh
  154006. * @param scene defines the hosting scene
  154007. * @param earcutInjection can be used to inject your own earcut reference
  154008. * @returns the polygon mesh
  154009. */
  154010. static CreatePolygon(name: string, options: {
  154011. shape: Vector3[];
  154012. holes?: Vector3[][];
  154013. depth?: number;
  154014. faceUV?: Vector4[];
  154015. faceColors?: Color4[];
  154016. updatable?: boolean;
  154017. sideOrientation?: number;
  154018. frontUVs?: Vector4;
  154019. backUVs?: Vector4;
  154020. wrap?: boolean;
  154021. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154022. /**
  154023. * Creates an extruded polygon mesh, with depth in the Y direction.
  154024. * * 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)
  154025. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154026. * @param name defines the name of the mesh
  154027. * @param options defines the options used to create the mesh
  154028. * @param scene defines the hosting scene
  154029. * @param earcutInjection can be used to inject your own earcut reference
  154030. * @returns the polygon mesh
  154031. */
  154032. static ExtrudePolygon(name: string, options: {
  154033. shape: Vector3[];
  154034. holes?: Vector3[][];
  154035. depth?: number;
  154036. faceUV?: Vector4[];
  154037. faceColors?: Color4[];
  154038. updatable?: boolean;
  154039. sideOrientation?: number;
  154040. frontUVs?: Vector4;
  154041. backUVs?: Vector4;
  154042. wrap?: boolean;
  154043. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154044. }
  154045. }
  154046. declare module BABYLON {
  154047. /**
  154048. * Class containing static functions to help procedurally build meshes
  154049. */
  154050. export class LatheBuilder {
  154051. /**
  154052. * Creates lathe mesh.
  154053. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  154054. * * 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
  154055. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  154056. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  154057. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  154058. * * 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
  154059. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  154060. * * 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
  154061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154062. * * 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
  154063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154065. * @param name defines the name of the mesh
  154066. * @param options defines the options used to create the mesh
  154067. * @param scene defines the hosting scene
  154068. * @returns the lathe mesh
  154069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  154070. */
  154071. static CreateLathe(name: string, options: {
  154072. shape: Vector3[];
  154073. radius?: number;
  154074. tessellation?: number;
  154075. clip?: number;
  154076. arc?: number;
  154077. closed?: boolean;
  154078. updatable?: boolean;
  154079. sideOrientation?: number;
  154080. frontUVs?: Vector4;
  154081. backUVs?: Vector4;
  154082. cap?: number;
  154083. invertUV?: boolean;
  154084. }, scene?: Nullable<Scene>): Mesh;
  154085. }
  154086. }
  154087. declare module BABYLON {
  154088. /**
  154089. * Class containing static functions to help procedurally build meshes
  154090. */
  154091. export class TiledPlaneBuilder {
  154092. /**
  154093. * Creates a tiled plane mesh
  154094. * * The parameter `pattern` will, depending on value, do nothing or
  154095. * * * flip (reflect about central vertical) alternate tiles across and up
  154096. * * * flip every tile on alternate rows
  154097. * * * rotate (180 degs) alternate tiles across and up
  154098. * * * rotate every tile on alternate rows
  154099. * * * flip and rotate alternate tiles across and up
  154100. * * * flip and rotate every tile on alternate rows
  154101. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  154102. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  154103. * * 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
  154104. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154105. * * 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)
  154106. * * 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)
  154107. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  154108. * @param name defines the name of the mesh
  154109. * @param options defines the options used to create the mesh
  154110. * @param scene defines the hosting scene
  154111. * @returns the box mesh
  154112. */
  154113. static CreateTiledPlane(name: string, options: {
  154114. pattern?: number;
  154115. tileSize?: number;
  154116. tileWidth?: number;
  154117. tileHeight?: number;
  154118. size?: number;
  154119. width?: number;
  154120. height?: number;
  154121. alignHorizontal?: number;
  154122. alignVertical?: number;
  154123. sideOrientation?: number;
  154124. frontUVs?: Vector4;
  154125. backUVs?: Vector4;
  154126. updatable?: boolean;
  154127. }, scene?: Nullable<Scene>): Mesh;
  154128. }
  154129. }
  154130. declare module BABYLON {
  154131. /**
  154132. * Class containing static functions to help procedurally build meshes
  154133. */
  154134. export class TubeBuilder {
  154135. /**
  154136. * Creates a tube mesh.
  154137. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154138. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  154139. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  154140. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  154141. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  154142. * * 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)
  154143. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  154144. * * 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
  154145. * * 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
  154146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154147. * * 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
  154148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154150. * @param name defines the name of the mesh
  154151. * @param options defines the options used to create the mesh
  154152. * @param scene defines the hosting scene
  154153. * @returns the tube mesh
  154154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154155. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  154156. */
  154157. static CreateTube(name: string, options: {
  154158. path: Vector3[];
  154159. radius?: number;
  154160. tessellation?: number;
  154161. radiusFunction?: {
  154162. (i: number, distance: number): number;
  154163. };
  154164. cap?: number;
  154165. arc?: number;
  154166. updatable?: boolean;
  154167. sideOrientation?: number;
  154168. frontUVs?: Vector4;
  154169. backUVs?: Vector4;
  154170. instance?: Mesh;
  154171. invertUV?: boolean;
  154172. }, scene?: Nullable<Scene>): Mesh;
  154173. }
  154174. }
  154175. declare module BABYLON {
  154176. /**
  154177. * Class containing static functions to help procedurally build meshes
  154178. */
  154179. export class IcoSphereBuilder {
  154180. /**
  154181. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  154182. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  154183. * * 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`)
  154184. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  154185. * * 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
  154186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154187. * * 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
  154188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154189. * @param name defines the name of the mesh
  154190. * @param options defines the options used to create the mesh
  154191. * @param scene defines the hosting scene
  154192. * @returns the icosahedron mesh
  154193. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  154194. */
  154195. static CreateIcoSphere(name: string, options: {
  154196. radius?: number;
  154197. radiusX?: number;
  154198. radiusY?: number;
  154199. radiusZ?: number;
  154200. flat?: boolean;
  154201. subdivisions?: number;
  154202. sideOrientation?: number;
  154203. frontUVs?: Vector4;
  154204. backUVs?: Vector4;
  154205. updatable?: boolean;
  154206. }, scene?: Nullable<Scene>): Mesh;
  154207. }
  154208. }
  154209. declare module BABYLON {
  154210. /**
  154211. * Class containing static functions to help procedurally build meshes
  154212. */
  154213. export class DecalBuilder {
  154214. /**
  154215. * Creates a decal mesh.
  154216. * 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
  154217. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  154218. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  154219. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  154220. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  154221. * @param name defines the name of the mesh
  154222. * @param sourceMesh defines the mesh where the decal must be applied
  154223. * @param options defines the options used to create the mesh
  154224. * @param scene defines the hosting scene
  154225. * @returns the decal mesh
  154226. * @see https://doc.babylonjs.com/how_to/decals
  154227. */
  154228. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  154229. position?: Vector3;
  154230. normal?: Vector3;
  154231. size?: Vector3;
  154232. angle?: number;
  154233. }): Mesh;
  154234. }
  154235. }
  154236. declare module BABYLON {
  154237. /**
  154238. * Class containing static functions to help procedurally build meshes
  154239. */
  154240. export class MeshBuilder {
  154241. /**
  154242. * Creates a box mesh
  154243. * * The parameter `size` sets the size (float) of each box side (default 1)
  154244. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  154245. * * 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)
  154246. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154248. * * 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
  154249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154250. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  154251. * @param name defines the name of the mesh
  154252. * @param options defines the options used to create the mesh
  154253. * @param scene defines the hosting scene
  154254. * @returns the box mesh
  154255. */
  154256. static CreateBox(name: string, options: {
  154257. size?: number;
  154258. width?: number;
  154259. height?: number;
  154260. depth?: number;
  154261. faceUV?: Vector4[];
  154262. faceColors?: Color4[];
  154263. sideOrientation?: number;
  154264. frontUVs?: Vector4;
  154265. backUVs?: Vector4;
  154266. wrap?: boolean;
  154267. topBaseAt?: number;
  154268. bottomBaseAt?: number;
  154269. updatable?: boolean;
  154270. }, scene?: Nullable<Scene>): Mesh;
  154271. /**
  154272. * Creates a tiled box mesh
  154273. * * faceTiles sets the pattern, tile size and number of tiles for a face
  154274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154275. * @param name defines the name of the mesh
  154276. * @param options defines the options used to create the mesh
  154277. * @param scene defines the hosting scene
  154278. * @returns the tiled box mesh
  154279. */
  154280. static CreateTiledBox(name: string, options: {
  154281. pattern?: number;
  154282. size?: number;
  154283. width?: number;
  154284. height?: number;
  154285. depth: number;
  154286. tileSize?: number;
  154287. tileWidth?: number;
  154288. tileHeight?: number;
  154289. faceUV?: Vector4[];
  154290. faceColors?: Color4[];
  154291. alignHorizontal?: number;
  154292. alignVertical?: number;
  154293. sideOrientation?: number;
  154294. updatable?: boolean;
  154295. }, scene?: Nullable<Scene>): Mesh;
  154296. /**
  154297. * Creates a sphere mesh
  154298. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  154299. * * 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`)
  154300. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  154301. * * 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
  154302. * * 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)
  154303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154304. * * 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
  154305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154306. * @param name defines the name of the mesh
  154307. * @param options defines the options used to create the mesh
  154308. * @param scene defines the hosting scene
  154309. * @returns the sphere mesh
  154310. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  154311. */
  154312. static CreateSphere(name: string, options: {
  154313. segments?: number;
  154314. diameter?: number;
  154315. diameterX?: number;
  154316. diameterY?: number;
  154317. diameterZ?: number;
  154318. arc?: number;
  154319. slice?: number;
  154320. sideOrientation?: number;
  154321. frontUVs?: Vector4;
  154322. backUVs?: Vector4;
  154323. updatable?: boolean;
  154324. }, scene?: Nullable<Scene>): Mesh;
  154325. /**
  154326. * Creates a plane polygonal mesh. By default, this is a disc
  154327. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  154328. * * 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
  154329. * * 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
  154330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154331. * * 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
  154332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154333. * @param name defines the name of the mesh
  154334. * @param options defines the options used to create the mesh
  154335. * @param scene defines the hosting scene
  154336. * @returns the plane polygonal mesh
  154337. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  154338. */
  154339. static CreateDisc(name: string, options: {
  154340. radius?: number;
  154341. tessellation?: number;
  154342. arc?: number;
  154343. updatable?: boolean;
  154344. sideOrientation?: number;
  154345. frontUVs?: Vector4;
  154346. backUVs?: Vector4;
  154347. }, scene?: Nullable<Scene>): Mesh;
  154348. /**
  154349. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  154350. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  154351. * * 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`)
  154352. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  154353. * * 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
  154354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154355. * * 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
  154356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154357. * @param name defines the name of the mesh
  154358. * @param options defines the options used to create the mesh
  154359. * @param scene defines the hosting scene
  154360. * @returns the icosahedron mesh
  154361. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  154362. */
  154363. static CreateIcoSphere(name: string, options: {
  154364. radius?: number;
  154365. radiusX?: number;
  154366. radiusY?: number;
  154367. radiusZ?: number;
  154368. flat?: boolean;
  154369. subdivisions?: number;
  154370. sideOrientation?: number;
  154371. frontUVs?: Vector4;
  154372. backUVs?: Vector4;
  154373. updatable?: boolean;
  154374. }, scene?: Nullable<Scene>): Mesh;
  154375. /**
  154376. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154377. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  154378. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  154379. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  154380. * * 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
  154381. * * 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
  154382. * * 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
  154383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154384. * * 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
  154385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154386. * * 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
  154387. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  154388. * * 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
  154389. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  154390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154391. * @param name defines the name of the mesh
  154392. * @param options defines the options used to create the mesh
  154393. * @param scene defines the hosting scene
  154394. * @returns the ribbon mesh
  154395. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  154396. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154397. */
  154398. static CreateRibbon(name: string, options: {
  154399. pathArray: Vector3[][];
  154400. closeArray?: boolean;
  154401. closePath?: boolean;
  154402. offset?: number;
  154403. updatable?: boolean;
  154404. sideOrientation?: number;
  154405. frontUVs?: Vector4;
  154406. backUVs?: Vector4;
  154407. instance?: Mesh;
  154408. invertUV?: boolean;
  154409. uvs?: Vector2[];
  154410. colors?: Color4[];
  154411. }, scene?: Nullable<Scene>): Mesh;
  154412. /**
  154413. * Creates a cylinder or a cone mesh
  154414. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  154415. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  154416. * * 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.
  154417. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  154418. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  154419. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  154420. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  154421. * * 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).
  154422. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  154423. * * 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).
  154424. * * 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
  154425. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  154426. * * 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
  154427. * * 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.
  154428. * * If `enclose` is false, a ring surface is one element.
  154429. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  154430. * * 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
  154431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154432. * * 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
  154433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154434. * @param name defines the name of the mesh
  154435. * @param options defines the options used to create the mesh
  154436. * @param scene defines the hosting scene
  154437. * @returns the cylinder mesh
  154438. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  154439. */
  154440. static CreateCylinder(name: string, options: {
  154441. height?: number;
  154442. diameterTop?: number;
  154443. diameterBottom?: number;
  154444. diameter?: number;
  154445. tessellation?: number;
  154446. subdivisions?: number;
  154447. arc?: number;
  154448. faceColors?: Color4[];
  154449. faceUV?: Vector4[];
  154450. updatable?: boolean;
  154451. hasRings?: boolean;
  154452. enclose?: boolean;
  154453. cap?: number;
  154454. sideOrientation?: number;
  154455. frontUVs?: Vector4;
  154456. backUVs?: Vector4;
  154457. }, scene?: Nullable<Scene>): Mesh;
  154458. /**
  154459. * Creates a torus mesh
  154460. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  154461. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  154462. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  154463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154464. * * 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
  154465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154466. * @param name defines the name of the mesh
  154467. * @param options defines the options used to create the mesh
  154468. * @param scene defines the hosting scene
  154469. * @returns the torus mesh
  154470. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  154471. */
  154472. static CreateTorus(name: string, options: {
  154473. diameter?: number;
  154474. thickness?: number;
  154475. tessellation?: number;
  154476. updatable?: boolean;
  154477. sideOrientation?: number;
  154478. frontUVs?: Vector4;
  154479. backUVs?: Vector4;
  154480. }, scene?: Nullable<Scene>): Mesh;
  154481. /**
  154482. * Creates a torus knot mesh
  154483. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  154484. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  154485. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  154486. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  154487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154488. * * 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
  154489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154490. * @param name defines the name of the mesh
  154491. * @param options defines the options used to create the mesh
  154492. * @param scene defines the hosting scene
  154493. * @returns the torus knot mesh
  154494. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  154495. */
  154496. static CreateTorusKnot(name: string, options: {
  154497. radius?: number;
  154498. tube?: number;
  154499. radialSegments?: number;
  154500. tubularSegments?: number;
  154501. p?: number;
  154502. q?: number;
  154503. updatable?: boolean;
  154504. sideOrientation?: number;
  154505. frontUVs?: Vector4;
  154506. backUVs?: Vector4;
  154507. }, scene?: Nullable<Scene>): Mesh;
  154508. /**
  154509. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  154510. * * 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
  154511. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  154512. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  154513. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  154514. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  154515. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  154516. * * 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
  154517. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  154518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154519. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  154520. * @param name defines the name of the new line system
  154521. * @param options defines the options used to create the line system
  154522. * @param scene defines the hosting scene
  154523. * @returns a new line system mesh
  154524. */
  154525. static CreateLineSystem(name: string, options: {
  154526. lines: Vector3[][];
  154527. updatable?: boolean;
  154528. instance?: Nullable<LinesMesh>;
  154529. colors?: Nullable<Color4[][]>;
  154530. useVertexAlpha?: boolean;
  154531. }, scene: Nullable<Scene>): LinesMesh;
  154532. /**
  154533. * Creates a line mesh
  154534. * 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
  154535. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  154536. * * The parameter `points` is an array successive Vector3
  154537. * * 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
  154538. * * The optional parameter `colors` is an array of successive Color4, one per line point
  154539. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  154540. * * When updating an instance, remember that only point positions can change, not the number of points
  154541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  154543. * @param name defines the name of the new line system
  154544. * @param options defines the options used to create the line system
  154545. * @param scene defines the hosting scene
  154546. * @returns a new line mesh
  154547. */
  154548. static CreateLines(name: string, options: {
  154549. points: Vector3[];
  154550. updatable?: boolean;
  154551. instance?: Nullable<LinesMesh>;
  154552. colors?: Color4[];
  154553. useVertexAlpha?: boolean;
  154554. }, scene?: Nullable<Scene>): LinesMesh;
  154555. /**
  154556. * Creates a dashed line mesh
  154557. * * 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
  154558. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  154559. * * The parameter `points` is an array successive Vector3
  154560. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  154561. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  154562. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  154563. * * 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
  154564. * * When updating an instance, remember that only point positions can change, not the number of points
  154565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154566. * @param name defines the name of the mesh
  154567. * @param options defines the options used to create the mesh
  154568. * @param scene defines the hosting scene
  154569. * @returns the dashed line mesh
  154570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  154571. */
  154572. static CreateDashedLines(name: string, options: {
  154573. points: Vector3[];
  154574. dashSize?: number;
  154575. gapSize?: number;
  154576. dashNb?: number;
  154577. updatable?: boolean;
  154578. instance?: LinesMesh;
  154579. }, scene?: Nullable<Scene>): LinesMesh;
  154580. /**
  154581. * 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.
  154582. * * 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.
  154583. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  154584. * * 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.
  154585. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  154586. * * 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
  154587. * * 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
  154588. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  154589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154590. * * 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
  154591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  154592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154593. * @param name defines the name of the mesh
  154594. * @param options defines the options used to create the mesh
  154595. * @param scene defines the hosting scene
  154596. * @returns the extruded shape mesh
  154597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  154599. */
  154600. static ExtrudeShape(name: string, options: {
  154601. shape: Vector3[];
  154602. path: Vector3[];
  154603. scale?: number;
  154604. rotation?: number;
  154605. cap?: number;
  154606. updatable?: boolean;
  154607. sideOrientation?: number;
  154608. frontUVs?: Vector4;
  154609. backUVs?: Vector4;
  154610. instance?: Mesh;
  154611. invertUV?: boolean;
  154612. }, scene?: Nullable<Scene>): Mesh;
  154613. /**
  154614. * Creates an custom extruded shape mesh.
  154615. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  154616. * * 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.
  154617. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  154618. * * 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
  154619. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  154620. * * 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
  154621. * * It must returns a float value that will be the scale value applied to the shape on each path point
  154622. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  154623. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  154624. * * 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
  154625. * * 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
  154626. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  154627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154628. * * 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
  154629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154631. * @param name defines the name of the mesh
  154632. * @param options defines the options used to create the mesh
  154633. * @param scene defines the hosting scene
  154634. * @returns the custom extruded shape mesh
  154635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  154636. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  154638. */
  154639. static ExtrudeShapeCustom(name: string, options: {
  154640. shape: Vector3[];
  154641. path: Vector3[];
  154642. scaleFunction?: any;
  154643. rotationFunction?: any;
  154644. ribbonCloseArray?: boolean;
  154645. ribbonClosePath?: boolean;
  154646. cap?: number;
  154647. updatable?: boolean;
  154648. sideOrientation?: number;
  154649. frontUVs?: Vector4;
  154650. backUVs?: Vector4;
  154651. instance?: Mesh;
  154652. invertUV?: boolean;
  154653. }, scene?: Nullable<Scene>): Mesh;
  154654. /**
  154655. * Creates lathe mesh.
  154656. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  154657. * * 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
  154658. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  154659. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  154660. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  154661. * * 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
  154662. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  154663. * * 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
  154664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154665. * * 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
  154666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154668. * @param name defines the name of the mesh
  154669. * @param options defines the options used to create the mesh
  154670. * @param scene defines the hosting scene
  154671. * @returns the lathe mesh
  154672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  154673. */
  154674. static CreateLathe(name: string, options: {
  154675. shape: Vector3[];
  154676. radius?: number;
  154677. tessellation?: number;
  154678. clip?: number;
  154679. arc?: number;
  154680. closed?: boolean;
  154681. updatable?: boolean;
  154682. sideOrientation?: number;
  154683. frontUVs?: Vector4;
  154684. backUVs?: Vector4;
  154685. cap?: number;
  154686. invertUV?: boolean;
  154687. }, scene?: Nullable<Scene>): Mesh;
  154688. /**
  154689. * Creates a tiled plane mesh
  154690. * * You can set a limited pattern arrangement with the tiles
  154691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154692. * * 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
  154693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154694. * @param name defines the name of the mesh
  154695. * @param options defines the options used to create the mesh
  154696. * @param scene defines the hosting scene
  154697. * @returns the plane mesh
  154698. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  154699. */
  154700. static CreateTiledPlane(name: string, options: {
  154701. pattern?: number;
  154702. tileSize?: number;
  154703. tileWidth?: number;
  154704. tileHeight?: number;
  154705. size?: number;
  154706. width?: number;
  154707. height?: number;
  154708. alignHorizontal?: number;
  154709. alignVertical?: number;
  154710. sideOrientation?: number;
  154711. frontUVs?: Vector4;
  154712. backUVs?: Vector4;
  154713. updatable?: boolean;
  154714. }, scene?: Nullable<Scene>): Mesh;
  154715. /**
  154716. * Creates a plane mesh
  154717. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  154718. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  154719. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  154720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154721. * * 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
  154722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154723. * @param name defines the name of the mesh
  154724. * @param options defines the options used to create the mesh
  154725. * @param scene defines the hosting scene
  154726. * @returns the plane mesh
  154727. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  154728. */
  154729. static CreatePlane(name: string, options: {
  154730. size?: number;
  154731. width?: number;
  154732. height?: number;
  154733. sideOrientation?: number;
  154734. frontUVs?: Vector4;
  154735. backUVs?: Vector4;
  154736. updatable?: boolean;
  154737. sourcePlane?: Plane;
  154738. }, scene?: Nullable<Scene>): Mesh;
  154739. /**
  154740. * Creates a ground mesh
  154741. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  154742. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  154743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154744. * @param name defines the name of the mesh
  154745. * @param options defines the options used to create the mesh
  154746. * @param scene defines the hosting scene
  154747. * @returns the ground mesh
  154748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  154749. */
  154750. static CreateGround(name: string, options: {
  154751. width?: number;
  154752. height?: number;
  154753. subdivisions?: number;
  154754. subdivisionsX?: number;
  154755. subdivisionsY?: number;
  154756. updatable?: boolean;
  154757. }, scene?: Nullable<Scene>): Mesh;
  154758. /**
  154759. * Creates a tiled ground mesh
  154760. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  154761. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  154762. * * 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
  154763. * * 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
  154764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154765. * @param name defines the name of the mesh
  154766. * @param options defines the options used to create the mesh
  154767. * @param scene defines the hosting scene
  154768. * @returns the tiled ground mesh
  154769. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  154770. */
  154771. static CreateTiledGround(name: string, options: {
  154772. xmin: number;
  154773. zmin: number;
  154774. xmax: number;
  154775. zmax: number;
  154776. subdivisions?: {
  154777. w: number;
  154778. h: number;
  154779. };
  154780. precision?: {
  154781. w: number;
  154782. h: number;
  154783. };
  154784. updatable?: boolean;
  154785. }, scene?: Nullable<Scene>): Mesh;
  154786. /**
  154787. * Creates a ground mesh from a height map
  154788. * * The parameter `url` sets the URL of the height map image resource.
  154789. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  154790. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  154791. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  154792. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  154793. * * 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.
  154794. * * 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).
  154795. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  154799. * @param options defines the options used to create the mesh
  154800. * @param scene defines the hosting scene
  154801. * @returns the ground mesh
  154802. * @see https://doc.babylonjs.com/babylon101/height_map
  154803. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  154804. */
  154805. static CreateGroundFromHeightMap(name: string, url: string, options: {
  154806. width?: number;
  154807. height?: number;
  154808. subdivisions?: number;
  154809. minHeight?: number;
  154810. maxHeight?: number;
  154811. colorFilter?: Color3;
  154812. alphaFilter?: number;
  154813. updatable?: boolean;
  154814. onReady?: (mesh: GroundMesh) => void;
  154815. }, scene?: Nullable<Scene>): GroundMesh;
  154816. /**
  154817. * Creates a polygon mesh
  154818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  154819. * * 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
  154820. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154822. * * 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)
  154823. * * Remember you can only change the shape positions, not their number when updating a polygon
  154824. * @param name defines the name of the mesh
  154825. * @param options defines the options used to create the mesh
  154826. * @param scene defines the hosting scene
  154827. * @param earcutInjection can be used to inject your own earcut reference
  154828. * @returns the polygon mesh
  154829. */
  154830. static CreatePolygon(name: string, options: {
  154831. shape: Vector3[];
  154832. holes?: Vector3[][];
  154833. depth?: number;
  154834. faceUV?: Vector4[];
  154835. faceColors?: Color4[];
  154836. updatable?: boolean;
  154837. sideOrientation?: number;
  154838. frontUVs?: Vector4;
  154839. backUVs?: Vector4;
  154840. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154841. /**
  154842. * Creates an extruded polygon mesh, with depth in the Y direction.
  154843. * * 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)
  154844. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154845. * @param name defines the name of the mesh
  154846. * @param options defines the options used to create the mesh
  154847. * @param scene defines the hosting scene
  154848. * @param earcutInjection can be used to inject your own earcut reference
  154849. * @returns the polygon mesh
  154850. */
  154851. static ExtrudePolygon(name: string, options: {
  154852. shape: Vector3[];
  154853. holes?: Vector3[][];
  154854. depth?: number;
  154855. faceUV?: Vector4[];
  154856. faceColors?: Color4[];
  154857. updatable?: boolean;
  154858. sideOrientation?: number;
  154859. frontUVs?: Vector4;
  154860. backUVs?: Vector4;
  154861. wrap?: boolean;
  154862. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154863. /**
  154864. * Creates a tube mesh.
  154865. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154866. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  154867. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  154868. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  154869. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  154870. * * 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)
  154871. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  154872. * * 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
  154873. * * 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
  154874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154875. * * 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
  154876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154878. * @param name defines the name of the mesh
  154879. * @param options defines the options used to create the mesh
  154880. * @param scene defines the hosting scene
  154881. * @returns the tube mesh
  154882. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154883. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  154884. */
  154885. static CreateTube(name: string, options: {
  154886. path: Vector3[];
  154887. radius?: number;
  154888. tessellation?: number;
  154889. radiusFunction?: {
  154890. (i: number, distance: number): number;
  154891. };
  154892. cap?: number;
  154893. arc?: number;
  154894. updatable?: boolean;
  154895. sideOrientation?: number;
  154896. frontUVs?: Vector4;
  154897. backUVs?: Vector4;
  154898. instance?: Mesh;
  154899. invertUV?: boolean;
  154900. }, scene?: Nullable<Scene>): Mesh;
  154901. /**
  154902. * Creates a polyhedron mesh
  154903. * * 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
  154904. * * The parameter `size` (positive float, default 1) sets the polygon size
  154905. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  154906. * * 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`
  154907. * * 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
  154908. * * 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)`)
  154909. * * 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
  154910. * * 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
  154911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154912. * * 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
  154913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154914. * @param name defines the name of the mesh
  154915. * @param options defines the options used to create the mesh
  154916. * @param scene defines the hosting scene
  154917. * @returns the polyhedron mesh
  154918. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  154919. */
  154920. static CreatePolyhedron(name: string, options: {
  154921. type?: number;
  154922. size?: number;
  154923. sizeX?: number;
  154924. sizeY?: number;
  154925. sizeZ?: number;
  154926. custom?: any;
  154927. faceUV?: Vector4[];
  154928. faceColors?: Color4[];
  154929. flat?: boolean;
  154930. updatable?: boolean;
  154931. sideOrientation?: number;
  154932. frontUVs?: Vector4;
  154933. backUVs?: Vector4;
  154934. }, scene?: Nullable<Scene>): Mesh;
  154935. /**
  154936. * Creates a decal mesh.
  154937. * 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
  154938. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  154939. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  154940. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  154941. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  154942. * @param name defines the name of the mesh
  154943. * @param sourceMesh defines the mesh where the decal must be applied
  154944. * @param options defines the options used to create the mesh
  154945. * @param scene defines the hosting scene
  154946. * @returns the decal mesh
  154947. * @see https://doc.babylonjs.com/how_to/decals
  154948. */
  154949. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  154950. position?: Vector3;
  154951. normal?: Vector3;
  154952. size?: Vector3;
  154953. angle?: number;
  154954. }): Mesh;
  154955. /**
  154956. * Creates a Capsule Mesh
  154957. * @param name defines the name of the mesh.
  154958. * @param options the constructors options used to shape the mesh.
  154959. * @param scene defines the scene the mesh is scoped to.
  154960. * @returns the capsule mesh
  154961. * @see https://doc.babylonjs.com/how_to/capsule_shape
  154962. */
  154963. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  154964. }
  154965. }
  154966. declare module BABYLON {
  154967. /**
  154968. * A simplifier interface for future simplification implementations
  154969. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  154970. */
  154971. export interface ISimplifier {
  154972. /**
  154973. * Simplification of a given mesh according to the given settings.
  154974. * Since this requires computation, it is assumed that the function runs async.
  154975. * @param settings The settings of the simplification, including quality and distance
  154976. * @param successCallback A callback that will be called after the mesh was simplified.
  154977. * @param errorCallback in case of an error, this callback will be called. optional.
  154978. */
  154979. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  154980. }
  154981. /**
  154982. * Expected simplification settings.
  154983. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  154984. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  154985. */
  154986. export interface ISimplificationSettings {
  154987. /**
  154988. * Gets or sets the expected quality
  154989. */
  154990. quality: number;
  154991. /**
  154992. * Gets or sets the distance when this optimized version should be used
  154993. */
  154994. distance: number;
  154995. /**
  154996. * Gets an already optimized mesh
  154997. */
  154998. optimizeMesh?: boolean;
  154999. }
  155000. /**
  155001. * Class used to specify simplification options
  155002. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155003. */
  155004. export class SimplificationSettings implements ISimplificationSettings {
  155005. /** expected quality */
  155006. quality: number;
  155007. /** distance when this optimized version should be used */
  155008. distance: number;
  155009. /** already optimized mesh */
  155010. optimizeMesh?: boolean | undefined;
  155011. /**
  155012. * Creates a SimplificationSettings
  155013. * @param quality expected quality
  155014. * @param distance distance when this optimized version should be used
  155015. * @param optimizeMesh already optimized mesh
  155016. */
  155017. constructor(
  155018. /** expected quality */
  155019. quality: number,
  155020. /** distance when this optimized version should be used */
  155021. distance: number,
  155022. /** already optimized mesh */
  155023. optimizeMesh?: boolean | undefined);
  155024. }
  155025. /**
  155026. * Interface used to define a simplification task
  155027. */
  155028. export interface ISimplificationTask {
  155029. /**
  155030. * Array of settings
  155031. */
  155032. settings: Array<ISimplificationSettings>;
  155033. /**
  155034. * Simplification type
  155035. */
  155036. simplificationType: SimplificationType;
  155037. /**
  155038. * Mesh to simplify
  155039. */
  155040. mesh: Mesh;
  155041. /**
  155042. * Callback called on success
  155043. */
  155044. successCallback?: () => void;
  155045. /**
  155046. * Defines if parallel processing can be used
  155047. */
  155048. parallelProcessing: boolean;
  155049. }
  155050. /**
  155051. * Queue used to order the simplification tasks
  155052. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155053. */
  155054. export class SimplificationQueue {
  155055. private _simplificationArray;
  155056. /**
  155057. * Gets a boolean indicating that the process is still running
  155058. */
  155059. running: boolean;
  155060. /**
  155061. * Creates a new queue
  155062. */
  155063. constructor();
  155064. /**
  155065. * Adds a new simplification task
  155066. * @param task defines a task to add
  155067. */
  155068. addTask(task: ISimplificationTask): void;
  155069. /**
  155070. * Execute next task
  155071. */
  155072. executeNext(): void;
  155073. /**
  155074. * Execute a simplification task
  155075. * @param task defines the task to run
  155076. */
  155077. runSimplification(task: ISimplificationTask): void;
  155078. private getSimplifier;
  155079. }
  155080. /**
  155081. * The implemented types of simplification
  155082. * At the moment only Quadratic Error Decimation is implemented
  155083. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155084. */
  155085. export enum SimplificationType {
  155086. /** Quadratic error decimation */
  155087. QUADRATIC = 0
  155088. }
  155089. /**
  155090. * An implementation of the Quadratic Error simplification algorithm.
  155091. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  155092. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  155093. * @author RaananW
  155094. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155095. */
  155096. export class QuadraticErrorSimplification implements ISimplifier {
  155097. private _mesh;
  155098. private triangles;
  155099. private vertices;
  155100. private references;
  155101. private _reconstructedMesh;
  155102. /** Gets or sets the number pf sync interations */
  155103. syncIterations: number;
  155104. /** Gets or sets the aggressiveness of the simplifier */
  155105. aggressiveness: number;
  155106. /** Gets or sets the number of allowed iterations for decimation */
  155107. decimationIterations: number;
  155108. /** Gets or sets the espilon to use for bounding box computation */
  155109. boundingBoxEpsilon: number;
  155110. /**
  155111. * Creates a new QuadraticErrorSimplification
  155112. * @param _mesh defines the target mesh
  155113. */
  155114. constructor(_mesh: Mesh);
  155115. /**
  155116. * Simplification of a given mesh according to the given settings.
  155117. * Since this requires computation, it is assumed that the function runs async.
  155118. * @param settings The settings of the simplification, including quality and distance
  155119. * @param successCallback A callback that will be called after the mesh was simplified.
  155120. */
  155121. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  155122. private runDecimation;
  155123. private initWithMesh;
  155124. private init;
  155125. private reconstructMesh;
  155126. private initDecimatedMesh;
  155127. private isFlipped;
  155128. private updateTriangles;
  155129. private identifyBorder;
  155130. private updateMesh;
  155131. private vertexError;
  155132. private calculateError;
  155133. }
  155134. }
  155135. declare module BABYLON {
  155136. interface Scene {
  155137. /** @hidden (Backing field) */
  155138. _simplificationQueue: SimplificationQueue;
  155139. /**
  155140. * Gets or sets the simplification queue attached to the scene
  155141. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155142. */
  155143. simplificationQueue: SimplificationQueue;
  155144. }
  155145. interface Mesh {
  155146. /**
  155147. * Simplify the mesh according to the given array of settings.
  155148. * Function will return immediately and will simplify async
  155149. * @param settings a collection of simplification settings
  155150. * @param parallelProcessing should all levels calculate parallel or one after the other
  155151. * @param simplificationType the type of simplification to run
  155152. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  155153. * @returns the current mesh
  155154. */
  155155. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  155156. }
  155157. /**
  155158. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  155159. * created in a scene
  155160. */
  155161. export class SimplicationQueueSceneComponent implements ISceneComponent {
  155162. /**
  155163. * The component name helpfull to identify the component in the list of scene components.
  155164. */
  155165. readonly name: string;
  155166. /**
  155167. * The scene the component belongs to.
  155168. */
  155169. scene: Scene;
  155170. /**
  155171. * Creates a new instance of the component for the given scene
  155172. * @param scene Defines the scene to register the component in
  155173. */
  155174. constructor(scene: Scene);
  155175. /**
  155176. * Registers the component in a given scene
  155177. */
  155178. register(): void;
  155179. /**
  155180. * Rebuilds the elements related to this component in case of
  155181. * context lost for instance.
  155182. */
  155183. rebuild(): void;
  155184. /**
  155185. * Disposes the component and the associated ressources
  155186. */
  155187. dispose(): void;
  155188. private _beforeCameraUpdate;
  155189. }
  155190. }
  155191. declare module BABYLON {
  155192. interface Mesh {
  155193. /**
  155194. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  155195. */
  155196. thinInstanceEnablePicking: boolean;
  155197. /**
  155198. * Creates a new thin instance
  155199. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  155200. * @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
  155201. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  155202. */
  155203. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  155204. /**
  155205. * Adds the transformation (matrix) of the current mesh as a thin instance
  155206. * @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
  155207. * @returns the thin instance index number
  155208. */
  155209. thinInstanceAddSelf(refresh: boolean): number;
  155210. /**
  155211. * Registers a custom attribute to be used with thin instances
  155212. * @param kind name of the attribute
  155213. * @param stride size in floats of the attribute
  155214. */
  155215. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  155216. /**
  155217. * Sets the matrix of a thin instance
  155218. * @param index index of the thin instance
  155219. * @param matrix matrix to set
  155220. * @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
  155221. */
  155222. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  155223. /**
  155224. * Sets the value of a custom attribute for a thin instance
  155225. * @param kind name of the attribute
  155226. * @param index index of the thin instance
  155227. * @param value value to set
  155228. * @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
  155229. */
  155230. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  155231. /**
  155232. * 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.
  155233. */
  155234. thinInstanceCount: number;
  155235. /**
  155236. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  155237. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  155238. * @param buffer buffer to set
  155239. * @param stride size in floats of each value of the buffer
  155240. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  155241. */
  155242. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  155243. /**
  155244. * Gets the list of world matrices
  155245. * @return an array containing all the world matrices from the thin instances
  155246. */
  155247. thinInstanceGetWorldMatrices(): Matrix[];
  155248. /**
  155249. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  155250. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  155251. */
  155252. thinInstanceBufferUpdated(kind: string): void;
  155253. /**
  155254. * Applies a partial update to a buffer directly on the GPU
  155255. * 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
  155256. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  155257. * @param data the data to set in the GPU buffer
  155258. * @param offset the offset in the GPU buffer where to update the data
  155259. */
  155260. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  155261. /**
  155262. * Refreshes the bounding info, taking into account all the thin instances defined
  155263. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  155264. */
  155265. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  155266. /** @hidden */
  155267. _thinInstanceInitializeUserStorage(): void;
  155268. /** @hidden */
  155269. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  155270. /** @hidden */
  155271. _userThinInstanceBuffersStorage: {
  155272. data: {
  155273. [key: string]: Float32Array;
  155274. };
  155275. sizes: {
  155276. [key: string]: number;
  155277. };
  155278. vertexBuffers: {
  155279. [key: string]: Nullable<VertexBuffer>;
  155280. };
  155281. strides: {
  155282. [key: string]: number;
  155283. };
  155284. };
  155285. }
  155286. }
  155287. declare module BABYLON {
  155288. /**
  155289. * Navigation plugin interface to add navigation constrained by a navigation mesh
  155290. */
  155291. export interface INavigationEnginePlugin {
  155292. /**
  155293. * plugin name
  155294. */
  155295. name: string;
  155296. /**
  155297. * Creates a navigation mesh
  155298. * @param meshes array of all the geometry used to compute the navigatio mesh
  155299. * @param parameters bunch of parameters used to filter geometry
  155300. */
  155301. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  155302. /**
  155303. * Create a navigation mesh debug mesh
  155304. * @param scene is where the mesh will be added
  155305. * @returns debug display mesh
  155306. */
  155307. createDebugNavMesh(scene: Scene): Mesh;
  155308. /**
  155309. * Get a navigation mesh constrained position, closest to the parameter position
  155310. * @param position world position
  155311. * @returns the closest point to position constrained by the navigation mesh
  155312. */
  155313. getClosestPoint(position: Vector3): Vector3;
  155314. /**
  155315. * Get a navigation mesh constrained position, closest to the parameter position
  155316. * @param position world position
  155317. * @param result output the closest point to position constrained by the navigation mesh
  155318. */
  155319. getClosestPointToRef(position: Vector3, result: Vector3): void;
  155320. /**
  155321. * Get a navigation mesh constrained position, within a particular radius
  155322. * @param position world position
  155323. * @param maxRadius the maximum distance to the constrained world position
  155324. * @returns the closest point to position constrained by the navigation mesh
  155325. */
  155326. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  155327. /**
  155328. * Get a navigation mesh constrained position, within a particular radius
  155329. * @param position world position
  155330. * @param maxRadius the maximum distance to the constrained world position
  155331. * @param result output the closest point to position constrained by the navigation mesh
  155332. */
  155333. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  155334. /**
  155335. * Compute the final position from a segment made of destination-position
  155336. * @param position world position
  155337. * @param destination world position
  155338. * @returns the resulting point along the navmesh
  155339. */
  155340. moveAlong(position: Vector3, destination: Vector3): Vector3;
  155341. /**
  155342. * Compute the final position from a segment made of destination-position
  155343. * @param position world position
  155344. * @param destination world position
  155345. * @param result output the resulting point along the navmesh
  155346. */
  155347. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  155348. /**
  155349. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  155350. * @param start world position
  155351. * @param end world position
  155352. * @returns array containing world position composing the path
  155353. */
  155354. computePath(start: Vector3, end: Vector3): Vector3[];
  155355. /**
  155356. * If this plugin is supported
  155357. * @returns true if plugin is supported
  155358. */
  155359. isSupported(): boolean;
  155360. /**
  155361. * Create a new Crowd so you can add agents
  155362. * @param maxAgents the maximum agent count in the crowd
  155363. * @param maxAgentRadius the maximum radius an agent can have
  155364. * @param scene to attach the crowd to
  155365. * @returns the crowd you can add agents to
  155366. */
  155367. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  155368. /**
  155369. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155370. * The queries will try to find a solution within those bounds
  155371. * default is (1,1,1)
  155372. * @param extent x,y,z value that define the extent around the queries point of reference
  155373. */
  155374. setDefaultQueryExtent(extent: Vector3): void;
  155375. /**
  155376. * Get the Bounding box extent specified by setDefaultQueryExtent
  155377. * @returns the box extent values
  155378. */
  155379. getDefaultQueryExtent(): Vector3;
  155380. /**
  155381. * build the navmesh from a previously saved state using getNavmeshData
  155382. * @param data the Uint8Array returned by getNavmeshData
  155383. */
  155384. buildFromNavmeshData(data: Uint8Array): void;
  155385. /**
  155386. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  155387. * @returns data the Uint8Array that can be saved and reused
  155388. */
  155389. getNavmeshData(): Uint8Array;
  155390. /**
  155391. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155392. * @param result output the box extent values
  155393. */
  155394. getDefaultQueryExtentToRef(result: Vector3): void;
  155395. /**
  155396. * Set the time step of the navigation tick update.
  155397. * Default is 1/60.
  155398. * A value of 0 will disable fixed time update
  155399. * @param newTimeStep the new timestep to apply to this world.
  155400. */
  155401. setTimeStep(newTimeStep: number): void;
  155402. /**
  155403. * Get the time step of the navigation tick update.
  155404. * @returns the current time step
  155405. */
  155406. getTimeStep(): number;
  155407. /**
  155408. * If delta time in navigation tick update is greater than the time step
  155409. * a number of sub iterations are done. If more iterations are need to reach deltatime
  155410. * they will be discarded.
  155411. * A value of 0 will set to no maximum and update will use as many substeps as needed
  155412. * @param newStepCount the maximum number of iterations
  155413. */
  155414. setMaximumSubStepCount(newStepCount: number): void;
  155415. /**
  155416. * Get the maximum number of iterations per navigation tick update
  155417. * @returns the maximum number of iterations
  155418. */
  155419. getMaximumSubStepCount(): number;
  155420. /**
  155421. * Release all resources
  155422. */
  155423. dispose(): void;
  155424. }
  155425. /**
  155426. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  155427. */
  155428. export interface ICrowd {
  155429. /**
  155430. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  155431. * You can attach anything to that node. The node position is updated in the scene update tick.
  155432. * @param pos world position that will be constrained by the navigation mesh
  155433. * @param parameters agent parameters
  155434. * @param transform hooked to the agent that will be update by the scene
  155435. * @returns agent index
  155436. */
  155437. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  155438. /**
  155439. * Returns the agent position in world space
  155440. * @param index agent index returned by addAgent
  155441. * @returns world space position
  155442. */
  155443. getAgentPosition(index: number): Vector3;
  155444. /**
  155445. * Gets the agent position result in world space
  155446. * @param index agent index returned by addAgent
  155447. * @param result output world space position
  155448. */
  155449. getAgentPositionToRef(index: number, result: Vector3): void;
  155450. /**
  155451. * Gets the agent velocity in world space
  155452. * @param index agent index returned by addAgent
  155453. * @returns world space velocity
  155454. */
  155455. getAgentVelocity(index: number): Vector3;
  155456. /**
  155457. * Gets the agent velocity result in world space
  155458. * @param index agent index returned by addAgent
  155459. * @param result output world space velocity
  155460. */
  155461. getAgentVelocityToRef(index: number, result: Vector3): void;
  155462. /**
  155463. * Gets the agent next target point on the path
  155464. * @param index agent index returned by addAgent
  155465. * @returns world space position
  155466. */
  155467. getAgentNextTargetPath(index: number): Vector3;
  155468. /**
  155469. * Gets the agent state
  155470. * @param index agent index returned by addAgent
  155471. * @returns agent state
  155472. */
  155473. getAgentState(index: number): number;
  155474. /**
  155475. * returns true if the agent in over an off mesh link connection
  155476. * @param index agent index returned by addAgent
  155477. * @returns true if over an off mesh link connection
  155478. */
  155479. overOffmeshConnection(index: number): boolean;
  155480. /**
  155481. * Gets the agent next target point on the path
  155482. * @param index agent index returned by addAgent
  155483. * @param result output world space position
  155484. */
  155485. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  155486. /**
  155487. * remove a particular agent previously created
  155488. * @param index agent index returned by addAgent
  155489. */
  155490. removeAgent(index: number): void;
  155491. /**
  155492. * get the list of all agents attached to this crowd
  155493. * @returns list of agent indices
  155494. */
  155495. getAgents(): number[];
  155496. /**
  155497. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  155498. * @param deltaTime in seconds
  155499. */
  155500. update(deltaTime: number): void;
  155501. /**
  155502. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  155503. * @param index agent index returned by addAgent
  155504. * @param destination targeted world position
  155505. */
  155506. agentGoto(index: number, destination: Vector3): void;
  155507. /**
  155508. * Teleport the agent to a new position
  155509. * @param index agent index returned by addAgent
  155510. * @param destination targeted world position
  155511. */
  155512. agentTeleport(index: number, destination: Vector3): void;
  155513. /**
  155514. * Update agent parameters
  155515. * @param index agent index returned by addAgent
  155516. * @param parameters agent parameters
  155517. */
  155518. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  155519. /**
  155520. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155521. * The queries will try to find a solution within those bounds
  155522. * default is (1,1,1)
  155523. * @param extent x,y,z value that define the extent around the queries point of reference
  155524. */
  155525. setDefaultQueryExtent(extent: Vector3): void;
  155526. /**
  155527. * Get the Bounding box extent specified by setDefaultQueryExtent
  155528. * @returns the box extent values
  155529. */
  155530. getDefaultQueryExtent(): Vector3;
  155531. /**
  155532. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155533. * @param result output the box extent values
  155534. */
  155535. getDefaultQueryExtentToRef(result: Vector3): void;
  155536. /**
  155537. * Release all resources
  155538. */
  155539. dispose(): void;
  155540. }
  155541. /**
  155542. * Configures an agent
  155543. */
  155544. export interface IAgentParameters {
  155545. /**
  155546. * Agent radius. [Limit: >= 0]
  155547. */
  155548. radius: number;
  155549. /**
  155550. * Agent height. [Limit: > 0]
  155551. */
  155552. height: number;
  155553. /**
  155554. * Maximum allowed acceleration. [Limit: >= 0]
  155555. */
  155556. maxAcceleration: number;
  155557. /**
  155558. * Maximum allowed speed. [Limit: >= 0]
  155559. */
  155560. maxSpeed: number;
  155561. /**
  155562. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  155563. */
  155564. collisionQueryRange: number;
  155565. /**
  155566. * The path visibility optimization range. [Limit: > 0]
  155567. */
  155568. pathOptimizationRange: number;
  155569. /**
  155570. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  155571. */
  155572. separationWeight: number;
  155573. }
  155574. /**
  155575. * Configures the navigation mesh creation
  155576. */
  155577. export interface INavMeshParameters {
  155578. /**
  155579. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  155580. */
  155581. cs: number;
  155582. /**
  155583. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  155584. */
  155585. ch: number;
  155586. /**
  155587. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  155588. */
  155589. walkableSlopeAngle: number;
  155590. /**
  155591. * Minimum floor to 'ceiling' height that will still allow the floor area to
  155592. * be considered walkable. [Limit: >= 3] [Units: vx]
  155593. */
  155594. walkableHeight: number;
  155595. /**
  155596. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  155597. */
  155598. walkableClimb: number;
  155599. /**
  155600. * The distance to erode/shrink the walkable area of the heightfield away from
  155601. * obstructions. [Limit: >=0] [Units: vx]
  155602. */
  155603. walkableRadius: number;
  155604. /**
  155605. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  155606. */
  155607. maxEdgeLen: number;
  155608. /**
  155609. * The maximum distance a simplfied contour's border edges should deviate
  155610. * the original raw contour. [Limit: >=0] [Units: vx]
  155611. */
  155612. maxSimplificationError: number;
  155613. /**
  155614. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  155615. */
  155616. minRegionArea: number;
  155617. /**
  155618. * Any regions with a span count smaller than this value will, if possible,
  155619. * be merged with larger regions. [Limit: >=0] [Units: vx]
  155620. */
  155621. mergeRegionArea: number;
  155622. /**
  155623. * The maximum number of vertices allowed for polygons generated during the
  155624. * contour to polygon conversion process. [Limit: >= 3]
  155625. */
  155626. maxVertsPerPoly: number;
  155627. /**
  155628. * Sets the sampling distance to use when generating the detail mesh.
  155629. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  155630. */
  155631. detailSampleDist: number;
  155632. /**
  155633. * The maximum distance the detail mesh surface should deviate from heightfield
  155634. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  155635. */
  155636. detailSampleMaxError: number;
  155637. }
  155638. }
  155639. declare module BABYLON {
  155640. /**
  155641. * RecastJS navigation plugin
  155642. */
  155643. export class RecastJSPlugin implements INavigationEnginePlugin {
  155644. /**
  155645. * Reference to the Recast library
  155646. */
  155647. bjsRECAST: any;
  155648. /**
  155649. * plugin name
  155650. */
  155651. name: string;
  155652. /**
  155653. * the first navmesh created. We might extend this to support multiple navmeshes
  155654. */
  155655. navMesh: any;
  155656. private _maximumSubStepCount;
  155657. private _timeStep;
  155658. /**
  155659. * Initializes the recastJS plugin
  155660. * @param recastInjection can be used to inject your own recast reference
  155661. */
  155662. constructor(recastInjection?: any);
  155663. /**
  155664. * Set the time step of the navigation tick update.
  155665. * Default is 1/60.
  155666. * A value of 0 will disable fixed time update
  155667. * @param newTimeStep the new timestep to apply to this world.
  155668. */
  155669. setTimeStep(newTimeStep?: number): void;
  155670. /**
  155671. * Get the time step of the navigation tick update.
  155672. * @returns the current time step
  155673. */
  155674. getTimeStep(): number;
  155675. /**
  155676. * If delta time in navigation tick update is greater than the time step
  155677. * a number of sub iterations are done. If more iterations are need to reach deltatime
  155678. * they will be discarded.
  155679. * A value of 0 will set to no maximum and update will use as many substeps as needed
  155680. * @param newStepCount the maximum number of iterations
  155681. */
  155682. setMaximumSubStepCount(newStepCount?: number): void;
  155683. /**
  155684. * Get the maximum number of iterations per navigation tick update
  155685. * @returns the maximum number of iterations
  155686. */
  155687. getMaximumSubStepCount(): number;
  155688. /**
  155689. * Creates a navigation mesh
  155690. * @param meshes array of all the geometry used to compute the navigatio mesh
  155691. * @param parameters bunch of parameters used to filter geometry
  155692. */
  155693. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  155694. /**
  155695. * Create a navigation mesh debug mesh
  155696. * @param scene is where the mesh will be added
  155697. * @returns debug display mesh
  155698. */
  155699. createDebugNavMesh(scene: Scene): Mesh;
  155700. /**
  155701. * Get a navigation mesh constrained position, closest to the parameter position
  155702. * @param position world position
  155703. * @returns the closest point to position constrained by the navigation mesh
  155704. */
  155705. getClosestPoint(position: Vector3): Vector3;
  155706. /**
  155707. * Get a navigation mesh constrained position, closest to the parameter position
  155708. * @param position world position
  155709. * @param result output the closest point to position constrained by the navigation mesh
  155710. */
  155711. getClosestPointToRef(position: Vector3, result: Vector3): void;
  155712. /**
  155713. * Get a navigation mesh constrained position, within a particular radius
  155714. * @param position world position
  155715. * @param maxRadius the maximum distance to the constrained world position
  155716. * @returns the closest point to position constrained by the navigation mesh
  155717. */
  155718. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  155719. /**
  155720. * Get a navigation mesh constrained position, within a particular radius
  155721. * @param position world position
  155722. * @param maxRadius the maximum distance to the constrained world position
  155723. * @param result output the closest point to position constrained by the navigation mesh
  155724. */
  155725. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  155726. /**
  155727. * Compute the final position from a segment made of destination-position
  155728. * @param position world position
  155729. * @param destination world position
  155730. * @returns the resulting point along the navmesh
  155731. */
  155732. moveAlong(position: Vector3, destination: Vector3): Vector3;
  155733. /**
  155734. * Compute the final position from a segment made of destination-position
  155735. * @param position world position
  155736. * @param destination world position
  155737. * @param result output the resulting point along the navmesh
  155738. */
  155739. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  155740. /**
  155741. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  155742. * @param start world position
  155743. * @param end world position
  155744. * @returns array containing world position composing the path
  155745. */
  155746. computePath(start: Vector3, end: Vector3): Vector3[];
  155747. /**
  155748. * Create a new Crowd so you can add agents
  155749. * @param maxAgents the maximum agent count in the crowd
  155750. * @param maxAgentRadius the maximum radius an agent can have
  155751. * @param scene to attach the crowd to
  155752. * @returns the crowd you can add agents to
  155753. */
  155754. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  155755. /**
  155756. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155757. * The queries will try to find a solution within those bounds
  155758. * default is (1,1,1)
  155759. * @param extent x,y,z value that define the extent around the queries point of reference
  155760. */
  155761. setDefaultQueryExtent(extent: Vector3): void;
  155762. /**
  155763. * Get the Bounding box extent specified by setDefaultQueryExtent
  155764. * @returns the box extent values
  155765. */
  155766. getDefaultQueryExtent(): Vector3;
  155767. /**
  155768. * build the navmesh from a previously saved state using getNavmeshData
  155769. * @param data the Uint8Array returned by getNavmeshData
  155770. */
  155771. buildFromNavmeshData(data: Uint8Array): void;
  155772. /**
  155773. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  155774. * @returns data the Uint8Array that can be saved and reused
  155775. */
  155776. getNavmeshData(): Uint8Array;
  155777. /**
  155778. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155779. * @param result output the box extent values
  155780. */
  155781. getDefaultQueryExtentToRef(result: Vector3): void;
  155782. /**
  155783. * Disposes
  155784. */
  155785. dispose(): void;
  155786. /**
  155787. * If this plugin is supported
  155788. * @returns true if plugin is supported
  155789. */
  155790. isSupported(): boolean;
  155791. }
  155792. /**
  155793. * Recast detour crowd implementation
  155794. */
  155795. export class RecastJSCrowd implements ICrowd {
  155796. /**
  155797. * Recast/detour plugin
  155798. */
  155799. bjsRECASTPlugin: RecastJSPlugin;
  155800. /**
  155801. * Link to the detour crowd
  155802. */
  155803. recastCrowd: any;
  155804. /**
  155805. * One transform per agent
  155806. */
  155807. transforms: TransformNode[];
  155808. /**
  155809. * All agents created
  155810. */
  155811. agents: number[];
  155812. /**
  155813. * Link to the scene is kept to unregister the crowd from the scene
  155814. */
  155815. private _scene;
  155816. /**
  155817. * Observer for crowd updates
  155818. */
  155819. private _onBeforeAnimationsObserver;
  155820. /**
  155821. * Constructor
  155822. * @param plugin recastJS plugin
  155823. * @param maxAgents the maximum agent count in the crowd
  155824. * @param maxAgentRadius the maximum radius an agent can have
  155825. * @param scene to attach the crowd to
  155826. * @returns the crowd you can add agents to
  155827. */
  155828. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  155829. /**
  155830. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  155831. * You can attach anything to that node. The node position is updated in the scene update tick.
  155832. * @param pos world position that will be constrained by the navigation mesh
  155833. * @param parameters agent parameters
  155834. * @param transform hooked to the agent that will be update by the scene
  155835. * @returns agent index
  155836. */
  155837. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  155838. /**
  155839. * Returns the agent position in world space
  155840. * @param index agent index returned by addAgent
  155841. * @returns world space position
  155842. */
  155843. getAgentPosition(index: number): Vector3;
  155844. /**
  155845. * Returns the agent position result in world space
  155846. * @param index agent index returned by addAgent
  155847. * @param result output world space position
  155848. */
  155849. getAgentPositionToRef(index: number, result: Vector3): void;
  155850. /**
  155851. * Returns the agent velocity in world space
  155852. * @param index agent index returned by addAgent
  155853. * @returns world space velocity
  155854. */
  155855. getAgentVelocity(index: number): Vector3;
  155856. /**
  155857. * Returns the agent velocity result in world space
  155858. * @param index agent index returned by addAgent
  155859. * @param result output world space velocity
  155860. */
  155861. getAgentVelocityToRef(index: number, result: Vector3): void;
  155862. /**
  155863. * Returns the agent next target point on the path
  155864. * @param index agent index returned by addAgent
  155865. * @returns world space position
  155866. */
  155867. getAgentNextTargetPath(index: number): Vector3;
  155868. /**
  155869. * Returns the agent next target point on the path
  155870. * @param index agent index returned by addAgent
  155871. * @param result output world space position
  155872. */
  155873. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  155874. /**
  155875. * Gets the agent state
  155876. * @param index agent index returned by addAgent
  155877. * @returns agent state
  155878. */
  155879. getAgentState(index: number): number;
  155880. /**
  155881. * returns true if the agent in over an off mesh link connection
  155882. * @param index agent index returned by addAgent
  155883. * @returns true if over an off mesh link connection
  155884. */
  155885. overOffmeshConnection(index: number): boolean;
  155886. /**
  155887. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  155888. * @param index agent index returned by addAgent
  155889. * @param destination targeted world position
  155890. */
  155891. agentGoto(index: number, destination: Vector3): void;
  155892. /**
  155893. * Teleport the agent to a new position
  155894. * @param index agent index returned by addAgent
  155895. * @param destination targeted world position
  155896. */
  155897. agentTeleport(index: number, destination: Vector3): void;
  155898. /**
  155899. * Update agent parameters
  155900. * @param index agent index returned by addAgent
  155901. * @param parameters agent parameters
  155902. */
  155903. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  155904. /**
  155905. * remove a particular agent previously created
  155906. * @param index agent index returned by addAgent
  155907. */
  155908. removeAgent(index: number): void;
  155909. /**
  155910. * get the list of all agents attached to this crowd
  155911. * @returns list of agent indices
  155912. */
  155913. getAgents(): number[];
  155914. /**
  155915. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  155916. * @param deltaTime in seconds
  155917. */
  155918. update(deltaTime: number): void;
  155919. /**
  155920. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155921. * The queries will try to find a solution within those bounds
  155922. * default is (1,1,1)
  155923. * @param extent x,y,z value that define the extent around the queries point of reference
  155924. */
  155925. setDefaultQueryExtent(extent: Vector3): void;
  155926. /**
  155927. * Get the Bounding box extent specified by setDefaultQueryExtent
  155928. * @returns the box extent values
  155929. */
  155930. getDefaultQueryExtent(): Vector3;
  155931. /**
  155932. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155933. * @param result output the box extent values
  155934. */
  155935. getDefaultQueryExtentToRef(result: Vector3): void;
  155936. /**
  155937. * Release all resources
  155938. */
  155939. dispose(): void;
  155940. }
  155941. }
  155942. declare module BABYLON {
  155943. /**
  155944. * Class used to enable access to IndexedDB
  155945. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  155946. */
  155947. export class Database implements IOfflineProvider {
  155948. private _callbackManifestChecked;
  155949. private _currentSceneUrl;
  155950. private _db;
  155951. private _enableSceneOffline;
  155952. private _enableTexturesOffline;
  155953. private _manifestVersionFound;
  155954. private _mustUpdateRessources;
  155955. private _hasReachedQuota;
  155956. private _isSupported;
  155957. private _idbFactory;
  155958. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  155959. private static IsUASupportingBlobStorage;
  155960. /**
  155961. * Gets a boolean indicating if Database storate is enabled (off by default)
  155962. */
  155963. static IDBStorageEnabled: boolean;
  155964. /**
  155965. * Gets a boolean indicating if scene must be saved in the database
  155966. */
  155967. get enableSceneOffline(): boolean;
  155968. /**
  155969. * Gets a boolean indicating if textures must be saved in the database
  155970. */
  155971. get enableTexturesOffline(): boolean;
  155972. /**
  155973. * Creates a new Database
  155974. * @param urlToScene defines the url to load the scene
  155975. * @param callbackManifestChecked defines the callback to use when manifest is checked
  155976. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  155977. */
  155978. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  155979. private static _ParseURL;
  155980. private static _ReturnFullUrlLocation;
  155981. private _checkManifestFile;
  155982. /**
  155983. * Open the database and make it available
  155984. * @param successCallback defines the callback to call on success
  155985. * @param errorCallback defines the callback to call on error
  155986. */
  155987. open(successCallback: () => void, errorCallback: () => void): void;
  155988. /**
  155989. * Loads an image from the database
  155990. * @param url defines the url to load from
  155991. * @param image defines the target DOM image
  155992. */
  155993. loadImage(url: string, image: HTMLImageElement): void;
  155994. private _loadImageFromDBAsync;
  155995. private _saveImageIntoDBAsync;
  155996. private _checkVersionFromDB;
  155997. private _loadVersionFromDBAsync;
  155998. private _saveVersionIntoDBAsync;
  155999. /**
  156000. * Loads a file from database
  156001. * @param url defines the URL to load from
  156002. * @param sceneLoaded defines a callback to call on success
  156003. * @param progressCallBack defines a callback to call when progress changed
  156004. * @param errorCallback defines a callback to call on error
  156005. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  156006. */
  156007. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  156008. private _loadFileAsync;
  156009. private _saveFileAsync;
  156010. /**
  156011. * Validates if xhr data is correct
  156012. * @param xhr defines the request to validate
  156013. * @param dataType defines the expected data type
  156014. * @returns true if data is correct
  156015. */
  156016. private static _ValidateXHRData;
  156017. }
  156018. }
  156019. declare module BABYLON {
  156020. /** @hidden */
  156021. export var gpuUpdateParticlesPixelShader: {
  156022. name: string;
  156023. shader: string;
  156024. };
  156025. }
  156026. declare module BABYLON {
  156027. /** @hidden */
  156028. export var gpuUpdateParticlesVertexShader: {
  156029. name: string;
  156030. shader: string;
  156031. };
  156032. }
  156033. declare module BABYLON {
  156034. /** @hidden */
  156035. export var clipPlaneFragmentDeclaration2: {
  156036. name: string;
  156037. shader: string;
  156038. };
  156039. }
  156040. declare module BABYLON {
  156041. /** @hidden */
  156042. export var gpuRenderParticlesPixelShader: {
  156043. name: string;
  156044. shader: string;
  156045. };
  156046. }
  156047. declare module BABYLON {
  156048. /** @hidden */
  156049. export var clipPlaneVertexDeclaration2: {
  156050. name: string;
  156051. shader: string;
  156052. };
  156053. }
  156054. declare module BABYLON {
  156055. /** @hidden */
  156056. export var gpuRenderParticlesVertexShader: {
  156057. name: string;
  156058. shader: string;
  156059. };
  156060. }
  156061. declare module BABYLON {
  156062. /**
  156063. * This represents a GPU particle system in Babylon
  156064. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  156065. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  156066. */
  156067. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  156068. /**
  156069. * The layer mask we are rendering the particles through.
  156070. */
  156071. layerMask: number;
  156072. private _capacity;
  156073. private _activeCount;
  156074. private _currentActiveCount;
  156075. private _accumulatedCount;
  156076. private _renderEffect;
  156077. private _updateEffect;
  156078. private _buffer0;
  156079. private _buffer1;
  156080. private _spriteBuffer;
  156081. private _updateVAO;
  156082. private _renderVAO;
  156083. private _targetIndex;
  156084. private _sourceBuffer;
  156085. private _targetBuffer;
  156086. private _currentRenderId;
  156087. private _started;
  156088. private _stopped;
  156089. private _timeDelta;
  156090. private _randomTexture;
  156091. private _randomTexture2;
  156092. private _attributesStrideSize;
  156093. private _updateEffectOptions;
  156094. private _randomTextureSize;
  156095. private _actualFrame;
  156096. private _customEffect;
  156097. private readonly _rawTextureWidth;
  156098. /**
  156099. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  156100. */
  156101. static get IsSupported(): boolean;
  156102. /**
  156103. * An event triggered when the system is disposed.
  156104. */
  156105. onDisposeObservable: Observable<IParticleSystem>;
  156106. /**
  156107. * An event triggered when the system is stopped
  156108. */
  156109. onStoppedObservable: Observable<IParticleSystem>;
  156110. /**
  156111. * Gets the maximum number of particles active at the same time.
  156112. * @returns The max number of active particles.
  156113. */
  156114. getCapacity(): number;
  156115. /**
  156116. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  156117. * to override the particles.
  156118. */
  156119. forceDepthWrite: boolean;
  156120. /**
  156121. * Gets or set the number of active particles
  156122. */
  156123. get activeParticleCount(): number;
  156124. set activeParticleCount(value: number);
  156125. private _preWarmDone;
  156126. /**
  156127. * Specifies if the particles are updated in emitter local space or world space.
  156128. */
  156129. isLocal: boolean;
  156130. /** Gets or sets a matrix to use to compute projection */
  156131. defaultProjectionMatrix: Matrix;
  156132. /**
  156133. * Is this system ready to be used/rendered
  156134. * @return true if the system is ready
  156135. */
  156136. isReady(): boolean;
  156137. /**
  156138. * Gets if the system has been started. (Note: this will still be true after stop is called)
  156139. * @returns True if it has been started, otherwise false.
  156140. */
  156141. isStarted(): boolean;
  156142. /**
  156143. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  156144. * @returns True if it has been stopped, otherwise false.
  156145. */
  156146. isStopped(): boolean;
  156147. /**
  156148. * Gets a boolean indicating that the system is stopping
  156149. * @returns true if the system is currently stopping
  156150. */
  156151. isStopping(): boolean;
  156152. /**
  156153. * Gets the number of particles active at the same time.
  156154. * @returns The number of active particles.
  156155. */
  156156. getActiveCount(): number;
  156157. /**
  156158. * Starts the particle system and begins to emit
  156159. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  156160. */
  156161. start(delay?: number): void;
  156162. /**
  156163. * Stops the particle system.
  156164. */
  156165. stop(): void;
  156166. /**
  156167. * Remove all active particles
  156168. */
  156169. reset(): void;
  156170. /**
  156171. * Returns the string "GPUParticleSystem"
  156172. * @returns a string containing the class name
  156173. */
  156174. getClassName(): string;
  156175. /**
  156176. * Gets the custom effect used to render the particles
  156177. * @param blendMode Blend mode for which the effect should be retrieved
  156178. * @returns The effect
  156179. */
  156180. getCustomEffect(blendMode?: number): Nullable<Effect>;
  156181. /**
  156182. * Sets the custom effect used to render the particles
  156183. * @param effect The effect to set
  156184. * @param blendMode Blend mode for which the effect should be set
  156185. */
  156186. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  156187. /** @hidden */
  156188. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  156189. /**
  156190. * Observable that will be called just before the particles are drawn
  156191. */
  156192. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  156193. /**
  156194. * Gets the name of the particle vertex shader
  156195. */
  156196. get vertexShaderName(): string;
  156197. private _colorGradientsTexture;
  156198. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  156199. /**
  156200. * Adds a new color gradient
  156201. * @param gradient defines the gradient to use (between 0 and 1)
  156202. * @param color1 defines the color to affect to the specified gradient
  156203. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  156204. * @returns the current particle system
  156205. */
  156206. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  156207. private _refreshColorGradient;
  156208. /** Force the system to rebuild all gradients that need to be resync */
  156209. forceRefreshGradients(): void;
  156210. /**
  156211. * Remove a specific color gradient
  156212. * @param gradient defines the gradient to remove
  156213. * @returns the current particle system
  156214. */
  156215. removeColorGradient(gradient: number): GPUParticleSystem;
  156216. private _angularSpeedGradientsTexture;
  156217. private _sizeGradientsTexture;
  156218. private _velocityGradientsTexture;
  156219. private _limitVelocityGradientsTexture;
  156220. private _dragGradientsTexture;
  156221. private _addFactorGradient;
  156222. /**
  156223. * Adds a new size gradient
  156224. * @param gradient defines the gradient to use (between 0 and 1)
  156225. * @param factor defines the size factor to affect to the specified gradient
  156226. * @returns the current particle system
  156227. */
  156228. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  156229. /**
  156230. * Remove a specific size gradient
  156231. * @param gradient defines the gradient to remove
  156232. * @returns the current particle system
  156233. */
  156234. removeSizeGradient(gradient: number): GPUParticleSystem;
  156235. private _refreshFactorGradient;
  156236. /**
  156237. * Adds a new angular speed gradient
  156238. * @param gradient defines the gradient to use (between 0 and 1)
  156239. * @param factor defines the angular speed to affect to the specified gradient
  156240. * @returns the current particle system
  156241. */
  156242. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  156243. /**
  156244. * Remove a specific angular speed gradient
  156245. * @param gradient defines the gradient to remove
  156246. * @returns the current particle system
  156247. */
  156248. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  156249. /**
  156250. * Adds a new velocity gradient
  156251. * @param gradient defines the gradient to use (between 0 and 1)
  156252. * @param factor defines the velocity to affect to the specified gradient
  156253. * @returns the current particle system
  156254. */
  156255. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  156256. /**
  156257. * Remove a specific velocity gradient
  156258. * @param gradient defines the gradient to remove
  156259. * @returns the current particle system
  156260. */
  156261. removeVelocityGradient(gradient: number): GPUParticleSystem;
  156262. /**
  156263. * Adds a new limit velocity gradient
  156264. * @param gradient defines the gradient to use (between 0 and 1)
  156265. * @param factor defines the limit velocity value to affect to the specified gradient
  156266. * @returns the current particle system
  156267. */
  156268. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  156269. /**
  156270. * Remove a specific limit velocity gradient
  156271. * @param gradient defines the gradient to remove
  156272. * @returns the current particle system
  156273. */
  156274. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  156275. /**
  156276. * Adds a new drag gradient
  156277. * @param gradient defines the gradient to use (between 0 and 1)
  156278. * @param factor defines the drag value to affect to the specified gradient
  156279. * @returns the current particle system
  156280. */
  156281. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  156282. /**
  156283. * Remove a specific drag gradient
  156284. * @param gradient defines the gradient to remove
  156285. * @returns the current particle system
  156286. */
  156287. removeDragGradient(gradient: number): GPUParticleSystem;
  156288. /**
  156289. * Not supported by GPUParticleSystem
  156290. * @param gradient defines the gradient to use (between 0 and 1)
  156291. * @param factor defines the emit rate value to affect to the specified gradient
  156292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156293. * @returns the current particle system
  156294. */
  156295. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156296. /**
  156297. * Not supported by GPUParticleSystem
  156298. * @param gradient defines the gradient to remove
  156299. * @returns the current particle system
  156300. */
  156301. removeEmitRateGradient(gradient: number): IParticleSystem;
  156302. /**
  156303. * Not supported by GPUParticleSystem
  156304. * @param gradient defines the gradient to use (between 0 and 1)
  156305. * @param factor defines the start size value to affect to the specified gradient
  156306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156307. * @returns the current particle system
  156308. */
  156309. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156310. /**
  156311. * Not supported by GPUParticleSystem
  156312. * @param gradient defines the gradient to remove
  156313. * @returns the current particle system
  156314. */
  156315. removeStartSizeGradient(gradient: number): IParticleSystem;
  156316. /**
  156317. * Not supported by GPUParticleSystem
  156318. * @param gradient defines the gradient to use (between 0 and 1)
  156319. * @param min defines the color remap minimal range
  156320. * @param max defines the color remap maximal range
  156321. * @returns the current particle system
  156322. */
  156323. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  156324. /**
  156325. * Not supported by GPUParticleSystem
  156326. * @param gradient defines the gradient to remove
  156327. * @returns the current particle system
  156328. */
  156329. removeColorRemapGradient(): IParticleSystem;
  156330. /**
  156331. * Not supported by GPUParticleSystem
  156332. * @param gradient defines the gradient to use (between 0 and 1)
  156333. * @param min defines the alpha remap minimal range
  156334. * @param max defines the alpha remap maximal range
  156335. * @returns the current particle system
  156336. */
  156337. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  156338. /**
  156339. * Not supported by GPUParticleSystem
  156340. * @param gradient defines the gradient to remove
  156341. * @returns the current particle system
  156342. */
  156343. removeAlphaRemapGradient(): IParticleSystem;
  156344. /**
  156345. * Not supported by GPUParticleSystem
  156346. * @param gradient defines the gradient to use (between 0 and 1)
  156347. * @param color defines the color to affect to the specified gradient
  156348. * @returns the current particle system
  156349. */
  156350. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  156351. /**
  156352. * Not supported by GPUParticleSystem
  156353. * @param gradient defines the gradient to remove
  156354. * @returns the current particle system
  156355. */
  156356. removeRampGradient(): IParticleSystem;
  156357. /**
  156358. * Not supported by GPUParticleSystem
  156359. * @returns the list of ramp gradients
  156360. */
  156361. getRampGradients(): Nullable<Array<Color3Gradient>>;
  156362. /**
  156363. * Not supported by GPUParticleSystem
  156364. * Gets or sets a boolean indicating that ramp gradients must be used
  156365. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  156366. */
  156367. get useRampGradients(): boolean;
  156368. set useRampGradients(value: boolean);
  156369. /**
  156370. * Not supported by GPUParticleSystem
  156371. * @param gradient defines the gradient to use (between 0 and 1)
  156372. * @param factor defines the life time factor to affect to the specified gradient
  156373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156374. * @returns the current particle system
  156375. */
  156376. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156377. /**
  156378. * Not supported by GPUParticleSystem
  156379. * @param gradient defines the gradient to remove
  156380. * @returns the current particle system
  156381. */
  156382. removeLifeTimeGradient(gradient: number): IParticleSystem;
  156383. /**
  156384. * Instantiates a GPU particle system.
  156385. * 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.
  156386. * @param name The name of the particle system
  156387. * @param options The options used to create the system
  156388. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  156389. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  156390. * @param customEffect a custom effect used to change the way particles are rendered by default
  156391. */
  156392. constructor(name: string, options: Partial<{
  156393. capacity: number;
  156394. randomTextureSize: number;
  156395. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  156396. protected _reset(): void;
  156397. private _createUpdateVAO;
  156398. private _createRenderVAO;
  156399. private _initialize;
  156400. /** @hidden */
  156401. _recreateUpdateEffect(): void;
  156402. private _getEffect;
  156403. /**
  156404. * Fill the defines array according to the current settings of the particle system
  156405. * @param defines Array to be updated
  156406. * @param blendMode blend mode to take into account when updating the array
  156407. */
  156408. fillDefines(defines: Array<string>, blendMode?: number): void;
  156409. /**
  156410. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  156411. * @param uniforms Uniforms array to fill
  156412. * @param attributes Attributes array to fill
  156413. * @param samplers Samplers array to fill
  156414. */
  156415. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  156416. /** @hidden */
  156417. _recreateRenderEffect(): Effect;
  156418. /**
  156419. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  156420. * @param preWarm defines if we are in the pre-warmimg phase
  156421. */
  156422. animate(preWarm?: boolean): void;
  156423. private _createFactorGradientTexture;
  156424. private _createSizeGradientTexture;
  156425. private _createAngularSpeedGradientTexture;
  156426. private _createVelocityGradientTexture;
  156427. private _createLimitVelocityGradientTexture;
  156428. private _createDragGradientTexture;
  156429. private _createColorGradientTexture;
  156430. /**
  156431. * Renders the particle system in its current state
  156432. * @param preWarm defines if the system should only update the particles but not render them
  156433. * @returns the current number of particles
  156434. */
  156435. render(preWarm?: boolean): number;
  156436. /**
  156437. * Rebuilds the particle system
  156438. */
  156439. rebuild(): void;
  156440. private _releaseBuffers;
  156441. private _releaseVAOs;
  156442. /**
  156443. * Disposes the particle system and free the associated resources
  156444. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  156445. */
  156446. dispose(disposeTexture?: boolean): void;
  156447. /**
  156448. * Clones the particle system.
  156449. * @param name The name of the cloned object
  156450. * @param newEmitter The new emitter to use
  156451. * @returns the cloned particle system
  156452. */
  156453. clone(name: string, newEmitter: any): GPUParticleSystem;
  156454. /**
  156455. * Serializes the particle system to a JSON object
  156456. * @param serializeTexture defines if the texture must be serialized as well
  156457. * @returns the JSON object
  156458. */
  156459. serialize(serializeTexture?: boolean): any;
  156460. /**
  156461. * Parses a JSON object to create a GPU particle system.
  156462. * @param parsedParticleSystem The JSON object to parse
  156463. * @param sceneOrEngine The scene or the engine to create the particle system in
  156464. * @param rootUrl The root url to use to load external dependencies like texture
  156465. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  156466. * @returns the parsed GPU particle system
  156467. */
  156468. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  156469. }
  156470. }
  156471. declare module BABYLON {
  156472. /**
  156473. * Represents a set of particle systems working together to create a specific effect
  156474. */
  156475. export class ParticleSystemSet implements IDisposable {
  156476. /**
  156477. * Gets or sets base Assets URL
  156478. */
  156479. static BaseAssetsUrl: string;
  156480. private _emitterCreationOptions;
  156481. private _emitterNode;
  156482. /**
  156483. * Gets the particle system list
  156484. */
  156485. systems: IParticleSystem[];
  156486. /**
  156487. * Gets the emitter node used with this set
  156488. */
  156489. get emitterNode(): Nullable<TransformNode>;
  156490. /**
  156491. * Creates a new emitter mesh as a sphere
  156492. * @param options defines the options used to create the sphere
  156493. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  156494. * @param scene defines the hosting scene
  156495. */
  156496. setEmitterAsSphere(options: {
  156497. diameter: number;
  156498. segments: number;
  156499. color: Color3;
  156500. }, renderingGroupId: number, scene: Scene): void;
  156501. /**
  156502. * Starts all particle systems of the set
  156503. * @param emitter defines an optional mesh to use as emitter for the particle systems
  156504. */
  156505. start(emitter?: AbstractMesh): void;
  156506. /**
  156507. * Release all associated resources
  156508. */
  156509. dispose(): void;
  156510. /**
  156511. * Serialize the set into a JSON compatible object
  156512. * @param serializeTexture defines if the texture must be serialized as well
  156513. * @returns a JSON compatible representation of the set
  156514. */
  156515. serialize(serializeTexture?: boolean): any;
  156516. /**
  156517. * Parse a new ParticleSystemSet from a serialized source
  156518. * @param data defines a JSON compatible representation of the set
  156519. * @param scene defines the hosting scene
  156520. * @param gpu defines if we want GPU particles or CPU particles
  156521. * @returns a new ParticleSystemSet
  156522. */
  156523. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  156524. }
  156525. }
  156526. declare module BABYLON {
  156527. /**
  156528. * This class is made for on one-liner static method to help creating particle system set.
  156529. */
  156530. export class ParticleHelper {
  156531. /**
  156532. * Gets or sets base Assets URL
  156533. */
  156534. static BaseAssetsUrl: string;
  156535. /** Define the Url to load snippets */
  156536. static SnippetUrl: string;
  156537. /**
  156538. * Create a default particle system that you can tweak
  156539. * @param emitter defines the emitter to use
  156540. * @param capacity defines the system capacity (default is 500 particles)
  156541. * @param scene defines the hosting scene
  156542. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  156543. * @returns the new Particle system
  156544. */
  156545. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  156546. /**
  156547. * This is the main static method (one-liner) of this helper to create different particle systems
  156548. * @param type This string represents the type to the particle system to create
  156549. * @param scene The scene where the particle system should live
  156550. * @param gpu If the system will use gpu
  156551. * @returns the ParticleSystemSet created
  156552. */
  156553. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  156554. /**
  156555. * Static function used to export a particle system to a ParticleSystemSet variable.
  156556. * Please note that the emitter shape is not exported
  156557. * @param systems defines the particle systems to export
  156558. * @returns the created particle system set
  156559. */
  156560. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  156561. /**
  156562. * Creates a particle system from a snippet saved in a remote file
  156563. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  156564. * @param url defines the url to load from
  156565. * @param scene defines the hosting scene
  156566. * @param gpu If the system will use gpu
  156567. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  156568. * @returns a promise that will resolve to the new particle system
  156569. */
  156570. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  156571. /**
  156572. * Creates a particle system from a snippet saved by the particle system editor
  156573. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  156574. * @param scene defines the hosting scene
  156575. * @param gpu If the system will use gpu
  156576. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  156577. * @returns a promise that will resolve to the new particle system
  156578. */
  156579. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  156580. }
  156581. }
  156582. declare module BABYLON {
  156583. interface Engine {
  156584. /**
  156585. * Create an effect to use with particle systems.
  156586. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  156587. * the particle system for which you want to create a custom effect in the last parameter
  156588. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  156589. * @param uniformsNames defines a list of attribute names
  156590. * @param samplers defines an array of string used to represent textures
  156591. * @param defines defines the string containing the defines to use to compile the shaders
  156592. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  156593. * @param onCompiled defines a function to call when the effect creation is successful
  156594. * @param onError defines a function to call when the effect creation has failed
  156595. * @param particleSystem the particle system you want to create the effect for
  156596. * @returns the new Effect
  156597. */
  156598. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  156599. }
  156600. interface Mesh {
  156601. /**
  156602. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  156603. * @returns an array of IParticleSystem
  156604. */
  156605. getEmittedParticleSystems(): IParticleSystem[];
  156606. /**
  156607. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  156608. * @returns an array of IParticleSystem
  156609. */
  156610. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  156611. }
  156612. }
  156613. declare module BABYLON {
  156614. /** Defines the 4 color options */
  156615. export enum PointColor {
  156616. /** color value */
  156617. Color = 2,
  156618. /** uv value */
  156619. UV = 1,
  156620. /** random value */
  156621. Random = 0,
  156622. /** stated value */
  156623. Stated = 3
  156624. }
  156625. /**
  156626. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  156627. * 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.
  156628. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  156629. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  156630. *
  156631. * Full documentation here : TO BE ENTERED
  156632. */
  156633. export class PointsCloudSystem implements IDisposable {
  156634. /**
  156635. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  156636. * Example : var p = SPS.particles[i];
  156637. */
  156638. particles: CloudPoint[];
  156639. /**
  156640. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  156641. */
  156642. nbParticles: number;
  156643. /**
  156644. * This a counter for your own usage. It's not set by any SPS functions.
  156645. */
  156646. counter: number;
  156647. /**
  156648. * The PCS name. This name is also given to the underlying mesh.
  156649. */
  156650. name: string;
  156651. /**
  156652. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  156653. */
  156654. mesh: Mesh;
  156655. /**
  156656. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  156657. * Please read :
  156658. */
  156659. vars: any;
  156660. /**
  156661. * @hidden
  156662. */
  156663. _size: number;
  156664. private _scene;
  156665. private _promises;
  156666. private _positions;
  156667. private _indices;
  156668. private _normals;
  156669. private _colors;
  156670. private _uvs;
  156671. private _indices32;
  156672. private _positions32;
  156673. private _colors32;
  156674. private _uvs32;
  156675. private _updatable;
  156676. private _isVisibilityBoxLocked;
  156677. private _alwaysVisible;
  156678. private _groups;
  156679. private _groupCounter;
  156680. private _computeParticleColor;
  156681. private _computeParticleTexture;
  156682. private _computeParticleRotation;
  156683. private _computeBoundingBox;
  156684. private _isReady;
  156685. /**
  156686. * Creates a PCS (Points Cloud System) object
  156687. * @param name (String) is the PCS name, this will be the underlying mesh name
  156688. * @param pointSize (number) is the size for each point
  156689. * @param scene (Scene) is the scene in which the PCS is added
  156690. * @param options defines the options of the PCS e.g.
  156691. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  156692. */
  156693. constructor(name: string, pointSize: number, scene: Scene, options?: {
  156694. updatable?: boolean;
  156695. });
  156696. /**
  156697. * Builds the PCS underlying mesh. Returns a standard Mesh.
  156698. * If no points were added to the PCS, the returned mesh is just a single point.
  156699. * @returns a promise for the created mesh
  156700. */
  156701. buildMeshAsync(): Promise<Mesh>;
  156702. /**
  156703. * @hidden
  156704. */
  156705. private _buildMesh;
  156706. private _addParticle;
  156707. private _randomUnitVector;
  156708. private _getColorIndicesForCoord;
  156709. private _setPointsColorOrUV;
  156710. private _colorFromTexture;
  156711. private _calculateDensity;
  156712. /**
  156713. * Adds points to the PCS in random positions within a unit sphere
  156714. * @param nb (positive integer) the number of particles to be created from this model
  156715. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  156716. * @returns the number of groups in the system
  156717. */
  156718. addPoints(nb: number, pointFunction?: any): number;
  156719. /**
  156720. * Adds points to the PCS from the surface of the model shape
  156721. * @param mesh is any Mesh object that will be used as a surface model for the points
  156722. * @param nb (positive integer) the number of particles to be created from this model
  156723. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  156724. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  156725. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  156726. * @returns the number of groups in the system
  156727. */
  156728. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  156729. /**
  156730. * Adds points to the PCS inside the model shape
  156731. * @param mesh is any Mesh object that will be used as a surface model for the points
  156732. * @param nb (positive integer) the number of particles to be created from this model
  156733. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  156734. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  156735. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  156736. * @returns the number of groups in the system
  156737. */
  156738. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  156739. /**
  156740. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  156741. * This method calls `updateParticle()` for each particle of the SPS.
  156742. * For an animated SPS, it is usually called within the render loop.
  156743. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  156744. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  156745. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  156746. * @returns the PCS.
  156747. */
  156748. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  156749. /**
  156750. * Disposes the PCS.
  156751. */
  156752. dispose(): void;
  156753. /**
  156754. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  156755. * doc :
  156756. * @returns the PCS.
  156757. */
  156758. refreshVisibleSize(): PointsCloudSystem;
  156759. /**
  156760. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  156761. * @param size the size (float) of the visibility box
  156762. * note : this doesn't lock the PCS mesh bounding box.
  156763. * doc :
  156764. */
  156765. setVisibilityBox(size: number): void;
  156766. /**
  156767. * Gets whether the PCS is always visible or not
  156768. * doc :
  156769. */
  156770. get isAlwaysVisible(): boolean;
  156771. /**
  156772. * Sets the PCS as always visible or not
  156773. * doc :
  156774. */
  156775. set isAlwaysVisible(val: boolean);
  156776. /**
  156777. * Tells to `setParticles()` to compute the particle rotations or not
  156778. * Default value : false. The PCS is faster when it's set to false
  156779. * Note : particle rotations are only applied to parent particles
  156780. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  156781. */
  156782. set computeParticleRotation(val: boolean);
  156783. /**
  156784. * Tells to `setParticles()` to compute the particle colors or not.
  156785. * Default value : true. The PCS is faster when it's set to false.
  156786. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  156787. */
  156788. set computeParticleColor(val: boolean);
  156789. set computeParticleTexture(val: boolean);
  156790. /**
  156791. * Gets if `setParticles()` computes the particle colors or not.
  156792. * Default value : false. The PCS is faster when it's set to false.
  156793. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  156794. */
  156795. get computeParticleColor(): boolean;
  156796. /**
  156797. * Gets if `setParticles()` computes the particle textures or not.
  156798. * Default value : false. The PCS is faster when it's set to false.
  156799. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  156800. */
  156801. get computeParticleTexture(): boolean;
  156802. /**
  156803. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  156804. */
  156805. set computeBoundingBox(val: boolean);
  156806. /**
  156807. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  156808. */
  156809. get computeBoundingBox(): boolean;
  156810. /**
  156811. * This function does nothing. It may be overwritten to set all the particle first values.
  156812. * The PCS doesn't call this function, you may have to call it by your own.
  156813. * doc :
  156814. */
  156815. initParticles(): void;
  156816. /**
  156817. * This function does nothing. It may be overwritten to recycle a particle
  156818. * The PCS doesn't call this function, you can to call it
  156819. * doc :
  156820. * @param particle The particle to recycle
  156821. * @returns the recycled particle
  156822. */
  156823. recycleParticle(particle: CloudPoint): CloudPoint;
  156824. /**
  156825. * Updates a particle : this function should be overwritten by the user.
  156826. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  156827. * doc :
  156828. * @example : just set a particle position or velocity and recycle conditions
  156829. * @param particle The particle to update
  156830. * @returns the updated particle
  156831. */
  156832. updateParticle(particle: CloudPoint): CloudPoint;
  156833. /**
  156834. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  156835. * This does nothing and may be overwritten by the user.
  156836. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  156837. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  156838. * @param update the boolean update value actually passed to setParticles()
  156839. */
  156840. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  156841. /**
  156842. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  156843. * This will be passed three parameters.
  156844. * This does nothing and may be overwritten by the user.
  156845. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  156846. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  156847. * @param update the boolean update value actually passed to setParticles()
  156848. */
  156849. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  156850. }
  156851. }
  156852. declare module BABYLON {
  156853. /**
  156854. * Represents one particle of a points cloud system.
  156855. */
  156856. export class CloudPoint {
  156857. /**
  156858. * particle global index
  156859. */
  156860. idx: number;
  156861. /**
  156862. * The color of the particle
  156863. */
  156864. color: Nullable<Color4>;
  156865. /**
  156866. * The world space position of the particle.
  156867. */
  156868. position: Vector3;
  156869. /**
  156870. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  156871. */
  156872. rotation: Vector3;
  156873. /**
  156874. * The world space rotation quaternion of the particle.
  156875. */
  156876. rotationQuaternion: Nullable<Quaternion>;
  156877. /**
  156878. * The uv of the particle.
  156879. */
  156880. uv: Nullable<Vector2>;
  156881. /**
  156882. * The current speed of the particle.
  156883. */
  156884. velocity: Vector3;
  156885. /**
  156886. * The pivot point in the particle local space.
  156887. */
  156888. pivot: Vector3;
  156889. /**
  156890. * Must the particle be translated from its pivot point in its local space ?
  156891. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  156892. * Default : false
  156893. */
  156894. translateFromPivot: boolean;
  156895. /**
  156896. * Index of this particle in the global "positions" array (Internal use)
  156897. * @hidden
  156898. */
  156899. _pos: number;
  156900. /**
  156901. * @hidden Index of this particle in the global "indices" array (Internal use)
  156902. */
  156903. _ind: number;
  156904. /**
  156905. * Group this particle belongs to
  156906. */
  156907. _group: PointsGroup;
  156908. /**
  156909. * Group id of this particle
  156910. */
  156911. groupId: number;
  156912. /**
  156913. * Index of the particle in its group id (Internal use)
  156914. */
  156915. idxInGroup: number;
  156916. /**
  156917. * @hidden Particle BoundingInfo object (Internal use)
  156918. */
  156919. _boundingInfo: BoundingInfo;
  156920. /**
  156921. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  156922. */
  156923. _pcs: PointsCloudSystem;
  156924. /**
  156925. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  156926. */
  156927. _stillInvisible: boolean;
  156928. /**
  156929. * @hidden Last computed particle rotation matrix
  156930. */
  156931. _rotationMatrix: number[];
  156932. /**
  156933. * Parent particle Id, if any.
  156934. * Default null.
  156935. */
  156936. parentId: Nullable<number>;
  156937. /**
  156938. * @hidden Internal global position in the PCS.
  156939. */
  156940. _globalPosition: Vector3;
  156941. /**
  156942. * Creates a Point Cloud object.
  156943. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  156944. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  156945. * @param group (PointsGroup) is the group the particle belongs to
  156946. * @param groupId (integer) is the group identifier in the PCS.
  156947. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  156948. * @param pcs defines the PCS it is associated to
  156949. */
  156950. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  156951. /**
  156952. * get point size
  156953. */
  156954. get size(): Vector3;
  156955. /**
  156956. * Set point size
  156957. */
  156958. set size(scale: Vector3);
  156959. /**
  156960. * Legacy support, changed quaternion to rotationQuaternion
  156961. */
  156962. get quaternion(): Nullable<Quaternion>;
  156963. /**
  156964. * Legacy support, changed quaternion to rotationQuaternion
  156965. */
  156966. set quaternion(q: Nullable<Quaternion>);
  156967. /**
  156968. * Returns a boolean. True if the particle intersects a mesh, else false
  156969. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  156970. * @param target is the object (point or mesh) what the intersection is computed against
  156971. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  156972. * @returns true if it intersects
  156973. */
  156974. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  156975. /**
  156976. * get the rotation matrix of the particle
  156977. * @hidden
  156978. */
  156979. getRotationMatrix(m: Matrix): void;
  156980. }
  156981. /**
  156982. * Represents a group of points in a points cloud system
  156983. * * PCS internal tool, don't use it manually.
  156984. */
  156985. export class PointsGroup {
  156986. /**
  156987. * The group id
  156988. * @hidden
  156989. */
  156990. groupID: number;
  156991. /**
  156992. * image data for group (internal use)
  156993. * @hidden
  156994. */
  156995. _groupImageData: Nullable<ArrayBufferView>;
  156996. /**
  156997. * Image Width (internal use)
  156998. * @hidden
  156999. */
  157000. _groupImgWidth: number;
  157001. /**
  157002. * Image Height (internal use)
  157003. * @hidden
  157004. */
  157005. _groupImgHeight: number;
  157006. /**
  157007. * Custom position function (internal use)
  157008. * @hidden
  157009. */
  157010. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  157011. /**
  157012. * density per facet for surface points
  157013. * @hidden
  157014. */
  157015. _groupDensity: number[];
  157016. /**
  157017. * Only when points are colored by texture carries pointer to texture list array
  157018. * @hidden
  157019. */
  157020. _textureNb: number;
  157021. /**
  157022. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  157023. * PCS internal tool, don't use it manually.
  157024. * @hidden
  157025. */
  157026. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  157027. }
  157028. }
  157029. declare module BABYLON {
  157030. interface Scene {
  157031. /** @hidden (Backing field) */
  157032. _physicsEngine: Nullable<IPhysicsEngine>;
  157033. /** @hidden */
  157034. _physicsTimeAccumulator: number;
  157035. /**
  157036. * Gets the current physics engine
  157037. * @returns a IPhysicsEngine or null if none attached
  157038. */
  157039. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  157040. /**
  157041. * Enables physics to the current scene
  157042. * @param gravity defines the scene's gravity for the physics engine
  157043. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  157044. * @return a boolean indicating if the physics engine was initialized
  157045. */
  157046. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  157047. /**
  157048. * Disables and disposes the physics engine associated with the scene
  157049. */
  157050. disablePhysicsEngine(): void;
  157051. /**
  157052. * Gets a boolean indicating if there is an active physics engine
  157053. * @returns a boolean indicating if there is an active physics engine
  157054. */
  157055. isPhysicsEnabled(): boolean;
  157056. /**
  157057. * Deletes a physics compound impostor
  157058. * @param compound defines the compound to delete
  157059. */
  157060. deleteCompoundImpostor(compound: any): void;
  157061. /**
  157062. * An event triggered when physic simulation is about to be run
  157063. */
  157064. onBeforePhysicsObservable: Observable<Scene>;
  157065. /**
  157066. * An event triggered when physic simulation has been done
  157067. */
  157068. onAfterPhysicsObservable: Observable<Scene>;
  157069. }
  157070. interface AbstractMesh {
  157071. /** @hidden */
  157072. _physicsImpostor: Nullable<PhysicsImpostor>;
  157073. /**
  157074. * Gets or sets impostor used for physic simulation
  157075. * @see https://doc.babylonjs.com/features/physics_engine
  157076. */
  157077. physicsImpostor: Nullable<PhysicsImpostor>;
  157078. /**
  157079. * Gets the current physics impostor
  157080. * @see https://doc.babylonjs.com/features/physics_engine
  157081. * @returns a physics impostor or null
  157082. */
  157083. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  157084. /** Apply a physic impulse to the mesh
  157085. * @param force defines the force to apply
  157086. * @param contactPoint defines where to apply the force
  157087. * @returns the current mesh
  157088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  157089. */
  157090. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  157091. /**
  157092. * Creates a physic joint between two meshes
  157093. * @param otherMesh defines the other mesh to use
  157094. * @param pivot1 defines the pivot to use on this mesh
  157095. * @param pivot2 defines the pivot to use on the other mesh
  157096. * @param options defines additional options (can be plugin dependent)
  157097. * @returns the current mesh
  157098. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  157099. */
  157100. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  157101. /** @hidden */
  157102. _disposePhysicsObserver: Nullable<Observer<Node>>;
  157103. }
  157104. /**
  157105. * Defines the physics engine scene component responsible to manage a physics engine
  157106. */
  157107. export class PhysicsEngineSceneComponent implements ISceneComponent {
  157108. /**
  157109. * The component name helpful to identify the component in the list of scene components.
  157110. */
  157111. readonly name: string;
  157112. /**
  157113. * The scene the component belongs to.
  157114. */
  157115. scene: Scene;
  157116. /**
  157117. * Creates a new instance of the component for the given scene
  157118. * @param scene Defines the scene to register the component in
  157119. */
  157120. constructor(scene: Scene);
  157121. /**
  157122. * Registers the component in a given scene
  157123. */
  157124. register(): void;
  157125. /**
  157126. * Rebuilds the elements related to this component in case of
  157127. * context lost for instance.
  157128. */
  157129. rebuild(): void;
  157130. /**
  157131. * Disposes the component and the associated ressources
  157132. */
  157133. dispose(): void;
  157134. }
  157135. }
  157136. declare module BABYLON {
  157137. /**
  157138. * A helper for physics simulations
  157139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157140. */
  157141. export class PhysicsHelper {
  157142. private _scene;
  157143. private _physicsEngine;
  157144. /**
  157145. * Initializes the Physics helper
  157146. * @param scene Babylon.js scene
  157147. */
  157148. constructor(scene: Scene);
  157149. /**
  157150. * Applies a radial explosion impulse
  157151. * @param origin the origin of the explosion
  157152. * @param radiusOrEventOptions the radius or the options of radial explosion
  157153. * @param strength the explosion strength
  157154. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157155. * @returns A physics radial explosion event, or null
  157156. */
  157157. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  157158. /**
  157159. * Applies a radial explosion force
  157160. * @param origin the origin of the explosion
  157161. * @param radiusOrEventOptions the radius or the options of radial explosion
  157162. * @param strength the explosion strength
  157163. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157164. * @returns A physics radial explosion event, or null
  157165. */
  157166. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  157167. /**
  157168. * Creates a gravitational field
  157169. * @param origin the origin of the explosion
  157170. * @param radiusOrEventOptions the radius or the options of radial explosion
  157171. * @param strength the explosion strength
  157172. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157173. * @returns A physics gravitational field event, or null
  157174. */
  157175. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  157176. /**
  157177. * Creates a physics updraft event
  157178. * @param origin the origin of the updraft
  157179. * @param radiusOrEventOptions the radius or the options of the updraft
  157180. * @param strength the strength of the updraft
  157181. * @param height the height of the updraft
  157182. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  157183. * @returns A physics updraft event, or null
  157184. */
  157185. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  157186. /**
  157187. * Creates a physics vortex event
  157188. * @param origin the of the vortex
  157189. * @param radiusOrEventOptions the radius or the options of the vortex
  157190. * @param strength the strength of the vortex
  157191. * @param height the height of the vortex
  157192. * @returns a Physics vortex event, or null
  157193. * A physics vortex event or null
  157194. */
  157195. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  157196. }
  157197. /**
  157198. * Represents a physics radial explosion event
  157199. */
  157200. class PhysicsRadialExplosionEvent {
  157201. private _scene;
  157202. private _options;
  157203. private _sphere;
  157204. private _dataFetched;
  157205. /**
  157206. * Initializes a radial explosioin event
  157207. * @param _scene BabylonJS scene
  157208. * @param _options The options for the vortex event
  157209. */
  157210. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  157211. /**
  157212. * Returns the data related to the radial explosion event (sphere).
  157213. * @returns The radial explosion event data
  157214. */
  157215. getData(): PhysicsRadialExplosionEventData;
  157216. /**
  157217. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  157218. * @param impostor A physics imposter
  157219. * @param origin the origin of the explosion
  157220. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  157221. */
  157222. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  157223. /**
  157224. * Triggers affecterd impostors callbacks
  157225. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  157226. */
  157227. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  157228. /**
  157229. * Disposes the sphere.
  157230. * @param force Specifies if the sphere should be disposed by force
  157231. */
  157232. dispose(force?: boolean): void;
  157233. /*** Helpers ***/
  157234. private _prepareSphere;
  157235. private _intersectsWithSphere;
  157236. }
  157237. /**
  157238. * Represents a gravitational field event
  157239. */
  157240. class PhysicsGravitationalFieldEvent {
  157241. private _physicsHelper;
  157242. private _scene;
  157243. private _origin;
  157244. private _options;
  157245. private _tickCallback;
  157246. private _sphere;
  157247. private _dataFetched;
  157248. /**
  157249. * Initializes the physics gravitational field event
  157250. * @param _physicsHelper A physics helper
  157251. * @param _scene BabylonJS scene
  157252. * @param _origin The origin position of the gravitational field event
  157253. * @param _options The options for the vortex event
  157254. */
  157255. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  157256. /**
  157257. * Returns the data related to the gravitational field event (sphere).
  157258. * @returns A gravitational field event
  157259. */
  157260. getData(): PhysicsGravitationalFieldEventData;
  157261. /**
  157262. * Enables the gravitational field.
  157263. */
  157264. enable(): void;
  157265. /**
  157266. * Disables the gravitational field.
  157267. */
  157268. disable(): void;
  157269. /**
  157270. * Disposes the sphere.
  157271. * @param force The force to dispose from the gravitational field event
  157272. */
  157273. dispose(force?: boolean): void;
  157274. private _tick;
  157275. }
  157276. /**
  157277. * Represents a physics updraft event
  157278. */
  157279. class PhysicsUpdraftEvent {
  157280. private _scene;
  157281. private _origin;
  157282. private _options;
  157283. private _physicsEngine;
  157284. private _originTop;
  157285. private _originDirection;
  157286. private _tickCallback;
  157287. private _cylinder;
  157288. private _cylinderPosition;
  157289. private _dataFetched;
  157290. /**
  157291. * Initializes the physics updraft event
  157292. * @param _scene BabylonJS scene
  157293. * @param _origin The origin position of the updraft
  157294. * @param _options The options for the updraft event
  157295. */
  157296. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  157297. /**
  157298. * Returns the data related to the updraft event (cylinder).
  157299. * @returns A physics updraft event
  157300. */
  157301. getData(): PhysicsUpdraftEventData;
  157302. /**
  157303. * Enables the updraft.
  157304. */
  157305. enable(): void;
  157306. /**
  157307. * Disables the updraft.
  157308. */
  157309. disable(): void;
  157310. /**
  157311. * Disposes the cylinder.
  157312. * @param force Specifies if the updraft should be disposed by force
  157313. */
  157314. dispose(force?: boolean): void;
  157315. private getImpostorHitData;
  157316. private _tick;
  157317. /*** Helpers ***/
  157318. private _prepareCylinder;
  157319. private _intersectsWithCylinder;
  157320. }
  157321. /**
  157322. * Represents a physics vortex event
  157323. */
  157324. class PhysicsVortexEvent {
  157325. private _scene;
  157326. private _origin;
  157327. private _options;
  157328. private _physicsEngine;
  157329. private _originTop;
  157330. private _tickCallback;
  157331. private _cylinder;
  157332. private _cylinderPosition;
  157333. private _dataFetched;
  157334. /**
  157335. * Initializes the physics vortex event
  157336. * @param _scene The BabylonJS scene
  157337. * @param _origin The origin position of the vortex
  157338. * @param _options The options for the vortex event
  157339. */
  157340. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  157341. /**
  157342. * Returns the data related to the vortex event (cylinder).
  157343. * @returns The physics vortex event data
  157344. */
  157345. getData(): PhysicsVortexEventData;
  157346. /**
  157347. * Enables the vortex.
  157348. */
  157349. enable(): void;
  157350. /**
  157351. * Disables the cortex.
  157352. */
  157353. disable(): void;
  157354. /**
  157355. * Disposes the sphere.
  157356. * @param force
  157357. */
  157358. dispose(force?: boolean): void;
  157359. private getImpostorHitData;
  157360. private _tick;
  157361. /*** Helpers ***/
  157362. private _prepareCylinder;
  157363. private _intersectsWithCylinder;
  157364. }
  157365. /**
  157366. * Options fot the radial explosion event
  157367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157368. */
  157369. export class PhysicsRadialExplosionEventOptions {
  157370. /**
  157371. * The radius of the sphere for the radial explosion.
  157372. */
  157373. radius: number;
  157374. /**
  157375. * The strenth of the explosion.
  157376. */
  157377. strength: number;
  157378. /**
  157379. * The strenght of the force in correspondence to the distance of the affected object
  157380. */
  157381. falloff: PhysicsRadialImpulseFalloff;
  157382. /**
  157383. * Sphere options for the radial explosion.
  157384. */
  157385. sphere: {
  157386. segments: number;
  157387. diameter: number;
  157388. };
  157389. /**
  157390. * Sphere options for the radial explosion.
  157391. */
  157392. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  157393. }
  157394. /**
  157395. * Options fot the updraft event
  157396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157397. */
  157398. export class PhysicsUpdraftEventOptions {
  157399. /**
  157400. * The radius of the cylinder for the vortex
  157401. */
  157402. radius: number;
  157403. /**
  157404. * The strenth of the updraft.
  157405. */
  157406. strength: number;
  157407. /**
  157408. * The height of the cylinder for the updraft.
  157409. */
  157410. height: number;
  157411. /**
  157412. * The mode for the the updraft.
  157413. */
  157414. updraftMode: PhysicsUpdraftMode;
  157415. }
  157416. /**
  157417. * Options fot the vortex event
  157418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157419. */
  157420. export class PhysicsVortexEventOptions {
  157421. /**
  157422. * The radius of the cylinder for the vortex
  157423. */
  157424. radius: number;
  157425. /**
  157426. * The strenth of the vortex.
  157427. */
  157428. strength: number;
  157429. /**
  157430. * The height of the cylinder for the vortex.
  157431. */
  157432. height: number;
  157433. /**
  157434. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  157435. */
  157436. centripetalForceThreshold: number;
  157437. /**
  157438. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  157439. */
  157440. centripetalForceMultiplier: number;
  157441. /**
  157442. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  157443. */
  157444. centrifugalForceMultiplier: number;
  157445. /**
  157446. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  157447. */
  157448. updraftForceMultiplier: number;
  157449. }
  157450. /**
  157451. * The strenght of the force in correspondence to the distance of the affected object
  157452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157453. */
  157454. export enum PhysicsRadialImpulseFalloff {
  157455. /** Defines that impulse is constant in strength across it's whole radius */
  157456. Constant = 0,
  157457. /** Defines that impulse gets weaker if it's further from the origin */
  157458. Linear = 1
  157459. }
  157460. /**
  157461. * The strength of the force in correspondence to the distance of the affected object
  157462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157463. */
  157464. export enum PhysicsUpdraftMode {
  157465. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  157466. Center = 0,
  157467. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  157468. Perpendicular = 1
  157469. }
  157470. /**
  157471. * Interface for a physics hit data
  157472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157473. */
  157474. export interface PhysicsHitData {
  157475. /**
  157476. * The force applied at the contact point
  157477. */
  157478. force: Vector3;
  157479. /**
  157480. * The contact point
  157481. */
  157482. contactPoint: Vector3;
  157483. /**
  157484. * The distance from the origin to the contact point
  157485. */
  157486. distanceFromOrigin: number;
  157487. }
  157488. /**
  157489. * Interface for radial explosion event data
  157490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157491. */
  157492. export interface PhysicsRadialExplosionEventData {
  157493. /**
  157494. * A sphere used for the radial explosion event
  157495. */
  157496. sphere: Mesh;
  157497. }
  157498. /**
  157499. * Interface for gravitational field event data
  157500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157501. */
  157502. export interface PhysicsGravitationalFieldEventData {
  157503. /**
  157504. * A sphere mesh used for the gravitational field event
  157505. */
  157506. sphere: Mesh;
  157507. }
  157508. /**
  157509. * Interface for updraft event data
  157510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157511. */
  157512. export interface PhysicsUpdraftEventData {
  157513. /**
  157514. * A cylinder used for the updraft event
  157515. */
  157516. cylinder: Mesh;
  157517. }
  157518. /**
  157519. * Interface for vortex event data
  157520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157521. */
  157522. export interface PhysicsVortexEventData {
  157523. /**
  157524. * A cylinder used for the vortex event
  157525. */
  157526. cylinder: Mesh;
  157527. }
  157528. /**
  157529. * Interface for an affected physics impostor
  157530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157531. */
  157532. export interface PhysicsAffectedImpostorWithData {
  157533. /**
  157534. * The impostor affected by the effect
  157535. */
  157536. impostor: PhysicsImpostor;
  157537. /**
  157538. * The data about the hit/horce from the explosion
  157539. */
  157540. hitData: PhysicsHitData;
  157541. }
  157542. }
  157543. declare module BABYLON {
  157544. /** @hidden */
  157545. export var blackAndWhitePixelShader: {
  157546. name: string;
  157547. shader: string;
  157548. };
  157549. }
  157550. declare module BABYLON {
  157551. /**
  157552. * Post process used to render in black and white
  157553. */
  157554. export class BlackAndWhitePostProcess extends PostProcess {
  157555. /**
  157556. * Linear about to convert he result to black and white (default: 1)
  157557. */
  157558. degree: number;
  157559. /**
  157560. * Gets a string identifying the name of the class
  157561. * @returns "BlackAndWhitePostProcess" string
  157562. */
  157563. getClassName(): string;
  157564. /**
  157565. * Creates a black and white post process
  157566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  157567. * @param name The name of the effect.
  157568. * @param options The required width/height ratio to downsize to before computing the render pass.
  157569. * @param camera The camera to apply the render pass to.
  157570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157571. * @param engine The engine which the post process will be applied. (default: current engine)
  157572. * @param reusable If the post process can be reused on the same frame. (default: false)
  157573. */
  157574. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  157575. /** @hidden */
  157576. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  157577. }
  157578. }
  157579. declare module BABYLON {
  157580. /**
  157581. * This represents a set of one or more post processes in Babylon.
  157582. * A post process can be used to apply a shader to a texture after it is rendered.
  157583. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  157584. */
  157585. export class PostProcessRenderEffect {
  157586. private _postProcesses;
  157587. private _getPostProcesses;
  157588. private _singleInstance;
  157589. private _cameras;
  157590. private _indicesForCamera;
  157591. /**
  157592. * Name of the effect
  157593. * @hidden
  157594. */
  157595. _name: string;
  157596. /**
  157597. * Instantiates a post process render effect.
  157598. * A post process can be used to apply a shader to a texture after it is rendered.
  157599. * @param engine The engine the effect is tied to
  157600. * @param name The name of the effect
  157601. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  157602. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  157603. */
  157604. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  157605. /**
  157606. * Checks if all the post processes in the effect are supported.
  157607. */
  157608. get isSupported(): boolean;
  157609. /**
  157610. * Updates the current state of the effect
  157611. * @hidden
  157612. */
  157613. _update(): void;
  157614. /**
  157615. * Attaches the effect on cameras
  157616. * @param cameras The camera to attach to.
  157617. * @hidden
  157618. */
  157619. _attachCameras(cameras: Camera): void;
  157620. /**
  157621. * Attaches the effect on cameras
  157622. * @param cameras The camera to attach to.
  157623. * @hidden
  157624. */
  157625. _attachCameras(cameras: Camera[]): void;
  157626. /**
  157627. * Detaches the effect on cameras
  157628. * @param cameras The camera to detatch from.
  157629. * @hidden
  157630. */
  157631. _detachCameras(cameras: Camera): void;
  157632. /**
  157633. * Detatches the effect on cameras
  157634. * @param cameras The camera to detatch from.
  157635. * @hidden
  157636. */
  157637. _detachCameras(cameras: Camera[]): void;
  157638. /**
  157639. * Enables the effect on given cameras
  157640. * @param cameras The camera to enable.
  157641. * @hidden
  157642. */
  157643. _enable(cameras: Camera): void;
  157644. /**
  157645. * Enables the effect on given cameras
  157646. * @param cameras The camera to enable.
  157647. * @hidden
  157648. */
  157649. _enable(cameras: Nullable<Camera[]>): void;
  157650. /**
  157651. * Disables the effect on the given cameras
  157652. * @param cameras The camera to disable.
  157653. * @hidden
  157654. */
  157655. _disable(cameras: Camera): void;
  157656. /**
  157657. * Disables the effect on the given cameras
  157658. * @param cameras The camera to disable.
  157659. * @hidden
  157660. */
  157661. _disable(cameras: Nullable<Camera[]>): void;
  157662. /**
  157663. * Gets a list of the post processes contained in the effect.
  157664. * @param camera The camera to get the post processes on.
  157665. * @returns The list of the post processes in the effect.
  157666. */
  157667. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  157668. }
  157669. }
  157670. declare module BABYLON {
  157671. /** @hidden */
  157672. export var extractHighlightsPixelShader: {
  157673. name: string;
  157674. shader: string;
  157675. };
  157676. }
  157677. declare module BABYLON {
  157678. /**
  157679. * 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.
  157680. */
  157681. export class ExtractHighlightsPostProcess extends PostProcess {
  157682. /**
  157683. * The luminance threshold, pixels below this value will be set to black.
  157684. */
  157685. threshold: number;
  157686. /** @hidden */
  157687. _exposure: number;
  157688. /**
  157689. * Post process which has the input texture to be used when performing highlight extraction
  157690. * @hidden
  157691. */
  157692. _inputPostProcess: Nullable<PostProcess>;
  157693. /**
  157694. * Gets a string identifying the name of the class
  157695. * @returns "ExtractHighlightsPostProcess" string
  157696. */
  157697. getClassName(): string;
  157698. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157699. }
  157700. }
  157701. declare module BABYLON {
  157702. /** @hidden */
  157703. export var bloomMergePixelShader: {
  157704. name: string;
  157705. shader: string;
  157706. };
  157707. }
  157708. declare module BABYLON {
  157709. /**
  157710. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  157711. */
  157712. export class BloomMergePostProcess extends PostProcess {
  157713. /** Weight of the bloom to be added to the original input. */
  157714. weight: number;
  157715. /**
  157716. * Gets a string identifying the name of the class
  157717. * @returns "BloomMergePostProcess" string
  157718. */
  157719. getClassName(): string;
  157720. /**
  157721. * Creates a new instance of @see BloomMergePostProcess
  157722. * @param name The name of the effect.
  157723. * @param originalFromInput Post process which's input will be used for the merge.
  157724. * @param blurred Blurred highlights post process which's output will be used.
  157725. * @param weight Weight of the bloom to be added to the original input.
  157726. * @param options The required width/height ratio to downsize to before computing the render pass.
  157727. * @param camera The camera to apply the render pass to.
  157728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157729. * @param engine The engine which the post process will be applied. (default: current engine)
  157730. * @param reusable If the post process can be reused on the same frame. (default: false)
  157731. * @param textureType Type of textures used when performing the post process. (default: 0)
  157732. * @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)
  157733. */
  157734. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  157735. /** Weight of the bloom to be added to the original input. */
  157736. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157737. }
  157738. }
  157739. declare module BABYLON {
  157740. /**
  157741. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  157742. */
  157743. export class BloomEffect extends PostProcessRenderEffect {
  157744. private bloomScale;
  157745. /**
  157746. * @hidden Internal
  157747. */
  157748. _effects: Array<PostProcess>;
  157749. /**
  157750. * @hidden Internal
  157751. */
  157752. _downscale: ExtractHighlightsPostProcess;
  157753. private _blurX;
  157754. private _blurY;
  157755. private _merge;
  157756. /**
  157757. * The luminance threshold to find bright areas of the image to bloom.
  157758. */
  157759. get threshold(): number;
  157760. set threshold(value: number);
  157761. /**
  157762. * The strength of the bloom.
  157763. */
  157764. get weight(): number;
  157765. set weight(value: number);
  157766. /**
  157767. * Specifies the size of the bloom blur kernel, relative to the final output size
  157768. */
  157769. get kernel(): number;
  157770. set kernel(value: number);
  157771. /**
  157772. * Creates a new instance of @see BloomEffect
  157773. * @param scene The scene the effect belongs to.
  157774. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  157775. * @param bloomKernel The size of the kernel to be used when applying the blur.
  157776. * @param bloomWeight The the strength of bloom.
  157777. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  157778. * @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)
  157779. */
  157780. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  157781. /**
  157782. * Disposes each of the internal effects for a given camera.
  157783. * @param camera The camera to dispose the effect on.
  157784. */
  157785. disposeEffects(camera: Camera): void;
  157786. /**
  157787. * @hidden Internal
  157788. */
  157789. _updateEffects(): void;
  157790. /**
  157791. * Internal
  157792. * @returns if all the contained post processes are ready.
  157793. * @hidden
  157794. */
  157795. _isReady(): boolean;
  157796. }
  157797. }
  157798. declare module BABYLON {
  157799. /** @hidden */
  157800. export var chromaticAberrationPixelShader: {
  157801. name: string;
  157802. shader: string;
  157803. };
  157804. }
  157805. declare module BABYLON {
  157806. /**
  157807. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  157808. */
  157809. export class ChromaticAberrationPostProcess extends PostProcess {
  157810. /**
  157811. * The amount of seperation of rgb channels (default: 30)
  157812. */
  157813. aberrationAmount: number;
  157814. /**
  157815. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  157816. */
  157817. radialIntensity: number;
  157818. /**
  157819. * 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))
  157820. */
  157821. direction: Vector2;
  157822. /**
  157823. * 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))
  157824. */
  157825. centerPosition: Vector2;
  157826. /** The width of the screen to apply the effect on */
  157827. screenWidth: number;
  157828. /** The height of the screen to apply the effect on */
  157829. screenHeight: number;
  157830. /**
  157831. * Gets a string identifying the name of the class
  157832. * @returns "ChromaticAberrationPostProcess" string
  157833. */
  157834. getClassName(): string;
  157835. /**
  157836. * Creates a new instance ChromaticAberrationPostProcess
  157837. * @param name The name of the effect.
  157838. * @param screenWidth The width of the screen to apply the effect on.
  157839. * @param screenHeight The height of the screen to apply the effect on.
  157840. * @param options The required width/height ratio to downsize to before computing the render pass.
  157841. * @param camera The camera to apply the render pass to.
  157842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157843. * @param engine The engine which the post process will be applied. (default: current engine)
  157844. * @param reusable If the post process can be reused on the same frame. (default: false)
  157845. * @param textureType Type of textures used when performing the post process. (default: 0)
  157846. * @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)
  157847. */
  157848. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157849. /** @hidden */
  157850. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  157851. }
  157852. }
  157853. declare module BABYLON {
  157854. /** @hidden */
  157855. export var circleOfConfusionPixelShader: {
  157856. name: string;
  157857. shader: string;
  157858. };
  157859. }
  157860. declare module BABYLON {
  157861. /**
  157862. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  157863. */
  157864. export class CircleOfConfusionPostProcess extends PostProcess {
  157865. /**
  157866. * 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.
  157867. */
  157868. lensSize: number;
  157869. /**
  157870. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  157871. */
  157872. fStop: number;
  157873. /**
  157874. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  157875. */
  157876. focusDistance: number;
  157877. /**
  157878. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  157879. */
  157880. focalLength: number;
  157881. /**
  157882. * Gets a string identifying the name of the class
  157883. * @returns "CircleOfConfusionPostProcess" string
  157884. */
  157885. getClassName(): string;
  157886. private _depthTexture;
  157887. /**
  157888. * Creates a new instance CircleOfConfusionPostProcess
  157889. * @param name The name of the effect.
  157890. * @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.
  157891. * @param options The required width/height ratio to downsize to before computing the render pass.
  157892. * @param camera The camera to apply the render pass to.
  157893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157894. * @param engine The engine which the post process will be applied. (default: current engine)
  157895. * @param reusable If the post process can be reused on the same frame. (default: false)
  157896. * @param textureType Type of textures used when performing the post process. (default: 0)
  157897. * @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)
  157898. */
  157899. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157900. /**
  157901. * 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.
  157902. */
  157903. set depthTexture(value: RenderTargetTexture);
  157904. }
  157905. }
  157906. declare module BABYLON {
  157907. /** @hidden */
  157908. export var colorCorrectionPixelShader: {
  157909. name: string;
  157910. shader: string;
  157911. };
  157912. }
  157913. declare module BABYLON {
  157914. /**
  157915. *
  157916. * This post-process allows the modification of rendered colors by using
  157917. * a 'look-up table' (LUT). This effect is also called Color Grading.
  157918. *
  157919. * The object needs to be provided an url to a texture containing the color
  157920. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  157921. * Use an image editing software to tweak the LUT to match your needs.
  157922. *
  157923. * For an example of a color LUT, see here:
  157924. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  157925. * For explanations on color grading, see here:
  157926. * @see http://udn.epicgames.com/Three/ColorGrading.html
  157927. *
  157928. */
  157929. export class ColorCorrectionPostProcess extends PostProcess {
  157930. private _colorTableTexture;
  157931. /**
  157932. * Gets the color table url used to create the LUT texture
  157933. */
  157934. colorTableUrl: string;
  157935. /**
  157936. * Gets a string identifying the name of the class
  157937. * @returns "ColorCorrectionPostProcess" string
  157938. */
  157939. getClassName(): string;
  157940. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  157941. /** @hidden */
  157942. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  157943. }
  157944. }
  157945. declare module BABYLON {
  157946. /** @hidden */
  157947. export var convolutionPixelShader: {
  157948. name: string;
  157949. shader: string;
  157950. };
  157951. }
  157952. declare module BABYLON {
  157953. /**
  157954. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  157955. * input texture to perform effects such as edge detection or sharpening
  157956. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  157957. */
  157958. export class ConvolutionPostProcess extends PostProcess {
  157959. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  157960. kernel: number[];
  157961. /**
  157962. * Gets a string identifying the name of the class
  157963. * @returns "ConvolutionPostProcess" string
  157964. */
  157965. getClassName(): string;
  157966. /**
  157967. * Creates a new instance ConvolutionPostProcess
  157968. * @param name The name of the effect.
  157969. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  157970. * @param options The required width/height ratio to downsize to before computing the render pass.
  157971. * @param camera The camera to apply the render pass to.
  157972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157973. * @param engine The engine which the post process will be applied. (default: current engine)
  157974. * @param reusable If the post process can be reused on the same frame. (default: false)
  157975. * @param textureType Type of textures used when performing the post process. (default: 0)
  157976. */
  157977. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  157978. /** @hidden */
  157979. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  157980. /**
  157981. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  157982. */
  157983. static EdgeDetect0Kernel: number[];
  157984. /**
  157985. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  157986. */
  157987. static EdgeDetect1Kernel: number[];
  157988. /**
  157989. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  157990. */
  157991. static EdgeDetect2Kernel: number[];
  157992. /**
  157993. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  157994. */
  157995. static SharpenKernel: number[];
  157996. /**
  157997. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  157998. */
  157999. static EmbossKernel: number[];
  158000. /**
  158001. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158002. */
  158003. static GaussianKernel: number[];
  158004. }
  158005. }
  158006. declare module BABYLON {
  158007. /**
  158008. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  158009. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  158010. * based on samples that have a large difference in distance than the center pixel.
  158011. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  158012. */
  158013. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  158014. /**
  158015. * The direction the blur should be applied
  158016. */
  158017. direction: Vector2;
  158018. /**
  158019. * Gets a string identifying the name of the class
  158020. * @returns "DepthOfFieldBlurPostProcess" string
  158021. */
  158022. getClassName(): string;
  158023. /**
  158024. * Creates a new instance CircleOfConfusionPostProcess
  158025. * @param name The name of the effect.
  158026. * @param scene The scene the effect belongs to.
  158027. * @param direction The direction the blur should be applied.
  158028. * @param kernel The size of the kernel used to blur.
  158029. * @param options The required width/height ratio to downsize to before computing the render pass.
  158030. * @param camera The camera to apply the render pass to.
  158031. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  158032. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  158033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158034. * @param engine The engine which the post process will be applied. (default: current engine)
  158035. * @param reusable If the post process can be reused on the same frame. (default: false)
  158036. * @param textureType Type of textures used when performing the post process. (default: 0)
  158037. * @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)
  158038. */
  158039. 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);
  158040. }
  158041. }
  158042. declare module BABYLON {
  158043. /** @hidden */
  158044. export var depthOfFieldMergePixelShader: {
  158045. name: string;
  158046. shader: string;
  158047. };
  158048. }
  158049. declare module BABYLON {
  158050. /**
  158051. * Options to be set when merging outputs from the default pipeline.
  158052. */
  158053. export class DepthOfFieldMergePostProcessOptions {
  158054. /**
  158055. * The original image to merge on top of
  158056. */
  158057. originalFromInput: PostProcess;
  158058. /**
  158059. * Parameters to perform the merge of the depth of field effect
  158060. */
  158061. depthOfField?: {
  158062. circleOfConfusion: PostProcess;
  158063. blurSteps: Array<PostProcess>;
  158064. };
  158065. /**
  158066. * Parameters to perform the merge of bloom effect
  158067. */
  158068. bloom?: {
  158069. blurred: PostProcess;
  158070. weight: number;
  158071. };
  158072. }
  158073. /**
  158074. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  158075. */
  158076. export class DepthOfFieldMergePostProcess extends PostProcess {
  158077. private blurSteps;
  158078. /**
  158079. * Gets a string identifying the name of the class
  158080. * @returns "DepthOfFieldMergePostProcess" string
  158081. */
  158082. getClassName(): string;
  158083. /**
  158084. * Creates a new instance of DepthOfFieldMergePostProcess
  158085. * @param name The name of the effect.
  158086. * @param originalFromInput Post process which's input will be used for the merge.
  158087. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  158088. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  158089. * @param options The required width/height ratio to downsize to before computing the render pass.
  158090. * @param camera The camera to apply the render pass to.
  158091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158092. * @param engine The engine which the post process will be applied. (default: current engine)
  158093. * @param reusable If the post process can be reused on the same frame. (default: false)
  158094. * @param textureType Type of textures used when performing the post process. (default: 0)
  158095. * @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)
  158096. */
  158097. 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);
  158098. /**
  158099. * Updates the effect with the current post process compile time values and recompiles the shader.
  158100. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  158101. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  158102. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  158103. * @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
  158104. * @param onCompiled Called when the shader has been compiled.
  158105. * @param onError Called if there is an error when compiling a shader.
  158106. */
  158107. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  158108. }
  158109. }
  158110. declare module BABYLON {
  158111. /**
  158112. * Specifies the level of max blur that should be applied when using the depth of field effect
  158113. */
  158114. export enum DepthOfFieldEffectBlurLevel {
  158115. /**
  158116. * Subtle blur
  158117. */
  158118. Low = 0,
  158119. /**
  158120. * Medium blur
  158121. */
  158122. Medium = 1,
  158123. /**
  158124. * Large blur
  158125. */
  158126. High = 2
  158127. }
  158128. /**
  158129. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  158130. */
  158131. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  158132. private _circleOfConfusion;
  158133. /**
  158134. * @hidden Internal, blurs from high to low
  158135. */
  158136. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  158137. private _depthOfFieldBlurY;
  158138. private _dofMerge;
  158139. /**
  158140. * @hidden Internal post processes in depth of field effect
  158141. */
  158142. _effects: Array<PostProcess>;
  158143. /**
  158144. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  158145. */
  158146. set focalLength(value: number);
  158147. get focalLength(): number;
  158148. /**
  158149. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  158150. */
  158151. set fStop(value: number);
  158152. get fStop(): number;
  158153. /**
  158154. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  158155. */
  158156. set focusDistance(value: number);
  158157. get focusDistance(): number;
  158158. /**
  158159. * 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.
  158160. */
  158161. set lensSize(value: number);
  158162. get lensSize(): number;
  158163. /**
  158164. * Creates a new instance DepthOfFieldEffect
  158165. * @param scene The scene the effect belongs to.
  158166. * @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.
  158167. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  158168. * @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)
  158169. */
  158170. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  158171. /**
  158172. * Get the current class name of the current effet
  158173. * @returns "DepthOfFieldEffect"
  158174. */
  158175. getClassName(): string;
  158176. /**
  158177. * 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.
  158178. */
  158179. set depthTexture(value: RenderTargetTexture);
  158180. /**
  158181. * Disposes each of the internal effects for a given camera.
  158182. * @param camera The camera to dispose the effect on.
  158183. */
  158184. disposeEffects(camera: Camera): void;
  158185. /**
  158186. * @hidden Internal
  158187. */
  158188. _updateEffects(): void;
  158189. /**
  158190. * Internal
  158191. * @returns if all the contained post processes are ready.
  158192. * @hidden
  158193. */
  158194. _isReady(): boolean;
  158195. }
  158196. }
  158197. declare module BABYLON {
  158198. /** @hidden */
  158199. export var displayPassPixelShader: {
  158200. name: string;
  158201. shader: string;
  158202. };
  158203. }
  158204. declare module BABYLON {
  158205. /**
  158206. * DisplayPassPostProcess which produces an output the same as it's input
  158207. */
  158208. export class DisplayPassPostProcess extends PostProcess {
  158209. /**
  158210. * Gets a string identifying the name of the class
  158211. * @returns "DisplayPassPostProcess" string
  158212. */
  158213. getClassName(): string;
  158214. /**
  158215. * Creates the DisplayPassPostProcess
  158216. * @param name The name of the effect.
  158217. * @param options The required width/height ratio to downsize to before computing the render pass.
  158218. * @param camera The camera to apply the render pass to.
  158219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158220. * @param engine The engine which the post process will be applied. (default: current engine)
  158221. * @param reusable If the post process can be reused on the same frame. (default: false)
  158222. */
  158223. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158224. /** @hidden */
  158225. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  158226. }
  158227. }
  158228. declare module BABYLON {
  158229. /** @hidden */
  158230. export var filterPixelShader: {
  158231. name: string;
  158232. shader: string;
  158233. };
  158234. }
  158235. declare module BABYLON {
  158236. /**
  158237. * Applies a kernel filter to the image
  158238. */
  158239. export class FilterPostProcess extends PostProcess {
  158240. /** The matrix to be applied to the image */
  158241. kernelMatrix: Matrix;
  158242. /**
  158243. * Gets a string identifying the name of the class
  158244. * @returns "FilterPostProcess" string
  158245. */
  158246. getClassName(): string;
  158247. /**
  158248. *
  158249. * @param name The name of the effect.
  158250. * @param kernelMatrix The matrix to be applied to the image
  158251. * @param options The required width/height ratio to downsize to before computing the render pass.
  158252. * @param camera The camera to apply the render pass to.
  158253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158254. * @param engine The engine which the post process will be applied. (default: current engine)
  158255. * @param reusable If the post process can be reused on the same frame. (default: false)
  158256. */
  158257. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158258. /** @hidden */
  158259. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  158260. }
  158261. }
  158262. declare module BABYLON {
  158263. /** @hidden */
  158264. export var fxaaPixelShader: {
  158265. name: string;
  158266. shader: string;
  158267. };
  158268. }
  158269. declare module BABYLON {
  158270. /** @hidden */
  158271. export var fxaaVertexShader: {
  158272. name: string;
  158273. shader: string;
  158274. };
  158275. }
  158276. declare module BABYLON {
  158277. /**
  158278. * Fxaa post process
  158279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  158280. */
  158281. export class FxaaPostProcess extends PostProcess {
  158282. /**
  158283. * Gets a string identifying the name of the class
  158284. * @returns "FxaaPostProcess" string
  158285. */
  158286. getClassName(): string;
  158287. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158288. private _getDefines;
  158289. /** @hidden */
  158290. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  158291. }
  158292. }
  158293. declare module BABYLON {
  158294. /** @hidden */
  158295. export var grainPixelShader: {
  158296. name: string;
  158297. shader: string;
  158298. };
  158299. }
  158300. declare module BABYLON {
  158301. /**
  158302. * The GrainPostProcess adds noise to the image at mid luminance levels
  158303. */
  158304. export class GrainPostProcess extends PostProcess {
  158305. /**
  158306. * The intensity of the grain added (default: 30)
  158307. */
  158308. intensity: number;
  158309. /**
  158310. * If the grain should be randomized on every frame
  158311. */
  158312. animated: boolean;
  158313. /**
  158314. * Gets a string identifying the name of the class
  158315. * @returns "GrainPostProcess" string
  158316. */
  158317. getClassName(): string;
  158318. /**
  158319. * Creates a new instance of @see GrainPostProcess
  158320. * @param name The name of the effect.
  158321. * @param options The required width/height ratio to downsize to before computing the render pass.
  158322. * @param camera The camera to apply the render pass to.
  158323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158324. * @param engine The engine which the post process will be applied. (default: current engine)
  158325. * @param reusable If the post process can be reused on the same frame. (default: false)
  158326. * @param textureType Type of textures used when performing the post process. (default: 0)
  158327. * @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)
  158328. */
  158329. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158330. /** @hidden */
  158331. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  158332. }
  158333. }
  158334. declare module BABYLON {
  158335. /** @hidden */
  158336. export var highlightsPixelShader: {
  158337. name: string;
  158338. shader: string;
  158339. };
  158340. }
  158341. declare module BABYLON {
  158342. /**
  158343. * Extracts highlights from the image
  158344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  158345. */
  158346. export class HighlightsPostProcess extends PostProcess {
  158347. /**
  158348. * Gets a string identifying the name of the class
  158349. * @returns "HighlightsPostProcess" string
  158350. */
  158351. getClassName(): string;
  158352. /**
  158353. * Extracts highlights from the image
  158354. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  158355. * @param name The name of the effect.
  158356. * @param options The required width/height ratio to downsize to before computing the render pass.
  158357. * @param camera The camera to apply the render pass to.
  158358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158359. * @param engine The engine which the post process will be applied. (default: current engine)
  158360. * @param reusable If the post process can be reused on the same frame. (default: false)
  158361. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  158362. */
  158363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158364. }
  158365. }
  158366. declare module BABYLON {
  158367. /**
  158368. * Contains all parameters needed for the prepass to perform
  158369. * motion blur
  158370. */
  158371. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  158372. /**
  158373. * Is motion blur enabled
  158374. */
  158375. enabled: boolean;
  158376. /**
  158377. * Name of the configuration
  158378. */
  158379. name: string;
  158380. /**
  158381. * Textures that should be present in the MRT for this effect to work
  158382. */
  158383. readonly texturesRequired: number[];
  158384. }
  158385. }
  158386. declare module BABYLON {
  158387. interface Scene {
  158388. /** @hidden (Backing field) */
  158389. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  158390. /**
  158391. * Gets or Sets the current geometry buffer associated to the scene.
  158392. */
  158393. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  158394. /**
  158395. * Enables a GeometryBufferRender and associates it with the scene
  158396. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  158397. * @returns the GeometryBufferRenderer
  158398. */
  158399. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  158400. /**
  158401. * Disables the GeometryBufferRender associated with the scene
  158402. */
  158403. disableGeometryBufferRenderer(): void;
  158404. }
  158405. /**
  158406. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  158407. * in several rendering techniques.
  158408. */
  158409. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  158410. /**
  158411. * The component name helpful to identify the component in the list of scene components.
  158412. */
  158413. readonly name: string;
  158414. /**
  158415. * The scene the component belongs to.
  158416. */
  158417. scene: Scene;
  158418. /**
  158419. * Creates a new instance of the component for the given scene
  158420. * @param scene Defines the scene to register the component in
  158421. */
  158422. constructor(scene: Scene);
  158423. /**
  158424. * Registers the component in a given scene
  158425. */
  158426. register(): void;
  158427. /**
  158428. * Rebuilds the elements related to this component in case of
  158429. * context lost for instance.
  158430. */
  158431. rebuild(): void;
  158432. /**
  158433. * Disposes the component and the associated ressources
  158434. */
  158435. dispose(): void;
  158436. private _gatherRenderTargets;
  158437. }
  158438. }
  158439. declare module BABYLON {
  158440. /** @hidden */
  158441. export var motionBlurPixelShader: {
  158442. name: string;
  158443. shader: string;
  158444. };
  158445. }
  158446. declare module BABYLON {
  158447. /**
  158448. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  158449. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  158450. * As an example, all you have to do is to create the post-process:
  158451. * var mb = new BABYLON.MotionBlurPostProcess(
  158452. * 'mb', // The name of the effect.
  158453. * scene, // The scene containing the objects to blur according to their velocity.
  158454. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  158455. * camera // The camera to apply the render pass to.
  158456. * );
  158457. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  158458. */
  158459. export class MotionBlurPostProcess extends PostProcess {
  158460. /**
  158461. * Defines how much the image is blurred by the movement. Default value is equal to 1
  158462. */
  158463. motionStrength: number;
  158464. /**
  158465. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  158466. */
  158467. get motionBlurSamples(): number;
  158468. /**
  158469. * Sets the number of iterations to be used for motion blur quality
  158470. */
  158471. set motionBlurSamples(samples: number);
  158472. private _motionBlurSamples;
  158473. /**
  158474. * Gets wether or not the motion blur post-process is in object based mode.
  158475. */
  158476. get isObjectBased(): boolean;
  158477. /**
  158478. * Sets wether or not the motion blur post-process is in object based mode.
  158479. */
  158480. set isObjectBased(value: boolean);
  158481. private _isObjectBased;
  158482. private _forceGeometryBuffer;
  158483. private _geometryBufferRenderer;
  158484. private _prePassRenderer;
  158485. private _invViewProjection;
  158486. private _previousViewProjection;
  158487. /**
  158488. * Gets a string identifying the name of the class
  158489. * @returns "MotionBlurPostProcess" string
  158490. */
  158491. getClassName(): string;
  158492. /**
  158493. * Creates a new instance MotionBlurPostProcess
  158494. * @param name The name of the effect.
  158495. * @param scene The scene containing the objects to blur according to their velocity.
  158496. * @param options The required width/height ratio to downsize to before computing the render pass.
  158497. * @param camera The camera to apply the render pass to.
  158498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158499. * @param engine The engine which the post process will be applied. (default: current engine)
  158500. * @param reusable If the post process can be reused on the same frame. (default: false)
  158501. * @param textureType Type of textures used when performing the post process. (default: 0)
  158502. * @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)
  158503. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  158504. */
  158505. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  158506. /**
  158507. * Excludes the given skinned mesh from computing bones velocities.
  158508. * 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.
  158509. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  158510. */
  158511. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  158512. /**
  158513. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  158514. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  158515. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  158516. */
  158517. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  158518. /**
  158519. * Disposes the post process.
  158520. * @param camera The camera to dispose the post process on.
  158521. */
  158522. dispose(camera?: Camera): void;
  158523. /**
  158524. * Called on the mode changed (object based or screen based).
  158525. */
  158526. private _applyMode;
  158527. /**
  158528. * Called on the effect is applied when the motion blur post-process is in object based mode.
  158529. */
  158530. private _onApplyObjectBased;
  158531. /**
  158532. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  158533. */
  158534. private _onApplyScreenBased;
  158535. /**
  158536. * Called on the effect must be updated (changed mode, samples count, etc.).
  158537. */
  158538. private _updateEffect;
  158539. /** @hidden */
  158540. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  158541. }
  158542. }
  158543. declare module BABYLON {
  158544. /** @hidden */
  158545. export var refractionPixelShader: {
  158546. name: string;
  158547. shader: string;
  158548. };
  158549. }
  158550. declare module BABYLON {
  158551. /**
  158552. * Post process which applies a refractin texture
  158553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  158554. */
  158555. export class RefractionPostProcess extends PostProcess {
  158556. private _refTexture;
  158557. private _ownRefractionTexture;
  158558. /** the base color of the refraction (used to taint the rendering) */
  158559. color: Color3;
  158560. /** simulated refraction depth */
  158561. depth: number;
  158562. /** the coefficient of the base color (0 to remove base color tainting) */
  158563. colorLevel: number;
  158564. /** Gets the url used to load the refraction texture */
  158565. refractionTextureUrl: string;
  158566. /**
  158567. * Gets or sets the refraction texture
  158568. * Please note that you are responsible for disposing the texture if you set it manually
  158569. */
  158570. get refractionTexture(): Texture;
  158571. set refractionTexture(value: Texture);
  158572. /**
  158573. * Gets a string identifying the name of the class
  158574. * @returns "RefractionPostProcess" string
  158575. */
  158576. getClassName(): string;
  158577. /**
  158578. * Initializes the RefractionPostProcess
  158579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  158580. * @param name The name of the effect.
  158581. * @param refractionTextureUrl Url of the refraction texture to use
  158582. * @param color the base color of the refraction (used to taint the rendering)
  158583. * @param depth simulated refraction depth
  158584. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  158585. * @param camera The camera to apply the render pass to.
  158586. * @param options The required width/height ratio to downsize to before computing the render pass.
  158587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158588. * @param engine The engine which the post process will be applied. (default: current engine)
  158589. * @param reusable If the post process can be reused on the same frame. (default: false)
  158590. */
  158591. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158592. /**
  158593. * Disposes of the post process
  158594. * @param camera Camera to dispose post process on
  158595. */
  158596. dispose(camera: Camera): void;
  158597. /** @hidden */
  158598. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  158599. }
  158600. }
  158601. declare module BABYLON {
  158602. /** @hidden */
  158603. export var sharpenPixelShader: {
  158604. name: string;
  158605. shader: string;
  158606. };
  158607. }
  158608. declare module BABYLON {
  158609. /**
  158610. * The SharpenPostProcess applies a sharpen kernel to every pixel
  158611. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  158612. */
  158613. export class SharpenPostProcess extends PostProcess {
  158614. /**
  158615. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  158616. */
  158617. colorAmount: number;
  158618. /**
  158619. * How much sharpness should be applied (default: 0.3)
  158620. */
  158621. edgeAmount: number;
  158622. /**
  158623. * Gets a string identifying the name of the class
  158624. * @returns "SharpenPostProcess" string
  158625. */
  158626. getClassName(): string;
  158627. /**
  158628. * Creates a new instance ConvolutionPostProcess
  158629. * @param name The name of the effect.
  158630. * @param options The required width/height ratio to downsize to before computing the render pass.
  158631. * @param camera The camera to apply the render pass to.
  158632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158633. * @param engine The engine which the post process will be applied. (default: current engine)
  158634. * @param reusable If the post process can be reused on the same frame. (default: false)
  158635. * @param textureType Type of textures used when performing the post process. (default: 0)
  158636. * @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)
  158637. */
  158638. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158639. /** @hidden */
  158640. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  158641. }
  158642. }
  158643. declare module BABYLON {
  158644. /**
  158645. * PostProcessRenderPipeline
  158646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158647. */
  158648. export class PostProcessRenderPipeline {
  158649. private engine;
  158650. private _renderEffects;
  158651. private _renderEffectsForIsolatedPass;
  158652. /**
  158653. * List of inspectable custom properties (used by the Inspector)
  158654. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  158655. */
  158656. inspectableCustomProperties: IInspectable[];
  158657. /**
  158658. * @hidden
  158659. */
  158660. protected _cameras: Camera[];
  158661. /** @hidden */
  158662. _name: string;
  158663. /**
  158664. * Gets pipeline name
  158665. */
  158666. get name(): string;
  158667. /** Gets the list of attached cameras */
  158668. get cameras(): Camera[];
  158669. /**
  158670. * Initializes a PostProcessRenderPipeline
  158671. * @param engine engine to add the pipeline to
  158672. * @param name name of the pipeline
  158673. */
  158674. constructor(engine: Engine, name: string);
  158675. /**
  158676. * Gets the class name
  158677. * @returns "PostProcessRenderPipeline"
  158678. */
  158679. getClassName(): string;
  158680. /**
  158681. * If all the render effects in the pipeline are supported
  158682. */
  158683. get isSupported(): boolean;
  158684. /**
  158685. * Adds an effect to the pipeline
  158686. * @param renderEffect the effect to add
  158687. */
  158688. addEffect(renderEffect: PostProcessRenderEffect): void;
  158689. /** @hidden */
  158690. _rebuild(): void;
  158691. /** @hidden */
  158692. _enableEffect(renderEffectName: string, cameras: Camera): void;
  158693. /** @hidden */
  158694. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  158695. /** @hidden */
  158696. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  158697. /** @hidden */
  158698. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  158699. /** @hidden */
  158700. _attachCameras(cameras: Camera, unique: boolean): void;
  158701. /** @hidden */
  158702. _attachCameras(cameras: Camera[], unique: boolean): void;
  158703. /** @hidden */
  158704. _detachCameras(cameras: Camera): void;
  158705. /** @hidden */
  158706. _detachCameras(cameras: Nullable<Camera[]>): void;
  158707. /** @hidden */
  158708. _update(): void;
  158709. /** @hidden */
  158710. _reset(): void;
  158711. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  158712. /**
  158713. * Sets the required values to the prepass renderer.
  158714. * @param prePassRenderer defines the prepass renderer to setup.
  158715. * @returns true if the pre pass is needed.
  158716. */
  158717. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  158718. /**
  158719. * Disposes of the pipeline
  158720. */
  158721. dispose(): void;
  158722. }
  158723. }
  158724. declare module BABYLON {
  158725. /**
  158726. * PostProcessRenderPipelineManager class
  158727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158728. */
  158729. export class PostProcessRenderPipelineManager {
  158730. private _renderPipelines;
  158731. /**
  158732. * Initializes a PostProcessRenderPipelineManager
  158733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158734. */
  158735. constructor();
  158736. /**
  158737. * Gets the list of supported render pipelines
  158738. */
  158739. get supportedPipelines(): PostProcessRenderPipeline[];
  158740. /**
  158741. * Adds a pipeline to the manager
  158742. * @param renderPipeline The pipeline to add
  158743. */
  158744. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  158745. /**
  158746. * Attaches a camera to the pipeline
  158747. * @param renderPipelineName The name of the pipeline to attach to
  158748. * @param cameras the camera to attach
  158749. * @param unique if the camera can be attached multiple times to the pipeline
  158750. */
  158751. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  158752. /**
  158753. * Detaches a camera from the pipeline
  158754. * @param renderPipelineName The name of the pipeline to detach from
  158755. * @param cameras the camera to detach
  158756. */
  158757. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  158758. /**
  158759. * Enables an effect by name on a pipeline
  158760. * @param renderPipelineName the name of the pipeline to enable the effect in
  158761. * @param renderEffectName the name of the effect to enable
  158762. * @param cameras the cameras that the effect should be enabled on
  158763. */
  158764. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  158765. /**
  158766. * Disables an effect by name on a pipeline
  158767. * @param renderPipelineName the name of the pipeline to disable the effect in
  158768. * @param renderEffectName the name of the effect to disable
  158769. * @param cameras the cameras that the effect should be disabled on
  158770. */
  158771. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  158772. /**
  158773. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  158774. */
  158775. update(): void;
  158776. /** @hidden */
  158777. _rebuild(): void;
  158778. /**
  158779. * Disposes of the manager and pipelines
  158780. */
  158781. dispose(): void;
  158782. }
  158783. }
  158784. declare module BABYLON {
  158785. interface Scene {
  158786. /** @hidden (Backing field) */
  158787. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  158788. /**
  158789. * Gets the postprocess render pipeline manager
  158790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158791. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  158792. */
  158793. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  158794. }
  158795. /**
  158796. * Defines the Render Pipeline scene component responsible to rendering pipelines
  158797. */
  158798. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  158799. /**
  158800. * The component name helpfull to identify the component in the list of scene components.
  158801. */
  158802. readonly name: string;
  158803. /**
  158804. * The scene the component belongs to.
  158805. */
  158806. scene: Scene;
  158807. /**
  158808. * Creates a new instance of the component for the given scene
  158809. * @param scene Defines the scene to register the component in
  158810. */
  158811. constructor(scene: Scene);
  158812. /**
  158813. * Registers the component in a given scene
  158814. */
  158815. register(): void;
  158816. /**
  158817. * Rebuilds the elements related to this component in case of
  158818. * context lost for instance.
  158819. */
  158820. rebuild(): void;
  158821. /**
  158822. * Disposes the component and the associated ressources
  158823. */
  158824. dispose(): void;
  158825. private _gatherRenderTargets;
  158826. }
  158827. }
  158828. declare module BABYLON {
  158829. /**
  158830. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  158831. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  158832. */
  158833. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  158834. private _scene;
  158835. private _camerasToBeAttached;
  158836. /**
  158837. * ID of the sharpen post process,
  158838. */
  158839. private readonly SharpenPostProcessId;
  158840. /**
  158841. * @ignore
  158842. * ID of the image processing post process;
  158843. */
  158844. readonly ImageProcessingPostProcessId: string;
  158845. /**
  158846. * @ignore
  158847. * ID of the Fast Approximate Anti-Aliasing post process;
  158848. */
  158849. readonly FxaaPostProcessId: string;
  158850. /**
  158851. * ID of the chromatic aberration post process,
  158852. */
  158853. private readonly ChromaticAberrationPostProcessId;
  158854. /**
  158855. * ID of the grain post process
  158856. */
  158857. private readonly GrainPostProcessId;
  158858. /**
  158859. * Sharpen post process which will apply a sharpen convolution to enhance edges
  158860. */
  158861. sharpen: SharpenPostProcess;
  158862. private _sharpenEffect;
  158863. private bloom;
  158864. /**
  158865. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  158866. */
  158867. depthOfField: DepthOfFieldEffect;
  158868. /**
  158869. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  158870. */
  158871. fxaa: FxaaPostProcess;
  158872. /**
  158873. * Image post processing pass used to perform operations such as tone mapping or color grading.
  158874. */
  158875. imageProcessing: ImageProcessingPostProcess;
  158876. /**
  158877. * Chromatic aberration post process which will shift rgb colors in the image
  158878. */
  158879. chromaticAberration: ChromaticAberrationPostProcess;
  158880. private _chromaticAberrationEffect;
  158881. /**
  158882. * Grain post process which add noise to the image
  158883. */
  158884. grain: GrainPostProcess;
  158885. private _grainEffect;
  158886. /**
  158887. * Glow post process which adds a glow to emissive areas of the image
  158888. */
  158889. private _glowLayer;
  158890. /**
  158891. * Animations which can be used to tweak settings over a period of time
  158892. */
  158893. animations: Animation[];
  158894. private _imageProcessingConfigurationObserver;
  158895. private _sharpenEnabled;
  158896. private _bloomEnabled;
  158897. private _depthOfFieldEnabled;
  158898. private _depthOfFieldBlurLevel;
  158899. private _fxaaEnabled;
  158900. private _imageProcessingEnabled;
  158901. private _defaultPipelineTextureType;
  158902. private _bloomScale;
  158903. private _chromaticAberrationEnabled;
  158904. private _grainEnabled;
  158905. private _buildAllowed;
  158906. /**
  158907. * This is triggered each time the pipeline has been built.
  158908. */
  158909. onBuildObservable: Observable<DefaultRenderingPipeline>;
  158910. /**
  158911. * Gets active scene
  158912. */
  158913. get scene(): Scene;
  158914. /**
  158915. * Enable or disable the sharpen process from the pipeline
  158916. */
  158917. set sharpenEnabled(enabled: boolean);
  158918. get sharpenEnabled(): boolean;
  158919. private _resizeObserver;
  158920. private _hardwareScaleLevel;
  158921. private _bloomKernel;
  158922. /**
  158923. * Specifies the size of the bloom blur kernel, relative to the final output size
  158924. */
  158925. get bloomKernel(): number;
  158926. set bloomKernel(value: number);
  158927. /**
  158928. * Specifies the weight of the bloom in the final rendering
  158929. */
  158930. private _bloomWeight;
  158931. /**
  158932. * Specifies the luma threshold for the area that will be blurred by the bloom
  158933. */
  158934. private _bloomThreshold;
  158935. private _hdr;
  158936. /**
  158937. * The strength of the bloom.
  158938. */
  158939. set bloomWeight(value: number);
  158940. get bloomWeight(): number;
  158941. /**
  158942. * The strength of the bloom.
  158943. */
  158944. set bloomThreshold(value: number);
  158945. get bloomThreshold(): number;
  158946. /**
  158947. * The scale of the bloom, lower value will provide better performance.
  158948. */
  158949. set bloomScale(value: number);
  158950. get bloomScale(): number;
  158951. /**
  158952. * Enable or disable the bloom from the pipeline
  158953. */
  158954. set bloomEnabled(enabled: boolean);
  158955. get bloomEnabled(): boolean;
  158956. private _rebuildBloom;
  158957. /**
  158958. * If the depth of field is enabled.
  158959. */
  158960. get depthOfFieldEnabled(): boolean;
  158961. set depthOfFieldEnabled(enabled: boolean);
  158962. /**
  158963. * Blur level of the depth of field effect. (Higher blur will effect performance)
  158964. */
  158965. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  158966. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  158967. /**
  158968. * If the anti aliasing is enabled.
  158969. */
  158970. set fxaaEnabled(enabled: boolean);
  158971. get fxaaEnabled(): boolean;
  158972. private _samples;
  158973. /**
  158974. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  158975. */
  158976. set samples(sampleCount: number);
  158977. get samples(): number;
  158978. /**
  158979. * If image processing is enabled.
  158980. */
  158981. set imageProcessingEnabled(enabled: boolean);
  158982. get imageProcessingEnabled(): boolean;
  158983. /**
  158984. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  158985. */
  158986. set glowLayerEnabled(enabled: boolean);
  158987. get glowLayerEnabled(): boolean;
  158988. /**
  158989. * Gets the glow layer (or null if not defined)
  158990. */
  158991. get glowLayer(): Nullable<GlowLayer>;
  158992. /**
  158993. * Enable or disable the chromaticAberration process from the pipeline
  158994. */
  158995. set chromaticAberrationEnabled(enabled: boolean);
  158996. get chromaticAberrationEnabled(): boolean;
  158997. /**
  158998. * Enable or disable the grain process from the pipeline
  158999. */
  159000. set grainEnabled(enabled: boolean);
  159001. get grainEnabled(): boolean;
  159002. /**
  159003. * @constructor
  159004. * @param name - The rendering pipeline name (default: "")
  159005. * @param hdr - If high dynamic range textures should be used (default: true)
  159006. * @param scene - The scene linked to this pipeline (default: the last created scene)
  159007. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  159008. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  159009. */
  159010. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  159011. /**
  159012. * Get the class name
  159013. * @returns "DefaultRenderingPipeline"
  159014. */
  159015. getClassName(): string;
  159016. /**
  159017. * Force the compilation of the entire pipeline.
  159018. */
  159019. prepare(): void;
  159020. private _hasCleared;
  159021. private _prevPostProcess;
  159022. private _prevPrevPostProcess;
  159023. private _setAutoClearAndTextureSharing;
  159024. private _depthOfFieldSceneObserver;
  159025. private _buildPipeline;
  159026. private _disposePostProcesses;
  159027. /**
  159028. * Adds a camera to the pipeline
  159029. * @param camera the camera to be added
  159030. */
  159031. addCamera(camera: Camera): void;
  159032. /**
  159033. * Removes a camera from the pipeline
  159034. * @param camera the camera to remove
  159035. */
  159036. removeCamera(camera: Camera): void;
  159037. /**
  159038. * Dispose of the pipeline and stop all post processes
  159039. */
  159040. dispose(): void;
  159041. /**
  159042. * Serialize the rendering pipeline (Used when exporting)
  159043. * @returns the serialized object
  159044. */
  159045. serialize(): any;
  159046. /**
  159047. * Parse the serialized pipeline
  159048. * @param source Source pipeline.
  159049. * @param scene The scene to load the pipeline to.
  159050. * @param rootUrl The URL of the serialized pipeline.
  159051. * @returns An instantiated pipeline from the serialized object.
  159052. */
  159053. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  159054. }
  159055. }
  159056. declare module BABYLON {
  159057. /** @hidden */
  159058. export var lensHighlightsPixelShader: {
  159059. name: string;
  159060. shader: string;
  159061. };
  159062. }
  159063. declare module BABYLON {
  159064. /** @hidden */
  159065. export var depthOfFieldPixelShader: {
  159066. name: string;
  159067. shader: string;
  159068. };
  159069. }
  159070. declare module BABYLON {
  159071. /**
  159072. * BABYLON.JS Chromatic Aberration GLSL Shader
  159073. * Author: Olivier Guyot
  159074. * Separates very slightly R, G and B colors on the edges of the screen
  159075. * Inspired by Francois Tarlier & Martins Upitis
  159076. */
  159077. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  159078. /**
  159079. * @ignore
  159080. * The chromatic aberration PostProcess id in the pipeline
  159081. */
  159082. LensChromaticAberrationEffect: string;
  159083. /**
  159084. * @ignore
  159085. * The highlights enhancing PostProcess id in the pipeline
  159086. */
  159087. HighlightsEnhancingEffect: string;
  159088. /**
  159089. * @ignore
  159090. * The depth-of-field PostProcess id in the pipeline
  159091. */
  159092. LensDepthOfFieldEffect: string;
  159093. private _scene;
  159094. private _depthTexture;
  159095. private _grainTexture;
  159096. private _chromaticAberrationPostProcess;
  159097. private _highlightsPostProcess;
  159098. private _depthOfFieldPostProcess;
  159099. private _edgeBlur;
  159100. private _grainAmount;
  159101. private _chromaticAberration;
  159102. private _distortion;
  159103. private _highlightsGain;
  159104. private _highlightsThreshold;
  159105. private _dofDistance;
  159106. private _dofAperture;
  159107. private _dofDarken;
  159108. private _dofPentagon;
  159109. private _blurNoise;
  159110. /**
  159111. * @constructor
  159112. *
  159113. * Effect parameters are as follow:
  159114. * {
  159115. * chromatic_aberration: number; // from 0 to x (1 for realism)
  159116. * edge_blur: number; // from 0 to x (1 for realism)
  159117. * distortion: number; // from 0 to x (1 for realism)
  159118. * grain_amount: number; // from 0 to 1
  159119. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  159120. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  159121. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  159122. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  159123. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  159124. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  159125. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  159126. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  159127. * }
  159128. * Note: if an effect parameter is unset, effect is disabled
  159129. *
  159130. * @param name The rendering pipeline name
  159131. * @param parameters - An object containing all parameters (see above)
  159132. * @param scene The scene linked to this pipeline
  159133. * @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)
  159134. * @param cameras The array of cameras that the rendering pipeline will be attached to
  159135. */
  159136. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  159137. /**
  159138. * Get the class name
  159139. * @returns "LensRenderingPipeline"
  159140. */
  159141. getClassName(): string;
  159142. /**
  159143. * Gets associated scene
  159144. */
  159145. get scene(): Scene;
  159146. /**
  159147. * Gets or sets the edge blur
  159148. */
  159149. get edgeBlur(): number;
  159150. set edgeBlur(value: number);
  159151. /**
  159152. * Gets or sets the grain amount
  159153. */
  159154. get grainAmount(): number;
  159155. set grainAmount(value: number);
  159156. /**
  159157. * Gets or sets the chromatic aberration amount
  159158. */
  159159. get chromaticAberration(): number;
  159160. set chromaticAberration(value: number);
  159161. /**
  159162. * Gets or sets the depth of field aperture
  159163. */
  159164. get dofAperture(): number;
  159165. set dofAperture(value: number);
  159166. /**
  159167. * Gets or sets the edge distortion
  159168. */
  159169. get edgeDistortion(): number;
  159170. set edgeDistortion(value: number);
  159171. /**
  159172. * Gets or sets the depth of field distortion
  159173. */
  159174. get dofDistortion(): number;
  159175. set dofDistortion(value: number);
  159176. /**
  159177. * Gets or sets the darken out of focus amount
  159178. */
  159179. get darkenOutOfFocus(): number;
  159180. set darkenOutOfFocus(value: number);
  159181. /**
  159182. * Gets or sets a boolean indicating if blur noise is enabled
  159183. */
  159184. get blurNoise(): boolean;
  159185. set blurNoise(value: boolean);
  159186. /**
  159187. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  159188. */
  159189. get pentagonBokeh(): boolean;
  159190. set pentagonBokeh(value: boolean);
  159191. /**
  159192. * Gets or sets the highlight grain amount
  159193. */
  159194. get highlightsGain(): number;
  159195. set highlightsGain(value: number);
  159196. /**
  159197. * Gets or sets the highlight threshold
  159198. */
  159199. get highlightsThreshold(): number;
  159200. set highlightsThreshold(value: number);
  159201. /**
  159202. * Sets the amount of blur at the edges
  159203. * @param amount blur amount
  159204. */
  159205. setEdgeBlur(amount: number): void;
  159206. /**
  159207. * Sets edge blur to 0
  159208. */
  159209. disableEdgeBlur(): void;
  159210. /**
  159211. * Sets the amout of grain
  159212. * @param amount Amount of grain
  159213. */
  159214. setGrainAmount(amount: number): void;
  159215. /**
  159216. * Set grain amount to 0
  159217. */
  159218. disableGrain(): void;
  159219. /**
  159220. * Sets the chromatic aberration amount
  159221. * @param amount amount of chromatic aberration
  159222. */
  159223. setChromaticAberration(amount: number): void;
  159224. /**
  159225. * Sets chromatic aberration amount to 0
  159226. */
  159227. disableChromaticAberration(): void;
  159228. /**
  159229. * Sets the EdgeDistortion amount
  159230. * @param amount amount of EdgeDistortion
  159231. */
  159232. setEdgeDistortion(amount: number): void;
  159233. /**
  159234. * Sets edge distortion to 0
  159235. */
  159236. disableEdgeDistortion(): void;
  159237. /**
  159238. * Sets the FocusDistance amount
  159239. * @param amount amount of FocusDistance
  159240. */
  159241. setFocusDistance(amount: number): void;
  159242. /**
  159243. * Disables depth of field
  159244. */
  159245. disableDepthOfField(): void;
  159246. /**
  159247. * Sets the Aperture amount
  159248. * @param amount amount of Aperture
  159249. */
  159250. setAperture(amount: number): void;
  159251. /**
  159252. * Sets the DarkenOutOfFocus amount
  159253. * @param amount amount of DarkenOutOfFocus
  159254. */
  159255. setDarkenOutOfFocus(amount: number): void;
  159256. private _pentagonBokehIsEnabled;
  159257. /**
  159258. * Creates a pentagon bokeh effect
  159259. */
  159260. enablePentagonBokeh(): void;
  159261. /**
  159262. * Disables the pentagon bokeh effect
  159263. */
  159264. disablePentagonBokeh(): void;
  159265. /**
  159266. * Enables noise blur
  159267. */
  159268. enableNoiseBlur(): void;
  159269. /**
  159270. * Disables noise blur
  159271. */
  159272. disableNoiseBlur(): void;
  159273. /**
  159274. * Sets the HighlightsGain amount
  159275. * @param amount amount of HighlightsGain
  159276. */
  159277. setHighlightsGain(amount: number): void;
  159278. /**
  159279. * Sets the HighlightsThreshold amount
  159280. * @param amount amount of HighlightsThreshold
  159281. */
  159282. setHighlightsThreshold(amount: number): void;
  159283. /**
  159284. * Disables highlights
  159285. */
  159286. disableHighlights(): void;
  159287. /**
  159288. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  159289. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  159290. */
  159291. dispose(disableDepthRender?: boolean): void;
  159292. private _createChromaticAberrationPostProcess;
  159293. private _createHighlightsPostProcess;
  159294. private _createDepthOfFieldPostProcess;
  159295. private _createGrainTexture;
  159296. }
  159297. }
  159298. declare module BABYLON {
  159299. /**
  159300. * Contains all parameters needed for the prepass to perform
  159301. * screen space subsurface scattering
  159302. */
  159303. export class SSAO2Configuration implements PrePassEffectConfiguration {
  159304. /**
  159305. * Is subsurface enabled
  159306. */
  159307. enabled: boolean;
  159308. /**
  159309. * Name of the configuration
  159310. */
  159311. name: string;
  159312. /**
  159313. * Textures that should be present in the MRT for this effect to work
  159314. */
  159315. readonly texturesRequired: number[];
  159316. }
  159317. }
  159318. declare module BABYLON {
  159319. /** @hidden */
  159320. export var ssao2PixelShader: {
  159321. name: string;
  159322. shader: string;
  159323. };
  159324. }
  159325. declare module BABYLON {
  159326. /** @hidden */
  159327. export var ssaoCombinePixelShader: {
  159328. name: string;
  159329. shader: string;
  159330. };
  159331. }
  159332. declare module BABYLON {
  159333. /**
  159334. * Render pipeline to produce ssao effect
  159335. */
  159336. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  159337. /**
  159338. * @ignore
  159339. * The PassPostProcess id in the pipeline that contains the original scene color
  159340. */
  159341. SSAOOriginalSceneColorEffect: string;
  159342. /**
  159343. * @ignore
  159344. * The SSAO PostProcess id in the pipeline
  159345. */
  159346. SSAORenderEffect: string;
  159347. /**
  159348. * @ignore
  159349. * The horizontal blur PostProcess id in the pipeline
  159350. */
  159351. SSAOBlurHRenderEffect: string;
  159352. /**
  159353. * @ignore
  159354. * The vertical blur PostProcess id in the pipeline
  159355. */
  159356. SSAOBlurVRenderEffect: string;
  159357. /**
  159358. * @ignore
  159359. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  159360. */
  159361. SSAOCombineRenderEffect: string;
  159362. /**
  159363. * The output strength of the SSAO post-process. Default value is 1.0.
  159364. */
  159365. totalStrength: number;
  159366. /**
  159367. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  159368. */
  159369. maxZ: number;
  159370. /**
  159371. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  159372. */
  159373. minZAspect: number;
  159374. private _samples;
  159375. /**
  159376. * Number of samples used for the SSAO calculations. Default value is 8
  159377. */
  159378. set samples(n: number);
  159379. get samples(): number;
  159380. private _textureSamples;
  159381. /**
  159382. * Number of samples to use for antialiasing
  159383. */
  159384. set textureSamples(n: number);
  159385. get textureSamples(): number;
  159386. /**
  159387. * Force rendering the geometry through geometry buffer
  159388. */
  159389. private _forceGeometryBuffer;
  159390. /**
  159391. * Ratio object used for SSAO ratio and blur ratio
  159392. */
  159393. private _ratio;
  159394. /**
  159395. * Dynamically generated sphere sampler.
  159396. */
  159397. private _sampleSphere;
  159398. /**
  159399. * Blur filter offsets
  159400. */
  159401. private _samplerOffsets;
  159402. private _expensiveBlur;
  159403. /**
  159404. * If bilateral blur should be used
  159405. */
  159406. set expensiveBlur(b: boolean);
  159407. get expensiveBlur(): boolean;
  159408. /**
  159409. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  159410. */
  159411. radius: number;
  159412. /**
  159413. * The base color of the SSAO post-process
  159414. * The final result is "base + ssao" between [0, 1]
  159415. */
  159416. base: number;
  159417. /**
  159418. * Support test.
  159419. */
  159420. static get IsSupported(): boolean;
  159421. private _scene;
  159422. private _randomTexture;
  159423. private _originalColorPostProcess;
  159424. private _ssaoPostProcess;
  159425. private _blurHPostProcess;
  159426. private _blurVPostProcess;
  159427. private _ssaoCombinePostProcess;
  159428. private _prePassRenderer;
  159429. /**
  159430. * Gets active scene
  159431. */
  159432. get scene(): Scene;
  159433. /**
  159434. * @constructor
  159435. * @param name The rendering pipeline name
  159436. * @param scene The scene linked to this pipeline
  159437. * @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 }
  159438. * @param cameras The array of cameras that the rendering pipeline will be attached to
  159439. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  159440. */
  159441. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  159442. /**
  159443. * Get the class name
  159444. * @returns "SSAO2RenderingPipeline"
  159445. */
  159446. getClassName(): string;
  159447. /**
  159448. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  159449. */
  159450. dispose(disableGeometryBufferRenderer?: boolean): void;
  159451. private _createBlurPostProcess;
  159452. /** @hidden */
  159453. _rebuild(): void;
  159454. private _bits;
  159455. private _radicalInverse_VdC;
  159456. private _hammersley;
  159457. private _hemisphereSample_uniform;
  159458. private _generateHemisphere;
  159459. private _getDefinesForSSAO;
  159460. private static readonly ORTHO_DEPTH_PROJECTION;
  159461. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  159462. private _createSSAOPostProcess;
  159463. private _createSSAOCombinePostProcess;
  159464. private _createRandomTexture;
  159465. /**
  159466. * Serialize the rendering pipeline (Used when exporting)
  159467. * @returns the serialized object
  159468. */
  159469. serialize(): any;
  159470. /**
  159471. * Parse the serialized pipeline
  159472. * @param source Source pipeline.
  159473. * @param scene The scene to load the pipeline to.
  159474. * @param rootUrl The URL of the serialized pipeline.
  159475. * @returns An instantiated pipeline from the serialized object.
  159476. */
  159477. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  159478. }
  159479. }
  159480. declare module BABYLON {
  159481. /** @hidden */
  159482. export var ssaoPixelShader: {
  159483. name: string;
  159484. shader: string;
  159485. };
  159486. }
  159487. declare module BABYLON {
  159488. /**
  159489. * Render pipeline to produce ssao effect
  159490. */
  159491. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  159492. /**
  159493. * @ignore
  159494. * The PassPostProcess id in the pipeline that contains the original scene color
  159495. */
  159496. SSAOOriginalSceneColorEffect: string;
  159497. /**
  159498. * @ignore
  159499. * The SSAO PostProcess id in the pipeline
  159500. */
  159501. SSAORenderEffect: string;
  159502. /**
  159503. * @ignore
  159504. * The horizontal blur PostProcess id in the pipeline
  159505. */
  159506. SSAOBlurHRenderEffect: string;
  159507. /**
  159508. * @ignore
  159509. * The vertical blur PostProcess id in the pipeline
  159510. */
  159511. SSAOBlurVRenderEffect: string;
  159512. /**
  159513. * @ignore
  159514. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  159515. */
  159516. SSAOCombineRenderEffect: string;
  159517. /**
  159518. * The output strength of the SSAO post-process. Default value is 1.0.
  159519. */
  159520. totalStrength: number;
  159521. /**
  159522. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  159523. */
  159524. radius: number;
  159525. /**
  159526. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  159527. * Must not be equal to fallOff and superior to fallOff.
  159528. * Default value is 0.0075
  159529. */
  159530. area: number;
  159531. /**
  159532. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  159533. * Must not be equal to area and inferior to area.
  159534. * Default value is 0.000001
  159535. */
  159536. fallOff: number;
  159537. /**
  159538. * The base color of the SSAO post-process
  159539. * The final result is "base + ssao" between [0, 1]
  159540. */
  159541. base: number;
  159542. private _scene;
  159543. private _depthTexture;
  159544. private _randomTexture;
  159545. private _originalColorPostProcess;
  159546. private _ssaoPostProcess;
  159547. private _blurHPostProcess;
  159548. private _blurVPostProcess;
  159549. private _ssaoCombinePostProcess;
  159550. private _firstUpdate;
  159551. /**
  159552. * Gets active scene
  159553. */
  159554. get scene(): Scene;
  159555. /**
  159556. * @constructor
  159557. * @param name - The rendering pipeline name
  159558. * @param scene - The scene linked to this pipeline
  159559. * @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 }
  159560. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  159561. */
  159562. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  159563. /**
  159564. * Get the class name
  159565. * @returns "SSAORenderingPipeline"
  159566. */
  159567. getClassName(): string;
  159568. /**
  159569. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  159570. */
  159571. dispose(disableDepthRender?: boolean): void;
  159572. private _createBlurPostProcess;
  159573. /** @hidden */
  159574. _rebuild(): void;
  159575. private _createSSAOPostProcess;
  159576. private _createSSAOCombinePostProcess;
  159577. private _createRandomTexture;
  159578. }
  159579. }
  159580. declare module BABYLON {
  159581. /**
  159582. * Contains all parameters needed for the prepass to perform
  159583. * screen space reflections
  159584. */
  159585. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  159586. /**
  159587. * Is ssr enabled
  159588. */
  159589. enabled: boolean;
  159590. /**
  159591. * Name of the configuration
  159592. */
  159593. name: string;
  159594. /**
  159595. * Textures that should be present in the MRT for this effect to work
  159596. */
  159597. readonly texturesRequired: number[];
  159598. }
  159599. }
  159600. declare module BABYLON {
  159601. /** @hidden */
  159602. export var screenSpaceReflectionPixelShader: {
  159603. name: string;
  159604. shader: string;
  159605. };
  159606. }
  159607. declare module BABYLON {
  159608. /**
  159609. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  159610. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  159611. */
  159612. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  159613. /**
  159614. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  159615. */
  159616. threshold: number;
  159617. /**
  159618. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  159619. */
  159620. strength: number;
  159621. /**
  159622. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  159623. */
  159624. reflectionSpecularFalloffExponent: number;
  159625. /**
  159626. * 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]
  159627. */
  159628. step: number;
  159629. /**
  159630. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  159631. */
  159632. roughnessFactor: number;
  159633. private _forceGeometryBuffer;
  159634. private _geometryBufferRenderer;
  159635. private _prePassRenderer;
  159636. private _enableSmoothReflections;
  159637. private _reflectionSamples;
  159638. private _smoothSteps;
  159639. /**
  159640. * Gets a string identifying the name of the class
  159641. * @returns "ScreenSpaceReflectionPostProcess" string
  159642. */
  159643. getClassName(): string;
  159644. /**
  159645. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  159646. * @param name The name of the effect.
  159647. * @param scene The scene containing the objects to calculate reflections.
  159648. * @param options The required width/height ratio to downsize to before computing the render pass.
  159649. * @param camera The camera to apply the render pass to.
  159650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159651. * @param engine The engine which the post process will be applied. (default: current engine)
  159652. * @param reusable If the post process can be reused on the same frame. (default: false)
  159653. * @param textureType Type of textures used when performing the post process. (default: 0)
  159654. * @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)
  159655. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  159656. */
  159657. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  159658. /**
  159659. * Gets wether or not smoothing reflections is enabled.
  159660. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  159661. */
  159662. get enableSmoothReflections(): boolean;
  159663. /**
  159664. * Sets wether or not smoothing reflections is enabled.
  159665. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  159666. */
  159667. set enableSmoothReflections(enabled: boolean);
  159668. /**
  159669. * Gets the number of samples taken while computing reflections. More samples count is high,
  159670. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  159671. */
  159672. get reflectionSamples(): number;
  159673. /**
  159674. * Sets the number of samples taken while computing reflections. More samples count is high,
  159675. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  159676. */
  159677. set reflectionSamples(samples: number);
  159678. /**
  159679. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  159680. * more the post-process will require GPU power and can generate a drop in FPS.
  159681. * Default value (5.0) work pretty well in all cases but can be adjusted.
  159682. */
  159683. get smoothSteps(): number;
  159684. set smoothSteps(steps: number);
  159685. private _updateEffectDefines;
  159686. /** @hidden */
  159687. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  159688. }
  159689. }
  159690. declare module BABYLON {
  159691. /** @hidden */
  159692. export var standardPixelShader: {
  159693. name: string;
  159694. shader: string;
  159695. };
  159696. }
  159697. declare module BABYLON {
  159698. /**
  159699. * Standard rendering pipeline
  159700. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  159701. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  159702. */
  159703. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  159704. /**
  159705. * Public members
  159706. */
  159707. /**
  159708. * Post-process which contains the original scene color before the pipeline applies all the effects
  159709. */
  159710. originalPostProcess: Nullable<PostProcess>;
  159711. /**
  159712. * Post-process used to down scale an image x4
  159713. */
  159714. downSampleX4PostProcess: Nullable<PostProcess>;
  159715. /**
  159716. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  159717. */
  159718. brightPassPostProcess: Nullable<PostProcess>;
  159719. /**
  159720. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  159721. */
  159722. blurHPostProcesses: PostProcess[];
  159723. /**
  159724. * Post-process array storing all the vertical blur post-processes used by the pipeline
  159725. */
  159726. blurVPostProcesses: PostProcess[];
  159727. /**
  159728. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  159729. */
  159730. textureAdderPostProcess: Nullable<PostProcess>;
  159731. /**
  159732. * Post-process used to create volumetric lighting effect
  159733. */
  159734. volumetricLightPostProcess: Nullable<PostProcess>;
  159735. /**
  159736. * Post-process used to smooth the previous volumetric light post-process on the X axis
  159737. */
  159738. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  159739. /**
  159740. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  159741. */
  159742. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  159743. /**
  159744. * Post-process used to merge the volumetric light effect and the real scene color
  159745. */
  159746. volumetricLightMergePostProces: Nullable<PostProcess>;
  159747. /**
  159748. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  159749. */
  159750. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  159751. /**
  159752. * Base post-process used to calculate the average luminance of the final image for HDR
  159753. */
  159754. luminancePostProcess: Nullable<PostProcess>;
  159755. /**
  159756. * Post-processes used to create down sample post-processes in order to get
  159757. * the average luminance of the final image for HDR
  159758. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  159759. */
  159760. luminanceDownSamplePostProcesses: PostProcess[];
  159761. /**
  159762. * Post-process used to create a HDR effect (light adaptation)
  159763. */
  159764. hdrPostProcess: Nullable<PostProcess>;
  159765. /**
  159766. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  159767. */
  159768. textureAdderFinalPostProcess: Nullable<PostProcess>;
  159769. /**
  159770. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  159771. */
  159772. lensFlareFinalPostProcess: Nullable<PostProcess>;
  159773. /**
  159774. * Post-process used to merge the final HDR post-process and the real scene color
  159775. */
  159776. hdrFinalPostProcess: Nullable<PostProcess>;
  159777. /**
  159778. * Post-process used to create a lens flare effect
  159779. */
  159780. lensFlarePostProcess: Nullable<PostProcess>;
  159781. /**
  159782. * Post-process that merges the result of the lens flare post-process and the real scene color
  159783. */
  159784. lensFlareComposePostProcess: Nullable<PostProcess>;
  159785. /**
  159786. * Post-process used to create a motion blur effect
  159787. */
  159788. motionBlurPostProcess: Nullable<PostProcess>;
  159789. /**
  159790. * Post-process used to create a depth of field effect
  159791. */
  159792. depthOfFieldPostProcess: Nullable<PostProcess>;
  159793. /**
  159794. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  159795. */
  159796. fxaaPostProcess: Nullable<FxaaPostProcess>;
  159797. /**
  159798. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  159799. */
  159800. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  159801. /**
  159802. * Represents the brightness threshold in order to configure the illuminated surfaces
  159803. */
  159804. brightThreshold: number;
  159805. /**
  159806. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  159807. */
  159808. blurWidth: number;
  159809. /**
  159810. * Sets if the blur for highlighted surfaces must be only horizontal
  159811. */
  159812. horizontalBlur: boolean;
  159813. /**
  159814. * Gets the overall exposure used by the pipeline
  159815. */
  159816. get exposure(): number;
  159817. /**
  159818. * Sets the overall exposure used by the pipeline
  159819. */
  159820. set exposure(value: number);
  159821. /**
  159822. * Texture used typically to simulate "dirty" on camera lens
  159823. */
  159824. lensTexture: Nullable<Texture>;
  159825. /**
  159826. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  159827. */
  159828. volumetricLightCoefficient: number;
  159829. /**
  159830. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  159831. */
  159832. volumetricLightPower: number;
  159833. /**
  159834. * Used the set the blur intensity to smooth the volumetric lights
  159835. */
  159836. volumetricLightBlurScale: number;
  159837. /**
  159838. * Light (spot or directional) used to generate the volumetric lights rays
  159839. * The source light must have a shadow generate so the pipeline can get its
  159840. * depth map
  159841. */
  159842. sourceLight: Nullable<SpotLight | DirectionalLight>;
  159843. /**
  159844. * For eye adaptation, represents the minimum luminance the eye can see
  159845. */
  159846. hdrMinimumLuminance: number;
  159847. /**
  159848. * For eye adaptation, represents the decrease luminance speed
  159849. */
  159850. hdrDecreaseRate: number;
  159851. /**
  159852. * For eye adaptation, represents the increase luminance speed
  159853. */
  159854. hdrIncreaseRate: number;
  159855. /**
  159856. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  159857. */
  159858. get hdrAutoExposure(): boolean;
  159859. /**
  159860. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  159861. */
  159862. set hdrAutoExposure(value: boolean);
  159863. /**
  159864. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  159865. */
  159866. lensColorTexture: Nullable<Texture>;
  159867. /**
  159868. * The overall strengh for the lens flare effect
  159869. */
  159870. lensFlareStrength: number;
  159871. /**
  159872. * Dispersion coefficient for lens flare ghosts
  159873. */
  159874. lensFlareGhostDispersal: number;
  159875. /**
  159876. * Main lens flare halo width
  159877. */
  159878. lensFlareHaloWidth: number;
  159879. /**
  159880. * Based on the lens distortion effect, defines how much the lens flare result
  159881. * is distorted
  159882. */
  159883. lensFlareDistortionStrength: number;
  159884. /**
  159885. * Configures the blur intensity used for for lens flare (halo)
  159886. */
  159887. lensFlareBlurWidth: number;
  159888. /**
  159889. * Lens star texture must be used to simulate rays on the flares and is available
  159890. * in the documentation
  159891. */
  159892. lensStarTexture: Nullable<Texture>;
  159893. /**
  159894. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  159895. * flare effect by taking account of the dirt texture
  159896. */
  159897. lensFlareDirtTexture: Nullable<Texture>;
  159898. /**
  159899. * Represents the focal length for the depth of field effect
  159900. */
  159901. depthOfFieldDistance: number;
  159902. /**
  159903. * Represents the blur intensity for the blurred part of the depth of field effect
  159904. */
  159905. depthOfFieldBlurWidth: number;
  159906. /**
  159907. * Gets how much the image is blurred by the movement while using the motion blur post-process
  159908. */
  159909. get motionStrength(): number;
  159910. /**
  159911. * Sets how much the image is blurred by the movement while using the motion blur post-process
  159912. */
  159913. set motionStrength(strength: number);
  159914. /**
  159915. * Gets wether or not the motion blur post-process is object based or screen based.
  159916. */
  159917. get objectBasedMotionBlur(): boolean;
  159918. /**
  159919. * Sets wether or not the motion blur post-process should be object based or screen based
  159920. */
  159921. set objectBasedMotionBlur(value: boolean);
  159922. /**
  159923. * List of animations for the pipeline (IAnimatable implementation)
  159924. */
  159925. animations: Animation[];
  159926. /**
  159927. * Private members
  159928. */
  159929. private _scene;
  159930. private _currentDepthOfFieldSource;
  159931. private _basePostProcess;
  159932. private _fixedExposure;
  159933. private _currentExposure;
  159934. private _hdrAutoExposure;
  159935. private _hdrCurrentLuminance;
  159936. private _motionStrength;
  159937. private _isObjectBasedMotionBlur;
  159938. private _floatTextureType;
  159939. private _camerasToBeAttached;
  159940. private _ratio;
  159941. private _bloomEnabled;
  159942. private _depthOfFieldEnabled;
  159943. private _vlsEnabled;
  159944. private _lensFlareEnabled;
  159945. private _hdrEnabled;
  159946. private _motionBlurEnabled;
  159947. private _fxaaEnabled;
  159948. private _screenSpaceReflectionsEnabled;
  159949. private _motionBlurSamples;
  159950. private _volumetricLightStepsCount;
  159951. private _samples;
  159952. /**
  159953. * @ignore
  159954. * Specifies if the bloom pipeline is enabled
  159955. */
  159956. get BloomEnabled(): boolean;
  159957. set BloomEnabled(enabled: boolean);
  159958. /**
  159959. * @ignore
  159960. * Specifies if the depth of field pipeline is enabed
  159961. */
  159962. get DepthOfFieldEnabled(): boolean;
  159963. set DepthOfFieldEnabled(enabled: boolean);
  159964. /**
  159965. * @ignore
  159966. * Specifies if the lens flare pipeline is enabed
  159967. */
  159968. get LensFlareEnabled(): boolean;
  159969. set LensFlareEnabled(enabled: boolean);
  159970. /**
  159971. * @ignore
  159972. * Specifies if the HDR pipeline is enabled
  159973. */
  159974. get HDREnabled(): boolean;
  159975. set HDREnabled(enabled: boolean);
  159976. /**
  159977. * @ignore
  159978. * Specifies if the volumetric lights scattering effect is enabled
  159979. */
  159980. get VLSEnabled(): boolean;
  159981. set VLSEnabled(enabled: boolean);
  159982. /**
  159983. * @ignore
  159984. * Specifies if the motion blur effect is enabled
  159985. */
  159986. get MotionBlurEnabled(): boolean;
  159987. set MotionBlurEnabled(enabled: boolean);
  159988. /**
  159989. * Specifies if anti-aliasing is enabled
  159990. */
  159991. get fxaaEnabled(): boolean;
  159992. set fxaaEnabled(enabled: boolean);
  159993. /**
  159994. * Specifies if screen space reflections are enabled.
  159995. */
  159996. get screenSpaceReflectionsEnabled(): boolean;
  159997. set screenSpaceReflectionsEnabled(enabled: boolean);
  159998. /**
  159999. * Specifies the number of steps used to calculate the volumetric lights
  160000. * Typically in interval [50, 200]
  160001. */
  160002. get volumetricLightStepsCount(): number;
  160003. set volumetricLightStepsCount(count: number);
  160004. /**
  160005. * Specifies the number of samples used for the motion blur effect
  160006. * Typically in interval [16, 64]
  160007. */
  160008. get motionBlurSamples(): number;
  160009. set motionBlurSamples(samples: number);
  160010. /**
  160011. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  160012. */
  160013. get samples(): number;
  160014. set samples(sampleCount: number);
  160015. /**
  160016. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  160017. * @constructor
  160018. * @param name The rendering pipeline name
  160019. * @param scene The scene linked to this pipeline
  160020. * @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)
  160021. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  160022. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160023. */
  160024. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  160025. private _buildPipeline;
  160026. private _createDownSampleX4PostProcess;
  160027. private _createBrightPassPostProcess;
  160028. private _createBlurPostProcesses;
  160029. private _createTextureAdderPostProcess;
  160030. private _createVolumetricLightPostProcess;
  160031. private _createLuminancePostProcesses;
  160032. private _createHdrPostProcess;
  160033. private _createLensFlarePostProcess;
  160034. private _createDepthOfFieldPostProcess;
  160035. private _createMotionBlurPostProcess;
  160036. private _getDepthTexture;
  160037. private _disposePostProcesses;
  160038. /**
  160039. * Dispose of the pipeline and stop all post processes
  160040. */
  160041. dispose(): void;
  160042. /**
  160043. * Serialize the rendering pipeline (Used when exporting)
  160044. * @returns the serialized object
  160045. */
  160046. serialize(): any;
  160047. /**
  160048. * Parse the serialized pipeline
  160049. * @param source Source pipeline.
  160050. * @param scene The scene to load the pipeline to.
  160051. * @param rootUrl The URL of the serialized pipeline.
  160052. * @returns An instantiated pipeline from the serialized object.
  160053. */
  160054. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  160055. /**
  160056. * Luminance steps
  160057. */
  160058. static LuminanceSteps: number;
  160059. }
  160060. }
  160061. declare module BABYLON {
  160062. /** @hidden */
  160063. export var stereoscopicInterlacePixelShader: {
  160064. name: string;
  160065. shader: string;
  160066. };
  160067. }
  160068. declare module BABYLON {
  160069. /**
  160070. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  160071. */
  160072. export class StereoscopicInterlacePostProcessI extends PostProcess {
  160073. private _stepSize;
  160074. private _passedProcess;
  160075. /**
  160076. * Gets a string identifying the name of the class
  160077. * @returns "StereoscopicInterlacePostProcessI" string
  160078. */
  160079. getClassName(): string;
  160080. /**
  160081. * Initializes a StereoscopicInterlacePostProcessI
  160082. * @param name The name of the effect.
  160083. * @param rigCameras The rig cameras to be appled to the post process
  160084. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  160085. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  160086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160087. * @param engine The engine which the post process will be applied. (default: current engine)
  160088. * @param reusable If the post process can be reused on the same frame. (default: false)
  160089. */
  160090. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  160091. }
  160092. /**
  160093. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  160094. */
  160095. export class StereoscopicInterlacePostProcess extends PostProcess {
  160096. private _stepSize;
  160097. private _passedProcess;
  160098. /**
  160099. * Gets a string identifying the name of the class
  160100. * @returns "StereoscopicInterlacePostProcess" string
  160101. */
  160102. getClassName(): string;
  160103. /**
  160104. * Initializes a StereoscopicInterlacePostProcess
  160105. * @param name The name of the effect.
  160106. * @param rigCameras The rig cameras to be appled to the post process
  160107. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  160108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160109. * @param engine The engine which the post process will be applied. (default: current engine)
  160110. * @param reusable If the post process can be reused on the same frame. (default: false)
  160111. */
  160112. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  160113. }
  160114. }
  160115. declare module BABYLON {
  160116. /** @hidden */
  160117. export var tonemapPixelShader: {
  160118. name: string;
  160119. shader: string;
  160120. };
  160121. }
  160122. declare module BABYLON {
  160123. /** Defines operator used for tonemapping */
  160124. export enum TonemappingOperator {
  160125. /** Hable */
  160126. Hable = 0,
  160127. /** Reinhard */
  160128. Reinhard = 1,
  160129. /** HejiDawson */
  160130. HejiDawson = 2,
  160131. /** Photographic */
  160132. Photographic = 3
  160133. }
  160134. /**
  160135. * Defines a post process to apply tone mapping
  160136. */
  160137. export class TonemapPostProcess extends PostProcess {
  160138. private _operator;
  160139. /** Defines the required exposure adjustement */
  160140. exposureAdjustment: number;
  160141. /**
  160142. * Gets a string identifying the name of the class
  160143. * @returns "TonemapPostProcess" string
  160144. */
  160145. getClassName(): string;
  160146. /**
  160147. * Creates a new TonemapPostProcess
  160148. * @param name defines the name of the postprocess
  160149. * @param _operator defines the operator to use
  160150. * @param exposureAdjustment defines the required exposure adjustement
  160151. * @param camera defines the camera to use (can be null)
  160152. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  160153. * @param engine defines the hosting engine (can be ignore if camera is set)
  160154. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  160155. */
  160156. constructor(name: string, _operator: TonemappingOperator,
  160157. /** Defines the required exposure adjustement */
  160158. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  160159. }
  160160. }
  160161. declare module BABYLON {
  160162. /** @hidden */
  160163. export var volumetricLightScatteringPixelShader: {
  160164. name: string;
  160165. shader: string;
  160166. };
  160167. }
  160168. declare module BABYLON {
  160169. /** @hidden */
  160170. export var volumetricLightScatteringPassVertexShader: {
  160171. name: string;
  160172. shader: string;
  160173. };
  160174. }
  160175. declare module BABYLON {
  160176. /** @hidden */
  160177. export var volumetricLightScatteringPassPixelShader: {
  160178. name: string;
  160179. shader: string;
  160180. };
  160181. }
  160182. declare module BABYLON {
  160183. /**
  160184. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  160185. */
  160186. export class VolumetricLightScatteringPostProcess extends PostProcess {
  160187. private _volumetricLightScatteringPass;
  160188. private _volumetricLightScatteringRTT;
  160189. private _viewPort;
  160190. private _screenCoordinates;
  160191. private _cachedDefines;
  160192. /**
  160193. * If not undefined, the mesh position is computed from the attached node position
  160194. */
  160195. attachedNode: {
  160196. position: Vector3;
  160197. };
  160198. /**
  160199. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  160200. */
  160201. customMeshPosition: Vector3;
  160202. /**
  160203. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  160204. */
  160205. useCustomMeshPosition: boolean;
  160206. /**
  160207. * If the post-process should inverse the light scattering direction
  160208. */
  160209. invert: boolean;
  160210. /**
  160211. * The internal mesh used by the post-process
  160212. */
  160213. mesh: Mesh;
  160214. /**
  160215. * @hidden
  160216. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  160217. */
  160218. get useDiffuseColor(): boolean;
  160219. set useDiffuseColor(useDiffuseColor: boolean);
  160220. /**
  160221. * Array containing the excluded meshes not rendered in the internal pass
  160222. */
  160223. excludedMeshes: AbstractMesh[];
  160224. /**
  160225. * Controls the overall intensity of the post-process
  160226. */
  160227. exposure: number;
  160228. /**
  160229. * Dissipates each sample's contribution in range [0, 1]
  160230. */
  160231. decay: number;
  160232. /**
  160233. * Controls the overall intensity of each sample
  160234. */
  160235. weight: number;
  160236. /**
  160237. * Controls the density of each sample
  160238. */
  160239. density: number;
  160240. /**
  160241. * @constructor
  160242. * @param name The post-process name
  160243. * @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)
  160244. * @param camera The camera that the post-process will be attached to
  160245. * @param mesh The mesh used to create the light scattering
  160246. * @param samples The post-process quality, default 100
  160247. * @param samplingModeThe post-process filtering mode
  160248. * @param engine The babylon engine
  160249. * @param reusable If the post-process is reusable
  160250. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  160251. */
  160252. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  160253. /**
  160254. * Returns the string "VolumetricLightScatteringPostProcess"
  160255. * @returns "VolumetricLightScatteringPostProcess"
  160256. */
  160257. getClassName(): string;
  160258. private _isReady;
  160259. /**
  160260. * Sets the new light position for light scattering effect
  160261. * @param position The new custom light position
  160262. */
  160263. setCustomMeshPosition(position: Vector3): void;
  160264. /**
  160265. * Returns the light position for light scattering effect
  160266. * @return Vector3 The custom light position
  160267. */
  160268. getCustomMeshPosition(): Vector3;
  160269. /**
  160270. * Disposes the internal assets and detaches the post-process from the camera
  160271. */
  160272. dispose(camera: Camera): void;
  160273. /**
  160274. * Returns the render target texture used by the post-process
  160275. * @return the render target texture used by the post-process
  160276. */
  160277. getPass(): RenderTargetTexture;
  160278. private _meshExcluded;
  160279. private _createPass;
  160280. private _updateMeshScreenCoordinates;
  160281. /**
  160282. * Creates a default mesh for the Volumeric Light Scattering post-process
  160283. * @param name The mesh name
  160284. * @param scene The scene where to create the mesh
  160285. * @return the default mesh
  160286. */
  160287. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  160288. }
  160289. }
  160290. declare module BABYLON {
  160291. /** @hidden */
  160292. export var screenSpaceCurvaturePixelShader: {
  160293. name: string;
  160294. shader: string;
  160295. };
  160296. }
  160297. declare module BABYLON {
  160298. /**
  160299. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  160300. */
  160301. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  160302. /**
  160303. * Defines how much ridge the curvature effect displays.
  160304. */
  160305. ridge: number;
  160306. /**
  160307. * Defines how much valley the curvature effect displays.
  160308. */
  160309. valley: number;
  160310. private _geometryBufferRenderer;
  160311. /**
  160312. * Gets a string identifying the name of the class
  160313. * @returns "ScreenSpaceCurvaturePostProcess" string
  160314. */
  160315. getClassName(): string;
  160316. /**
  160317. * Creates a new instance ScreenSpaceCurvaturePostProcess
  160318. * @param name The name of the effect.
  160319. * @param scene The scene containing the objects to blur according to their velocity.
  160320. * @param options The required width/height ratio to downsize to before computing the render pass.
  160321. * @param camera The camera to apply the render pass to.
  160322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160323. * @param engine The engine which the post process will be applied. (default: current engine)
  160324. * @param reusable If the post process can be reused on the same frame. (default: false)
  160325. * @param textureType Type of textures used when performing the post process. (default: 0)
  160326. * @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)
  160327. */
  160328. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  160329. /**
  160330. * Support test.
  160331. */
  160332. static get IsSupported(): boolean;
  160333. /** @hidden */
  160334. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  160335. }
  160336. }
  160337. declare module BABYLON {
  160338. interface Scene {
  160339. /** @hidden (Backing field) */
  160340. _boundingBoxRenderer: BoundingBoxRenderer;
  160341. /** @hidden (Backing field) */
  160342. _forceShowBoundingBoxes: boolean;
  160343. /**
  160344. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  160345. */
  160346. forceShowBoundingBoxes: boolean;
  160347. /**
  160348. * Gets the bounding box renderer associated with the scene
  160349. * @returns a BoundingBoxRenderer
  160350. */
  160351. getBoundingBoxRenderer(): BoundingBoxRenderer;
  160352. }
  160353. interface AbstractMesh {
  160354. /** @hidden (Backing field) */
  160355. _showBoundingBox: boolean;
  160356. /**
  160357. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  160358. */
  160359. showBoundingBox: boolean;
  160360. }
  160361. /**
  160362. * Component responsible of rendering the bounding box of the meshes in a scene.
  160363. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  160364. */
  160365. export class BoundingBoxRenderer implements ISceneComponent {
  160366. /**
  160367. * The component name helpfull to identify the component in the list of scene components.
  160368. */
  160369. readonly name: string;
  160370. /**
  160371. * The scene the component belongs to.
  160372. */
  160373. scene: Scene;
  160374. /**
  160375. * Color of the bounding box lines placed in front of an object
  160376. */
  160377. frontColor: Color3;
  160378. /**
  160379. * Color of the bounding box lines placed behind an object
  160380. */
  160381. backColor: Color3;
  160382. /**
  160383. * Defines if the renderer should show the back lines or not
  160384. */
  160385. showBackLines: boolean;
  160386. /**
  160387. * Observable raised before rendering a bounding box
  160388. */
  160389. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  160390. /**
  160391. * Observable raised after rendering a bounding box
  160392. */
  160393. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  160394. /**
  160395. * Observable raised after resources are created
  160396. */
  160397. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  160398. /**
  160399. * When false, no bounding boxes will be rendered
  160400. */
  160401. enabled: boolean;
  160402. /**
  160403. * @hidden
  160404. */
  160405. renderList: SmartArray<BoundingBox>;
  160406. private _colorShader;
  160407. private _vertexBuffers;
  160408. private _indexBuffer;
  160409. private _fillIndexBuffer;
  160410. private _fillIndexData;
  160411. /**
  160412. * Instantiates a new bounding box renderer in a scene.
  160413. * @param scene the scene the renderer renders in
  160414. */
  160415. constructor(scene: Scene);
  160416. /**
  160417. * Registers the component in a given scene
  160418. */
  160419. register(): void;
  160420. private _evaluateSubMesh;
  160421. private _preActiveMesh;
  160422. private _prepareResources;
  160423. private _createIndexBuffer;
  160424. /**
  160425. * Rebuilds the elements related to this component in case of
  160426. * context lost for instance.
  160427. */
  160428. rebuild(): void;
  160429. /**
  160430. * @hidden
  160431. */
  160432. reset(): void;
  160433. /**
  160434. * Render the bounding boxes of a specific rendering group
  160435. * @param renderingGroupId defines the rendering group to render
  160436. */
  160437. render(renderingGroupId: number): void;
  160438. /**
  160439. * In case of occlusion queries, we can render the occlusion bounding box through this method
  160440. * @param mesh Define the mesh to render the occlusion bounding box for
  160441. */
  160442. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  160443. /**
  160444. * Dispose and release the resources attached to this renderer.
  160445. */
  160446. dispose(): void;
  160447. }
  160448. }
  160449. declare module BABYLON {
  160450. interface Scene {
  160451. /** @hidden (Backing field) */
  160452. _depthRenderer: {
  160453. [id: string]: DepthRenderer;
  160454. };
  160455. /**
  160456. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  160457. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  160458. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  160459. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  160460. * @returns the created depth renderer
  160461. */
  160462. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  160463. /**
  160464. * Disables a depth renderer for a given camera
  160465. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  160466. */
  160467. disableDepthRenderer(camera?: Nullable<Camera>): void;
  160468. }
  160469. /**
  160470. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  160471. * in several rendering techniques.
  160472. */
  160473. export class DepthRendererSceneComponent implements ISceneComponent {
  160474. /**
  160475. * The component name helpfull to identify the component in the list of scene components.
  160476. */
  160477. readonly name: string;
  160478. /**
  160479. * The scene the component belongs to.
  160480. */
  160481. scene: Scene;
  160482. /**
  160483. * Creates a new instance of the component for the given scene
  160484. * @param scene Defines the scene to register the component in
  160485. */
  160486. constructor(scene: Scene);
  160487. /**
  160488. * Registers the component in a given scene
  160489. */
  160490. register(): void;
  160491. /**
  160492. * Rebuilds the elements related to this component in case of
  160493. * context lost for instance.
  160494. */
  160495. rebuild(): void;
  160496. /**
  160497. * Disposes the component and the associated ressources
  160498. */
  160499. dispose(): void;
  160500. private _gatherRenderTargets;
  160501. private _gatherActiveCameraRenderTargets;
  160502. }
  160503. }
  160504. declare module BABYLON {
  160505. interface AbstractScene {
  160506. /** @hidden (Backing field) */
  160507. _prePassRenderer: Nullable<PrePassRenderer>;
  160508. /**
  160509. * Gets or Sets the current prepass renderer associated to the scene.
  160510. */
  160511. prePassRenderer: Nullable<PrePassRenderer>;
  160512. /**
  160513. * Enables the prepass and associates it with the scene
  160514. * @returns the PrePassRenderer
  160515. */
  160516. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  160517. /**
  160518. * Disables the prepass associated with the scene
  160519. */
  160520. disablePrePassRenderer(): void;
  160521. }
  160522. /**
  160523. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  160524. * in several rendering techniques.
  160525. */
  160526. export class PrePassRendererSceneComponent implements ISceneComponent {
  160527. /**
  160528. * The component name helpful to identify the component in the list of scene components.
  160529. */
  160530. readonly name: string;
  160531. /**
  160532. * The scene the component belongs to.
  160533. */
  160534. scene: Scene;
  160535. /**
  160536. * Creates a new instance of the component for the given scene
  160537. * @param scene Defines the scene to register the component in
  160538. */
  160539. constructor(scene: Scene);
  160540. /**
  160541. * Registers the component in a given scene
  160542. */
  160543. register(): void;
  160544. private _beforeCameraDraw;
  160545. private _afterCameraDraw;
  160546. private _beforeClearStage;
  160547. private _beforeRenderingMeshStage;
  160548. private _afterRenderingMeshStage;
  160549. /**
  160550. * Rebuilds the elements related to this component in case of
  160551. * context lost for instance.
  160552. */
  160553. rebuild(): void;
  160554. /**
  160555. * Disposes the component and the associated ressources
  160556. */
  160557. dispose(): void;
  160558. }
  160559. }
  160560. declare module BABYLON {
  160561. /** @hidden */
  160562. export var fibonacci: {
  160563. name: string;
  160564. shader: string;
  160565. };
  160566. }
  160567. declare module BABYLON {
  160568. /** @hidden */
  160569. export var diffusionProfile: {
  160570. name: string;
  160571. shader: string;
  160572. };
  160573. }
  160574. declare module BABYLON {
  160575. /** @hidden */
  160576. export var subSurfaceScatteringPixelShader: {
  160577. name: string;
  160578. shader: string;
  160579. };
  160580. }
  160581. declare module BABYLON {
  160582. /**
  160583. * Sub surface scattering post process
  160584. */
  160585. export class SubSurfaceScatteringPostProcess extends PostProcess {
  160586. /**
  160587. * Gets a string identifying the name of the class
  160588. * @returns "SubSurfaceScatteringPostProcess" string
  160589. */
  160590. getClassName(): string;
  160591. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  160592. }
  160593. }
  160594. declare module BABYLON {
  160595. /**
  160596. * Contains all parameters needed for the prepass to perform
  160597. * screen space subsurface scattering
  160598. */
  160599. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  160600. /** @hidden */
  160601. static _SceneComponentInitialization: (scene: Scene) => void;
  160602. private _ssDiffusionS;
  160603. private _ssFilterRadii;
  160604. private _ssDiffusionD;
  160605. /**
  160606. * Post process to attach for screen space subsurface scattering
  160607. */
  160608. postProcess: SubSurfaceScatteringPostProcess;
  160609. /**
  160610. * Diffusion profile color for subsurface scattering
  160611. */
  160612. get ssDiffusionS(): number[];
  160613. /**
  160614. * Diffusion profile max color channel value for subsurface scattering
  160615. */
  160616. get ssDiffusionD(): number[];
  160617. /**
  160618. * Diffusion profile filter radius for subsurface scattering
  160619. */
  160620. get ssFilterRadii(): number[];
  160621. /**
  160622. * Is subsurface enabled
  160623. */
  160624. enabled: boolean;
  160625. /**
  160626. * Name of the configuration
  160627. */
  160628. name: string;
  160629. /**
  160630. * Diffusion profile colors for subsurface scattering
  160631. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  160632. * See ...
  160633. * Note that you can only store up to 5 of them
  160634. */
  160635. ssDiffusionProfileColors: Color3[];
  160636. /**
  160637. * Defines the ratio real world => scene units.
  160638. * Used for subsurface scattering
  160639. */
  160640. metersPerUnit: number;
  160641. /**
  160642. * Textures that should be present in the MRT for this effect to work
  160643. */
  160644. readonly texturesRequired: number[];
  160645. private _scene;
  160646. /**
  160647. * Builds a subsurface configuration object
  160648. * @param scene The scene
  160649. */
  160650. constructor(scene: Scene);
  160651. /**
  160652. * Adds a new diffusion profile.
  160653. * Useful for more realistic subsurface scattering on diverse materials.
  160654. * @param color The color of the diffusion profile. Should be the average color of the material.
  160655. * @return The index of the diffusion profile for the material subsurface configuration
  160656. */
  160657. addDiffusionProfile(color: Color3): number;
  160658. /**
  160659. * Creates the sss post process
  160660. * @return The created post process
  160661. */
  160662. createPostProcess(): SubSurfaceScatteringPostProcess;
  160663. /**
  160664. * Deletes all diffusion profiles.
  160665. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  160666. */
  160667. clearAllDiffusionProfiles(): void;
  160668. /**
  160669. * Disposes this object
  160670. */
  160671. dispose(): void;
  160672. /**
  160673. * @hidden
  160674. * https://zero-radiance.github.io/post/sampling-diffusion/
  160675. *
  160676. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  160677. * ------------------------------------------------------------------------------------
  160678. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  160679. * PDF[r, phi, s] = r * R[r, phi, s]
  160680. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  160681. * ------------------------------------------------------------------------------------
  160682. * We importance sample the color channel with the widest scattering distance.
  160683. */
  160684. getDiffusionProfileParameters(color: Color3): number;
  160685. /**
  160686. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  160687. * 'u' is the random number (the value of the CDF): [0, 1).
  160688. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  160689. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  160690. */
  160691. private _sampleBurleyDiffusionProfile;
  160692. }
  160693. }
  160694. declare module BABYLON {
  160695. interface AbstractScene {
  160696. /** @hidden (Backing field) */
  160697. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  160698. /**
  160699. * Gets or Sets the current prepass renderer associated to the scene.
  160700. */
  160701. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  160702. /**
  160703. * Enables the subsurface effect for prepass
  160704. * @returns the SubSurfaceConfiguration
  160705. */
  160706. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  160707. /**
  160708. * Disables the subsurface effect for prepass
  160709. */
  160710. disableSubSurfaceForPrePass(): void;
  160711. }
  160712. /**
  160713. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  160714. * in several rendering techniques.
  160715. */
  160716. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  160717. /**
  160718. * The component name helpful to identify the component in the list of scene components.
  160719. */
  160720. readonly name: string;
  160721. /**
  160722. * The scene the component belongs to.
  160723. */
  160724. scene: Scene;
  160725. /**
  160726. * Creates a new instance of the component for the given scene
  160727. * @param scene Defines the scene to register the component in
  160728. */
  160729. constructor(scene: Scene);
  160730. /**
  160731. * Registers the component in a given scene
  160732. */
  160733. register(): void;
  160734. /**
  160735. * Serializes the component data to the specified json object
  160736. * @param serializationObject The object to serialize to
  160737. */
  160738. serialize(serializationObject: any): void;
  160739. /**
  160740. * Adds all the elements from the container to the scene
  160741. * @param container the container holding the elements
  160742. */
  160743. addFromContainer(container: AbstractScene): void;
  160744. /**
  160745. * Removes all the elements in the container from the scene
  160746. * @param container contains the elements to remove
  160747. * @param dispose if the removed element should be disposed (default: false)
  160748. */
  160749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  160750. /**
  160751. * Rebuilds the elements related to this component in case of
  160752. * context lost for instance.
  160753. */
  160754. rebuild(): void;
  160755. /**
  160756. * Disposes the component and the associated ressources
  160757. */
  160758. dispose(): void;
  160759. }
  160760. }
  160761. declare module BABYLON {
  160762. /** @hidden */
  160763. export var outlinePixelShader: {
  160764. name: string;
  160765. shader: string;
  160766. };
  160767. }
  160768. declare module BABYLON {
  160769. /** @hidden */
  160770. export var outlineVertexShader: {
  160771. name: string;
  160772. shader: string;
  160773. };
  160774. }
  160775. declare module BABYLON {
  160776. interface Scene {
  160777. /** @hidden */
  160778. _outlineRenderer: OutlineRenderer;
  160779. /**
  160780. * Gets the outline renderer associated with the scene
  160781. * @returns a OutlineRenderer
  160782. */
  160783. getOutlineRenderer(): OutlineRenderer;
  160784. }
  160785. interface AbstractMesh {
  160786. /** @hidden (Backing field) */
  160787. _renderOutline: boolean;
  160788. /**
  160789. * Gets or sets a boolean indicating if the outline must be rendered as well
  160790. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  160791. */
  160792. renderOutline: boolean;
  160793. /** @hidden (Backing field) */
  160794. _renderOverlay: boolean;
  160795. /**
  160796. * Gets or sets a boolean indicating if the overlay must be rendered as well
  160797. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  160798. */
  160799. renderOverlay: boolean;
  160800. }
  160801. /**
  160802. * This class is responsible to draw bothe outline/overlay of meshes.
  160803. * It should not be used directly but through the available method on mesh.
  160804. */
  160805. export class OutlineRenderer implements ISceneComponent {
  160806. /**
  160807. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  160808. */
  160809. private static _StencilReference;
  160810. /**
  160811. * The name of the component. Each component must have a unique name.
  160812. */
  160813. name: string;
  160814. /**
  160815. * The scene the component belongs to.
  160816. */
  160817. scene: Scene;
  160818. /**
  160819. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  160820. */
  160821. zOffset: number;
  160822. private _engine;
  160823. private _effect;
  160824. private _cachedDefines;
  160825. private _savedDepthWrite;
  160826. /**
  160827. * Instantiates a new outline renderer. (There could be only one per scene).
  160828. * @param scene Defines the scene it belongs to
  160829. */
  160830. constructor(scene: Scene);
  160831. /**
  160832. * Register the component to one instance of a scene.
  160833. */
  160834. register(): void;
  160835. /**
  160836. * Rebuilds the elements related to this component in case of
  160837. * context lost for instance.
  160838. */
  160839. rebuild(): void;
  160840. /**
  160841. * Disposes the component and the associated ressources.
  160842. */
  160843. dispose(): void;
  160844. /**
  160845. * Renders the outline in the canvas.
  160846. * @param subMesh Defines the sumesh to render
  160847. * @param batch Defines the batch of meshes in case of instances
  160848. * @param useOverlay Defines if the rendering is for the overlay or the outline
  160849. */
  160850. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  160851. /**
  160852. * Returns whether or not the outline renderer is ready for a given submesh.
  160853. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  160854. * @param subMesh Defines the submesh to check readyness for
  160855. * @param useInstances Defines wheter wee are trying to render instances or not
  160856. * @returns true if ready otherwise false
  160857. */
  160858. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  160859. private _beforeRenderingMesh;
  160860. private _afterRenderingMesh;
  160861. }
  160862. }
  160863. declare module BABYLON {
  160864. /**
  160865. * Defines the basic options interface of a Sprite Frame Source Size.
  160866. */
  160867. export interface ISpriteJSONSpriteSourceSize {
  160868. /**
  160869. * number of the original width of the Frame
  160870. */
  160871. w: number;
  160872. /**
  160873. * number of the original height of the Frame
  160874. */
  160875. h: number;
  160876. }
  160877. /**
  160878. * Defines the basic options interface of a Sprite Frame Data.
  160879. */
  160880. export interface ISpriteJSONSpriteFrameData {
  160881. /**
  160882. * number of the x offset of the Frame
  160883. */
  160884. x: number;
  160885. /**
  160886. * number of the y offset of the Frame
  160887. */
  160888. y: number;
  160889. /**
  160890. * number of the width of the Frame
  160891. */
  160892. w: number;
  160893. /**
  160894. * number of the height of the Frame
  160895. */
  160896. h: number;
  160897. }
  160898. /**
  160899. * Defines the basic options interface of a JSON Sprite.
  160900. */
  160901. export interface ISpriteJSONSprite {
  160902. /**
  160903. * string name of the Frame
  160904. */
  160905. filename: string;
  160906. /**
  160907. * ISpriteJSONSpriteFrame basic object of the frame data
  160908. */
  160909. frame: ISpriteJSONSpriteFrameData;
  160910. /**
  160911. * boolean to flag is the frame was rotated.
  160912. */
  160913. rotated: boolean;
  160914. /**
  160915. * boolean to flag is the frame was trimmed.
  160916. */
  160917. trimmed: boolean;
  160918. /**
  160919. * ISpriteJSONSpriteFrame basic object of the source data
  160920. */
  160921. spriteSourceSize: ISpriteJSONSpriteFrameData;
  160922. /**
  160923. * ISpriteJSONSpriteFrame basic object of the source data
  160924. */
  160925. sourceSize: ISpriteJSONSpriteSourceSize;
  160926. }
  160927. /**
  160928. * Defines the basic options interface of a JSON atlas.
  160929. */
  160930. export interface ISpriteJSONAtlas {
  160931. /**
  160932. * Array of objects that contain the frame data.
  160933. */
  160934. frames: Array<ISpriteJSONSprite>;
  160935. /**
  160936. * object basic object containing the sprite meta data.
  160937. */
  160938. meta?: object;
  160939. }
  160940. }
  160941. declare module BABYLON {
  160942. /** @hidden */
  160943. export var spriteMapPixelShader: {
  160944. name: string;
  160945. shader: string;
  160946. };
  160947. }
  160948. declare module BABYLON {
  160949. /** @hidden */
  160950. export var spriteMapVertexShader: {
  160951. name: string;
  160952. shader: string;
  160953. };
  160954. }
  160955. declare module BABYLON {
  160956. /**
  160957. * Defines the basic options interface of a SpriteMap
  160958. */
  160959. export interface ISpriteMapOptions {
  160960. /**
  160961. * Vector2 of the number of cells in the grid.
  160962. */
  160963. stageSize?: Vector2;
  160964. /**
  160965. * Vector2 of the size of the output plane in World Units.
  160966. */
  160967. outputSize?: Vector2;
  160968. /**
  160969. * Vector3 of the position of the output plane in World Units.
  160970. */
  160971. outputPosition?: Vector3;
  160972. /**
  160973. * Vector3 of the rotation of the output plane.
  160974. */
  160975. outputRotation?: Vector3;
  160976. /**
  160977. * number of layers that the system will reserve in resources.
  160978. */
  160979. layerCount?: number;
  160980. /**
  160981. * number of max animation frames a single cell will reserve in resources.
  160982. */
  160983. maxAnimationFrames?: number;
  160984. /**
  160985. * number cell index of the base tile when the system compiles.
  160986. */
  160987. baseTile?: number;
  160988. /**
  160989. * boolean flip the sprite after its been repositioned by the framing data.
  160990. */
  160991. flipU?: boolean;
  160992. /**
  160993. * Vector3 scalar of the global RGB values of the SpriteMap.
  160994. */
  160995. colorMultiply?: Vector3;
  160996. }
  160997. /**
  160998. * Defines the IDisposable interface in order to be cleanable from resources.
  160999. */
  161000. export interface ISpriteMap extends IDisposable {
  161001. /**
  161002. * String name of the SpriteMap.
  161003. */
  161004. name: string;
  161005. /**
  161006. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  161007. */
  161008. atlasJSON: ISpriteJSONAtlas;
  161009. /**
  161010. * Texture of the SpriteMap.
  161011. */
  161012. spriteSheet: Texture;
  161013. /**
  161014. * The parameters to initialize the SpriteMap with.
  161015. */
  161016. options: ISpriteMapOptions;
  161017. }
  161018. /**
  161019. * Class used to manage a grid restricted sprite deployment on an Output plane.
  161020. */
  161021. export class SpriteMap implements ISpriteMap {
  161022. /** The Name of the spriteMap */
  161023. name: string;
  161024. /** The JSON file with the frame and meta data */
  161025. atlasJSON: ISpriteJSONAtlas;
  161026. /** The systems Sprite Sheet Texture */
  161027. spriteSheet: Texture;
  161028. /** Arguments passed with the Constructor */
  161029. options: ISpriteMapOptions;
  161030. /** Public Sprite Storage array, parsed from atlasJSON */
  161031. sprites: Array<ISpriteJSONSprite>;
  161032. /** Returns the Number of Sprites in the System */
  161033. get spriteCount(): number;
  161034. /** Returns the Position of Output Plane*/
  161035. get position(): Vector3;
  161036. /** Returns the Position of Output Plane*/
  161037. set position(v: Vector3);
  161038. /** Returns the Rotation of Output Plane*/
  161039. get rotation(): Vector3;
  161040. /** Returns the Rotation of Output Plane*/
  161041. set rotation(v: Vector3);
  161042. /** Sets the AnimationMap*/
  161043. get animationMap(): RawTexture;
  161044. /** Sets the AnimationMap*/
  161045. set animationMap(v: RawTexture);
  161046. /** Scene that the SpriteMap was created in */
  161047. private _scene;
  161048. /** Texture Buffer of Float32 that holds tile frame data*/
  161049. private _frameMap;
  161050. /** Texture Buffers of Float32 that holds tileMap data*/
  161051. private _tileMaps;
  161052. /** Texture Buffer of Float32 that holds Animation Data*/
  161053. private _animationMap;
  161054. /** Custom ShaderMaterial Central to the System*/
  161055. private _material;
  161056. /** Custom ShaderMaterial Central to the System*/
  161057. private _output;
  161058. /** Systems Time Ticker*/
  161059. private _time;
  161060. /**
  161061. * Creates a new SpriteMap
  161062. * @param name defines the SpriteMaps Name
  161063. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  161064. * @param spriteSheet is the Texture that the Sprites are on.
  161065. * @param options a basic deployment configuration
  161066. * @param scene The Scene that the map is deployed on
  161067. */
  161068. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  161069. /**
  161070. * Returns tileID location
  161071. * @returns Vector2 the cell position ID
  161072. */
  161073. getTileID(): Vector2;
  161074. /**
  161075. * Gets the UV location of the mouse over the SpriteMap.
  161076. * @returns Vector2 the UV position of the mouse interaction
  161077. */
  161078. getMousePosition(): Vector2;
  161079. /**
  161080. * Creates the "frame" texture Buffer
  161081. * -------------------------------------
  161082. * Structure of frames
  161083. * "filename": "Falling-Water-2.png",
  161084. * "frame": {"x":69,"y":103,"w":24,"h":32},
  161085. * "rotated": true,
  161086. * "trimmed": true,
  161087. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  161088. * "sourceSize": {"w":32,"h":32}
  161089. * @returns RawTexture of the frameMap
  161090. */
  161091. private _createFrameBuffer;
  161092. /**
  161093. * Creates the tileMap texture Buffer
  161094. * @param buffer normally and array of numbers, or a false to generate from scratch
  161095. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  161096. * @returns RawTexture of the tileMap
  161097. */
  161098. private _createTileBuffer;
  161099. /**
  161100. * Modifies the data of the tileMaps
  161101. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  161102. * @param pos is the iVector2 Coordinates of the Tile
  161103. * @param tile The SpriteIndex of the new Tile
  161104. */
  161105. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  161106. /**
  161107. * Creates the animationMap texture Buffer
  161108. * @param buffer normally and array of numbers, or a false to generate from scratch
  161109. * @returns RawTexture of the animationMap
  161110. */
  161111. private _createTileAnimationBuffer;
  161112. /**
  161113. * Modifies the data of the animationMap
  161114. * @param cellID is the Index of the Sprite
  161115. * @param _frame is the target Animation frame
  161116. * @param toCell is the Target Index of the next frame of the animation
  161117. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  161118. * @param speed is a global scalar of the time variable on the map.
  161119. */
  161120. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  161121. /**
  161122. * Exports the .tilemaps file
  161123. */
  161124. saveTileMaps(): void;
  161125. /**
  161126. * Imports the .tilemaps file
  161127. * @param url of the .tilemaps file
  161128. */
  161129. loadTileMaps(url: string): void;
  161130. /**
  161131. * Release associated resources
  161132. */
  161133. dispose(): void;
  161134. }
  161135. }
  161136. declare module BABYLON {
  161137. /**
  161138. * Class used to manage multiple sprites of different sizes on the same spritesheet
  161139. * @see https://doc.babylonjs.com/babylon101/sprites
  161140. */
  161141. export class SpritePackedManager extends SpriteManager {
  161142. /** defines the packed manager's name */
  161143. name: string;
  161144. /**
  161145. * Creates a new sprite manager from a packed sprite sheet
  161146. * @param name defines the manager's name
  161147. * @param imgUrl defines the sprite sheet url
  161148. * @param capacity defines the maximum allowed number of sprites
  161149. * @param scene defines the hosting scene
  161150. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  161151. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  161152. * @param samplingMode defines the smapling mode to use with spritesheet
  161153. * @param fromPacked set to true; do not alter
  161154. */
  161155. constructor(
  161156. /** defines the packed manager's name */
  161157. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  161158. }
  161159. }
  161160. declare module BABYLON {
  161161. /**
  161162. * Defines the list of states available for a task inside a AssetsManager
  161163. */
  161164. export enum AssetTaskState {
  161165. /**
  161166. * Initialization
  161167. */
  161168. INIT = 0,
  161169. /**
  161170. * Running
  161171. */
  161172. RUNNING = 1,
  161173. /**
  161174. * Done
  161175. */
  161176. DONE = 2,
  161177. /**
  161178. * Error
  161179. */
  161180. ERROR = 3
  161181. }
  161182. /**
  161183. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  161184. */
  161185. export abstract class AbstractAssetTask {
  161186. /**
  161187. * Task name
  161188. */ name: string;
  161189. /**
  161190. * Callback called when the task is successful
  161191. */
  161192. onSuccess: (task: any) => void;
  161193. /**
  161194. * Callback called when the task is not successful
  161195. */
  161196. onError: (task: any, message?: string, exception?: any) => void;
  161197. /**
  161198. * Creates a new AssetsManager
  161199. * @param name defines the name of the task
  161200. */
  161201. constructor(
  161202. /**
  161203. * Task name
  161204. */ name: string);
  161205. private _isCompleted;
  161206. private _taskState;
  161207. private _errorObject;
  161208. /**
  161209. * Get if the task is completed
  161210. */
  161211. get isCompleted(): boolean;
  161212. /**
  161213. * Gets the current state of the task
  161214. */
  161215. get taskState(): AssetTaskState;
  161216. /**
  161217. * Gets the current error object (if task is in error)
  161218. */
  161219. get errorObject(): {
  161220. message?: string;
  161221. exception?: any;
  161222. };
  161223. /**
  161224. * Internal only
  161225. * @hidden
  161226. */
  161227. _setErrorObject(message?: string, exception?: any): void;
  161228. /**
  161229. * Execute the current task
  161230. * @param scene defines the scene where you want your assets to be loaded
  161231. * @param onSuccess is a callback called when the task is successfully executed
  161232. * @param onError is a callback called if an error occurs
  161233. */
  161234. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161235. /**
  161236. * Execute the current task
  161237. * @param scene defines the scene where you want your assets to be loaded
  161238. * @param onSuccess is a callback called when the task is successfully executed
  161239. * @param onError is a callback called if an error occurs
  161240. */
  161241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161242. /**
  161243. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  161244. * This can be used with failed tasks that have the reason for failure fixed.
  161245. */
  161246. reset(): void;
  161247. private onErrorCallback;
  161248. private onDoneCallback;
  161249. }
  161250. /**
  161251. * Define the interface used by progress events raised during assets loading
  161252. */
  161253. export interface IAssetsProgressEvent {
  161254. /**
  161255. * Defines the number of remaining tasks to process
  161256. */
  161257. remainingCount: number;
  161258. /**
  161259. * Defines the total number of tasks
  161260. */
  161261. totalCount: number;
  161262. /**
  161263. * Defines the task that was just processed
  161264. */
  161265. task: AbstractAssetTask;
  161266. }
  161267. /**
  161268. * Class used to share progress information about assets loading
  161269. */
  161270. export class AssetsProgressEvent implements IAssetsProgressEvent {
  161271. /**
  161272. * Defines the number of remaining tasks to process
  161273. */
  161274. remainingCount: number;
  161275. /**
  161276. * Defines the total number of tasks
  161277. */
  161278. totalCount: number;
  161279. /**
  161280. * Defines the task that was just processed
  161281. */
  161282. task: AbstractAssetTask;
  161283. /**
  161284. * Creates a AssetsProgressEvent
  161285. * @param remainingCount defines the number of remaining tasks to process
  161286. * @param totalCount defines the total number of tasks
  161287. * @param task defines the task that was just processed
  161288. */
  161289. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  161290. }
  161291. /**
  161292. * Define a task used by AssetsManager to load assets into a container
  161293. */
  161294. export class ContainerAssetTask extends AbstractAssetTask {
  161295. /**
  161296. * Defines the name of the task
  161297. */
  161298. name: string;
  161299. /**
  161300. * Defines the list of mesh's names you want to load
  161301. */
  161302. meshesNames: any;
  161303. /**
  161304. * Defines the root url to use as a base to load your meshes and associated resources
  161305. */
  161306. rootUrl: string;
  161307. /**
  161308. * Defines the filename or File of the scene to load from
  161309. */
  161310. sceneFilename: string | File;
  161311. /**
  161312. * Get the loaded asset container
  161313. */
  161314. loadedContainer: AssetContainer;
  161315. /**
  161316. * Gets the list of loaded meshes
  161317. */
  161318. loadedMeshes: Array<AbstractMesh>;
  161319. /**
  161320. * Gets the list of loaded particle systems
  161321. */
  161322. loadedParticleSystems: Array<IParticleSystem>;
  161323. /**
  161324. * Gets the list of loaded skeletons
  161325. */
  161326. loadedSkeletons: Array<Skeleton>;
  161327. /**
  161328. * Gets the list of loaded animation groups
  161329. */
  161330. loadedAnimationGroups: Array<AnimationGroup>;
  161331. /**
  161332. * Callback called when the task is successful
  161333. */
  161334. onSuccess: (task: ContainerAssetTask) => void;
  161335. /**
  161336. * Callback called when the task is successful
  161337. */
  161338. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  161339. /**
  161340. * Creates a new ContainerAssetTask
  161341. * @param name defines the name of the task
  161342. * @param meshesNames defines the list of mesh's names you want to load
  161343. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  161344. * @param sceneFilename defines the filename or File of the scene to load from
  161345. */
  161346. constructor(
  161347. /**
  161348. * Defines the name of the task
  161349. */
  161350. name: string,
  161351. /**
  161352. * Defines the list of mesh's names you want to load
  161353. */
  161354. meshesNames: any,
  161355. /**
  161356. * Defines the root url to use as a base to load your meshes and associated resources
  161357. */
  161358. rootUrl: string,
  161359. /**
  161360. * Defines the filename or File of the scene to load from
  161361. */
  161362. sceneFilename: string | File);
  161363. /**
  161364. * Execute the current task
  161365. * @param scene defines the scene where you want your assets to be loaded
  161366. * @param onSuccess is a callback called when the task is successfully executed
  161367. * @param onError is a callback called if an error occurs
  161368. */
  161369. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161370. }
  161371. /**
  161372. * Define a task used by AssetsManager to load meshes
  161373. */
  161374. export class MeshAssetTask extends AbstractAssetTask {
  161375. /**
  161376. * Defines the name of the task
  161377. */
  161378. name: string;
  161379. /**
  161380. * Defines the list of mesh's names you want to load
  161381. */
  161382. meshesNames: any;
  161383. /**
  161384. * Defines the root url to use as a base to load your meshes and associated resources
  161385. */
  161386. rootUrl: string;
  161387. /**
  161388. * Defines the filename or File of the scene to load from
  161389. */
  161390. sceneFilename: string | File;
  161391. /**
  161392. * Gets the list of loaded meshes
  161393. */
  161394. loadedMeshes: Array<AbstractMesh>;
  161395. /**
  161396. * Gets the list of loaded particle systems
  161397. */
  161398. loadedParticleSystems: Array<IParticleSystem>;
  161399. /**
  161400. * Gets the list of loaded skeletons
  161401. */
  161402. loadedSkeletons: Array<Skeleton>;
  161403. /**
  161404. * Gets the list of loaded animation groups
  161405. */
  161406. loadedAnimationGroups: Array<AnimationGroup>;
  161407. /**
  161408. * Callback called when the task is successful
  161409. */
  161410. onSuccess: (task: MeshAssetTask) => void;
  161411. /**
  161412. * Callback called when the task is successful
  161413. */
  161414. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  161415. /**
  161416. * Creates a new MeshAssetTask
  161417. * @param name defines the name of the task
  161418. * @param meshesNames defines the list of mesh's names you want to load
  161419. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  161420. * @param sceneFilename defines the filename or File of the scene to load from
  161421. */
  161422. constructor(
  161423. /**
  161424. * Defines the name of the task
  161425. */
  161426. name: string,
  161427. /**
  161428. * Defines the list of mesh's names you want to load
  161429. */
  161430. meshesNames: any,
  161431. /**
  161432. * Defines the root url to use as a base to load your meshes and associated resources
  161433. */
  161434. rootUrl: string,
  161435. /**
  161436. * Defines the filename or File of the scene to load from
  161437. */
  161438. sceneFilename: string | File);
  161439. /**
  161440. * Execute the current task
  161441. * @param scene defines the scene where you want your assets to be loaded
  161442. * @param onSuccess is a callback called when the task is successfully executed
  161443. * @param onError is a callback called if an error occurs
  161444. */
  161445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161446. }
  161447. /**
  161448. * Define a task used by AssetsManager to load text content
  161449. */
  161450. export class TextFileAssetTask extends AbstractAssetTask {
  161451. /**
  161452. * Defines the name of the task
  161453. */
  161454. name: string;
  161455. /**
  161456. * Defines the location of the file to load
  161457. */
  161458. url: string;
  161459. /**
  161460. * Gets the loaded text string
  161461. */
  161462. text: string;
  161463. /**
  161464. * Callback called when the task is successful
  161465. */
  161466. onSuccess: (task: TextFileAssetTask) => void;
  161467. /**
  161468. * Callback called when the task is successful
  161469. */
  161470. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  161471. /**
  161472. * Creates a new TextFileAssetTask object
  161473. * @param name defines the name of the task
  161474. * @param url defines the location of the file to load
  161475. */
  161476. constructor(
  161477. /**
  161478. * Defines the name of the task
  161479. */
  161480. name: string,
  161481. /**
  161482. * Defines the location of the file to load
  161483. */
  161484. url: string);
  161485. /**
  161486. * Execute the current task
  161487. * @param scene defines the scene where you want your assets to be loaded
  161488. * @param onSuccess is a callback called when the task is successfully executed
  161489. * @param onError is a callback called if an error occurs
  161490. */
  161491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161492. }
  161493. /**
  161494. * Define a task used by AssetsManager to load binary data
  161495. */
  161496. export class BinaryFileAssetTask extends AbstractAssetTask {
  161497. /**
  161498. * Defines the name of the task
  161499. */
  161500. name: string;
  161501. /**
  161502. * Defines the location of the file to load
  161503. */
  161504. url: string;
  161505. /**
  161506. * Gets the lodaded data (as an array buffer)
  161507. */
  161508. data: ArrayBuffer;
  161509. /**
  161510. * Callback called when the task is successful
  161511. */
  161512. onSuccess: (task: BinaryFileAssetTask) => void;
  161513. /**
  161514. * Callback called when the task is successful
  161515. */
  161516. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  161517. /**
  161518. * Creates a new BinaryFileAssetTask object
  161519. * @param name defines the name of the new task
  161520. * @param url defines the location of the file to load
  161521. */
  161522. constructor(
  161523. /**
  161524. * Defines the name of the task
  161525. */
  161526. name: string,
  161527. /**
  161528. * Defines the location of the file to load
  161529. */
  161530. url: string);
  161531. /**
  161532. * Execute the current task
  161533. * @param scene defines the scene where you want your assets to be loaded
  161534. * @param onSuccess is a callback called when the task is successfully executed
  161535. * @param onError is a callback called if an error occurs
  161536. */
  161537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161538. }
  161539. /**
  161540. * Define a task used by AssetsManager to load images
  161541. */
  161542. export class ImageAssetTask extends AbstractAssetTask {
  161543. /**
  161544. * Defines the name of the task
  161545. */
  161546. name: string;
  161547. /**
  161548. * Defines the location of the image to load
  161549. */
  161550. url: string;
  161551. /**
  161552. * Gets the loaded images
  161553. */
  161554. image: HTMLImageElement;
  161555. /**
  161556. * Callback called when the task is successful
  161557. */
  161558. onSuccess: (task: ImageAssetTask) => void;
  161559. /**
  161560. * Callback called when the task is successful
  161561. */
  161562. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  161563. /**
  161564. * Creates a new ImageAssetTask
  161565. * @param name defines the name of the task
  161566. * @param url defines the location of the image to load
  161567. */
  161568. constructor(
  161569. /**
  161570. * Defines the name of the task
  161571. */
  161572. name: string,
  161573. /**
  161574. * Defines the location of the image to load
  161575. */
  161576. url: string);
  161577. /**
  161578. * Execute the current task
  161579. * @param scene defines the scene where you want your assets to be loaded
  161580. * @param onSuccess is a callback called when the task is successfully executed
  161581. * @param onError is a callback called if an error occurs
  161582. */
  161583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161584. }
  161585. /**
  161586. * Defines the interface used by texture loading tasks
  161587. */
  161588. export interface ITextureAssetTask<TEX extends BaseTexture> {
  161589. /**
  161590. * Gets the loaded texture
  161591. */
  161592. texture: TEX;
  161593. }
  161594. /**
  161595. * Define a task used by AssetsManager to load 2D textures
  161596. */
  161597. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  161598. /**
  161599. * Defines the name of the task
  161600. */
  161601. name: string;
  161602. /**
  161603. * Defines the location of the file to load
  161604. */
  161605. url: string;
  161606. /**
  161607. * Defines if mipmap should not be generated (default is false)
  161608. */
  161609. noMipmap?: boolean | undefined;
  161610. /**
  161611. * Defines if texture must be inverted on Y axis (default is true)
  161612. */
  161613. invertY: boolean;
  161614. /**
  161615. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  161616. */
  161617. samplingMode: number;
  161618. /**
  161619. * Gets the loaded texture
  161620. */
  161621. texture: Texture;
  161622. /**
  161623. * Callback called when the task is successful
  161624. */
  161625. onSuccess: (task: TextureAssetTask) => void;
  161626. /**
  161627. * Callback called when the task is successful
  161628. */
  161629. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  161630. /**
  161631. * Creates a new TextureAssetTask object
  161632. * @param name defines the name of the task
  161633. * @param url defines the location of the file to load
  161634. * @param noMipmap defines if mipmap should not be generated (default is false)
  161635. * @param invertY defines if texture must be inverted on Y axis (default is true)
  161636. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  161637. */
  161638. constructor(
  161639. /**
  161640. * Defines the name of the task
  161641. */
  161642. name: string,
  161643. /**
  161644. * Defines the location of the file to load
  161645. */
  161646. url: string,
  161647. /**
  161648. * Defines if mipmap should not be generated (default is false)
  161649. */
  161650. noMipmap?: boolean | undefined,
  161651. /**
  161652. * Defines if texture must be inverted on Y axis (default is true)
  161653. */
  161654. invertY?: boolean,
  161655. /**
  161656. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  161657. */
  161658. samplingMode?: number);
  161659. /**
  161660. * Execute the current task
  161661. * @param scene defines the scene where you want your assets to be loaded
  161662. * @param onSuccess is a callback called when the task is successfully executed
  161663. * @param onError is a callback called if an error occurs
  161664. */
  161665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161666. }
  161667. /**
  161668. * Define a task used by AssetsManager to load cube textures
  161669. */
  161670. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  161671. /**
  161672. * Defines the name of the task
  161673. */
  161674. name: string;
  161675. /**
  161676. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  161677. */
  161678. url: string;
  161679. /**
  161680. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  161681. */
  161682. extensions?: string[] | undefined;
  161683. /**
  161684. * Defines if mipmaps should not be generated (default is false)
  161685. */
  161686. noMipmap?: boolean | undefined;
  161687. /**
  161688. * Defines the explicit list of files (undefined by default)
  161689. */
  161690. files?: string[] | undefined;
  161691. /**
  161692. * Gets the loaded texture
  161693. */
  161694. texture: CubeTexture;
  161695. /**
  161696. * Callback called when the task is successful
  161697. */
  161698. onSuccess: (task: CubeTextureAssetTask) => void;
  161699. /**
  161700. * Callback called when the task is successful
  161701. */
  161702. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  161703. /**
  161704. * Creates a new CubeTextureAssetTask
  161705. * @param name defines the name of the task
  161706. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  161707. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  161708. * @param noMipmap defines if mipmaps should not be generated (default is false)
  161709. * @param files defines the explicit list of files (undefined by default)
  161710. */
  161711. constructor(
  161712. /**
  161713. * Defines the name of the task
  161714. */
  161715. name: string,
  161716. /**
  161717. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  161718. */
  161719. url: string,
  161720. /**
  161721. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  161722. */
  161723. extensions?: string[] | undefined,
  161724. /**
  161725. * Defines if mipmaps should not be generated (default is false)
  161726. */
  161727. noMipmap?: boolean | undefined,
  161728. /**
  161729. * Defines the explicit list of files (undefined by default)
  161730. */
  161731. files?: string[] | undefined);
  161732. /**
  161733. * Execute the current task
  161734. * @param scene defines the scene where you want your assets to be loaded
  161735. * @param onSuccess is a callback called when the task is successfully executed
  161736. * @param onError is a callback called if an error occurs
  161737. */
  161738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161739. }
  161740. /**
  161741. * Define a task used by AssetsManager to load HDR cube textures
  161742. */
  161743. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  161744. /**
  161745. * Defines the name of the task
  161746. */
  161747. name: string;
  161748. /**
  161749. * Defines the location of the file to load
  161750. */
  161751. url: string;
  161752. /**
  161753. * Defines the desired size (the more it increases the longer the generation will be)
  161754. */
  161755. size: number;
  161756. /**
  161757. * Defines if mipmaps should not be generated (default is false)
  161758. */
  161759. noMipmap: boolean;
  161760. /**
  161761. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  161762. */
  161763. generateHarmonics: boolean;
  161764. /**
  161765. * 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)
  161766. */
  161767. gammaSpace: boolean;
  161768. /**
  161769. * Internal Use Only
  161770. */
  161771. reserved: boolean;
  161772. /**
  161773. * Gets the loaded texture
  161774. */
  161775. texture: HDRCubeTexture;
  161776. /**
  161777. * Callback called when the task is successful
  161778. */
  161779. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  161780. /**
  161781. * Callback called when the task is successful
  161782. */
  161783. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  161784. /**
  161785. * Creates a new HDRCubeTextureAssetTask object
  161786. * @param name defines the name of the task
  161787. * @param url defines the location of the file to load
  161788. * @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.
  161789. * @param noMipmap defines if mipmaps should not be generated (default is false)
  161790. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  161791. * @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)
  161792. * @param reserved Internal use only
  161793. */
  161794. constructor(
  161795. /**
  161796. * Defines the name of the task
  161797. */
  161798. name: string,
  161799. /**
  161800. * Defines the location of the file to load
  161801. */
  161802. url: string,
  161803. /**
  161804. * Defines the desired size (the more it increases the longer the generation will be)
  161805. */
  161806. size: number,
  161807. /**
  161808. * Defines if mipmaps should not be generated (default is false)
  161809. */
  161810. noMipmap?: boolean,
  161811. /**
  161812. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  161813. */
  161814. generateHarmonics?: boolean,
  161815. /**
  161816. * 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)
  161817. */
  161818. gammaSpace?: boolean,
  161819. /**
  161820. * Internal Use Only
  161821. */
  161822. reserved?: boolean);
  161823. /**
  161824. * Execute the current task
  161825. * @param scene defines the scene where you want your assets to be loaded
  161826. * @param onSuccess is a callback called when the task is successfully executed
  161827. * @param onError is a callback called if an error occurs
  161828. */
  161829. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161830. }
  161831. /**
  161832. * Define a task used by AssetsManager to load Equirectangular cube textures
  161833. */
  161834. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  161835. /**
  161836. * Defines the name of the task
  161837. */
  161838. name: string;
  161839. /**
  161840. * Defines the location of the file to load
  161841. */
  161842. url: string;
  161843. /**
  161844. * Defines the desired size (the more it increases the longer the generation will be)
  161845. */
  161846. size: number;
  161847. /**
  161848. * Defines if mipmaps should not be generated (default is false)
  161849. */
  161850. noMipmap: boolean;
  161851. /**
  161852. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  161853. * but the standard material would require them in Gamma space) (default is true)
  161854. */
  161855. gammaSpace: boolean;
  161856. /**
  161857. * Gets the loaded texture
  161858. */
  161859. texture: EquiRectangularCubeTexture;
  161860. /**
  161861. * Callback called when the task is successful
  161862. */
  161863. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  161864. /**
  161865. * Callback called when the task is successful
  161866. */
  161867. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  161868. /**
  161869. * Creates a new EquiRectangularCubeTextureAssetTask object
  161870. * @param name defines the name of the task
  161871. * @param url defines the location of the file to load
  161872. * @param size defines the desired size (the more it increases the longer the generation will be)
  161873. * If the size is omitted this implies you are using a preprocessed cubemap.
  161874. * @param noMipmap defines if mipmaps should not be generated (default is false)
  161875. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  161876. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  161877. * (default is true)
  161878. */
  161879. constructor(
  161880. /**
  161881. * Defines the name of the task
  161882. */
  161883. name: string,
  161884. /**
  161885. * Defines the location of the file to load
  161886. */
  161887. url: string,
  161888. /**
  161889. * Defines the desired size (the more it increases the longer the generation will be)
  161890. */
  161891. size: number,
  161892. /**
  161893. * Defines if mipmaps should not be generated (default is false)
  161894. */
  161895. noMipmap?: boolean,
  161896. /**
  161897. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  161898. * but the standard material would require them in Gamma space) (default is true)
  161899. */
  161900. gammaSpace?: boolean);
  161901. /**
  161902. * Execute the current task
  161903. * @param scene defines the scene where you want your assets to be loaded
  161904. * @param onSuccess is a callback called when the task is successfully executed
  161905. * @param onError is a callback called if an error occurs
  161906. */
  161907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161908. }
  161909. /**
  161910. * This class can be used to easily import assets into a scene
  161911. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  161912. */
  161913. export class AssetsManager {
  161914. private _scene;
  161915. private _isLoading;
  161916. protected _tasks: AbstractAssetTask[];
  161917. protected _waitingTasksCount: number;
  161918. protected _totalTasksCount: number;
  161919. /**
  161920. * Callback called when all tasks are processed
  161921. */
  161922. onFinish: (tasks: AbstractAssetTask[]) => void;
  161923. /**
  161924. * Callback called when a task is successful
  161925. */
  161926. onTaskSuccess: (task: AbstractAssetTask) => void;
  161927. /**
  161928. * Callback called when a task had an error
  161929. */
  161930. onTaskError: (task: AbstractAssetTask) => void;
  161931. /**
  161932. * Callback called when a task is done (whatever the result is)
  161933. */
  161934. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  161935. /**
  161936. * Observable called when all tasks are processed
  161937. */
  161938. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  161939. /**
  161940. * Observable called when a task had an error
  161941. */
  161942. onTaskErrorObservable: Observable<AbstractAssetTask>;
  161943. /**
  161944. * Observable called when all tasks were executed
  161945. */
  161946. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  161947. /**
  161948. * Observable called when a task is done (whatever the result is)
  161949. */
  161950. onProgressObservable: Observable<IAssetsProgressEvent>;
  161951. /**
  161952. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  161953. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  161954. */
  161955. useDefaultLoadingScreen: boolean;
  161956. /**
  161957. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  161958. * when all assets have been downloaded.
  161959. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  161960. */
  161961. autoHideLoadingUI: boolean;
  161962. /**
  161963. * Creates a new AssetsManager
  161964. * @param scene defines the scene to work on
  161965. */
  161966. constructor(scene: Scene);
  161967. /**
  161968. * Add a ContainerAssetTask to the list of active tasks
  161969. * @param taskName defines the name of the new task
  161970. * @param meshesNames defines the name of meshes to load
  161971. * @param rootUrl defines the root url to use to locate files
  161972. * @param sceneFilename defines the filename of the scene file
  161973. * @returns a new ContainerAssetTask object
  161974. */
  161975. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  161976. /**
  161977. * Add a MeshAssetTask to the list of active tasks
  161978. * @param taskName defines the name of the new task
  161979. * @param meshesNames defines the name of meshes to load
  161980. * @param rootUrl defines the root url to use to locate files
  161981. * @param sceneFilename defines the filename of the scene file
  161982. * @returns a new MeshAssetTask object
  161983. */
  161984. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  161985. /**
  161986. * Add a TextFileAssetTask to the list of active tasks
  161987. * @param taskName defines the name of the new task
  161988. * @param url defines the url of the file to load
  161989. * @returns a new TextFileAssetTask object
  161990. */
  161991. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  161992. /**
  161993. * Add a BinaryFileAssetTask to the list of active tasks
  161994. * @param taskName defines the name of the new task
  161995. * @param url defines the url of the file to load
  161996. * @returns a new BinaryFileAssetTask object
  161997. */
  161998. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  161999. /**
  162000. * Add a ImageAssetTask to the list of active tasks
  162001. * @param taskName defines the name of the new task
  162002. * @param url defines the url of the file to load
  162003. * @returns a new ImageAssetTask object
  162004. */
  162005. addImageTask(taskName: string, url: string): ImageAssetTask;
  162006. /**
  162007. * Add a TextureAssetTask to the list of active tasks
  162008. * @param taskName defines the name of the new task
  162009. * @param url defines the url of the file to load
  162010. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162011. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  162012. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  162013. * @returns a new TextureAssetTask object
  162014. */
  162015. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  162016. /**
  162017. * Add a CubeTextureAssetTask to the list of active tasks
  162018. * @param taskName defines the name of the new task
  162019. * @param url defines the url of the file to load
  162020. * @param extensions defines the extension to use to load the cube map (can be null)
  162021. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162022. * @param files defines the list of files to load (can be null)
  162023. * @returns a new CubeTextureAssetTask object
  162024. */
  162025. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  162026. /**
  162027. *
  162028. * Add a HDRCubeTextureAssetTask to the list of active tasks
  162029. * @param taskName defines the name of the new task
  162030. * @param url defines the url of the file to load
  162031. * @param size defines the size you want for the cubemap (can be null)
  162032. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162033. * @param generateHarmonics defines if you want to automatically generate (true by default)
  162034. * @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)
  162035. * @param reserved Internal use only
  162036. * @returns a new HDRCubeTextureAssetTask object
  162037. */
  162038. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  162039. /**
  162040. *
  162041. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  162042. * @param taskName defines the name of the new task
  162043. * @param url defines the url of the file to load
  162044. * @param size defines the size you want for the cubemap (can be null)
  162045. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162046. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  162047. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  162048. * @returns a new EquiRectangularCubeTextureAssetTask object
  162049. */
  162050. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  162051. /**
  162052. * Remove a task from the assets manager.
  162053. * @param task the task to remove
  162054. */
  162055. removeTask(task: AbstractAssetTask): void;
  162056. private _decreaseWaitingTasksCount;
  162057. private _runTask;
  162058. /**
  162059. * Reset the AssetsManager and remove all tasks
  162060. * @return the current instance of the AssetsManager
  162061. */
  162062. reset(): AssetsManager;
  162063. /**
  162064. * Start the loading process
  162065. * @return the current instance of the AssetsManager
  162066. */
  162067. load(): AssetsManager;
  162068. /**
  162069. * Start the loading process as an async operation
  162070. * @return a promise returning the list of failed tasks
  162071. */
  162072. loadAsync(): Promise<void>;
  162073. }
  162074. }
  162075. declare module BABYLON {
  162076. /**
  162077. * Wrapper class for promise with external resolve and reject.
  162078. */
  162079. export class Deferred<T> {
  162080. /**
  162081. * The promise associated with this deferred object.
  162082. */
  162083. readonly promise: Promise<T>;
  162084. private _resolve;
  162085. private _reject;
  162086. /**
  162087. * The resolve method of the promise associated with this deferred object.
  162088. */
  162089. get resolve(): (value: T | PromiseLike<T>) => void;
  162090. /**
  162091. * The reject method of the promise associated with this deferred object.
  162092. */
  162093. get reject(): (reason?: any) => void;
  162094. /**
  162095. * Constructor for this deferred object.
  162096. */
  162097. constructor();
  162098. }
  162099. }
  162100. declare module BABYLON {
  162101. /**
  162102. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  162103. */
  162104. export class MeshExploder {
  162105. private _centerMesh;
  162106. private _meshes;
  162107. private _meshesOrigins;
  162108. private _toCenterVectors;
  162109. private _scaledDirection;
  162110. private _newPosition;
  162111. private _centerPosition;
  162112. /**
  162113. * Explodes meshes from a center mesh.
  162114. * @param meshes The meshes to explode.
  162115. * @param centerMesh The mesh to be center of explosion.
  162116. */
  162117. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  162118. private _setCenterMesh;
  162119. /**
  162120. * Get class name
  162121. * @returns "MeshExploder"
  162122. */
  162123. getClassName(): string;
  162124. /**
  162125. * "Exploded meshes"
  162126. * @returns Array of meshes with the centerMesh at index 0.
  162127. */
  162128. getMeshes(): Array<Mesh>;
  162129. /**
  162130. * Explodes meshes giving a specific direction
  162131. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  162132. */
  162133. explode(direction?: number): void;
  162134. }
  162135. }
  162136. declare module BABYLON {
  162137. /**
  162138. * Class used to help managing file picking and drag'n'drop
  162139. */
  162140. export class FilesInput {
  162141. /**
  162142. * List of files ready to be loaded
  162143. */
  162144. static get FilesToLoad(): {
  162145. [key: string]: File;
  162146. };
  162147. /**
  162148. * Callback called when a file is processed
  162149. */
  162150. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  162151. /**
  162152. * Function used when loading the scene file
  162153. */
  162154. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  162155. private _engine;
  162156. private _currentScene;
  162157. private _sceneLoadedCallback;
  162158. private _progressCallback;
  162159. private _additionalRenderLoopLogicCallback;
  162160. private _textureLoadingCallback;
  162161. private _startingProcessingFilesCallback;
  162162. private _onReloadCallback;
  162163. private _errorCallback;
  162164. private _elementToMonitor;
  162165. private _sceneFileToLoad;
  162166. private _filesToLoad;
  162167. /**
  162168. * Creates a new FilesInput
  162169. * @param engine defines the rendering engine
  162170. * @param scene defines the hosting scene
  162171. * @param sceneLoadedCallback callback called when scene is loaded
  162172. * @param progressCallback callback called to track progress
  162173. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  162174. * @param textureLoadingCallback callback called when a texture is loading
  162175. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  162176. * @param onReloadCallback callback called when a reload is requested
  162177. * @param errorCallback callback call if an error occurs
  162178. */
  162179. 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>);
  162180. private _dragEnterHandler;
  162181. private _dragOverHandler;
  162182. private _dropHandler;
  162183. /**
  162184. * Calls this function to listen to drag'n'drop events on a specific DOM element
  162185. * @param elementToMonitor defines the DOM element to track
  162186. */
  162187. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  162188. /** Gets the current list of files to load */
  162189. get filesToLoad(): File[];
  162190. /**
  162191. * Release all associated resources
  162192. */
  162193. dispose(): void;
  162194. private renderFunction;
  162195. private drag;
  162196. private drop;
  162197. private _traverseFolder;
  162198. private _processFiles;
  162199. /**
  162200. * Load files from a drop event
  162201. * @param event defines the drop event to use as source
  162202. */
  162203. loadFiles(event: any): void;
  162204. private _processReload;
  162205. /**
  162206. * Reload the current scene from the loaded files
  162207. */
  162208. reload(): void;
  162209. }
  162210. }
  162211. declare module BABYLON {
  162212. /**
  162213. * Defines the root class used to create scene optimization to use with SceneOptimizer
  162214. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162215. */
  162216. export class SceneOptimization {
  162217. /**
  162218. * Defines the priority of this optimization (0 by default which means first in the list)
  162219. */
  162220. priority: number;
  162221. /**
  162222. * Gets a string describing the action executed by the current optimization
  162223. * @returns description string
  162224. */
  162225. getDescription(): string;
  162226. /**
  162227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162228. * @param scene defines the current scene where to apply this optimization
  162229. * @param optimizer defines the current optimizer
  162230. * @returns true if everything that can be done was applied
  162231. */
  162232. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162233. /**
  162234. * Creates the SceneOptimization object
  162235. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162236. * @param desc defines the description associated with the optimization
  162237. */
  162238. constructor(
  162239. /**
  162240. * Defines the priority of this optimization (0 by default which means first in the list)
  162241. */
  162242. priority?: number);
  162243. }
  162244. /**
  162245. * Defines an optimization used to reduce the size of render target textures
  162246. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162247. */
  162248. export class TextureOptimization extends SceneOptimization {
  162249. /**
  162250. * Defines the priority of this optimization (0 by default which means first in the list)
  162251. */
  162252. priority: number;
  162253. /**
  162254. * 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
  162255. */
  162256. maximumSize: number;
  162257. /**
  162258. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162259. */
  162260. step: number;
  162261. /**
  162262. * Gets a string describing the action executed by the current optimization
  162263. * @returns description string
  162264. */
  162265. getDescription(): string;
  162266. /**
  162267. * Creates the TextureOptimization object
  162268. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162269. * @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
  162270. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162271. */
  162272. constructor(
  162273. /**
  162274. * Defines the priority of this optimization (0 by default which means first in the list)
  162275. */
  162276. priority?: number,
  162277. /**
  162278. * 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
  162279. */
  162280. maximumSize?: number,
  162281. /**
  162282. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162283. */
  162284. step?: number);
  162285. /**
  162286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162287. * @param scene defines the current scene where to apply this optimization
  162288. * @param optimizer defines the current optimizer
  162289. * @returns true if everything that can be done was applied
  162290. */
  162291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162292. }
  162293. /**
  162294. * Defines an optimization used to increase or decrease the rendering resolution
  162295. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162296. */
  162297. export class HardwareScalingOptimization extends SceneOptimization {
  162298. /**
  162299. * Defines the priority of this optimization (0 by default which means first in the list)
  162300. */
  162301. priority: number;
  162302. /**
  162303. * Defines the maximum scale to use (2 by default)
  162304. */
  162305. maximumScale: number;
  162306. /**
  162307. * Defines the step to use between two passes (0.5 by default)
  162308. */
  162309. step: number;
  162310. private _currentScale;
  162311. private _directionOffset;
  162312. /**
  162313. * Gets a string describing the action executed by the current optimization
  162314. * @return description string
  162315. */
  162316. getDescription(): string;
  162317. /**
  162318. * Creates the HardwareScalingOptimization object
  162319. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162320. * @param maximumScale defines the maximum scale to use (2 by default)
  162321. * @param step defines the step to use between two passes (0.5 by default)
  162322. */
  162323. constructor(
  162324. /**
  162325. * Defines the priority of this optimization (0 by default which means first in the list)
  162326. */
  162327. priority?: number,
  162328. /**
  162329. * Defines the maximum scale to use (2 by default)
  162330. */
  162331. maximumScale?: number,
  162332. /**
  162333. * Defines the step to use between two passes (0.5 by default)
  162334. */
  162335. step?: number);
  162336. /**
  162337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162338. * @param scene defines the current scene where to apply this optimization
  162339. * @param optimizer defines the current optimizer
  162340. * @returns true if everything that can be done was applied
  162341. */
  162342. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162343. }
  162344. /**
  162345. * Defines an optimization used to remove shadows
  162346. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162347. */
  162348. export class ShadowsOptimization extends SceneOptimization {
  162349. /**
  162350. * Gets a string describing the action executed by the current optimization
  162351. * @return description string
  162352. */
  162353. getDescription(): string;
  162354. /**
  162355. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162356. * @param scene defines the current scene where to apply this optimization
  162357. * @param optimizer defines the current optimizer
  162358. * @returns true if everything that can be done was applied
  162359. */
  162360. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162361. }
  162362. /**
  162363. * Defines an optimization used to turn post-processes off
  162364. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162365. */
  162366. export class PostProcessesOptimization extends SceneOptimization {
  162367. /**
  162368. * Gets a string describing the action executed by the current optimization
  162369. * @return description string
  162370. */
  162371. getDescription(): string;
  162372. /**
  162373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162374. * @param scene defines the current scene where to apply this optimization
  162375. * @param optimizer defines the current optimizer
  162376. * @returns true if everything that can be done was applied
  162377. */
  162378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162379. }
  162380. /**
  162381. * Defines an optimization used to turn lens flares off
  162382. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162383. */
  162384. export class LensFlaresOptimization extends SceneOptimization {
  162385. /**
  162386. * Gets a string describing the action executed by the current optimization
  162387. * @return description string
  162388. */
  162389. getDescription(): string;
  162390. /**
  162391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162392. * @param scene defines the current scene where to apply this optimization
  162393. * @param optimizer defines the current optimizer
  162394. * @returns true if everything that can be done was applied
  162395. */
  162396. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162397. }
  162398. /**
  162399. * Defines an optimization based on user defined callback.
  162400. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162401. */
  162402. export class CustomOptimization extends SceneOptimization {
  162403. /**
  162404. * Callback called to apply the custom optimization.
  162405. */
  162406. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  162407. /**
  162408. * Callback called to get custom description
  162409. */
  162410. onGetDescription: () => string;
  162411. /**
  162412. * Gets a string describing the action executed by the current optimization
  162413. * @returns description string
  162414. */
  162415. getDescription(): string;
  162416. /**
  162417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162418. * @param scene defines the current scene where to apply this optimization
  162419. * @param optimizer defines the current optimizer
  162420. * @returns true if everything that can be done was applied
  162421. */
  162422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162423. }
  162424. /**
  162425. * Defines an optimization used to turn particles off
  162426. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162427. */
  162428. export class ParticlesOptimization extends SceneOptimization {
  162429. /**
  162430. * Gets a string describing the action executed by the current optimization
  162431. * @return description string
  162432. */
  162433. getDescription(): string;
  162434. /**
  162435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162436. * @param scene defines the current scene where to apply this optimization
  162437. * @param optimizer defines the current optimizer
  162438. * @returns true if everything that can be done was applied
  162439. */
  162440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162441. }
  162442. /**
  162443. * Defines an optimization used to turn render targets off
  162444. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162445. */
  162446. export class RenderTargetsOptimization extends SceneOptimization {
  162447. /**
  162448. * Gets a string describing the action executed by the current optimization
  162449. * @return description string
  162450. */
  162451. getDescription(): string;
  162452. /**
  162453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162454. * @param scene defines the current scene where to apply this optimization
  162455. * @param optimizer defines the current optimizer
  162456. * @returns true if everything that can be done was applied
  162457. */
  162458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162459. }
  162460. /**
  162461. * Defines an optimization used to merge meshes with compatible materials
  162462. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162463. */
  162464. export class MergeMeshesOptimization extends SceneOptimization {
  162465. private static _UpdateSelectionTree;
  162466. /**
  162467. * Gets or sets a boolean which defines if optimization octree has to be updated
  162468. */
  162469. static get UpdateSelectionTree(): boolean;
  162470. /**
  162471. * Gets or sets a boolean which defines if optimization octree has to be updated
  162472. */
  162473. static set UpdateSelectionTree(value: boolean);
  162474. /**
  162475. * Gets a string describing the action executed by the current optimization
  162476. * @return description string
  162477. */
  162478. getDescription(): string;
  162479. private _canBeMerged;
  162480. /**
  162481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162482. * @param scene defines the current scene where to apply this optimization
  162483. * @param optimizer defines the current optimizer
  162484. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  162485. * @returns true if everything that can be done was applied
  162486. */
  162487. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  162488. }
  162489. /**
  162490. * Defines a list of options used by SceneOptimizer
  162491. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162492. */
  162493. export class SceneOptimizerOptions {
  162494. /**
  162495. * Defines the target frame rate to reach (60 by default)
  162496. */
  162497. targetFrameRate: number;
  162498. /**
  162499. * Defines the interval between two checkes (2000ms by default)
  162500. */
  162501. trackerDuration: number;
  162502. /**
  162503. * Gets the list of optimizations to apply
  162504. */
  162505. optimizations: SceneOptimization[];
  162506. /**
  162507. * Creates a new list of options used by SceneOptimizer
  162508. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  162509. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  162510. */
  162511. constructor(
  162512. /**
  162513. * Defines the target frame rate to reach (60 by default)
  162514. */
  162515. targetFrameRate?: number,
  162516. /**
  162517. * Defines the interval between two checkes (2000ms by default)
  162518. */
  162519. trackerDuration?: number);
  162520. /**
  162521. * Add a new optimization
  162522. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  162523. * @returns the current SceneOptimizerOptions
  162524. */
  162525. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  162526. /**
  162527. * Add a new custom optimization
  162528. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  162529. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  162530. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162531. * @returns the current SceneOptimizerOptions
  162532. */
  162533. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  162534. /**
  162535. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  162536. * @param targetFrameRate defines the target frame rate (60 by default)
  162537. * @returns a SceneOptimizerOptions object
  162538. */
  162539. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  162540. /**
  162541. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  162542. * @param targetFrameRate defines the target frame rate (60 by default)
  162543. * @returns a SceneOptimizerOptions object
  162544. */
  162545. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  162546. /**
  162547. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  162548. * @param targetFrameRate defines the target frame rate (60 by default)
  162549. * @returns a SceneOptimizerOptions object
  162550. */
  162551. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  162552. }
  162553. /**
  162554. * Class used to run optimizations in order to reach a target frame rate
  162555. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162556. */
  162557. export class SceneOptimizer implements IDisposable {
  162558. private _isRunning;
  162559. private _options;
  162560. private _scene;
  162561. private _currentPriorityLevel;
  162562. private _targetFrameRate;
  162563. private _trackerDuration;
  162564. private _currentFrameRate;
  162565. private _sceneDisposeObserver;
  162566. private _improvementMode;
  162567. /**
  162568. * Defines an observable called when the optimizer reaches the target frame rate
  162569. */
  162570. onSuccessObservable: Observable<SceneOptimizer>;
  162571. /**
  162572. * Defines an observable called when the optimizer enables an optimization
  162573. */
  162574. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  162575. /**
  162576. * Defines an observable called when the optimizer is not able to reach the target frame rate
  162577. */
  162578. onFailureObservable: Observable<SceneOptimizer>;
  162579. /**
  162580. * Gets a boolean indicating if the optimizer is in improvement mode
  162581. */
  162582. get isInImprovementMode(): boolean;
  162583. /**
  162584. * Gets the current priority level (0 at start)
  162585. */
  162586. get currentPriorityLevel(): number;
  162587. /**
  162588. * Gets the current frame rate checked by the SceneOptimizer
  162589. */
  162590. get currentFrameRate(): number;
  162591. /**
  162592. * Gets or sets the current target frame rate (60 by default)
  162593. */
  162594. get targetFrameRate(): number;
  162595. /**
  162596. * Gets or sets the current target frame rate (60 by default)
  162597. */
  162598. set targetFrameRate(value: number);
  162599. /**
  162600. * Gets or sets the current interval between two checks (every 2000ms by default)
  162601. */
  162602. get trackerDuration(): number;
  162603. /**
  162604. * Gets or sets the current interval between two checks (every 2000ms by default)
  162605. */
  162606. set trackerDuration(value: number);
  162607. /**
  162608. * Gets the list of active optimizations
  162609. */
  162610. get optimizations(): SceneOptimization[];
  162611. /**
  162612. * Creates a new SceneOptimizer
  162613. * @param scene defines the scene to work on
  162614. * @param options defines the options to use with the SceneOptimizer
  162615. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  162616. * @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)
  162617. */
  162618. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  162619. /**
  162620. * Stops the current optimizer
  162621. */
  162622. stop(): void;
  162623. /**
  162624. * Reset the optimizer to initial step (current priority level = 0)
  162625. */
  162626. reset(): void;
  162627. /**
  162628. * Start the optimizer. By default it will try to reach a specific framerate
  162629. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  162630. */
  162631. start(): void;
  162632. private _checkCurrentState;
  162633. /**
  162634. * Release all resources
  162635. */
  162636. dispose(): void;
  162637. /**
  162638. * Helper function to create a SceneOptimizer with one single line of code
  162639. * @param scene defines the scene to work on
  162640. * @param options defines the options to use with the SceneOptimizer
  162641. * @param onSuccess defines a callback to call on success
  162642. * @param onFailure defines a callback to call on failure
  162643. * @returns the new SceneOptimizer object
  162644. */
  162645. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  162646. }
  162647. }
  162648. declare module BABYLON {
  162649. /**
  162650. * Class used to serialize a scene into a string
  162651. */
  162652. export class SceneSerializer {
  162653. /**
  162654. * Clear cache used by a previous serialization
  162655. */
  162656. static ClearCache(): void;
  162657. /**
  162658. * Serialize a scene into a JSON compatible object
  162659. * @param scene defines the scene to serialize
  162660. * @returns a JSON compatible object
  162661. */
  162662. static Serialize(scene: Scene): any;
  162663. /**
  162664. * Serialize a mesh into a JSON compatible object
  162665. * @param toSerialize defines the mesh to serialize
  162666. * @param withParents defines if parents must be serialized as well
  162667. * @param withChildren defines if children must be serialized as well
  162668. * @returns a JSON compatible object
  162669. */
  162670. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  162671. }
  162672. }
  162673. declare module BABYLON {
  162674. /**
  162675. * This represents the different options available for the video capture.
  162676. */
  162677. export interface VideoRecorderOptions {
  162678. /** Defines the mime type of the video. */
  162679. mimeType: string;
  162680. /** Defines the FPS the video should be recorded at. */
  162681. fps: number;
  162682. /** Defines the chunk size for the recording data. */
  162683. recordChunckSize: number;
  162684. /** The audio tracks to attach to the recording. */
  162685. audioTracks?: MediaStreamTrack[];
  162686. }
  162687. /**
  162688. * This can help with recording videos from BabylonJS.
  162689. * This is based on the available WebRTC functionalities of the browser.
  162690. *
  162691. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  162692. */
  162693. export class VideoRecorder {
  162694. private static readonly _defaultOptions;
  162695. /**
  162696. * Returns whether or not the VideoRecorder is available in your browser.
  162697. * @param engine Defines the Babylon Engine.
  162698. * @returns true if supported otherwise false.
  162699. */
  162700. static IsSupported(engine: Engine): boolean;
  162701. private readonly _options;
  162702. private _canvas;
  162703. private _mediaRecorder;
  162704. private _recordedChunks;
  162705. private _fileName;
  162706. private _resolve;
  162707. private _reject;
  162708. /**
  162709. * True when a recording is already in progress.
  162710. */
  162711. get isRecording(): boolean;
  162712. /**
  162713. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  162714. * @param engine Defines the BabylonJS Engine you wish to record.
  162715. * @param options Defines options that can be used to customize the capture.
  162716. */
  162717. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  162718. /**
  162719. * Stops the current recording before the default capture timeout passed in the startRecording function.
  162720. */
  162721. stopRecording(): void;
  162722. /**
  162723. * Starts recording the canvas for a max duration specified in parameters.
  162724. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  162725. * If null no automatic download will start and you can rely on the promise to get the data back.
  162726. * @param maxDuration Defines the maximum recording time in seconds.
  162727. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  162728. * @return A promise callback at the end of the recording with the video data in Blob.
  162729. */
  162730. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  162731. /**
  162732. * Releases internal resources used during the recording.
  162733. */
  162734. dispose(): void;
  162735. private _handleDataAvailable;
  162736. private _handleError;
  162737. private _handleStop;
  162738. }
  162739. }
  162740. declare module BABYLON {
  162741. /**
  162742. * Class containing a set of static utilities functions for screenshots
  162743. */
  162744. export class ScreenshotTools {
  162745. /**
  162746. * Captures a screenshot of the current rendering
  162747. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162748. * @param engine defines the rendering engine
  162749. * @param camera defines the source camera
  162750. * @param size This parameter can be set to a single number or to an object with the
  162751. * following (optional) properties: precision, width, height. If a single number is passed,
  162752. * it will be used for both width and height. If an object is passed, the screenshot size
  162753. * will be derived from the parameters. The precision property is a multiplier allowing
  162754. * rendering at a higher or lower resolution
  162755. * @param successCallback defines the callback receives a single parameter which contains the
  162756. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  162757. * src parameter of an <img> to display it
  162758. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  162759. * Check your browser for supported MIME types
  162760. */
  162761. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  162762. /**
  162763. * Captures a screenshot of the current rendering
  162764. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162765. * @param engine defines the rendering engine
  162766. * @param camera defines the source camera
  162767. * @param size This parameter can be set to a single number or to an object with the
  162768. * following (optional) properties: precision, width, height. If a single number is passed,
  162769. * it will be used for both width and height. If an object is passed, the screenshot size
  162770. * will be derived from the parameters. The precision property is a multiplier allowing
  162771. * rendering at a higher or lower resolution
  162772. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  162773. * Check your browser for supported MIME types
  162774. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  162775. * to the src parameter of an <img> to display it
  162776. */
  162777. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  162778. /**
  162779. * Generates an image screenshot from the specified camera.
  162780. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162781. * @param engine The engine to use for rendering
  162782. * @param camera The camera to use for rendering
  162783. * @param size This parameter can be set to a single number or to an object with the
  162784. * following (optional) properties: precision, width, height. If a single number is passed,
  162785. * it will be used for both width and height. If an object is passed, the screenshot size
  162786. * will be derived from the parameters. The precision property is a multiplier allowing
  162787. * rendering at a higher or lower resolution
  162788. * @param successCallback The callback receives a single parameter which contains the
  162789. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  162790. * src parameter of an <img> to display it
  162791. * @param mimeType The MIME type of the screenshot image (default: image/png).
  162792. * Check your browser for supported MIME types
  162793. * @param samples Texture samples (default: 1)
  162794. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  162795. * @param fileName A name for for the downloaded file.
  162796. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  162797. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  162798. */
  162799. 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;
  162800. /**
  162801. * Generates an image screenshot from the specified camera.
  162802. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162803. * @param engine The engine to use for rendering
  162804. * @param camera The camera to use for rendering
  162805. * @param size This parameter can be set to a single number or to an object with the
  162806. * following (optional) properties: precision, width, height. If a single number is passed,
  162807. * it will be used for both width and height. If an object is passed, the screenshot size
  162808. * will be derived from the parameters. The precision property is a multiplier allowing
  162809. * rendering at a higher or lower resolution
  162810. * @param mimeType The MIME type of the screenshot image (default: image/png).
  162811. * Check your browser for supported MIME types
  162812. * @param samples Texture samples (default: 1)
  162813. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  162814. * @param fileName A name for for the downloaded file.
  162815. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  162816. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  162817. * to the src parameter of an <img> to display it
  162818. */
  162819. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  162820. /**
  162821. * Gets height and width for screenshot size
  162822. * @private
  162823. */
  162824. private static _getScreenshotSize;
  162825. }
  162826. }
  162827. declare module BABYLON {
  162828. /**
  162829. * Interface for a data buffer
  162830. */
  162831. export interface IDataBuffer {
  162832. /**
  162833. * Reads bytes from the data buffer.
  162834. * @param byteOffset The byte offset to read
  162835. * @param byteLength The byte length to read
  162836. * @returns A promise that resolves when the bytes are read
  162837. */
  162838. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  162839. /**
  162840. * The byte length of the buffer.
  162841. */
  162842. readonly byteLength: number;
  162843. }
  162844. /**
  162845. * Utility class for reading from a data buffer
  162846. */
  162847. export class DataReader {
  162848. /**
  162849. * The data buffer associated with this data reader.
  162850. */
  162851. readonly buffer: IDataBuffer;
  162852. /**
  162853. * The current byte offset from the beginning of the data buffer.
  162854. */
  162855. byteOffset: number;
  162856. private _dataView;
  162857. private _dataByteOffset;
  162858. /**
  162859. * Constructor
  162860. * @param buffer The buffer to read
  162861. */
  162862. constructor(buffer: IDataBuffer);
  162863. /**
  162864. * Loads the given byte length.
  162865. * @param byteLength The byte length to load
  162866. * @returns A promise that resolves when the load is complete
  162867. */
  162868. loadAsync(byteLength: number): Promise<void>;
  162869. /**
  162870. * Read a unsigned 32-bit integer from the currently loaded data range.
  162871. * @returns The 32-bit integer read
  162872. */
  162873. readUint32(): number;
  162874. /**
  162875. * Read a byte array from the currently loaded data range.
  162876. * @param byteLength The byte length to read
  162877. * @returns The byte array read
  162878. */
  162879. readUint8Array(byteLength: number): Uint8Array;
  162880. /**
  162881. * Read a string from the currently loaded data range.
  162882. * @param byteLength The byte length to read
  162883. * @returns The string read
  162884. */
  162885. readString(byteLength: number): string;
  162886. /**
  162887. * Skips the given byte length the currently loaded data range.
  162888. * @param byteLength The byte length to skip
  162889. */
  162890. skipBytes(byteLength: number): void;
  162891. }
  162892. }
  162893. declare module BABYLON {
  162894. /**
  162895. * Class for storing data to local storage if available or in-memory storage otherwise
  162896. */
  162897. export class DataStorage {
  162898. private static _Storage;
  162899. private static _GetStorage;
  162900. /**
  162901. * Reads a string from the data storage
  162902. * @param key The key to read
  162903. * @param defaultValue The value if the key doesn't exist
  162904. * @returns The string value
  162905. */
  162906. static ReadString(key: string, defaultValue: string): string;
  162907. /**
  162908. * Writes a string to the data storage
  162909. * @param key The key to write
  162910. * @param value The value to write
  162911. */
  162912. static WriteString(key: string, value: string): void;
  162913. /**
  162914. * Reads a boolean from the data storage
  162915. * @param key The key to read
  162916. * @param defaultValue The value if the key doesn't exist
  162917. * @returns The boolean value
  162918. */
  162919. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  162920. /**
  162921. * Writes a boolean to the data storage
  162922. * @param key The key to write
  162923. * @param value The value to write
  162924. */
  162925. static WriteBoolean(key: string, value: boolean): void;
  162926. /**
  162927. * Reads a number from the data storage
  162928. * @param key The key to read
  162929. * @param defaultValue The value if the key doesn't exist
  162930. * @returns The number value
  162931. */
  162932. static ReadNumber(key: string, defaultValue: number): number;
  162933. /**
  162934. * Writes a number to the data storage
  162935. * @param key The key to write
  162936. * @param value The value to write
  162937. */
  162938. static WriteNumber(key: string, value: number): void;
  162939. }
  162940. }
  162941. declare module BABYLON {
  162942. /**
  162943. * Class used to record delta files between 2 scene states
  162944. */
  162945. export class SceneRecorder {
  162946. private _trackedScene;
  162947. private _savedJSON;
  162948. /**
  162949. * Track a given scene. This means the current scene state will be considered the original state
  162950. * @param scene defines the scene to track
  162951. */
  162952. track(scene: Scene): void;
  162953. /**
  162954. * Get the delta between current state and original state
  162955. * @returns a string containing the delta
  162956. */
  162957. getDelta(): any;
  162958. private _compareArray;
  162959. private _compareObjects;
  162960. private _compareCollections;
  162961. private static GetShadowGeneratorById;
  162962. /**
  162963. * Apply a given delta to a given scene
  162964. * @param deltaJSON defines the JSON containing the delta
  162965. * @param scene defines the scene to apply the delta to
  162966. */
  162967. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  162968. private static _ApplyPropertiesToEntity;
  162969. private static _ApplyDeltaForEntity;
  162970. }
  162971. }
  162972. declare module BABYLON {
  162973. /**
  162974. * A 3D trajectory consisting of an order list of vectors describing a
  162975. * path of motion through 3D space.
  162976. */
  162977. export class Trajectory {
  162978. private _points;
  162979. private readonly _segmentLength;
  162980. /**
  162981. * Serialize to JSON.
  162982. * @returns serialized JSON string
  162983. */
  162984. serialize(): string;
  162985. /**
  162986. * Deserialize from JSON.
  162987. * @param json serialized JSON string
  162988. * @returns deserialized Trajectory
  162989. */
  162990. static Deserialize(json: string): Trajectory;
  162991. /**
  162992. * Create a new empty Trajectory.
  162993. * @param segmentLength radius of discretization for Trajectory points
  162994. */
  162995. constructor(segmentLength?: number);
  162996. /**
  162997. * Get the length of the Trajectory.
  162998. * @returns length of the Trajectory
  162999. */
  163000. getLength(): number;
  163001. /**
  163002. * Append a new point to the Trajectory.
  163003. * NOTE: This implementation has many allocations.
  163004. * @param point point to append to the Trajectory
  163005. */
  163006. add(point: DeepImmutable<Vector3>): void;
  163007. /**
  163008. * Create a new Trajectory with a segment length chosen to make it
  163009. * probable that the new Trajectory will have a specified number of
  163010. * segments. This operation is imprecise.
  163011. * @param targetResolution number of segments desired
  163012. * @returns new Trajectory with approximately the requested number of segments
  163013. */
  163014. resampleAtTargetResolution(targetResolution: number): Trajectory;
  163015. /**
  163016. * Convert Trajectory segments into tokenized representation. This
  163017. * representation is an array of numbers where each nth number is the
  163018. * index of the token which is most similar to the nth segment of the
  163019. * Trajectory.
  163020. * @param tokens list of vectors which serve as discrete tokens
  163021. * @returns list of indices of most similar token per segment
  163022. */
  163023. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  163024. private static _forwardDir;
  163025. private static _inverseFromVec;
  163026. private static _upDir;
  163027. private static _fromToVec;
  163028. private static _lookMatrix;
  163029. /**
  163030. * Transform the rotation (i.e., direction) of a segment to isolate
  163031. * the relative transformation represented by the segment. This operation
  163032. * may or may not succeed due to singularities in the equations that define
  163033. * motion relativity in this context.
  163034. * @param priorVec the origin of the prior segment
  163035. * @param fromVec the origin of the current segment
  163036. * @param toVec the destination of the current segment
  163037. * @param result reference to output variable
  163038. * @returns whether or not transformation was successful
  163039. */
  163040. private static _transformSegmentDirToRef;
  163041. private static _bestMatch;
  163042. private static _score;
  163043. private static _bestScore;
  163044. /**
  163045. * Determine which token vector is most similar to the
  163046. * segment vector.
  163047. * @param segment segment vector
  163048. * @param tokens token vector list
  163049. * @returns index of the most similar token to the segment
  163050. */
  163051. private static _tokenizeSegment;
  163052. }
  163053. /**
  163054. * Class representing a set of known, named trajectories to which Trajectories can be
  163055. * added and using which Trajectories can be recognized.
  163056. */
  163057. export class TrajectoryClassifier {
  163058. private _maximumAllowableMatchCost;
  163059. private _vector3Alphabet;
  163060. private _levenshteinAlphabet;
  163061. private _nameToDescribedTrajectory;
  163062. /**
  163063. * Serialize to JSON.
  163064. * @returns JSON serialization
  163065. */
  163066. serialize(): string;
  163067. /**
  163068. * Deserialize from JSON.
  163069. * @param json JSON serialization
  163070. * @returns deserialized TrajectorySet
  163071. */
  163072. static Deserialize(json: string): TrajectoryClassifier;
  163073. /**
  163074. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  163075. * VERY naive, need to be generating these things from known
  163076. * sets. Better version later, probably eliminating this one.
  163077. * @returns auto-generated TrajectorySet
  163078. */
  163079. static Generate(): TrajectoryClassifier;
  163080. private constructor();
  163081. /**
  163082. * Add a new Trajectory to the set with a given name.
  163083. * @param trajectory new Trajectory to be added
  163084. * @param classification name to which to add the Trajectory
  163085. */
  163086. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  163087. /**
  163088. * Remove a known named trajectory and all Trajectories associated with it.
  163089. * @param classification name to remove
  163090. * @returns whether anything was removed
  163091. */
  163092. deleteClassification(classification: string): boolean;
  163093. /**
  163094. * Attempt to recognize a Trajectory from among all the classifications
  163095. * already known to the classifier.
  163096. * @param trajectory Trajectory to be recognized
  163097. * @returns classification of Trajectory if recognized, null otherwise
  163098. */
  163099. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  163100. }
  163101. }
  163102. declare module BABYLON {
  163103. /**
  163104. * An interface for all Hit test features
  163105. */
  163106. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  163107. /**
  163108. * Triggered when new babylon (transformed) hit test results are available
  163109. */
  163110. onHitTestResultObservable: Observable<T[]>;
  163111. }
  163112. /**
  163113. * Options used for hit testing
  163114. */
  163115. export interface IWebXRLegacyHitTestOptions {
  163116. /**
  163117. * Only test when user interacted with the scene. Default - hit test every frame
  163118. */
  163119. testOnPointerDownOnly?: boolean;
  163120. /**
  163121. * The node to use to transform the local results to world coordinates
  163122. */
  163123. worldParentNode?: TransformNode;
  163124. }
  163125. /**
  163126. * Interface defining the babylon result of raycasting/hit-test
  163127. */
  163128. export interface IWebXRLegacyHitResult {
  163129. /**
  163130. * Transformation matrix that can be applied to a node that will put it in the hit point location
  163131. */
  163132. transformationMatrix: Matrix;
  163133. /**
  163134. * The native hit test result
  163135. */
  163136. xrHitResult: XRHitResult | XRHitTestResult;
  163137. }
  163138. /**
  163139. * The currently-working hit-test module.
  163140. * Hit test (or Ray-casting) is used to interact with the real world.
  163141. * For further information read here - https://github.com/immersive-web/hit-test
  163142. */
  163143. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  163144. /**
  163145. * options to use when constructing this feature
  163146. */
  163147. readonly options: IWebXRLegacyHitTestOptions;
  163148. private _direction;
  163149. private _mat;
  163150. private _onSelectEnabled;
  163151. private _origin;
  163152. /**
  163153. * The module's name
  163154. */
  163155. static readonly Name: string;
  163156. /**
  163157. * The (Babylon) version of this module.
  163158. * This is an integer representing the implementation version.
  163159. * This number does not correspond to the WebXR specs version
  163160. */
  163161. static readonly Version: number;
  163162. /**
  163163. * Populated with the last native XR Hit Results
  163164. */
  163165. lastNativeXRHitResults: XRHitResult[];
  163166. /**
  163167. * Triggered when new babylon (transformed) hit test results are available
  163168. */
  163169. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  163170. /**
  163171. * Creates a new instance of the (legacy version) hit test feature
  163172. * @param _xrSessionManager an instance of WebXRSessionManager
  163173. * @param options options to use when constructing this feature
  163174. */
  163175. constructor(_xrSessionManager: WebXRSessionManager,
  163176. /**
  163177. * options to use when constructing this feature
  163178. */
  163179. options?: IWebXRLegacyHitTestOptions);
  163180. /**
  163181. * execute a hit test with an XR Ray
  163182. *
  163183. * @param xrSession a native xrSession that will execute this hit test
  163184. * @param xrRay the ray (position and direction) to use for ray-casting
  163185. * @param referenceSpace native XR reference space to use for the hit-test
  163186. * @param filter filter function that will filter the results
  163187. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  163188. */
  163189. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  163190. /**
  163191. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  163192. * @param event the (select) event to use to select with
  163193. * @param referenceSpace the reference space to use for this hit test
  163194. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  163195. */
  163196. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  163197. /**
  163198. * attach this feature
  163199. * Will usually be called by the features manager
  163200. *
  163201. * @returns true if successful.
  163202. */
  163203. attach(): boolean;
  163204. /**
  163205. * detach this feature.
  163206. * Will usually be called by the features manager
  163207. *
  163208. * @returns true if successful.
  163209. */
  163210. detach(): boolean;
  163211. /**
  163212. * Dispose this feature and all of the resources attached
  163213. */
  163214. dispose(): void;
  163215. protected _onXRFrame(frame: XRFrame): void;
  163216. private _onHitTestResults;
  163217. private _onSelect;
  163218. }
  163219. }
  163220. declare module BABYLON {
  163221. /**
  163222. * Options used for hit testing (version 2)
  163223. */
  163224. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  163225. /**
  163226. * Do not create a permanent hit test. Will usually be used when only
  163227. * transient inputs are needed.
  163228. */
  163229. disablePermanentHitTest?: boolean;
  163230. /**
  163231. * Enable transient (for example touch-based) hit test inspections
  163232. */
  163233. enableTransientHitTest?: boolean;
  163234. /**
  163235. * Offset ray for the permanent hit test
  163236. */
  163237. offsetRay?: Vector3;
  163238. /**
  163239. * Offset ray for the transient hit test
  163240. */
  163241. transientOffsetRay?: Vector3;
  163242. /**
  163243. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  163244. */
  163245. useReferenceSpace?: boolean;
  163246. /**
  163247. * Override the default entity type(s) of the hit-test result
  163248. */
  163249. entityTypes?: XRHitTestTrackableType[];
  163250. }
  163251. /**
  163252. * Interface defining the babylon result of hit-test
  163253. */
  163254. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  163255. /**
  163256. * The input source that generated this hit test (if transient)
  163257. */
  163258. inputSource?: XRInputSource;
  163259. /**
  163260. * Is this a transient hit test
  163261. */
  163262. isTransient?: boolean;
  163263. /**
  163264. * Position of the hit test result
  163265. */
  163266. position: Vector3;
  163267. /**
  163268. * Rotation of the hit test result
  163269. */
  163270. rotationQuaternion: Quaternion;
  163271. /**
  163272. * The native hit test result
  163273. */
  163274. xrHitResult: XRHitTestResult;
  163275. }
  163276. /**
  163277. * The currently-working hit-test module.
  163278. * Hit test (or Ray-casting) is used to interact with the real world.
  163279. * For further information read here - https://github.com/immersive-web/hit-test
  163280. *
  163281. * Tested on chrome (mobile) 80.
  163282. */
  163283. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  163284. /**
  163285. * options to use when constructing this feature
  163286. */
  163287. readonly options: IWebXRHitTestOptions;
  163288. private _tmpMat;
  163289. private _tmpPos;
  163290. private _tmpQuat;
  163291. private _transientXrHitTestSource;
  163292. private _xrHitTestSource;
  163293. private initHitTestSource;
  163294. /**
  163295. * The module's name
  163296. */
  163297. static readonly Name: string;
  163298. /**
  163299. * The (Babylon) version of this module.
  163300. * This is an integer representing the implementation version.
  163301. * This number does not correspond to the WebXR specs version
  163302. */
  163303. static readonly Version: number;
  163304. /**
  163305. * When set to true, each hit test will have its own position/rotation objects
  163306. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  163307. * the developers will clone them or copy them as they see fit.
  163308. */
  163309. autoCloneTransformation: boolean;
  163310. /**
  163311. * Triggered when new babylon (transformed) hit test results are available
  163312. * Note - this will be called when results come back from the device. It can be an empty array!!
  163313. */
  163314. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  163315. /**
  163316. * Use this to temporarily pause hit test checks.
  163317. */
  163318. paused: boolean;
  163319. /**
  163320. * Creates a new instance of the hit test feature
  163321. * @param _xrSessionManager an instance of WebXRSessionManager
  163322. * @param options options to use when constructing this feature
  163323. */
  163324. constructor(_xrSessionManager: WebXRSessionManager,
  163325. /**
  163326. * options to use when constructing this feature
  163327. */
  163328. options?: IWebXRHitTestOptions);
  163329. /**
  163330. * attach this feature
  163331. * Will usually be called by the features manager
  163332. *
  163333. * @returns true if successful.
  163334. */
  163335. attach(): boolean;
  163336. /**
  163337. * detach this feature.
  163338. * Will usually be called by the features manager
  163339. *
  163340. * @returns true if successful.
  163341. */
  163342. detach(): boolean;
  163343. /**
  163344. * Dispose this feature and all of the resources attached
  163345. */
  163346. dispose(): void;
  163347. protected _onXRFrame(frame: XRFrame): void;
  163348. private _processWebXRHitTestResult;
  163349. }
  163350. }
  163351. declare module BABYLON {
  163352. /**
  163353. * Configuration options of the anchor system
  163354. */
  163355. export interface IWebXRAnchorSystemOptions {
  163356. /**
  163357. * a node that will be used to convert local to world coordinates
  163358. */
  163359. worldParentNode?: TransformNode;
  163360. /**
  163361. * If set to true a reference of the created anchors will be kept until the next session starts
  163362. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  163363. */
  163364. doNotRemoveAnchorsOnSessionEnded?: boolean;
  163365. }
  163366. /**
  163367. * A babylon container for an XR Anchor
  163368. */
  163369. export interface IWebXRAnchor {
  163370. /**
  163371. * A babylon-assigned ID for this anchor
  163372. */
  163373. id: number;
  163374. /**
  163375. * Transformation matrix to apply to an object attached to this anchor
  163376. */
  163377. transformationMatrix: Matrix;
  163378. /**
  163379. * The native anchor object
  163380. */
  163381. xrAnchor: XRAnchor;
  163382. /**
  163383. * if defined, this object will be constantly updated by the anchor's position and rotation
  163384. */
  163385. attachedNode?: TransformNode;
  163386. /**
  163387. * Remove this anchor from the scene
  163388. */
  163389. remove(): void;
  163390. }
  163391. /**
  163392. * An implementation of the anchor system for WebXR.
  163393. * For further information see https://github.com/immersive-web/anchors/
  163394. */
  163395. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  163396. private _options;
  163397. private _lastFrameDetected;
  163398. private _trackedAnchors;
  163399. private _referenceSpaceForFrameAnchors;
  163400. private _futureAnchors;
  163401. /**
  163402. * The module's name
  163403. */
  163404. static readonly Name: string;
  163405. /**
  163406. * The (Babylon) version of this module.
  163407. * This is an integer representing the implementation version.
  163408. * This number does not correspond to the WebXR specs version
  163409. */
  163410. static readonly Version: number;
  163411. /**
  163412. * Observers registered here will be executed when a new anchor was added to the session
  163413. */
  163414. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  163415. /**
  163416. * Observers registered here will be executed when an anchor was removed from the session
  163417. */
  163418. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  163419. /**
  163420. * Observers registered here will be executed when an existing anchor updates
  163421. * This can execute N times every frame
  163422. */
  163423. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  163424. /**
  163425. * Set the reference space to use for anchor creation, when not using a hit test.
  163426. * Will default to the session's reference space if not defined
  163427. */
  163428. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  163429. /**
  163430. * constructs a new anchor system
  163431. * @param _xrSessionManager an instance of WebXRSessionManager
  163432. * @param _options configuration object for this feature
  163433. */
  163434. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  163435. private _tmpVector;
  163436. private _tmpQuaternion;
  163437. private _populateTmpTransformation;
  163438. /**
  163439. * Create a new anchor point using a hit test result at a specific point in the scene
  163440. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  163441. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  163442. *
  163443. * @param hitTestResult The hit test result to use for this anchor creation
  163444. * @param position an optional position offset for this anchor
  163445. * @param rotationQuaternion an optional rotation offset for this anchor
  163446. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  163447. */
  163448. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  163449. /**
  163450. * Add a new anchor at a specific position and rotation
  163451. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  163452. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  163453. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  163454. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  163455. *
  163456. * @param position the position in which to add an anchor
  163457. * @param rotationQuaternion an optional rotation for the anchor transformation
  163458. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  163459. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  163460. */
  163461. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  163462. /**
  163463. * Get the list of anchors currently being tracked by the system
  163464. */
  163465. get anchors(): IWebXRAnchor[];
  163466. /**
  163467. * detach this feature.
  163468. * Will usually be called by the features manager
  163469. *
  163470. * @returns true if successful.
  163471. */
  163472. detach(): boolean;
  163473. /**
  163474. * Dispose this feature and all of the resources attached
  163475. */
  163476. dispose(): void;
  163477. protected _onXRFrame(frame: XRFrame): void;
  163478. /**
  163479. * avoiding using Array.find for global support.
  163480. * @param xrAnchor the plane to find in the array
  163481. */
  163482. private _findIndexInAnchorArray;
  163483. private _updateAnchorWithXRFrame;
  163484. private _createAnchorAtTransformation;
  163485. }
  163486. }
  163487. declare module BABYLON {
  163488. /**
  163489. * Options used in the plane detector module
  163490. */
  163491. export interface IWebXRPlaneDetectorOptions {
  163492. /**
  163493. * The node to use to transform the local results to world coordinates
  163494. */
  163495. worldParentNode?: TransformNode;
  163496. /**
  163497. * If set to true a reference of the created planes will be kept until the next session starts
  163498. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  163499. */
  163500. doNotRemovePlanesOnSessionEnded?: boolean;
  163501. /**
  163502. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  163503. */
  163504. preferredDetectorOptions?: XRGeometryDetectorOptions;
  163505. }
  163506. /**
  163507. * A babylon interface for a WebXR plane.
  163508. * A Plane is actually a polygon, built from N points in space
  163509. *
  163510. * Supported in chrome 79, not supported in canary 81 ATM
  163511. */
  163512. export interface IWebXRPlane {
  163513. /**
  163514. * a babylon-assigned ID for this polygon
  163515. */
  163516. id: number;
  163517. /**
  163518. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  163519. */
  163520. polygonDefinition: Array<Vector3>;
  163521. /**
  163522. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  163523. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  163524. */
  163525. transformationMatrix: Matrix;
  163526. /**
  163527. * the native xr-plane object
  163528. */
  163529. xrPlane: XRPlane;
  163530. }
  163531. /**
  163532. * The plane detector is used to detect planes in the real world when in AR
  163533. * For more information see https://github.com/immersive-web/real-world-geometry/
  163534. */
  163535. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  163536. private _options;
  163537. private _detectedPlanes;
  163538. private _enabled;
  163539. private _lastFrameDetected;
  163540. /**
  163541. * The module's name
  163542. */
  163543. static readonly Name: string;
  163544. /**
  163545. * The (Babylon) version of this module.
  163546. * This is an integer representing the implementation version.
  163547. * This number does not correspond to the WebXR specs version
  163548. */
  163549. static readonly Version: number;
  163550. /**
  163551. * Observers registered here will be executed when a new plane was added to the session
  163552. */
  163553. onPlaneAddedObservable: Observable<IWebXRPlane>;
  163554. /**
  163555. * Observers registered here will be executed when a plane is no longer detected in the session
  163556. */
  163557. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  163558. /**
  163559. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  163560. * This can execute N times every frame
  163561. */
  163562. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  163563. /**
  163564. * construct a new Plane Detector
  163565. * @param _xrSessionManager an instance of xr Session manager
  163566. * @param _options configuration to use when constructing this feature
  163567. */
  163568. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  163569. /**
  163570. * detach this feature.
  163571. * Will usually be called by the features manager
  163572. *
  163573. * @returns true if successful.
  163574. */
  163575. detach(): boolean;
  163576. /**
  163577. * Dispose this feature and all of the resources attached
  163578. */
  163579. dispose(): void;
  163580. /**
  163581. * Check if the needed objects are defined.
  163582. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  163583. */
  163584. isCompatible(): boolean;
  163585. protected _onXRFrame(frame: XRFrame): void;
  163586. private _init;
  163587. private _updatePlaneWithXRPlane;
  163588. /**
  163589. * avoiding using Array.find for global support.
  163590. * @param xrPlane the plane to find in the array
  163591. */
  163592. private _findIndexInPlaneArray;
  163593. }
  163594. }
  163595. declare module BABYLON {
  163596. /**
  163597. * Options interface for the background remover plugin
  163598. */
  163599. export interface IWebXRBackgroundRemoverOptions {
  163600. /**
  163601. * Further background meshes to disable when entering AR
  163602. */
  163603. backgroundMeshes?: AbstractMesh[];
  163604. /**
  163605. * flags to configure the removal of the environment helper.
  163606. * If not set, the entire background will be removed. If set, flags should be set as well.
  163607. */
  163608. environmentHelperRemovalFlags?: {
  163609. /**
  163610. * Should the skybox be removed (default false)
  163611. */
  163612. skyBox?: boolean;
  163613. /**
  163614. * Should the ground be removed (default false)
  163615. */
  163616. ground?: boolean;
  163617. };
  163618. /**
  163619. * don't disable the environment helper
  163620. */
  163621. ignoreEnvironmentHelper?: boolean;
  163622. }
  163623. /**
  163624. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  163625. */
  163626. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  163627. /**
  163628. * read-only options to be used in this module
  163629. */
  163630. readonly options: IWebXRBackgroundRemoverOptions;
  163631. /**
  163632. * The module's name
  163633. */
  163634. static readonly Name: string;
  163635. /**
  163636. * The (Babylon) version of this module.
  163637. * This is an integer representing the implementation version.
  163638. * This number does not correspond to the WebXR specs version
  163639. */
  163640. static readonly Version: number;
  163641. /**
  163642. * registered observers will be triggered when the background state changes
  163643. */
  163644. onBackgroundStateChangedObservable: Observable<boolean>;
  163645. /**
  163646. * constructs a new background remover module
  163647. * @param _xrSessionManager the session manager for this module
  163648. * @param options read-only options to be used in this module
  163649. */
  163650. constructor(_xrSessionManager: WebXRSessionManager,
  163651. /**
  163652. * read-only options to be used in this module
  163653. */
  163654. options?: IWebXRBackgroundRemoverOptions);
  163655. /**
  163656. * attach this feature
  163657. * Will usually be called by the features manager
  163658. *
  163659. * @returns true if successful.
  163660. */
  163661. attach(): boolean;
  163662. /**
  163663. * detach this feature.
  163664. * Will usually be called by the features manager
  163665. *
  163666. * @returns true if successful.
  163667. */
  163668. detach(): boolean;
  163669. /**
  163670. * Dispose this feature and all of the resources attached
  163671. */
  163672. dispose(): void;
  163673. protected _onXRFrame(_xrFrame: XRFrame): void;
  163674. private _setBackgroundState;
  163675. }
  163676. }
  163677. declare module BABYLON {
  163678. /**
  163679. * Options for the controller physics feature
  163680. */
  163681. export class IWebXRControllerPhysicsOptions {
  163682. /**
  163683. * Should the headset get its own impostor
  163684. */
  163685. enableHeadsetImpostor?: boolean;
  163686. /**
  163687. * Optional parameters for the headset impostor
  163688. */
  163689. headsetImpostorParams?: {
  163690. /**
  163691. * The type of impostor to create. Default is sphere
  163692. */
  163693. impostorType: number;
  163694. /**
  163695. * the size of the impostor. Defaults to 10cm
  163696. */
  163697. impostorSize?: number | {
  163698. width: number;
  163699. height: number;
  163700. depth: number;
  163701. };
  163702. /**
  163703. * Friction definitions
  163704. */
  163705. friction?: number;
  163706. /**
  163707. * Restitution
  163708. */
  163709. restitution?: number;
  163710. };
  163711. /**
  163712. * The physics properties of the future impostors
  163713. */
  163714. physicsProperties?: {
  163715. /**
  163716. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  163717. * Note that this requires a physics engine that supports mesh impostors!
  163718. */
  163719. useControllerMesh?: boolean;
  163720. /**
  163721. * The type of impostor to create. Default is sphere
  163722. */
  163723. impostorType?: number;
  163724. /**
  163725. * the size of the impostor. Defaults to 10cm
  163726. */
  163727. impostorSize?: number | {
  163728. width: number;
  163729. height: number;
  163730. depth: number;
  163731. };
  163732. /**
  163733. * Friction definitions
  163734. */
  163735. friction?: number;
  163736. /**
  163737. * Restitution
  163738. */
  163739. restitution?: number;
  163740. };
  163741. /**
  163742. * the xr input to use with this pointer selection
  163743. */
  163744. xrInput: WebXRInput;
  163745. }
  163746. /**
  163747. * Add physics impostor to your webxr controllers,
  163748. * including naive calculation of their linear and angular velocity
  163749. */
  163750. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  163751. private readonly _options;
  163752. private _attachController;
  163753. private _controllers;
  163754. private _debugMode;
  163755. private _delta;
  163756. private _headsetImpostor?;
  163757. private _headsetMesh?;
  163758. private _lastTimestamp;
  163759. private _tmpQuaternion;
  163760. private _tmpVector;
  163761. /**
  163762. * The module's name
  163763. */
  163764. static readonly Name: string;
  163765. /**
  163766. * The (Babylon) version of this module.
  163767. * This is an integer representing the implementation version.
  163768. * This number does not correspond to the webxr specs version
  163769. */
  163770. static readonly Version: number;
  163771. /**
  163772. * Construct a new Controller Physics Feature
  163773. * @param _xrSessionManager the corresponding xr session manager
  163774. * @param _options options to create this feature with
  163775. */
  163776. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  163777. /**
  163778. * @hidden
  163779. * enable debugging - will show console outputs and the impostor mesh
  163780. */
  163781. _enablePhysicsDebug(): void;
  163782. /**
  163783. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  163784. * @param xrController the controller to add
  163785. */
  163786. addController(xrController: WebXRInputSource): void;
  163787. /**
  163788. * attach this feature
  163789. * Will usually be called by the features manager
  163790. *
  163791. * @returns true if successful.
  163792. */
  163793. attach(): boolean;
  163794. /**
  163795. * detach this feature.
  163796. * Will usually be called by the features manager
  163797. *
  163798. * @returns true if successful.
  163799. */
  163800. detach(): boolean;
  163801. /**
  163802. * Get the headset impostor, if enabled
  163803. * @returns the impostor
  163804. */
  163805. getHeadsetImpostor(): PhysicsImpostor | undefined;
  163806. /**
  163807. * Get the physics impostor of a specific controller.
  163808. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  163809. * @param controller the controller or the controller id of which to get the impostor
  163810. * @returns the impostor or null
  163811. */
  163812. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  163813. /**
  163814. * Update the physics properties provided in the constructor
  163815. * @param newProperties the new properties object
  163816. */
  163817. setPhysicsProperties(newProperties: {
  163818. impostorType?: number;
  163819. impostorSize?: number | {
  163820. width: number;
  163821. height: number;
  163822. depth: number;
  163823. };
  163824. friction?: number;
  163825. restitution?: number;
  163826. }): void;
  163827. protected _onXRFrame(_xrFrame: any): void;
  163828. private _detachController;
  163829. }
  163830. }
  163831. declare module BABYLON {
  163832. /**
  163833. * A babylon interface for a "WebXR" feature point.
  163834. * Represents the position and confidence value of a given feature point.
  163835. */
  163836. export interface IWebXRFeaturePoint {
  163837. /**
  163838. * Represents the position of the feature point in world space.
  163839. */
  163840. position: Vector3;
  163841. /**
  163842. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  163843. */
  163844. confidenceValue: number;
  163845. }
  163846. /**
  163847. * The feature point system is used to detect feature points from real world geometry.
  163848. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  163849. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  163850. */
  163851. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  163852. private _enabled;
  163853. private _featurePointCloud;
  163854. /**
  163855. * The module's name
  163856. */
  163857. static readonly Name: string;
  163858. /**
  163859. * The (Babylon) version of this module.
  163860. * This is an integer representing the implementation version.
  163861. * This number does not correspond to the WebXR specs version
  163862. */
  163863. static readonly Version: number;
  163864. /**
  163865. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  163866. * Will notify the observers about which feature points have been added.
  163867. */
  163868. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  163869. /**
  163870. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  163871. * Will notify the observers about which feature points have been updated.
  163872. */
  163873. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  163874. /**
  163875. * The current feature point cloud maintained across frames.
  163876. */
  163877. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  163878. /**
  163879. * construct the feature point system
  163880. * @param _xrSessionManager an instance of xr Session manager
  163881. */
  163882. constructor(_xrSessionManager: WebXRSessionManager);
  163883. /**
  163884. * Detach this feature.
  163885. * Will usually be called by the features manager
  163886. *
  163887. * @returns true if successful.
  163888. */
  163889. detach(): boolean;
  163890. /**
  163891. * Dispose this feature and all of the resources attached
  163892. */
  163893. dispose(): void;
  163894. /**
  163895. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  163896. */
  163897. protected _onXRFrame(frame: XRFrame): void;
  163898. /**
  163899. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  163900. */
  163901. private _init;
  163902. }
  163903. }
  163904. declare module BABYLON {
  163905. /**
  163906. * Configuration interface for the hand tracking feature
  163907. */
  163908. export interface IWebXRHandTrackingOptions {
  163909. /**
  163910. * The xrInput that will be used as source for new hands
  163911. */
  163912. xrInput: WebXRInput;
  163913. /**
  163914. * Configuration object for the joint meshes
  163915. */
  163916. jointMeshes?: {
  163917. /**
  163918. * Should the meshes created be invisible (defaults to false)
  163919. */
  163920. invisible?: boolean;
  163921. /**
  163922. * A source mesh to be used to create instances. Defaults to a sphere.
  163923. * This mesh will be the source for all other (25) meshes.
  163924. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  163925. */
  163926. sourceMesh?: Mesh;
  163927. /**
  163928. * This function will be called after a mesh was created for a specific joint.
  163929. * Using this function you can either manipulate the instance or return a new mesh.
  163930. * When returning a new mesh the instance created before will be disposed
  163931. */
  163932. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  163933. /**
  163934. * Should the source mesh stay visible. Defaults to false
  163935. */
  163936. keepOriginalVisible?: boolean;
  163937. /**
  163938. * Scale factor for all instances (defaults to 2)
  163939. */
  163940. scaleFactor?: number;
  163941. /**
  163942. * Should each instance have its own physics impostor
  163943. */
  163944. enablePhysics?: boolean;
  163945. /**
  163946. * If enabled, override default physics properties
  163947. */
  163948. physicsProps?: {
  163949. friction?: number;
  163950. restitution?: number;
  163951. impostorType?: number;
  163952. };
  163953. /**
  163954. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  163955. */
  163956. disableDefaultHandMesh?: boolean;
  163957. /**
  163958. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  163959. */
  163960. handMeshes?: {
  163961. right: AbstractMesh;
  163962. left: AbstractMesh;
  163963. };
  163964. /**
  163965. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  163966. */
  163967. rigMapping?: {
  163968. right: string[];
  163969. left: string[];
  163970. };
  163971. };
  163972. }
  163973. /**
  163974. * Parts of the hands divided to writs and finger names
  163975. */
  163976. export const enum HandPart {
  163977. /**
  163978. * HandPart - Wrist
  163979. */
  163980. WRIST = "wrist",
  163981. /**
  163982. * HandPart - The THumb
  163983. */
  163984. THUMB = "thumb",
  163985. /**
  163986. * HandPart - Index finger
  163987. */
  163988. INDEX = "index",
  163989. /**
  163990. * HandPart - Middle finger
  163991. */
  163992. MIDDLE = "middle",
  163993. /**
  163994. * HandPart - Ring finger
  163995. */
  163996. RING = "ring",
  163997. /**
  163998. * HandPart - Little finger
  163999. */
  164000. LITTLE = "little"
  164001. }
  164002. /**
  164003. * Representing a single hand (with its corresponding native XRHand object)
  164004. */
  164005. export class WebXRHand implements IDisposable {
  164006. /** the controller to which the hand correlates */
  164007. readonly xrController: WebXRInputSource;
  164008. /** the meshes to be used to track the hand joints */
  164009. readonly trackedMeshes: AbstractMesh[];
  164010. private _handMesh?;
  164011. private _rigMapping?;
  164012. private _scene;
  164013. private _defaultHandMesh;
  164014. private _transformNodeMapping;
  164015. /**
  164016. * Hand-parts definition (key is HandPart)
  164017. */
  164018. handPartsDefinition: {
  164019. [key: string]: number[];
  164020. };
  164021. /**
  164022. * Observers will be triggered when the mesh for this hand was initialized.
  164023. */
  164024. onHandMeshReadyObservable: Observable<WebXRHand>;
  164025. /**
  164026. * Populate the HandPartsDefinition object.
  164027. * This is called as a side effect since certain browsers don't have XRHand defined.
  164028. */
  164029. private generateHandPartsDefinition;
  164030. /**
  164031. * Construct a new hand object
  164032. * @param xrController the controller to which the hand correlates
  164033. * @param trackedMeshes the meshes to be used to track the hand joints
  164034. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  164035. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  164036. * @param disableDefaultHandMesh should the default mesh creation be disabled
  164037. */
  164038. constructor(
  164039. /** the controller to which the hand correlates */
  164040. xrController: WebXRInputSource,
  164041. /** the meshes to be used to track the hand joints */
  164042. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  164043. /**
  164044. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  164045. */
  164046. get handMesh(): AbstractMesh | undefined;
  164047. /**
  164048. * Update this hand from the latest xr frame
  164049. * @param xrFrame xrFrame to update from
  164050. * @param referenceSpace The current viewer reference space
  164051. * @param scaleFactor optional scale factor for the meshes
  164052. */
  164053. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  164054. /**
  164055. * Get meshes of part of the hand
  164056. * @param part the part of hand to get
  164057. * @returns An array of meshes that correlate to the hand part requested
  164058. */
  164059. getHandPartMeshes(part: HandPart): AbstractMesh[];
  164060. /**
  164061. * Dispose this Hand object
  164062. */
  164063. dispose(): void;
  164064. private _generateDefaultHandMesh;
  164065. }
  164066. /**
  164067. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  164068. */
  164069. export class WebXRHandTracking extends WebXRAbstractFeature {
  164070. /**
  164071. * options to use when constructing this feature
  164072. */
  164073. readonly options: IWebXRHandTrackingOptions;
  164074. private static _idCounter;
  164075. /**
  164076. * The module's name
  164077. */
  164078. static readonly Name: string;
  164079. /**
  164080. * The (Babylon) version of this module.
  164081. * This is an integer representing the implementation version.
  164082. * This number does not correspond to the WebXR specs version
  164083. */
  164084. static readonly Version: number;
  164085. /**
  164086. * This observable will notify registered observers when a new hand object was added and initialized
  164087. */
  164088. onHandAddedObservable: Observable<WebXRHand>;
  164089. /**
  164090. * This observable will notify its observers right before the hand object is disposed
  164091. */
  164092. onHandRemovedObservable: Observable<WebXRHand>;
  164093. private _hands;
  164094. /**
  164095. * Creates a new instance of the hit test feature
  164096. * @param _xrSessionManager an instance of WebXRSessionManager
  164097. * @param options options to use when constructing this feature
  164098. */
  164099. constructor(_xrSessionManager: WebXRSessionManager,
  164100. /**
  164101. * options to use when constructing this feature
  164102. */
  164103. options: IWebXRHandTrackingOptions);
  164104. /**
  164105. * Check if the needed objects are defined.
  164106. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  164107. */
  164108. isCompatible(): boolean;
  164109. /**
  164110. * attach this feature
  164111. * Will usually be called by the features manager
  164112. *
  164113. * @returns true if successful.
  164114. */
  164115. attach(): boolean;
  164116. /**
  164117. * detach this feature.
  164118. * Will usually be called by the features manager
  164119. *
  164120. * @returns true if successful.
  164121. */
  164122. detach(): boolean;
  164123. /**
  164124. * Dispose this feature and all of the resources attached
  164125. */
  164126. dispose(): void;
  164127. /**
  164128. * Get the hand object according to the controller id
  164129. * @param controllerId the controller id to which we want to get the hand
  164130. * @returns null if not found or the WebXRHand object if found
  164131. */
  164132. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  164133. /**
  164134. * Get a hand object according to the requested handedness
  164135. * @param handedness the handedness to request
  164136. * @returns null if not found or the WebXRHand object if found
  164137. */
  164138. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  164139. protected _onXRFrame(_xrFrame: XRFrame): void;
  164140. private _attachHand;
  164141. private _detachHand;
  164142. }
  164143. }
  164144. declare module BABYLON {
  164145. /**
  164146. * Options used in the mesh detector module
  164147. */
  164148. export interface IWebXRMeshDetectorOptions {
  164149. /**
  164150. * The node to use to transform the local results to world coordinates
  164151. */
  164152. worldParentNode?: TransformNode;
  164153. /**
  164154. * If set to true a reference of the created meshes will be kept until the next session starts
  164155. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  164156. */
  164157. doNotRemoveMeshesOnSessionEnded?: boolean;
  164158. /**
  164159. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  164160. */
  164161. preferredDetectorOptions?: XRGeometryDetectorOptions;
  164162. /**
  164163. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  164164. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  164165. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  164166. */
  164167. convertCoordinateSystems?: boolean;
  164168. }
  164169. /**
  164170. * A babylon interface for a XR mesh's vertex data.
  164171. *
  164172. * Currently not supported by WebXR, available only with BabylonNative
  164173. */
  164174. export interface IWebXRVertexData {
  164175. /**
  164176. * A babylon-assigned ID for this mesh
  164177. */
  164178. id: number;
  164179. /**
  164180. * Data required for constructing a mesh in Babylon.js.
  164181. */
  164182. xrMesh: XRMesh;
  164183. /**
  164184. * The node to use to transform the local results to world coordinates.
  164185. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  164186. */
  164187. worldParentNode?: TransformNode;
  164188. /**
  164189. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  164190. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164191. */
  164192. positions?: Float32Array;
  164193. /**
  164194. * An array of indices in babylon space. right/left hand system is taken into account.
  164195. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164196. */
  164197. indices?: Uint32Array;
  164198. /**
  164199. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  164200. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  164201. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  164202. */
  164203. normals?: Float32Array;
  164204. /**
  164205. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  164206. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  164207. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164208. */
  164209. transformationMatrix?: Matrix;
  164210. }
  164211. /**
  164212. * The mesh detector is used to detect meshes in the real world when in AR
  164213. */
  164214. export class WebXRMeshDetector extends WebXRAbstractFeature {
  164215. private _options;
  164216. private _detectedMeshes;
  164217. /**
  164218. * The module's name
  164219. */
  164220. static readonly Name: string;
  164221. /**
  164222. * The (Babylon) version of this module.
  164223. * This is an integer representing the implementation version.
  164224. * This number does not correspond to the WebXR specs version
  164225. */
  164226. static readonly Version: number;
  164227. /**
  164228. * Observers registered here will be executed when a new mesh was added to the session
  164229. */
  164230. onMeshAddedObservable: Observable<IWebXRVertexData>;
  164231. /**
  164232. * Observers registered here will be executed when a mesh is no longer detected in the session
  164233. */
  164234. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  164235. /**
  164236. * Observers registered here will be executed when an existing mesh updates
  164237. */
  164238. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  164239. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  164240. detach(): boolean;
  164241. dispose(): void;
  164242. protected _onXRFrame(frame: XRFrame): void;
  164243. private _init;
  164244. private _updateVertexDataWithXRMesh;
  164245. }
  164246. }
  164247. declare module BABYLON {
  164248. /**
  164249. * The motion controller class for all microsoft mixed reality controllers
  164250. */
  164251. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  164252. protected readonly _mapping: {
  164253. defaultButton: {
  164254. valueNodeName: string;
  164255. unpressedNodeName: string;
  164256. pressedNodeName: string;
  164257. };
  164258. defaultAxis: {
  164259. valueNodeName: string;
  164260. minNodeName: string;
  164261. maxNodeName: string;
  164262. };
  164263. buttons: {
  164264. "xr-standard-trigger": {
  164265. rootNodeName: string;
  164266. componentProperty: string;
  164267. states: string[];
  164268. };
  164269. "xr-standard-squeeze": {
  164270. rootNodeName: string;
  164271. componentProperty: string;
  164272. states: string[];
  164273. };
  164274. "xr-standard-touchpad": {
  164275. rootNodeName: string;
  164276. labelAnchorNodeName: string;
  164277. touchPointNodeName: string;
  164278. };
  164279. "xr-standard-thumbstick": {
  164280. rootNodeName: string;
  164281. componentProperty: string;
  164282. states: string[];
  164283. };
  164284. };
  164285. axes: {
  164286. "xr-standard-touchpad": {
  164287. "x-axis": {
  164288. rootNodeName: string;
  164289. };
  164290. "y-axis": {
  164291. rootNodeName: string;
  164292. };
  164293. };
  164294. "xr-standard-thumbstick": {
  164295. "x-axis": {
  164296. rootNodeName: string;
  164297. };
  164298. "y-axis": {
  164299. rootNodeName: string;
  164300. };
  164301. };
  164302. };
  164303. };
  164304. /**
  164305. * The base url used to load the left and right controller models
  164306. */
  164307. static MODEL_BASE_URL: string;
  164308. /**
  164309. * The name of the left controller model file
  164310. */
  164311. static MODEL_LEFT_FILENAME: string;
  164312. /**
  164313. * The name of the right controller model file
  164314. */
  164315. static MODEL_RIGHT_FILENAME: string;
  164316. profileId: string;
  164317. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  164318. protected _getFilenameAndPath(): {
  164319. filename: string;
  164320. path: string;
  164321. };
  164322. protected _getModelLoadingConstraints(): boolean;
  164323. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  164324. protected _setRootMesh(meshes: AbstractMesh[]): void;
  164325. protected _updateModel(): void;
  164326. }
  164327. }
  164328. declare module BABYLON {
  164329. /**
  164330. * The motion controller class for oculus touch (quest, rift).
  164331. * This class supports legacy mapping as well the standard xr mapping
  164332. */
  164333. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  164334. private _forceLegacyControllers;
  164335. private _modelRootNode;
  164336. /**
  164337. * The base url used to load the left and right controller models
  164338. */
  164339. static MODEL_BASE_URL: string;
  164340. /**
  164341. * The name of the left controller model file
  164342. */
  164343. static MODEL_LEFT_FILENAME: string;
  164344. /**
  164345. * The name of the right controller model file
  164346. */
  164347. static MODEL_RIGHT_FILENAME: string;
  164348. /**
  164349. * Base Url for the Quest controller model.
  164350. */
  164351. static QUEST_MODEL_BASE_URL: string;
  164352. profileId: string;
  164353. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  164354. protected _getFilenameAndPath(): {
  164355. filename: string;
  164356. path: string;
  164357. };
  164358. protected _getModelLoadingConstraints(): boolean;
  164359. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  164360. protected _setRootMesh(meshes: AbstractMesh[]): void;
  164361. protected _updateModel(): void;
  164362. /**
  164363. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  164364. * between the touch and touch 2.
  164365. */
  164366. private _isQuest;
  164367. }
  164368. }
  164369. declare module BABYLON {
  164370. /**
  164371. * The motion controller class for the standard HTC-Vive controllers
  164372. */
  164373. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  164374. private _modelRootNode;
  164375. /**
  164376. * The base url used to load the left and right controller models
  164377. */
  164378. static MODEL_BASE_URL: string;
  164379. /**
  164380. * File name for the controller model.
  164381. */
  164382. static MODEL_FILENAME: string;
  164383. profileId: string;
  164384. /**
  164385. * Create a new Vive motion controller object
  164386. * @param scene the scene to use to create this controller
  164387. * @param gamepadObject the corresponding gamepad object
  164388. * @param handedness the handedness of the controller
  164389. */
  164390. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  164391. protected _getFilenameAndPath(): {
  164392. filename: string;
  164393. path: string;
  164394. };
  164395. protected _getModelLoadingConstraints(): boolean;
  164396. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  164397. protected _setRootMesh(meshes: AbstractMesh[]): void;
  164398. protected _updateModel(): void;
  164399. }
  164400. }
  164401. declare module BABYLON {
  164402. /**
  164403. * A cursor which tracks a point on a path
  164404. */
  164405. export class PathCursor {
  164406. private path;
  164407. /**
  164408. * Stores path cursor callbacks for when an onchange event is triggered
  164409. */
  164410. private _onchange;
  164411. /**
  164412. * The value of the path cursor
  164413. */
  164414. value: number;
  164415. /**
  164416. * The animation array of the path cursor
  164417. */
  164418. animations: Animation[];
  164419. /**
  164420. * Initializes the path cursor
  164421. * @param path The path to track
  164422. */
  164423. constructor(path: Path2);
  164424. /**
  164425. * Gets the cursor point on the path
  164426. * @returns A point on the path cursor at the cursor location
  164427. */
  164428. getPoint(): Vector3;
  164429. /**
  164430. * Moves the cursor ahead by the step amount
  164431. * @param step The amount to move the cursor forward
  164432. * @returns This path cursor
  164433. */
  164434. moveAhead(step?: number): PathCursor;
  164435. /**
  164436. * Moves the cursor behind by the step amount
  164437. * @param step The amount to move the cursor back
  164438. * @returns This path cursor
  164439. */
  164440. moveBack(step?: number): PathCursor;
  164441. /**
  164442. * Moves the cursor by the step amount
  164443. * If the step amount is greater than one, an exception is thrown
  164444. * @param step The amount to move the cursor
  164445. * @returns This path cursor
  164446. */
  164447. move(step: number): PathCursor;
  164448. /**
  164449. * Ensures that the value is limited between zero and one
  164450. * @returns This path cursor
  164451. */
  164452. private ensureLimits;
  164453. /**
  164454. * Runs onchange callbacks on change (used by the animation engine)
  164455. * @returns This path cursor
  164456. */
  164457. private raiseOnChange;
  164458. /**
  164459. * Executes a function on change
  164460. * @param f A path cursor onchange callback
  164461. * @returns This path cursor
  164462. */
  164463. onchange(f: (cursor: PathCursor) => void): PathCursor;
  164464. }
  164465. }
  164466. declare module BABYLON {
  164467. /** @hidden */
  164468. export var blurPixelShader: {
  164469. name: string;
  164470. shader: string;
  164471. };
  164472. }
  164473. declare module BABYLON {
  164474. /** @hidden */
  164475. export var pointCloudVertexDeclaration: {
  164476. name: string;
  164477. shader: string;
  164478. };
  164479. }
  164480. // Mixins
  164481. interface Window {
  164482. mozIndexedDB: IDBFactory;
  164483. webkitIndexedDB: IDBFactory;
  164484. msIndexedDB: IDBFactory;
  164485. webkitURL: typeof URL;
  164486. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  164487. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  164488. WebGLRenderingContext: WebGLRenderingContext;
  164489. MSGesture: MSGesture;
  164490. CANNON: any;
  164491. AudioContext: AudioContext;
  164492. webkitAudioContext: AudioContext;
  164493. PointerEvent: any;
  164494. Math: Math;
  164495. Uint8Array: Uint8ArrayConstructor;
  164496. Float32Array: Float32ArrayConstructor;
  164497. mozURL: typeof URL;
  164498. msURL: typeof URL;
  164499. VRFrameData: any; // WebVR, from specs 1.1
  164500. DracoDecoderModule: any;
  164501. setImmediate(handler: (...args: any[]) => void): number;
  164502. }
  164503. interface HTMLCanvasElement {
  164504. requestPointerLock(): void;
  164505. msRequestPointerLock?(): void;
  164506. mozRequestPointerLock?(): void;
  164507. webkitRequestPointerLock?(): void;
  164508. /** Track wether a record is in progress */
  164509. isRecording: boolean;
  164510. /** Capture Stream method defined by some browsers */
  164511. captureStream(fps?: number): MediaStream;
  164512. }
  164513. interface CanvasRenderingContext2D {
  164514. msImageSmoothingEnabled: boolean;
  164515. }
  164516. interface MouseEvent {
  164517. mozMovementX: number;
  164518. mozMovementY: number;
  164519. webkitMovementX: number;
  164520. webkitMovementY: number;
  164521. msMovementX: number;
  164522. msMovementY: number;
  164523. }
  164524. interface Navigator {
  164525. mozGetVRDevices: (any: any) => any;
  164526. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  164527. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  164528. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  164529. webkitGetGamepads(): Gamepad[];
  164530. msGetGamepads(): Gamepad[];
  164531. webkitGamepads(): Gamepad[];
  164532. }
  164533. interface HTMLVideoElement {
  164534. mozSrcObject: any;
  164535. }
  164536. interface Math {
  164537. fround(x: number): number;
  164538. imul(a: number, b: number): number;
  164539. log2(x: number): number;
  164540. }
  164541. interface WebGLRenderingContext {
  164542. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  164543. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  164544. vertexAttribDivisor(index: number, divisor: number): void;
  164545. createVertexArray(): any;
  164546. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  164547. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  164548. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  164549. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  164550. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  164551. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  164552. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  164553. // Queries
  164554. createQuery(): WebGLQuery;
  164555. deleteQuery(query: WebGLQuery): void;
  164556. beginQuery(target: number, query: WebGLQuery): void;
  164557. endQuery(target: number): void;
  164558. getQueryParameter(query: WebGLQuery, pname: number): any;
  164559. getQuery(target: number, pname: number): any;
  164560. MAX_SAMPLES: number;
  164561. RGBA8: number;
  164562. READ_FRAMEBUFFER: number;
  164563. DRAW_FRAMEBUFFER: number;
  164564. UNIFORM_BUFFER: number;
  164565. HALF_FLOAT_OES: number;
  164566. RGBA16F: number;
  164567. RGBA32F: number;
  164568. R32F: number;
  164569. RG32F: number;
  164570. RGB32F: number;
  164571. R16F: number;
  164572. RG16F: number;
  164573. RGB16F: number;
  164574. RED: number;
  164575. RG: number;
  164576. R8: number;
  164577. RG8: number;
  164578. UNSIGNED_INT_24_8: number;
  164579. DEPTH24_STENCIL8: number;
  164580. MIN: number;
  164581. MAX: number;
  164582. /* Multiple Render Targets */
  164583. drawBuffers(buffers: number[]): void;
  164584. readBuffer(src: number): void;
  164585. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  164586. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  164587. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  164588. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  164589. // Occlusion Query
  164590. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  164591. ANY_SAMPLES_PASSED: number;
  164592. QUERY_RESULT_AVAILABLE: number;
  164593. QUERY_RESULT: number;
  164594. }
  164595. interface WebGLProgram {
  164596. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  164597. }
  164598. interface EXT_disjoint_timer_query {
  164599. QUERY_COUNTER_BITS_EXT: number;
  164600. TIME_ELAPSED_EXT: number;
  164601. TIMESTAMP_EXT: number;
  164602. GPU_DISJOINT_EXT: number;
  164603. QUERY_RESULT_EXT: number;
  164604. QUERY_RESULT_AVAILABLE_EXT: number;
  164605. queryCounterEXT(query: WebGLQuery, target: number): void;
  164606. createQueryEXT(): WebGLQuery;
  164607. beginQueryEXT(target: number, query: WebGLQuery): void;
  164608. endQueryEXT(target: number): void;
  164609. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  164610. deleteQueryEXT(query: WebGLQuery): void;
  164611. }
  164612. interface WebGLUniformLocation {
  164613. _currentState: any;
  164614. }
  164615. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  164616. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  164617. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  164618. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  164619. interface WebGLRenderingContext {
  164620. readonly RASTERIZER_DISCARD: number;
  164621. readonly DEPTH_COMPONENT24: number;
  164622. readonly TEXTURE_3D: number;
  164623. readonly TEXTURE_2D_ARRAY: number;
  164624. readonly TEXTURE_COMPARE_FUNC: number;
  164625. readonly TEXTURE_COMPARE_MODE: number;
  164626. readonly COMPARE_REF_TO_TEXTURE: number;
  164627. readonly TEXTURE_WRAP_R: number;
  164628. readonly HALF_FLOAT: number;
  164629. readonly RGB8: number;
  164630. readonly RED_INTEGER: number;
  164631. readonly RG_INTEGER: number;
  164632. readonly RGB_INTEGER: number;
  164633. readonly RGBA_INTEGER: number;
  164634. readonly R8_SNORM: number;
  164635. readonly RG8_SNORM: number;
  164636. readonly RGB8_SNORM: number;
  164637. readonly RGBA8_SNORM: number;
  164638. readonly R8I: number;
  164639. readonly RG8I: number;
  164640. readonly RGB8I: number;
  164641. readonly RGBA8I: number;
  164642. readonly R8UI: number;
  164643. readonly RG8UI: number;
  164644. readonly RGB8UI: number;
  164645. readonly RGBA8UI: number;
  164646. readonly R16I: number;
  164647. readonly RG16I: number;
  164648. readonly RGB16I: number;
  164649. readonly RGBA16I: number;
  164650. readonly R16UI: number;
  164651. readonly RG16UI: number;
  164652. readonly RGB16UI: number;
  164653. readonly RGBA16UI: number;
  164654. readonly R32I: number;
  164655. readonly RG32I: number;
  164656. readonly RGB32I: number;
  164657. readonly RGBA32I: number;
  164658. readonly R32UI: number;
  164659. readonly RG32UI: number;
  164660. readonly RGB32UI: number;
  164661. readonly RGBA32UI: number;
  164662. readonly RGB10_A2UI: number;
  164663. readonly R11F_G11F_B10F: number;
  164664. readonly RGB9_E5: number;
  164665. readonly RGB10_A2: number;
  164666. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  164667. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  164668. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  164669. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  164670. readonly DEPTH_COMPONENT32F: number;
  164671. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  164672. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  164673. 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;
  164674. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  164675. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  164676. readonly TRANSFORM_FEEDBACK: number;
  164677. readonly INTERLEAVED_ATTRIBS: number;
  164678. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  164679. createTransformFeedback(): WebGLTransformFeedback;
  164680. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  164681. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  164682. beginTransformFeedback(primitiveMode: number): void;
  164683. endTransformFeedback(): void;
  164684. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  164685. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  164686. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  164687. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  164688. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  164689. }
  164690. interface ImageBitmap {
  164691. readonly width: number;
  164692. readonly height: number;
  164693. close(): void;
  164694. }
  164695. interface WebGLQuery extends WebGLObject {
  164696. }
  164697. declare var WebGLQuery: {
  164698. prototype: WebGLQuery;
  164699. new(): WebGLQuery;
  164700. };
  164701. interface WebGLSampler extends WebGLObject {
  164702. }
  164703. declare var WebGLSampler: {
  164704. prototype: WebGLSampler;
  164705. new(): WebGLSampler;
  164706. };
  164707. interface WebGLSync extends WebGLObject {
  164708. }
  164709. declare var WebGLSync: {
  164710. prototype: WebGLSync;
  164711. new(): WebGLSync;
  164712. };
  164713. interface WebGLTransformFeedback extends WebGLObject {
  164714. }
  164715. declare var WebGLTransformFeedback: {
  164716. prototype: WebGLTransformFeedback;
  164717. new(): WebGLTransformFeedback;
  164718. };
  164719. interface WebGLVertexArrayObject extends WebGLObject {
  164720. }
  164721. declare var WebGLVertexArrayObject: {
  164722. prototype: WebGLVertexArrayObject;
  164723. new(): WebGLVertexArrayObject;
  164724. };
  164725. interface Navigator {
  164726. readonly gpu: GPU | undefined;
  164727. }
  164728. interface GPUColorDict {
  164729. a: number;
  164730. b: number;
  164731. g: number;
  164732. r: number;
  164733. }
  164734. type GPUColor = [number, number, number, number] | GPUColorDict;
  164735. interface GPUOrigin2DDict {
  164736. x?: number;
  164737. y?: number;
  164738. }
  164739. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  164740. interface GPUOrigin3DDict {
  164741. x?: number;
  164742. y?: number;
  164743. z?: number;
  164744. }
  164745. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  164746. interface GPUExtent3DDict {
  164747. width: number;
  164748. height: number;
  164749. depth: number;
  164750. }
  164751. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  164752. type GPUBindingResource =
  164753. | GPUSampler
  164754. | GPUTextureView
  164755. | GPUBufferBinding;
  164756. type GPUExtensionName =
  164757. | "texture-compression-bc"
  164758. | "timestamp-query"
  164759. | "pipeline-statistics-query"
  164760. | "depth-clamping"
  164761. | "depth24unorm-stencil8"
  164762. | "depth32float-stencil8";
  164763. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  164764. type GPUBindingType =
  164765. | "uniform-buffer"
  164766. | "storage-buffer"
  164767. | "readonly-storage-buffer"
  164768. | "sampler"
  164769. | "comparison-sampler"
  164770. | "sampled-texture"
  164771. | "readonly-storage-texture"
  164772. | "writeonly-storage-texture";
  164773. type GPUBlendFactor =
  164774. | "zero"
  164775. | "one"
  164776. | "src-color"
  164777. | "one-minus-src-color"
  164778. | "src-alpha"
  164779. | "one-minus-src-alpha"
  164780. | "dst-color"
  164781. | "one-minus-dst-color"
  164782. | "dst-alpha"
  164783. | "one-minus-dst-alpha"
  164784. | "src-alpha-saturated"
  164785. | "blend-color"
  164786. | "one-minus-blend-color";
  164787. type GPUBlendOperation =
  164788. | "add"
  164789. | "subtract"
  164790. | "reverse-subtract"
  164791. | "min"
  164792. | "max";
  164793. type GPUCompareFunction =
  164794. | "never"
  164795. | "less"
  164796. | "equal"
  164797. | "less-equal"
  164798. | "greater"
  164799. | "not-equal"
  164800. | "greater-equal"
  164801. | "always";
  164802. type GPUCullMode = "none" | "front" | "back";
  164803. type GPUFilterMode = "nearest" | "linear";
  164804. type GPUFrontFace = "ccw" | "cw";
  164805. type GPUIndexFormat = "uint16" | "uint32";
  164806. type GPUInputStepMode = "vertex" | "instance";
  164807. type GPULoadOp = "load";
  164808. type GPUPrimitiveTopology =
  164809. | "point-list"
  164810. | "line-list"
  164811. | "line-strip"
  164812. | "triangle-list"
  164813. | "triangle-strip";
  164814. type GPUStencilOperation =
  164815. | "keep"
  164816. | "zero"
  164817. | "replace"
  164818. | "invert"
  164819. | "increment-clamp"
  164820. | "decrement-clamp"
  164821. | "increment-wrap"
  164822. | "decrement-wrap";
  164823. type GPUStoreOp = "store" | "clear";
  164824. type GPUTextureDimension = "1d" | "2d" | "3d";
  164825. type GPUTextureFormat =
  164826. | "r8unorm"
  164827. | "r8snorm"
  164828. | "r8uint"
  164829. | "r8sint"
  164830. | "r16uint"
  164831. | "r16sint"
  164832. | "r16float"
  164833. | "rg8unorm"
  164834. | "rg8snorm"
  164835. | "rg8uint"
  164836. | "rg8sint"
  164837. | "r32uint"
  164838. | "r32sint"
  164839. | "r32float"
  164840. | "rg16uint"
  164841. | "rg16sint"
  164842. | "rg16float"
  164843. | "rgba8unorm"
  164844. | "rgba8unorm-srgb"
  164845. | "rgba8snorm"
  164846. | "rgba8uint"
  164847. | "rgba8sint"
  164848. | "bgra8unorm"
  164849. | "bgra8unorm-srgb"
  164850. | "rgb9e5ufloat"
  164851. | "rgb10a2unorm"
  164852. | "rg11b10ufloat"
  164853. | "rg32uint"
  164854. | "rg32sint"
  164855. | "rg32float"
  164856. | "rgba16uint"
  164857. | "rgba16sint"
  164858. | "rgba16float"
  164859. | "rgba32uint"
  164860. | "rgba32sint"
  164861. | "rgba32float"
  164862. | "stencil8"
  164863. | "depth16unorm"
  164864. | "depth24plus"
  164865. | "depth24plus-stencil8"
  164866. | "depth32float"
  164867. | "bc1-rgba-unorm"
  164868. | "bc1-rgba-unorm-srgb"
  164869. | "bc2-rgba-unorm"
  164870. | "bc2-rgba-unorm-srgb"
  164871. | "bc3-rgba-unorm"
  164872. | "bc3-rgba-unorm-srgb"
  164873. | "bc4-r-unorm"
  164874. | "bc4-r-snorm"
  164875. | "bc5-rg-unorm"
  164876. | "bc5-rg-snorm"
  164877. | "bc6h-rgb-ufloat"
  164878. | "bc6h-rgb-float"
  164879. | "bc7-rgba-unorm"
  164880. | "bc7-rgba-unorm-srgb"
  164881. | "depth24unorm-stencil8"
  164882. | "depth32float-stencil8";
  164883. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  164884. type GPUTextureViewDimension =
  164885. | "1d"
  164886. | "2d"
  164887. | "2d-array"
  164888. | "cube"
  164889. | "cube-array"
  164890. | "3d";
  164891. type GPUVertexFormat =
  164892. | "uchar2"
  164893. | "uchar4"
  164894. | "char2"
  164895. | "char4"
  164896. | "uchar2norm"
  164897. | "uchar4norm"
  164898. | "char2norm"
  164899. | "char4norm"
  164900. | "ushort2"
  164901. | "ushort4"
  164902. | "short2"
  164903. | "short4"
  164904. | "ushort2norm"
  164905. | "ushort4norm"
  164906. | "short2norm"
  164907. | "short4norm"
  164908. | "half2"
  164909. | "half4"
  164910. | "float"
  164911. | "float2"
  164912. | "float3"
  164913. | "float4"
  164914. | "uint"
  164915. | "uint2"
  164916. | "uint3"
  164917. | "uint4"
  164918. | "int"
  164919. | "int2"
  164920. | "int3"
  164921. | "int4";
  164922. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  164923. type GPUBufferUsageFlags = number;
  164924. type GPUColorWriteFlags = number;
  164925. type GPUShaderStageFlags = number;
  164926. type GPUTextureUsageFlags = number;
  164927. type GPUMapModeFlags = number;
  164928. interface GPUBindGroupEntry {
  164929. binding: number;
  164930. resource: GPUBindingResource;
  164931. }
  164932. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  164933. layout: GPUBindGroupLayout;
  164934. entries: Iterable<GPUBindGroupEntry>;
  164935. }
  164936. interface GPUBindGroupLayoutEntry {
  164937. binding: number;
  164938. visibility: GPUShaderStageFlags;
  164939. type: GPUBindingType;
  164940. hasDynamicOffset?: boolean;
  164941. minBufferBindingSize?: number;
  164942. viewDimension?: GPUTextureViewDimension;
  164943. textureComponentType?: GPUTextureComponentType;
  164944. storageTextureFormat?: GPUTextureFormat;
  164945. }
  164946. interface GPUBindGroupLayoutDescriptor
  164947. extends GPUObjectDescriptorBase {
  164948. entries: Iterable<GPUBindGroupLayoutEntry>;
  164949. }
  164950. interface GPUBlendDescriptor {
  164951. dstFactor?: GPUBlendFactor;
  164952. operation?: GPUBlendOperation;
  164953. srcFactor?: GPUBlendFactor;
  164954. }
  164955. interface GPUColorStateDescriptor {
  164956. format: GPUTextureFormat;
  164957. alphaBlend?: GPUBlendDescriptor;
  164958. colorBlend?: GPUBlendDescriptor;
  164959. writeMask?: GPUColorWriteFlags;
  164960. }
  164961. interface GPUBufferBinding {
  164962. buffer: GPUBuffer;
  164963. offset?: number;
  164964. size?: number;
  164965. }
  164966. interface GPUTextureDataLayout {
  164967. offset?: number;
  164968. bytesPerRow: number;
  164969. rowsPerImage?: number;
  164970. }
  164971. interface GPUBufferCopyView extends GPUTextureDataLayout {
  164972. buffer: GPUBuffer;
  164973. }
  164974. interface GPUTextureCopyView {
  164975. texture: GPUTexture;
  164976. mipLevel?: number;
  164977. origin?: GPUOrigin3D;
  164978. }
  164979. interface GPUImageBitmapCopyView {
  164980. imageBitmap: ImageBitmap;
  164981. origin?: GPUOrigin2D;
  164982. }
  164983. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  164984. size: number;
  164985. usage: GPUBufferUsageFlags;
  164986. mappedAtCreation?: boolean;
  164987. }
  164988. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  164989. label?: string;
  164990. measureExecutionTime?: boolean;
  164991. }
  164992. interface GPUComputePipelineDescriptor
  164993. extends GPUPipelineDescriptorBase {
  164994. computeStage: GPUProgrammableStageDescriptor;
  164995. }
  164996. interface GPUDepthStencilStateDescriptor {
  164997. format: GPUTextureFormat;
  164998. depthWriteEnabled?: boolean;
  164999. depthCompare?: GPUCompareFunction;
  165000. stencilFront?: GPUStencilStateFaceDescriptor;
  165001. stencilBack?: GPUStencilStateFaceDescriptor;
  165002. stencilReadMask?: number;
  165003. stencilWriteMask?: number;
  165004. }
  165005. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  165006. extensions?: Iterable<GPUExtensionName>;
  165007. limits?: GPULimits;
  165008. }
  165009. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  165010. initialValue?: number;
  165011. label?: string;
  165012. signalQueue?: GPUQueue;
  165013. }
  165014. interface GPUVertexAttributeDescriptor {
  165015. format: GPUVertexFormat;
  165016. offset: number;
  165017. shaderLocation: number;
  165018. }
  165019. interface GPUVertexBufferLayoutDescriptor {
  165020. arrayStride: number;
  165021. stepMode?: GPUInputStepMode;
  165022. attributes: Iterable<GPUVertexAttributeDescriptor>;
  165023. }
  165024. interface GPUVertexStateDescriptor {
  165025. indexFormat?: GPUIndexFormat;
  165026. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  165027. }
  165028. interface GPULimits {
  165029. maxBindGroups?: number;
  165030. maxDynamicUniformBuffersPerPipelineLayout?: number;
  165031. maxDynamicStorageBuffersPerPipelineLayout?: number;
  165032. maxSampledTexturesPerShaderStage?: number;
  165033. maxSamplersPerShaderStage?: number;
  165034. maxStorageBuffersPerShaderStage?: number;
  165035. maxStorageTexturesPerShaderStage?: number;
  165036. maxUniformBuffersPerShaderStage?: number;
  165037. maxUniformBufferBindingSize?: number;
  165038. }
  165039. interface GPUPipelineDescriptorBase {
  165040. label?: string;
  165041. layout?: GPUPipelineLayout;
  165042. }
  165043. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  165044. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  165045. }
  165046. interface GPUProgrammableStageDescriptor {
  165047. module: GPUShaderModule;
  165048. entryPoint: string;
  165049. }
  165050. interface GPURasterizationStateDescriptor {
  165051. frontFace?: GPUFrontFace;
  165052. cullMode?: GPUCullMode;
  165053. clampDepth?: boolean;
  165054. depthBias?: number;
  165055. depthBiasSlopeScale?: number;
  165056. depthBiasClamp?: number;
  165057. }
  165058. interface GPURenderPassColorAttachmentDescriptor {
  165059. attachment: GPUTextureView;
  165060. resolveTarget?: GPUTextureView;
  165061. loadValue: GPULoadOp | GPUColor;
  165062. storeOp?: GPUStoreOp;
  165063. }
  165064. interface GPURenderPassDepthStencilAttachmentDescriptor {
  165065. attachment: GPUTextureView;
  165066. depthLoadValue: GPULoadOp | number;
  165067. depthStoreOp: GPUStoreOp;
  165068. depthReadOnly?: boolean;
  165069. stencilLoadValue: GPULoadOp | number;
  165070. stencilStoreOp: GPUStoreOp;
  165071. stencilReadOnly?: boolean;
  165072. }
  165073. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  165074. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  165075. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  165076. }
  165077. interface GPURenderPipelineDescriptor
  165078. extends GPUPipelineDescriptorBase {
  165079. vertexStage: GPUProgrammableStageDescriptor;
  165080. fragmentStage?: GPUProgrammableStageDescriptor;
  165081. primitiveTopology: GPUPrimitiveTopology;
  165082. rasterizationState?: GPURasterizationStateDescriptor;
  165083. colorStates: Iterable<GPUColorStateDescriptor>;
  165084. depthStencilState?: GPUDepthStencilStateDescriptor;
  165085. vertexState?: GPUVertexStateDescriptor;
  165086. sampleCount?: number;
  165087. sampleMask?: number;
  165088. alphaToCoverageEnabled?: boolean;
  165089. }
  165090. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  165091. addressModeU?: GPUAddressMode;
  165092. addressModeV?: GPUAddressMode;
  165093. addressModeW?: GPUAddressMode;
  165094. magFilter?: GPUFilterMode;
  165095. minFilter?: GPUFilterMode;
  165096. mipmapFilter?: GPUFilterMode;
  165097. lodMinClamp?: number;
  165098. lodMaxClamp?: number;
  165099. compare?: GPUCompareFunction;
  165100. maxAnisotropy?: number;
  165101. }
  165102. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  165103. code: Uint32Array | string;
  165104. label?: string;
  165105. sourceMap?: object;
  165106. }
  165107. interface GPUStencilStateFaceDescriptor {
  165108. compare?: GPUCompareFunction;
  165109. depthFailOp?: GPUStencilOperation;
  165110. passOp?: GPUStencilOperation;
  165111. failOp?: GPUStencilOperation;
  165112. }
  165113. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  165114. device: GPUDevice;
  165115. format: GPUTextureFormat;
  165116. usage?: GPUTextureUsageFlags;
  165117. }
  165118. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  165119. size: GPUExtent3D;
  165120. mipLevelCount?: number;
  165121. sampleCount?: number;
  165122. dimension?: GPUTextureDimension;
  165123. format: GPUTextureFormat;
  165124. usage: GPUTextureUsageFlags;
  165125. }
  165126. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  165127. format?: GPUTextureFormat;
  165128. dimension?: GPUTextureViewDimension;
  165129. aspect?: GPUTextureAspect;
  165130. baseArrayLayer?: number;
  165131. baseMipLevel?: number;
  165132. arrayLayerCount?: number;
  165133. mipLevelCount?: number;
  165134. }
  165135. declare class GPUAdapter {
  165136. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  165137. private __brand: void;
  165138. readonly name: string;
  165139. readonly extensions: GPUExtensionName[];
  165140. readonly limits: Required<GPULimits>;
  165141. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  165142. }
  165143. declare class GPUBindGroup implements GPUObjectBase {
  165144. private __brand: void;
  165145. label: string | undefined;
  165146. }
  165147. declare class GPUBindGroupLayout implements GPUObjectBase {
  165148. private __brand: void;
  165149. label: string | undefined;
  165150. }
  165151. declare class GPUBuffer implements GPUObjectBase {
  165152. private __brand: void;
  165153. label: string | undefined;
  165154. destroy(): void;
  165155. unmap(): void;
  165156. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  165157. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  165158. }
  165159. declare class GPUCommandBuffer implements GPUObjectBase {
  165160. private __brand: void;
  165161. label: string | undefined;
  165162. readonly executionTime: Promise<number>;
  165163. }
  165164. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  165165. declare class GPUCommandEncoder implements GPUObjectBase {
  165166. private __brand: void;
  165167. label: string | undefined;
  165168. beginComputePass(
  165169. descriptor?: GPUComputePassDescriptor
  165170. ): GPUComputePassEncoder;
  165171. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  165172. copyBufferToBuffer(
  165173. source: GPUBuffer,
  165174. sourceOffset: number,
  165175. destination: GPUBuffer,
  165176. destinationOffset: number,
  165177. size: number
  165178. ): void;
  165179. copyBufferToTexture(
  165180. source: GPUBufferCopyView,
  165181. destination: GPUTextureCopyView,
  165182. copySize: GPUExtent3D
  165183. ): void;
  165184. copyTextureToBuffer(
  165185. source: GPUTextureCopyView,
  165186. destination: GPUBufferCopyView,
  165187. copySize: GPUExtent3D
  165188. ): void;
  165189. copyTextureToTexture(
  165190. source: GPUTextureCopyView,
  165191. destination: GPUTextureCopyView,
  165192. copySize: GPUExtent3D
  165193. ): void;
  165194. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  165195. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165196. popDebugGroup(): void;
  165197. pushDebugGroup(groupLabel: string): void;
  165198. insertDebugMarker(markerLabel: string): void;
  165199. }
  165200. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  165201. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  165202. private __brand: void;
  165203. label: string | undefined;
  165204. setBindGroup(
  165205. index: number,
  165206. bindGroup: GPUBindGroup,
  165207. dynamicOffsets?: Iterable<number>
  165208. ): void;
  165209. popDebugGroup(): void;
  165210. pushDebugGroup(groupLabel: string): void;
  165211. insertDebugMarker(markerLabel: string): void;
  165212. setPipeline(pipeline: GPUComputePipeline): void;
  165213. dispatch(x: number, y?: number, z?: number): void;
  165214. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165215. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165216. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165217. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165218. endPass(): void;
  165219. }
  165220. declare class GPUComputePipeline implements GPUPipelineBase {
  165221. private __brand: void;
  165222. label: string | undefined;
  165223. getBindGroupLayout(index: number): GPUBindGroupLayout;
  165224. }
  165225. interface GPUObjectBase {
  165226. label: string | undefined;
  165227. }
  165228. interface GPUObjectDescriptorBase {
  165229. label?: string;
  165230. }
  165231. // SwapChain / CanvasContext
  165232. declare class GPUCanvasContext {
  165233. private __brand: void;
  165234. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  165235. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  165236. }
  165237. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  165238. private __brand: void;
  165239. label: string | undefined;
  165240. readonly adapter: GPUAdapter;
  165241. readonly extensions: GPUExtensionName[];
  165242. readonly limits: Required<GPULimits>;
  165243. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  165244. createBindGroupLayout(
  165245. descriptor: GPUBindGroupLayoutDescriptor
  165246. ): GPUBindGroupLayout;
  165247. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  165248. createPipelineLayout(
  165249. descriptor: GPUPipelineLayoutDescriptor
  165250. ): GPUPipelineLayout;
  165251. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  165252. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  165253. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  165254. createComputePipeline(
  165255. descriptor: GPUComputePipelineDescriptor
  165256. ): GPUComputePipeline;
  165257. createRenderPipeline(
  165258. descriptor: GPURenderPipelineDescriptor
  165259. ): GPURenderPipeline;
  165260. createReadyComputePipeline(
  165261. descriptor: GPUComputePipelineDescriptor
  165262. ): Promise<GPUComputePipeline>;
  165263. createReadyRenderPipeline(
  165264. descriptor: GPURenderPipelineDescriptor
  165265. ): Promise<GPURenderPipeline>;
  165266. createCommandEncoder(
  165267. descriptor?: GPUCommandEncoderDescriptor
  165268. ): GPUCommandEncoder;
  165269. createRenderBundleEncoder(
  165270. descriptor: GPURenderBundleEncoderDescriptor
  165271. ): GPURenderBundleEncoder;
  165272. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  165273. defaultQueue: GPUQueue;
  165274. pushErrorScope(filter: GPUErrorFilter): void;
  165275. popErrorScope(): Promise<GPUError | null>;
  165276. onuncapturederror: Event | undefined;
  165277. readonly lost: Promise<GPUDeviceLostInfo>;
  165278. }
  165279. declare class GPUFence implements GPUObjectBase {
  165280. private __brand: void;
  165281. label: string | undefined;
  165282. getCompletedValue(): number;
  165283. onCompletion(completionValue: number): Promise<void>;
  165284. }
  165285. interface GPUPipelineBase extends GPUObjectBase {
  165286. getBindGroupLayout(index: number): GPUBindGroupLayout;
  165287. }
  165288. declare class GPUPipelineLayout implements GPUObjectBase {
  165289. private __brand: void;
  165290. label: string | undefined;
  165291. }
  165292. interface GPUProgrammablePassEncoder {
  165293. setBindGroup(
  165294. index: number,
  165295. bindGroup: GPUBindGroup,
  165296. dynamicOffsets?: Iterable<number>
  165297. ): void;
  165298. popDebugGroup(): void;
  165299. pushDebugGroup(groupLabel: string): void;
  165300. insertDebugMarker(markerLabel: string): void;
  165301. }
  165302. declare class GPUQueue implements GPUObjectBase {
  165303. private __brand: void;
  165304. label: string | undefined;
  165305. signal(fence: GPUFence, signalValue: number): void;
  165306. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  165307. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  165308. writeBuffer(buffer: GPUBuffer,
  165309. bufferOffset: number,
  165310. data: BufferSource | ArrayBuffer,
  165311. dataOffset?: number,
  165312. size?: number): void;
  165313. writeTexture(destination: GPUTextureCopyView,
  165314. data: BufferSource | ArrayBuffer,
  165315. dataLayout: GPUTextureDataLayout,
  165316. size: GPUExtent3D): void;
  165317. copyImageBitmapToTexture(
  165318. source: GPUImageBitmapCopyView,
  165319. destination: GPUTextureCopyView,
  165320. copySize: GPUExtent3D
  165321. ): void;
  165322. }
  165323. type GPUQueryType =
  165324. | "occlusion"
  165325. | "timestamp"
  165326. | "pipeline-statistics";
  165327. type GPUPipelineStatisticName =
  165328. | "vertex-shader-invocations"
  165329. | "clipper-invocations"
  165330. | "clipper-primitives-out"
  165331. | "fragment-shader-invocations"
  165332. | "compute-shader-invocations";
  165333. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  165334. type: GPUQueryType;
  165335. count: number;
  165336. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  165337. }
  165338. declare class GPUQuerySet implements GPUObjectBase {
  165339. private __brand: void;
  165340. label: string | undefined;
  165341. destroy(): void;
  165342. }
  165343. interface GPURenderEncoderBase {
  165344. setPipeline(pipeline: GPURenderPipeline): void;
  165345. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  165346. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  165347. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  165348. draw(
  165349. vertexCount: number,
  165350. instanceCount?: number,
  165351. firstVertex?: number,
  165352. firstInstance?: number
  165353. ): void;
  165354. drawIndexed(
  165355. indexCount: number,
  165356. instanceCount?: number,
  165357. firstIndex?: number,
  165358. baseVertex?: number,
  165359. firstInstance?: number
  165360. ): void;
  165361. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165362. drawIndexedIndirect(
  165363. indirectBuffer: GPUBuffer,
  165364. indirectOffset: number
  165365. ): void;
  165366. }
  165367. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  165368. private __brand: void;
  165369. label: string | undefined;
  165370. setBindGroup(
  165371. index: number,
  165372. bindGroup: GPUBindGroup,
  165373. dynamicOffsets?: Iterable<number>
  165374. ): void;
  165375. popDebugGroup(): void;
  165376. pushDebugGroup(groupLabel: string): void;
  165377. insertDebugMarker(markerLabel: string): void;
  165378. setPipeline(pipeline: GPURenderPipeline): void;
  165379. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  165380. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  165381. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  165382. draw(
  165383. vertexCount: number,
  165384. instanceCount?: number,
  165385. firstVertex?: number,
  165386. firstInstance?: number
  165387. ): void;
  165388. drawIndexed(
  165389. indexCount: number,
  165390. instanceCount?: number,
  165391. firstIndex?: number,
  165392. baseVertex?: number,
  165393. firstInstance?: number
  165394. ): void;
  165395. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165396. drawIndexedIndirect(
  165397. indirectBuffer: GPUBuffer,
  165398. indirectOffset: number
  165399. ): void;
  165400. setViewport(
  165401. x: number,
  165402. y: number,
  165403. width: number,
  165404. height: number,
  165405. minDepth: number,
  165406. maxDepth: number
  165407. ): void;
  165408. setScissorRect(x: number, y: number, width: number, height: number): void;
  165409. setBlendColor(color: GPUColor): void;
  165410. setStencilReference(reference: number): void;
  165411. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165412. beginOcclusionQuery(queryIndex: number): void;
  165413. endOcclusionQuery(): void;
  165414. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165415. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165416. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  165417. endPass(): void;
  165418. }
  165419. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  165420. declare class GPURenderBundle implements GPUObjectBase {
  165421. private __brand: void;
  165422. label: string | undefined;
  165423. }
  165424. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  165425. private __brand: void;
  165426. label: string | undefined;
  165427. setBindGroup(
  165428. index: number,
  165429. bindGroup: GPUBindGroup,
  165430. dynamicOffsets?: Iterable<number>
  165431. ): void;
  165432. popDebugGroup(): void;
  165433. pushDebugGroup(groupLabel: string): void;
  165434. insertDebugMarker(markerLabel: string): void;
  165435. setPipeline(pipeline: GPURenderPipeline): void;
  165436. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  165437. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  165438. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  165439. draw(
  165440. vertexCount: number,
  165441. instanceCount?: number,
  165442. firstVertex?: number,
  165443. firstInstance?: number
  165444. ): void;
  165445. drawIndexed(
  165446. indexCount: number,
  165447. instanceCount?: number,
  165448. firstIndex?: number,
  165449. baseVertex?: number,
  165450. firstInstance?: number
  165451. ): void;
  165452. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165453. drawIndexedIndirect(
  165454. indirectBuffer: GPUBuffer,
  165455. indirectOffset: number
  165456. ): void;
  165457. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  165458. }
  165459. interface GPURenderBundleEncoderDescriptor
  165460. extends GPUObjectDescriptorBase {
  165461. colorFormats: Iterable<GPUTextureFormat>;
  165462. depthStencilFormat?: GPUTextureFormat;
  165463. sampleCount?: number;
  165464. }
  165465. declare class GPURenderPipeline implements GPUPipelineBase {
  165466. private __brand: void;
  165467. label: string | undefined;
  165468. getBindGroupLayout(index: number): GPUBindGroupLayout;
  165469. }
  165470. declare class GPUSampler implements GPUObjectBase {
  165471. private __brand: void;
  165472. label: string | undefined;
  165473. }
  165474. type GPUCompilationMessageType =
  165475. | "error"
  165476. | "warning"
  165477. | "info";
  165478. interface GPUCompilationMessage {
  165479. readonly message: string;
  165480. readonly type: GPUCompilationMessageType;
  165481. readonly lineNum: number;
  165482. readonly linePos: number;
  165483. }
  165484. interface GPUCompilationInfo {
  165485. readonly messages: readonly GPUCompilationMessage[];
  165486. }
  165487. declare class GPUShaderModule implements GPUObjectBase {
  165488. private __brand: void;
  165489. label: string | undefined;
  165490. compilationInfo(): Promise<GPUCompilationInfo>;
  165491. }
  165492. declare class GPUSwapChain implements GPUObjectBase {
  165493. private __brand: void;
  165494. label: string | undefined;
  165495. getCurrentTexture(): GPUTexture;
  165496. }
  165497. declare class GPUTexture implements GPUObjectBase {
  165498. private __brand: void;
  165499. label: string | undefined;
  165500. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  165501. destroy(): void;
  165502. }
  165503. declare class GPUTextureView implements GPUObjectBase {
  165504. private __brand: void;
  165505. label: string | undefined;
  165506. }
  165507. type GPUPowerPreference = "low-power" | "high-performance";
  165508. interface GPURequestAdapterOptions {
  165509. powerPreference?: GPUPowerPreference;
  165510. }
  165511. declare class GPU {
  165512. private __brand: void;
  165513. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  165514. }
  165515. // ****************************************************************************
  165516. // ERROR SCOPES
  165517. // ****************************************************************************
  165518. type GPUErrorFilter = "out-of-memory" | "validation";
  165519. declare class GPUOutOfMemoryError {
  165520. private __brand: void;
  165521. constructor();
  165522. }
  165523. declare class GPUValidationError {
  165524. private __brand: void;
  165525. constructor(message: string);
  165526. readonly message: string;
  165527. }
  165528. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  165529. // ****************************************************************************
  165530. // TELEMETRY
  165531. // ****************************************************************************
  165532. declare class GPUUncapturedErrorEvent extends Event {
  165533. private __brand: void;
  165534. constructor(
  165535. type: string,
  165536. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  165537. );
  165538. readonly error: GPUError;
  165539. }
  165540. interface GPUUncapturedErrorEventInit extends EventInit {
  165541. error: GPUError;
  165542. }
  165543. declare class GPUDeviceLostInfo {
  165544. private __brand: void;
  165545. readonly message: string;
  165546. }
  165547. // Type definitions for WebVR API
  165548. // Project: https://w3c.github.io/webvr/
  165549. // Definitions by: six a <https://github.com/lostfictions>
  165550. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  165551. interface VRDisplay extends EventTarget {
  165552. /**
  165553. * Dictionary of capabilities describing the VRDisplay.
  165554. */
  165555. readonly capabilities: VRDisplayCapabilities;
  165556. /**
  165557. * z-depth defining the far plane of the eye view frustum
  165558. * enables mapping of values in the render target depth
  165559. * attachment to scene coordinates. Initially set to 10000.0.
  165560. */
  165561. depthFar: number;
  165562. /**
  165563. * z-depth defining the near plane of the eye view frustum
  165564. * enables mapping of values in the render target depth
  165565. * attachment to scene coordinates. Initially set to 0.01.
  165566. */
  165567. depthNear: number;
  165568. /**
  165569. * An identifier for this distinct VRDisplay. Used as an
  165570. * association point in the Gamepad API.
  165571. */
  165572. readonly displayId: number;
  165573. /**
  165574. * A display name, a user-readable name identifying it.
  165575. */
  165576. readonly displayName: string;
  165577. readonly isConnected: boolean;
  165578. readonly isPresenting: boolean;
  165579. /**
  165580. * If this VRDisplay supports room-scale experiences, the optional
  165581. * stage attribute contains details on the room-scale parameters.
  165582. */
  165583. readonly stageParameters: VRStageParameters | null;
  165584. /**
  165585. * Passing the value returned by `requestAnimationFrame` to
  165586. * `cancelAnimationFrame` will unregister the callback.
  165587. * @param handle Define the hanle of the request to cancel
  165588. */
  165589. cancelAnimationFrame(handle: number): void;
  165590. /**
  165591. * Stops presenting to the VRDisplay.
  165592. * @returns a promise to know when it stopped
  165593. */
  165594. exitPresent(): Promise<void>;
  165595. /**
  165596. * Return the current VREyeParameters for the given eye.
  165597. * @param whichEye Define the eye we want the parameter for
  165598. * @returns the eye parameters
  165599. */
  165600. getEyeParameters(whichEye: string): VREyeParameters;
  165601. /**
  165602. * Populates the passed VRFrameData with the information required to render
  165603. * the current frame.
  165604. * @param frameData Define the data structure to populate
  165605. * @returns true if ok otherwise false
  165606. */
  165607. getFrameData(frameData: VRFrameData): boolean;
  165608. /**
  165609. * Get the layers currently being presented.
  165610. * @returns the list of VR layers
  165611. */
  165612. getLayers(): VRLayer[];
  165613. /**
  165614. * Return a VRPose containing the future predicted pose of the VRDisplay
  165615. * when the current frame will be presented. The value returned will not
  165616. * change until JavaScript has returned control to the browser.
  165617. *
  165618. * The VRPose will contain the position, orientation, velocity,
  165619. * and acceleration of each of these properties.
  165620. * @returns the pose object
  165621. */
  165622. getPose(): VRPose;
  165623. /**
  165624. * Return the current instantaneous pose of the VRDisplay, with no
  165625. * prediction applied.
  165626. * @returns the current instantaneous pose
  165627. */
  165628. getImmediatePose(): VRPose;
  165629. /**
  165630. * The callback passed to `requestAnimationFrame` will be called
  165631. * any time a new frame should be rendered. When the VRDisplay is
  165632. * presenting the callback will be called at the native refresh
  165633. * rate of the HMD. When not presenting this function acts
  165634. * identically to how window.requestAnimationFrame acts. Content should
  165635. * make no assumptions of frame rate or vsync behavior as the HMD runs
  165636. * asynchronously from other displays and at differing refresh rates.
  165637. * @param callback Define the eaction to run next frame
  165638. * @returns the request handle it
  165639. */
  165640. requestAnimationFrame(callback: FrameRequestCallback): number;
  165641. /**
  165642. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  165643. * Repeat calls while already presenting will update the VRLayers being displayed.
  165644. * @param layers Define the list of layer to present
  165645. * @returns a promise to know when the request has been fulfilled
  165646. */
  165647. requestPresent(layers: VRLayer[]): Promise<void>;
  165648. /**
  165649. * Reset the pose for this display, treating its current position and
  165650. * orientation as the "origin/zero" values. VRPose.position,
  165651. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  165652. * updated when calling resetPose(). This should be called in only
  165653. * sitting-space experiences.
  165654. */
  165655. resetPose(): void;
  165656. /**
  165657. * The VRLayer provided to the VRDisplay will be captured and presented
  165658. * in the HMD. Calling this function has the same effect on the source
  165659. * canvas as any other operation that uses its source image, and canvases
  165660. * created without preserveDrawingBuffer set to true will be cleared.
  165661. * @param pose Define the pose to submit
  165662. */
  165663. submitFrame(pose?: VRPose): void;
  165664. }
  165665. declare var VRDisplay: {
  165666. prototype: VRDisplay;
  165667. new(): VRDisplay;
  165668. };
  165669. interface VRLayer {
  165670. leftBounds?: number[] | Float32Array | null;
  165671. rightBounds?: number[] | Float32Array | null;
  165672. source?: HTMLCanvasElement | null;
  165673. }
  165674. interface VRDisplayCapabilities {
  165675. readonly canPresent: boolean;
  165676. readonly hasExternalDisplay: boolean;
  165677. readonly hasOrientation: boolean;
  165678. readonly hasPosition: boolean;
  165679. readonly maxLayers: number;
  165680. }
  165681. interface VREyeParameters {
  165682. /** @deprecated */
  165683. readonly fieldOfView: VRFieldOfView;
  165684. readonly offset: Float32Array;
  165685. readonly renderHeight: number;
  165686. readonly renderWidth: number;
  165687. }
  165688. interface VRFieldOfView {
  165689. readonly downDegrees: number;
  165690. readonly leftDegrees: number;
  165691. readonly rightDegrees: number;
  165692. readonly upDegrees: number;
  165693. }
  165694. interface VRFrameData {
  165695. readonly leftProjectionMatrix: Float32Array;
  165696. readonly leftViewMatrix: Float32Array;
  165697. readonly pose: VRPose;
  165698. readonly rightProjectionMatrix: Float32Array;
  165699. readonly rightViewMatrix: Float32Array;
  165700. readonly timestamp: number;
  165701. }
  165702. interface VRPose {
  165703. readonly angularAcceleration: Float32Array | null;
  165704. readonly angularVelocity: Float32Array | null;
  165705. readonly linearAcceleration: Float32Array | null;
  165706. readonly linearVelocity: Float32Array | null;
  165707. readonly orientation: Float32Array | null;
  165708. readonly position: Float32Array | null;
  165709. readonly timestamp: number;
  165710. }
  165711. interface VRStageParameters {
  165712. sittingToStandingTransform?: Float32Array;
  165713. sizeX?: number;
  165714. sizeY?: number;
  165715. }
  165716. interface Navigator {
  165717. getVRDisplays(): Promise<VRDisplay[]>;
  165718. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  165719. }
  165720. interface Window {
  165721. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  165722. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  165723. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  165724. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  165725. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  165726. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  165727. }
  165728. interface Gamepad {
  165729. readonly displayId: number;
  165730. }
  165731. /**
  165732. * Available session modes
  165733. */
  165734. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  165735. /**
  165736. * Reference space types
  165737. */
  165738. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  165739. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  165740. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  165741. /**
  165742. * Handedness types
  165743. */
  165744. type XRHandedness = "none" | "left" | "right";
  165745. /**
  165746. * InputSource target ray modes
  165747. */
  165748. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  165749. /**
  165750. * Eye types
  165751. */
  165752. type XREye = "none" | "left" | "right";
  165753. /**
  165754. * Type of XR events available
  165755. */
  165756. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  165757. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  165758. type XRPlaneSet = Set<XRPlane>;
  165759. type XRAnchorSet = Set<XRAnchor>;
  165760. type XREventHandler = (callback: any) => void;
  165761. interface XRLayer extends EventTarget {}
  165762. interface XRSessionInit {
  165763. optionalFeatures?: string[];
  165764. requiredFeatures?: string[];
  165765. }
  165766. interface XRSessionEvent extends Event {
  165767. readonly session: XRSession;
  165768. }
  165769. interface XRSystem {
  165770. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  165771. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  165772. }
  165773. interface XRViewport {
  165774. readonly x: number;
  165775. readonly y: number;
  165776. readonly width: number;
  165777. readonly height: number;
  165778. }
  165779. interface XRWebGLLayerInit {
  165780. antialias?: boolean;
  165781. depth?: boolean;
  165782. stencil?: boolean;
  165783. alpha?: boolean;
  165784. multiview?: boolean;
  165785. framebufferScaleFactor?: number;
  165786. }
  165787. declare class XRWebGLLayer {
  165788. static getNativeFramebufferScaleFactor(session: XRSession): number;
  165789. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  165790. readonly antialias: boolean;
  165791. readonly framebuffer: WebGLFramebuffer;
  165792. readonly framebufferWidth: number;
  165793. readonly framebufferHeight: number;
  165794. readonly ignoreDepthValues: boolean;
  165795. getViewport: (view: XRView) => XRViewport;
  165796. }
  165797. // tslint:disable-next-line no-empty-interface
  165798. interface XRSpace extends EventTarget {}
  165799. interface XRRenderState {
  165800. readonly baseLayer?: XRWebGLLayer;
  165801. readonly depthFar: number;
  165802. readonly depthNear: number;
  165803. readonly inlineVerticalFieldOfView?: number;
  165804. }
  165805. interface XRRenderStateInit extends XRRenderState {
  165806. baseLayer: XRWebGLLayer;
  165807. depthFar: number;
  165808. depthNear: number;
  165809. inlineVerticalFieldOfView?: number;
  165810. layers?: XRLayer[];
  165811. }
  165812. interface XRReferenceSpace extends XRSpace {
  165813. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  165814. onreset: XREventHandler;
  165815. }
  165816. interface XRBoundedReferenceSpace extends XRSpace {
  165817. readonly boundsGeometry: DOMPointReadOnly[];
  165818. }
  165819. interface XRInputSource {
  165820. readonly handedness: XRHandedness;
  165821. readonly targetRayMode: XRTargetRayMode;
  165822. readonly targetRaySpace: XRSpace;
  165823. readonly gripSpace?: XRSpace;
  165824. readonly gamepad?: Gamepad;
  165825. readonly profiles: Array<string>;
  165826. readonly hand?: XRHand;
  165827. }
  165828. interface XRPose {
  165829. readonly transform: XRRigidTransform;
  165830. readonly emulatedPosition: boolean;
  165831. }
  165832. interface XRWorldInformation {
  165833. detectedPlanes?: XRPlaneSet;
  165834. }
  165835. interface XRFrame {
  165836. readonly session: XRSession;
  165837. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  165838. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  165839. // AR
  165840. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  165841. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  165842. // Anchors
  165843. trackedAnchors?: XRAnchorSet;
  165844. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  165845. // World geometries
  165846. worldInformation?: XRWorldInformation;
  165847. // Hand tracking
  165848. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  165849. }
  165850. interface XRInputSourceEvent extends Event {
  165851. readonly frame: XRFrame;
  165852. readonly inputSource: XRInputSource;
  165853. }
  165854. type XRInputSourceArray = XRInputSource[];
  165855. interface XRSession {
  165856. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  165857. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  165858. /**
  165859. * Returns a list of this session's XRInputSources, each representing an input device
  165860. * used to control the camera and/or scene.
  165861. */
  165862. readonly inputSources: Array<XRInputSource>;
  165863. /**
  165864. * object which contains options affecting how the imagery is rendered.
  165865. * This includes things such as the near and far clipping planes
  165866. */
  165867. readonly renderState: XRRenderState;
  165868. readonly visibilityState: XRVisibilityState;
  165869. /**
  165870. * Removes a callback from the animation frame painting callback from
  165871. * XRSession's set of animation frame rendering callbacks, given the
  165872. * identifying handle returned by a previous call to requestAnimationFrame().
  165873. */
  165874. cancelAnimationFrame: (handle: number) => void;
  165875. /**
  165876. * Ends the WebXR session. Returns a promise which resolves when the
  165877. * session has been shut down.
  165878. */
  165879. end(): Promise<void>;
  165880. /**
  165881. * Schedules the specified method to be called the next time the user agent
  165882. * is working on rendering an animation frame for the WebXR device. Returns an
  165883. * integer value which can be used to identify the request for the purposes of
  165884. * canceling the callback using cancelAnimationFrame(). This method is comparable
  165885. * to the Window.requestAnimationFrame() method.
  165886. */
  165887. requestAnimationFrame: XRFrameRequestCallback;
  165888. /**
  165889. * Requests that a new XRReferenceSpace of the specified type be created.
  165890. * Returns a promise which resolves with the XRReferenceSpace or
  165891. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  165892. * the requested space type isn't supported by the device.
  165893. */
  165894. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  165895. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  165896. onend: XREventHandler;
  165897. oninputsourceschange: XREventHandler;
  165898. onselect: XREventHandler;
  165899. onselectstart: XREventHandler;
  165900. onselectend: XREventHandler;
  165901. onsqueeze: XREventHandler;
  165902. onsqueezestart: XREventHandler;
  165903. onsqueezeend: XREventHandler;
  165904. onvisibilitychange: XREventHandler;
  165905. // hit test
  165906. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  165907. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  165908. // legacy AR hit test
  165909. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  165910. // legacy plane detection
  165911. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  165912. }
  165913. interface XRViewerPose extends XRPose {
  165914. readonly views: Array<XRView>;
  165915. }
  165916. declare class XRRigidTransform {
  165917. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  165918. position: DOMPointReadOnly;
  165919. orientation: DOMPointReadOnly;
  165920. matrix: Float32Array;
  165921. inverse: XRRigidTransform;
  165922. }
  165923. interface XRView {
  165924. readonly eye: XREye;
  165925. readonly projectionMatrix: Float32Array;
  165926. readonly transform: XRRigidTransform;
  165927. readonly recommendedViewportScale?: number;
  165928. requestViewportScale(scale: number): void;
  165929. }
  165930. interface XRInputSourceChangeEvent extends Event {
  165931. session: XRSession;
  165932. removed: Array<XRInputSource>;
  165933. added: Array<XRInputSource>;
  165934. }
  165935. // Experimental/Draft features
  165936. declare class XRRay {
  165937. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  165938. origin: DOMPointReadOnly;
  165939. direction: DOMPointReadOnly;
  165940. matrix: Float32Array;
  165941. }
  165942. declare enum XRHitTestTrackableType {
  165943. "point",
  165944. "plane",
  165945. "mesh",
  165946. }
  165947. interface XRHitResult {
  165948. hitMatrix: Float32Array;
  165949. }
  165950. interface XRTransientInputHitTestResult {
  165951. readonly inputSource: XRInputSource;
  165952. readonly results: Array<XRHitTestResult>;
  165953. }
  165954. interface XRHitTestResult {
  165955. getPose(baseSpace: XRSpace): XRPose | undefined;
  165956. // When anchor system is enabled
  165957. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  165958. }
  165959. interface XRHitTestSource {
  165960. cancel(): void;
  165961. }
  165962. interface XRTransientInputHitTestSource {
  165963. cancel(): void;
  165964. }
  165965. interface XRHitTestOptionsInit {
  165966. space: XRSpace;
  165967. entityTypes?: Array<XRHitTestTrackableType>;
  165968. offsetRay?: XRRay;
  165969. }
  165970. interface XRTransientInputHitTestOptionsInit {
  165971. profile: string;
  165972. entityTypes?: Array<XRHitTestTrackableType>;
  165973. offsetRay?: XRRay;
  165974. }
  165975. interface XRAnchor {
  165976. anchorSpace: XRSpace;
  165977. delete(): void;
  165978. }
  165979. interface XRPlane {
  165980. orientation: "Horizontal" | "Vertical";
  165981. planeSpace: XRSpace;
  165982. polygon: Array<DOMPointReadOnly>;
  165983. lastChangedTime: number;
  165984. }
  165985. interface XRJointSpace extends XRSpace {}
  165986. interface XRJointPose extends XRPose {
  165987. radius: number | undefined;
  165988. }
  165989. interface XRHand extends Iterable<XRJointSpace> {
  165990. readonly length: number;
  165991. [index: number]: XRJointSpace;
  165992. readonly WRIST: number;
  165993. readonly THUMB_METACARPAL: number;
  165994. readonly THUMB_PHALANX_PROXIMAL: number;
  165995. readonly THUMB_PHALANX_DISTAL: number;
  165996. readonly THUMB_PHALANX_TIP: number;
  165997. readonly INDEX_METACARPAL: number;
  165998. readonly INDEX_PHALANX_PROXIMAL: number;
  165999. readonly INDEX_PHALANX_INTERMEDIATE: number;
  166000. readonly INDEX_PHALANX_DISTAL: number;
  166001. readonly INDEX_PHALANX_TIP: number;
  166002. readonly MIDDLE_METACARPAL: number;
  166003. readonly MIDDLE_PHALANX_PROXIMAL: number;
  166004. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  166005. readonly MIDDLE_PHALANX_DISTAL: number;
  166006. readonly MIDDLE_PHALANX_TIP: number;
  166007. readonly RING_METACARPAL: number;
  166008. readonly RING_PHALANX_PROXIMAL: number;
  166009. readonly RING_PHALANX_INTERMEDIATE: number;
  166010. readonly RING_PHALANX_DISTAL: number;
  166011. readonly RING_PHALANX_TIP: number;
  166012. readonly LITTLE_METACARPAL: number;
  166013. readonly LITTLE_PHALANX_PROXIMAL: number;
  166014. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  166015. readonly LITTLE_PHALANX_DISTAL: number;
  166016. readonly LITTLE_PHALANX_TIP: number;
  166017. }
  166018. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  166019. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  166020. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  166021. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  166022. interface XRSceneObject {
  166023. type: XRSceneObjectType;
  166024. }
  166025. interface XRFieldOfView {
  166026. angleLeft: number;
  166027. angleRight: number;
  166028. angleUp: number;
  166029. angleDown: number;
  166030. }
  166031. interface XRFrustum {
  166032. position: DOMPointReadOnly;
  166033. orientation: DOMPointReadOnly;
  166034. fieldOfView: XRFieldOfView;
  166035. farDistance: number;
  166036. }
  166037. interface XRPlane {
  166038. parentSceneObject?: XRSceneObject;
  166039. }
  166040. interface XRMesh {
  166041. meshSpace: XRSpace;
  166042. positions: Float32Array;
  166043. indices: Uint32Array;
  166044. normals?: Float32Array;
  166045. lastChangedTime: number;
  166046. parentSceneObject?: XRSceneObject;
  166047. }
  166048. interface XRFrustumDetectionBoundary {
  166049. type: "frustum";
  166050. frustum: XRFrustum;
  166051. }
  166052. interface XRSphereDetectionBoundary {
  166053. type: "sphere";
  166054. radius: number;
  166055. }
  166056. interface XRBoxDetectionBoundary {
  166057. type: "box";
  166058. extent: DOMPointReadOnly;
  166059. }
  166060. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  166061. interface XRGeometryDetectorOptions {
  166062. detectionBoundary?: XRDetectionBoundary;
  166063. updateInterval?: number;
  166064. }
  166065. interface XRSession {
  166066. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  166067. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  166068. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  166069. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  166070. }
  166071. interface XRFrame {
  166072. featurePointCloud?: Array<number>;
  166073. }
  166074. type XRMeshSet = Set<XRMesh>;
  166075. interface XRWorldInformation {
  166076. detectedMeshes?: XRMeshSet;
  166077. }